/*
 @license
 Shaka Player
 Copyright 2016 Google LLC
 SPDX-License-Identifier: Apache-2.0
*/
(function(){var innerGlobal=typeof window!="undefined"?window:global;var exportTo={};(function(window,global,module){/*

 Copyright The Closure Library Authors.
 SPDX-License-Identifier: Apache-2.0
*/
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_ES6=!1;$jscomp.ASSUME_ES2020=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.ISOLATE_POLYFILLS=!1;$jscomp.FORCE_POLYFILL_PROMISE=!1;$jscomp.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION=!1;$jscomp.INSTRUMENT_ASYNC_CONTEXT=!0;$jscomp.objectCreate=$jscomp.ASSUME_ES5||typeof Object.create=="function"?Object.create:function(a){var b=function(){};b.prototype=a;return new b};
$jscomp.defineProperty=$jscomp.ASSUME_ES5||typeof Object.defineProperties=="function"?Object.defineProperty:function(a,b,c){if(a==Array.prototype||a==Object.prototype)return a;a[b]=c.value;return a};$jscomp.getGlobal=function(a){a=["object"==typeof globalThis&&globalThis,a,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var b=0;b<a.length;++b){var c=a[b];if(c&&c.Math==Math)return c}throw Error("Cannot find global object");};
$jscomp.global=$jscomp.ASSUME_ES2020?globalThis:$jscomp.getGlobal(this);$jscomp.IS_SYMBOL_NATIVE=typeof Symbol==="function"&&typeof Symbol("x")==="symbol";$jscomp.TRUST_ES6_POLYFILLS=!$jscomp.ISOLATE_POLYFILLS||$jscomp.IS_SYMBOL_NATIVE;$jscomp.polyfills={};$jscomp.propertyToPolyfillSymbol={};$jscomp.POLYFILL_PREFIX="$jscp$";var $jscomp$lookupPolyfilledValue=function(a,b,c){if(!c||a!=null){c=$jscomp.propertyToPolyfillSymbol[b];if(c==null)return a[b];c=a[c];return c!==void 0?c:a[b]}};
$jscomp.TYPED_ARRAY_CLASSES=function(){var a="Int8 Uint8 Uint8Clamped Int16 Uint16 Int32 Uint32 Float32 Float64".split(" ");$jscomp.global.BigInt64Array&&(a.push("BigInt64"),a.push("BigUint64"));return a}();$jscomp.polyfillTypedArrayMethod=function(a,b,c,d){if(b)for(var e=0;e<$jscomp.TYPED_ARRAY_CLASSES.length;e++){var f=$jscomp.TYPED_ARRAY_CLASSES[e]+"Array.prototype."+a;$jscomp.ISOLATE_POLYFILLS?$jscomp.polyfillIsolated(f,b,c,d):$jscomp.polyfillUnisolated(f,b,c,d)}};
$jscomp.polyfill=function(a,b,c,d){b&&($jscomp.ISOLATE_POLYFILLS?$jscomp.polyfillIsolated(a,b,c,d):$jscomp.polyfillUnisolated(a,b,c,d))};$jscomp.polyfillUnisolated=function(a,b,c,d){c=$jscomp.global;a=a.split(".");for(d=0;d<a.length-1;d++){var e=a[d];if(!(e in c))return;c=c[e]}a=a[a.length-1];d=c[a];b=b(d);b!=d&&b!=null&&$jscomp.defineProperty(c,a,{configurable:!0,writable:!0,value:b})};
$jscomp.polyfillIsolated=function(a,b,c,d){var e=a.split(".");a=e.length===1;d=e[0];d=!a&&d in $jscomp.polyfills?$jscomp.polyfills:$jscomp.global;for(var f=0;f<e.length-1;f++){var g=e[f];if(!(g in d))return;d=d[g]}e=e[e.length-1];c=$jscomp.IS_SYMBOL_NATIVE&&c==="es6"?d[e]:null;b=b(c);b!=null&&(a?$jscomp.defineProperty($jscomp.polyfills,e,{configurable:!0,writable:!0,value:b}):b!==c&&($jscomp.propertyToPolyfillSymbol[e]===void 0&&(c=Math.random()*1E9>>>0,$jscomp.propertyToPolyfillSymbol[e]=$jscomp.IS_SYMBOL_NATIVE?
$jscomp.global.Symbol(e):$jscomp.POLYFILL_PREFIX+c+"$"+e),$jscomp.defineProperty(d,$jscomp.propertyToPolyfillSymbol[e],{configurable:!0,writable:!0,value:b})))};
$jscomp.getConstructImplementation=function(){function a(){function c(){}new c;Reflect.construct(c,[],function(){});return new c instanceof c}if($jscomp.TRUST_ES6_POLYFILLS&&typeof Reflect!="undefined"&&Reflect.construct){if(a())return Reflect.construct;var b=Reflect.construct;return function(c,d,e){c=b(c,d);e&&Reflect.setPrototypeOf(c,e.prototype);return c}}return function(c,d,e){e===void 0&&(e=c);e=$jscomp.objectCreate(e.prototype||Object.prototype);return Function.prototype.apply.call(c,e,d)||
e}};$jscomp.construct={valueOf:$jscomp.getConstructImplementation}.valueOf();$jscomp.underscoreProtoCanBeSet=function(){var a={a:!0},b={};try{return b.__proto__=a,b.a}catch(c){}return!1};$jscomp.setPrototypeOf=$jscomp.ASSUME_ES6||$jscomp.TRUST_ES6_POLYFILLS&&typeof Object.setPrototypeOf=="function"?Object.setPrototypeOf:$jscomp.underscoreProtoCanBeSet()?function(a,b){a.__proto__=b;if(a.__proto__!==b)throw new TypeError(a+" is not extensible");return a}:null;
$jscomp.inherits=function(a,b){a.prototype=$jscomp.objectCreate(b.prototype);a.prototype.constructor=a;if($jscomp.ASSUME_ES6||$jscomp.setPrototypeOf){var c=$jscomp.setPrototypeOf;c(a,b)}else for(c in b)if(c!="prototype")if(Object.defineProperties){var d=Object.getOwnPropertyDescriptor(b,c);d&&Object.defineProperty(a,c,d)}else a[c]=b[c];a.superClass_=b.prototype};$jscomp.arrayIteratorImpl=function(a){var b=0;return function(){return b<a.length?{done:!1,value:a[b++]}:{done:!0}}};
$jscomp.arrayIterator=function(a){return{next:$jscomp.arrayIteratorImpl(a)}};$jscomp.makeIterator=function(a){var b=typeof Symbol!="undefined"&&Symbol.iterator&&a[Symbol.iterator];if(b)return b.call(a);if(typeof a.length=="number")return $jscomp.arrayIterator(a);throw Error(String(a)+" is not an iterable or ArrayLike");};$jscomp.arrayFromIterator=function(a){for(var b,c=[];!(b=a.next()).done;)c.push(b.value);return c};$jscomp.arrayFromIterable=function(a){return a instanceof Array?a:$jscomp.arrayFromIterator($jscomp.makeIterator(a))};
$jscomp.createTemplateTagFirstArg=function(a){return $jscomp.createTemplateTagFirstArgWithRaw(a,a)};$jscomp.createTemplateTagFirstArgWithRaw=function(a,b){a.raw=b;Object.freeze&&(Object.freeze(a),Object.freeze(b));return a};$jscomp.generator={};$jscomp.generator.ensureIteratorResultIsObject_=function(a){if(!(a instanceof Object))throw new TypeError("Iterator result "+a+" is not an object");};
$jscomp.generator.Context=function(){this.isRunning_=!1;this.yieldAllIterator_=null;this.yieldResult=void 0;this.nextAddress=1;this.finallyAddress_=this.catchAddress_=0;this.finallyContexts_=this.abruptCompletion_=null};$jscomp.generator.Context.prototype.start_=function(){if(this.isRunning_)throw new TypeError("Generator is already running");this.isRunning_=!0};$jscomp.generator.Context.prototype.stop_=function(){this.isRunning_=!1};
$jscomp.generator.Context.prototype.jumpToErrorHandler_=function(){this.nextAddress=this.catchAddress_||this.finallyAddress_};$jscomp.generator.Context.prototype.next_=function(a){this.yieldResult=a};$jscomp.generator.Context.prototype.throw_=function(a){this.abruptCompletion_={exception:a,isException:!0};this.jumpToErrorHandler_()};$jscomp.generator.Context.prototype.getNextAddressJsc=function(){return this.nextAddress};$jscomp.generator.Context.prototype.getNextAddressJsc=function(){return this.nextAddress};
$jscomp.generator.Context.prototype.getYieldResultJsc=function(){return this.yieldResult};$jscomp.generator.Context.prototype.getYieldResultJsc=function(){return this.yieldResult};$jscomp.generator.Context.prototype.return=function(a){this.abruptCompletion_={return:a};this.nextAddress=this.finallyAddress_};$jscomp.generator.Context.prototype["return"]=$jscomp.generator.Context.prototype.return;
$jscomp.generator.Context.prototype.jumpThroughFinallyBlocks=function(a){this.abruptCompletion_={jumpTo:a};this.nextAddress=this.finallyAddress_};$jscomp.generator.Context.prototype.jumpThroughFinallyBlocks=$jscomp.generator.Context.prototype.jumpThroughFinallyBlocks;$jscomp.generator.Context.prototype.yield=function(a,b){this.nextAddress=b;return{value:a}};$jscomp.generator.Context.prototype.yield=$jscomp.generator.Context.prototype.yield;
$jscomp.generator.Context.prototype.yieldAll=function(a,b){a=$jscomp.makeIterator(a);var c=a.next();$jscomp.generator.ensureIteratorResultIsObject_(c);if(c.done)this.yieldResult=c.value,this.nextAddress=b;else return this.yieldAllIterator_=a,this.yield(c.value,b)};$jscomp.generator.Context.prototype.yieldAll=$jscomp.generator.Context.prototype.yieldAll;$jscomp.generator.Context.prototype.jumpTo=function(a){this.nextAddress=a};$jscomp.generator.Context.prototype.jumpTo=$jscomp.generator.Context.prototype.jumpTo;
$jscomp.generator.Context.prototype.jumpToEnd=function(){this.nextAddress=0};$jscomp.generator.Context.prototype.jumpToEnd=$jscomp.generator.Context.prototype.jumpToEnd;$jscomp.generator.Context.prototype.setCatchFinallyBlocks=function(a,b){this.catchAddress_=a;b!=void 0&&(this.finallyAddress_=b)};$jscomp.generator.Context.prototype.setCatchFinallyBlocks=$jscomp.generator.Context.prototype.setCatchFinallyBlocks;
$jscomp.generator.Context.prototype.setFinallyBlock=function(a){this.catchAddress_=0;this.finallyAddress_=a||0};$jscomp.generator.Context.prototype.setFinallyBlock=$jscomp.generator.Context.prototype.setFinallyBlock;$jscomp.generator.Context.prototype.leaveTryBlock=function(a,b){this.nextAddress=a;this.catchAddress_=b||0};$jscomp.generator.Context.prototype.leaveTryBlock=$jscomp.generator.Context.prototype.leaveTryBlock;
$jscomp.generator.Context.prototype.enterCatchBlock=function(a){this.catchAddress_=a||0;a=this.abruptCompletion_.exception;this.abruptCompletion_=null;return a};$jscomp.generator.Context.prototype.enterCatchBlock=$jscomp.generator.Context.prototype.enterCatchBlock;$jscomp.generator.Context.prototype.enterFinallyBlock=function(a,b,c){c?this.finallyContexts_[c]=this.abruptCompletion_:this.finallyContexts_=[this.abruptCompletion_];this.catchAddress_=a||0;this.finallyAddress_=b||0};
$jscomp.generator.Context.prototype.enterFinallyBlock=$jscomp.generator.Context.prototype.enterFinallyBlock;$jscomp.generator.Context.prototype.leaveFinallyBlock=function(a,b){b=this.finallyContexts_.splice(b||0)[0];if(b=this.abruptCompletion_=this.abruptCompletion_||b){if(b.isException)return this.jumpToErrorHandler_();b.jumpTo!=void 0&&this.finallyAddress_<b.jumpTo?(this.nextAddress=b.jumpTo,this.abruptCompletion_=null):this.nextAddress=this.finallyAddress_}else this.nextAddress=a};
$jscomp.generator.Context.prototype.leaveFinallyBlock=$jscomp.generator.Context.prototype.leaveFinallyBlock;$jscomp.generator.Context.prototype.forIn=function(a){return new $jscomp.generator.Context.PropertyIterator(a)};$jscomp.generator.Context.prototype.forIn=$jscomp.generator.Context.prototype.forIn;$jscomp.generator.Context.PropertyIterator=function(a){this.object_=a;this.properties_=[];for(var b in a)this.properties_.push(b);this.properties_.reverse()};
$jscomp.generator.Context.PropertyIterator.prototype.getNext=function(){for(;this.properties_.length>0;){var a=this.properties_.pop();if(a in this.object_)return a}return null};$jscomp.generator.Context.PropertyIterator.prototype.getNext=$jscomp.generator.Context.PropertyIterator.prototype.getNext;$jscomp.generator.Engine_=function(a){this.context_=new $jscomp.generator.Context;this.program_=a};
$jscomp.generator.Engine_.prototype.next_=function(a){this.context_.start_();if(this.context_.yieldAllIterator_)return this.yieldAllStep_(this.context_.yieldAllIterator_.next,a,this.context_.next_);this.context_.next_(a);return this.nextStep_()};
$jscomp.generator.Engine_.prototype.return_=function(a){this.context_.start_();var b=this.context_.yieldAllIterator_;if(b)return this.yieldAllStep_("return"in b?b["return"]:function(c){return{value:c,done:!0}},a,this.context_.return);this.context_.return(a);return this.nextStep_()};
$jscomp.generator.Engine_.prototype.throw_=function(a){this.context_.start_();if(this.context_.yieldAllIterator_)return this.yieldAllStep_(this.context_.yieldAllIterator_["throw"],a,this.context_.next_);this.context_.throw_(a);return this.nextStep_()};
$jscomp.generator.Engine_.prototype.yieldAllStep_=function(a,b,c){try{var d=a.call(this.context_.yieldAllIterator_,b);$jscomp.generator.ensureIteratorResultIsObject_(d);if(!d.done)return this.context_.stop_(),d;var e=d.value}catch(f){return this.context_.yieldAllIterator_=null,this.context_.throw_(f),this.nextStep_()}this.context_.yieldAllIterator_=null;c.call(this.context_,e);return this.nextStep_()};
$jscomp.generator.Engine_.prototype.nextStep_=function(){for(;this.context_.nextAddress;)try{var a=this.program_(this.context_);if(a)return this.context_.stop_(),{value:a.value,done:!1}}catch(b){this.context_.yieldResult=void 0,this.context_.throw_(b)}this.context_.stop_();if(this.context_.abruptCompletion_){a=this.context_.abruptCompletion_;this.context_.abruptCompletion_=null;if(a.isException)throw a.exception;return{value:a.return,done:!0}}return{value:void 0,done:!0}};
$jscomp.generator.Generator_=function(a){this.next=function(b){return a.next_(b)};this.throw=function(b){return a.throw_(b)};this.return=function(b){return a.return_(b)};this[Symbol.iterator]=function(){return this}};$jscomp.generator.createGenerator=function(a,b){b=new $jscomp.generator.Generator_(new $jscomp.generator.Engine_(b));$jscomp.setPrototypeOf&&a.prototype&&$jscomp.setPrototypeOf(b,a.prototype);return b};
$jscomp.asyncExecutePromiseGenerator=function(a){function b(d){return a.next(d)}function c(d){return a.throw(d)}return new Promise(function(d,e){function f(g){g.done?d(g.value):Promise.resolve(g.value).then(b,c).then(f,e)}f(a.next())})};$jscomp.asyncExecutePromiseGeneratorFunction=function(a){return $jscomp.asyncExecutePromiseGenerator(a())};$jscomp.asyncExecutePromiseGeneratorProgram=function(a){return $jscomp.asyncExecutePromiseGenerator(new $jscomp.generator.Generator_(new $jscomp.generator.Engine_(a)))};
$jscomp.getRestArguments=function(){for(var a=Number(this),b=[],c=a;c<arguments.length;c++)b[c-a]=arguments[c];return b};$jscomp.polyfill("Reflect",function(a){return a?a:{}},"es6","es3");$jscomp.polyfill("Reflect.construct",function(a){return $jscomp.construct},"es6","es3");$jscomp.polyfill("Reflect.setPrototypeOf",function(a){if(a)return a;if($jscomp.setPrototypeOf){var b=$jscomp.setPrototypeOf;return function(c,d){try{return b(c,d),!0}catch(e){return!1}}}return null},"es6","es5");
$jscomp.initSymbol=function(){};$jscomp.polyfill("Symbol",function(a){if(a)return a;var b=function(f,g){this.$jscomp$symbol$id_=f;$jscomp.defineProperty(this,"description",{configurable:!0,writable:!0,value:g})};b.prototype.toString=function(){return this.$jscomp$symbol$id_};var c="jscomp_symbol_"+(Math.random()*1E9>>>0)+"_",d=0,e=function(f){if(this instanceof e)throw new TypeError("Symbol is not a constructor");return new b(c+(f||"")+"_"+d++,f)};return e},"es6","es3");
$jscomp.polyfill("Symbol.iterator",function(a){if(a)return a;a=Symbol("Symbol.iterator");$jscomp.defineProperty(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return $jscomp.iteratorPrototype($jscomp.arrayIteratorImpl(this))}});return a},"es6","es3");$jscomp.iteratorPrototype=function(a){a={next:a};a[Symbol.iterator]=function(){return this};return a};
$jscomp.polyfill("Promise",function(a){function b(){this.batch_=null}function c(g){return g instanceof e?g:new e(function(h,k){h(g)})}if(a&&(!($jscomp.FORCE_POLYFILL_PROMISE||$jscomp.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION&&typeof $jscomp.global.PromiseRejectionEvent==="undefined")||!$jscomp.global.Promise||$jscomp.global.Promise.toString().indexOf("[native code]")===-1))return a;b.prototype.asyncExecute=function(g){if(this.batch_==null){this.batch_=[];var h=this;this.asyncExecuteFunction(function(){h.executeBatch_()})}this.batch_.push(g)};
var d=$jscomp.global.setTimeout;b.prototype.asyncExecuteFunction=function(g){d(g,0)};b.prototype.executeBatch_=function(){for(;this.batch_&&this.batch_.length;){var g=this.batch_;this.batch_=[];for(var h=0;h<g.length;++h){var k=g[h];g[h]=null;try{k()}catch(l){this.asyncThrow_(l)}}}this.batch_=null};b.prototype.asyncThrow_=function(g){this.asyncExecuteFunction(function(){throw g;})};var e=function(g){this.state_=0;this.result_=void 0;this.onSettledCallbacks_=[];this.isRejectionHandled_=!1;var h=this.createResolveAndReject_();
try{g(h.resolve,h.reject)}catch(k){h.reject(k)}};e.prototype.createResolveAndReject_=function(){function g(l){return function(m){k||(k=!0,l.call(h,m))}}var h=this,k=!1;return{resolve:g(this.resolveTo_),reject:g(this.reject_)}};e.prototype.resolveTo_=function(g){if(g===this)this.reject_(new TypeError("A Promise cannot resolve to itself"));else if(g instanceof e)this.settleSameAsPromise_(g);else{a:switch(typeof g){case "object":var h=g!=null;break a;case "function":h=!0;break a;default:h=!1}h?this.resolveToNonPromiseObj_(g):
this.fulfill_(g)}};e.prototype.resolveToNonPromiseObj_=function(g){var h=void 0;try{h=g.then}catch(k){this.reject_(k);return}typeof h=="function"?this.settleSameAsThenable_(h,g):this.fulfill_(g)};e.prototype.reject_=function(g){this.settle_(2,g)};e.prototype.fulfill_=function(g){this.settle_(1,g)};e.prototype.settle_=function(g,h){if(this.state_!=0)throw Error("Cannot settle("+g+", "+h+"): Promise already settled in state"+this.state_);this.state_=g;this.result_=h;this.state_===2&&this.scheduleUnhandledRejectionCheck_();
this.executeOnSettledCallbacks_()};e.prototype.scheduleUnhandledRejectionCheck_=function(){var g=this;d(function(){if(g.notifyUnhandledRejection_()){var h=$jscomp.global.console;typeof h!=="undefined"&&h.error(g.result_)}},1)};e.prototype.notifyUnhandledRejection_=function(){if(this.isRejectionHandled_)return!1;var g=$jscomp.global.CustomEvent,h=$jscomp.global.Event,k=$jscomp.global.dispatchEvent;if(typeof k==="undefined")return!0;typeof g==="function"?g=new g("unhandledrejection",{cancelable:!0}):
typeof h==="function"?g=new h("unhandledrejection",{cancelable:!0}):(g=$jscomp.global.document.createEvent("CustomEvent"),g.initCustomEvent("unhandledrejection",!1,!0,g));g.promise=this;g.reason=this.result_;return k(g)};e.prototype.executeOnSettledCallbacks_=function(){if(this.onSettledCallbacks_!=null){for(var g=0;g<this.onSettledCallbacks_.length;++g)f.asyncExecute(this.onSettledCallbacks_[g]);this.onSettledCallbacks_=null}};var f=new b;e.prototype.settleSameAsPromise_=function(g){var h=this.createResolveAndReject_();
g.callWhenSettled_(h.resolve,h.reject)};e.prototype.settleSameAsThenable_=function(g,h){var k=this.createResolveAndReject_();try{g.call(h,k.resolve,k.reject)}catch(l){k.reject(l)}};e.prototype.then=function(g,h){function k(p,q){return typeof p=="function"?function(r){try{l(p(r))}catch(t){m(t)}}:q}var l,m,n=new e(function(p,q){l=p;m=q});this.callWhenSettled_(k(g,l),k(h,m));return n};e.prototype.catch=function(g){return this.then(void 0,g)};e.prototype.callWhenSettled_=function(g,h){function k(){switch(l.state_){case 1:g(l.result_);
break;case 2:h(l.result_);break;default:throw Error("Unexpected state: "+l.state_);}}var l=this;this.onSettledCallbacks_==null?f.asyncExecute(k):this.onSettledCallbacks_.push(k);this.isRejectionHandled_=!0};e.resolve=c;e.reject=function(g){return new e(function(h,k){k(g)})};e.race=function(g){return new e(function(h,k){for(var l=$jscomp.makeIterator(g),m=l.next();!m.done;m=l.next())c(m.value).callWhenSettled_(h,k)})};e.all=function(g){var h=$jscomp.makeIterator(g),k=h.next();return k.done?c([]):new e(function(l,
m){function n(r){return function(t){p[r]=t;q--;q==0&&l(p)}}var p=[],q=0;do p.push(void 0),q++,c(k.value).callWhenSettled_(n(p.length-1),m),k=h.next();while(!k.done)})};return e},"es6","es3");$jscomp.checkEs6ConformanceViaProxy=function(){try{var a={},b=Object.create(new $jscomp.global.Proxy(a,{get:function(c,d,e){return c==a&&d=="q"&&e==b}}));return b.q===!0}catch(c){return!1}};$jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS=!1;$jscomp.ES6_CONFORMANCE=$jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS&&$jscomp.checkEs6ConformanceViaProxy();
$jscomp.owns=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)};
$jscomp.polyfill("WeakMap",function(a){function b(){if(!a||!Object.seal)return!1;try{var l=Object.seal({}),m=Object.seal({}),n=new a([[l,2],[m,3]]);if(n.get(l)!=2||n.get(m)!=3)return!1;n.delete(l);n.set(m,4);return!n.has(l)&&n.get(m)==4}catch(p){return!1}}function c(){}function d(l){var m=typeof l;return m==="object"&&l!==null||m==="function"}function e(l){if(!$jscomp.owns(l,g)){var m=new c;$jscomp.defineProperty(l,g,{value:m})}}function f(l){if(!$jscomp.ISOLATE_POLYFILLS){var m=Object[l];m&&(Object[l]=
function(n){if(n instanceof c)return n;Object.isExtensible(n)&&e(n);return m(n)})}}if($jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS){if(a&&$jscomp.ES6_CONFORMANCE)return a}else if(b())return a;var g="$jscomp_hidden_"+Math.random();f("freeze");f("preventExtensions");f("seal");var h=0,k=function(l){this.id_=(h+=Math.random()+1).toString();if(l){l=$jscomp.makeIterator(l);for(var m;!(m=l.next()).done;)m=m.value,this.set(m[0],m[1])}};k.prototype.set=function(l,m){if(!d(l))throw Error("Invalid WeakMap key");
e(l);if(!$jscomp.owns(l,g))throw Error("WeakMap key fail: "+l);l[g][this.id_]=m;return this};k.prototype.get=function(l){return d(l)&&$jscomp.owns(l,g)?l[g][this.id_]:void 0};k.prototype.has=function(l){return d(l)&&$jscomp.owns(l,g)&&$jscomp.owns(l[g],this.id_)};k.prototype.delete=function(l){return d(l)&&$jscomp.owns(l,g)&&$jscomp.owns(l[g],this.id_)?delete l[g][this.id_]:!1};return k},"es6","es3");$jscomp.MapEntry=function(){};
$jscomp.polyfill("Map",function(a){function b(){if($jscomp.ASSUME_NO_NATIVE_MAP||!a||typeof a!="function"||!a.prototype.entries||typeof Object.seal!="function")return!1;try{var k=Object.seal({x:4}),l=new a($jscomp.makeIterator([[k,"s"]]));if(l.get(k)!="s"||l.size!=1||l.get({x:4})||l.set({x:4},"t")!=l||l.size!=2)return!1;var m=l.entries(),n=m.next();if(n.done||n.value[0]!=k||n.value[1]!="s")return!1;n=m.next();return n.done||n.value[0].x!=4||n.value[1]!="t"||!m.next().done?!1:!0}catch(p){return!1}}
if($jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS){if(a&&$jscomp.ES6_CONFORMANCE)return a}else if(b())return a;var c=new WeakMap,d=function(k){this[0]={};this[1]=g();this.size=0;if(k){k=$jscomp.makeIterator(k);for(var l;!(l=k.next()).done;)l=l.value,this.set(l[0],l[1])}};d.prototype.set=function(k,l){k=k===0?0:k;var m=e(this,k);m.list||(m.list=this[0][m.id]=[]);m.entry?m.entry.value=l:(m.entry={next:this[1],previous:this[1].previous,head:this[1],key:k,value:l},m.list.push(m.entry),this[1].previous.next=
m.entry,this[1].previous=m.entry,this.size++);return this};d.prototype.delete=function(k){k=e(this,k);return k.entry&&k.list?(k.list.splice(k.index,1),k.list.length||delete this[0][k.id],k.entry.previous.next=k.entry.next,k.entry.next.previous=k.entry.previous,k.entry.head=null,this.size--,!0):!1};d.prototype.clear=function(){this[0]={};this[1]=this[1].previous=g();this.size=0};d.prototype.has=function(k){return!!e(this,k).entry};d.prototype.get=function(k){return(k=e(this,k).entry)&&k.value};d.prototype.entries=
function(){return f(this,function(k){return[k.key,k.value]})};d.prototype.keys=function(){return f(this,function(k){return k.key})};d.prototype.values=function(){return f(this,function(k){return k.value})};d.prototype.forEach=function(k,l){for(var m=this.entries(),n;!(n=m.next()).done;)n=n.value,k.call(l,n[1],n[0],this)};d.prototype[Symbol.iterator]=d.prototype.entries;var e=function(k,l){var m=l&&typeof l;m=="object"||m=="function"?c.has(l)?m=c.get(l):(m=""+ ++h,c.set(l,m)):m="p_"+l;var n=k[0][m];
if(n&&$jscomp.owns(k[0],m))for(k=0;k<n.length;k++){var p=n[k];if(l!==l&&p.key!==p.key||l===p.key)return{id:m,list:n,index:k,entry:p}}return{id:m,list:n,index:-1,entry:void 0}},f=function(k,l){var m=k[1];return $jscomp.iteratorPrototype(function(){if(m){for(;m.head!=k[1];)m=m.previous;for(;m.next!=m.head;)return m=m.next,{done:!1,value:l(m)};m=null}return{done:!0,value:void 0}})},g=function(){var k={};return k.previous=k.next=k.head=k},h=0;return d},"es6","es3");
$jscomp.polyfill("Set",function(a){function b(){if($jscomp.ASSUME_NO_NATIVE_SET||!a||typeof a!="function"||!a.prototype.entries||typeof Object.seal!="function")return!1;try{var d=Object.seal({x:4}),e=new a($jscomp.makeIterator([d]));if(!e.has(d)||e.size!=1||e.add(d)!=e||e.size!=1||e.add({x:4})!=e||e.size!=2)return!1;var f=e.entries(),g=f.next();if(g.done||g.value[0]!=d||g.value[1]!=d)return!1;g=f.next();return g.done||g.value[0]==d||g.value[0].x!=4||g.value[1]!=g.value[0]?!1:f.next().done}catch(h){return!1}}
if($jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS){if(a&&$jscomp.ES6_CONFORMANCE)return a}else if(b())return a;var c=function(d){this.map_=new Map;if(d){d=$jscomp.makeIterator(d);for(var e;!(e=d.next()).done;)this.add(e.value)}this.size=this.map_.size};c.prototype.add=function(d){d=d===0?0:d;this.map_.set(d,d);this.size=this.map_.size;return this};c.prototype.delete=function(d){d=this.map_.delete(d);this.size=this.map_.size;return d};c.prototype.clear=function(){this.map_.clear();this.size=0};c.prototype.has=
function(d){return this.map_.has(d)};c.prototype.entries=function(){return this.map_.entries()};c.prototype.values=function(){return this.map_.values()};c.prototype.keys=c.prototype.values;c.prototype[Symbol.iterator]=c.prototype.values;c.prototype.forEach=function(d,e){var f=this;this.map_.forEach(function(g){return d.call(e,g,g,f)})};return c},"es6","es3");
$jscomp.findInternal=function(a,b,c){a instanceof String&&(a=String(a));for(var d=a.length,e=0;e<d;e++){var f=a[e];if(b.call(c,f,e,a))return{i:e,v:f}}return{i:-1,v:void 0}};$jscomp.polyfill("Array.prototype.findIndex",function(a){return a?a:function(b,c){return $jscomp.findInternal(this,b,c).i}},"es6","es3");
$jscomp.iteratorFromArray=function(a,b){if($jscomp.ASSUME_ES6)return a[Symbol.iterator]();a instanceof String&&(a+="");var c=0,d=!1,e={next:function(){if(!d&&c<a.length){var f=c++;return{value:b(f,a[f]),done:!1}}d=!0;return{done:!0,value:void 0}}};e[Symbol.iterator]=function(){return e};return e};$jscomp.polyfill("Array.prototype.values",function(a){return a?a:function(){return $jscomp.iteratorFromArray(this,function(b,c){return c})}},"es8","es3");
$jscomp.polyfill("Array.from",function(a){return a?a:function(b,c,d){c=c!=null?c:function(h){return h};var e=[],f=typeof Symbol!="undefined"&&Symbol.iterator&&b[Symbol.iterator];if(typeof f=="function"){b=f.call(b);for(var g=0;!(f=b.next()).done;)e.push(c.call(d,f.value,g++))}else for(f=b.length,g=0;g<f;g++)e.push(c.call(d,b[g],g));return e}},"es6","es3");
$jscomp.polyfill("Array.prototype.keys",function(a){return a?a:function(){return $jscomp.iteratorFromArray(this,function(b){return b})}},"es6","es3");$jscomp.checkStringArgs=function(a,b,c){if(a==null)throw new TypeError("The 'this' value for String.prototype."+c+" must not be null or undefined");if(b instanceof RegExp)throw new TypeError("First argument to String.prototype."+c+" must not be a regular expression");return a+""};
$jscomp.polyfill("String.prototype.startsWith",function(a){return a?a:function(b,c){var d=$jscomp.checkStringArgs(this,b,"startsWith");b+="";var e=d.length,f=b.length;c=Math.max(0,Math.min(c|0,d.length));for(var g=0;g<f&&c<e;)if(d[c++]!=b[g++])return!1;return g>=f}},"es6","es3");$jscomp.polyfill("Object.is",function(a){return a?a:function(b,c){return b===c?b!==0||1/b===1/c:b!==b&&c!==c}},"es6","es3");
$jscomp.polyfill("Array.prototype.includes",function(a){return a?a:function(b,c){var d=this;d instanceof String&&(d=String(d));var e=d.length;c=c||0;for(c<0&&(c=Math.max(c+e,0));c<e;c++){var f=d[c];if(f===b||Object.is(f,b))return!0}return!1}},"es7","es3");$jscomp.polyfill("String.prototype.includes",function(a){return a?a:function(b,c){return $jscomp.checkStringArgs(this,b,"includes").indexOf(b,c||0)!==-1}},"es6","es3");
$jscomp.polyfill("String.fromCodePoint",function(a){return a?a:function(b){for(var c="",d=0;d<arguments.length;d++){var e=Number(arguments[d]);if(e<0||e>1114111||e!==Math.floor(e))throw new RangeError("invalid_code_point "+e);e<=65535?c+=String.fromCharCode(e):(e-=65536,c+=String.fromCharCode(e>>>10&1023|55296),c+=String.fromCharCode(e&1023|56320))}return c}},"es6","es3");
$jscomp.polyfill("WeakSet",function(a){function b(){if(!a||!Object.seal)return!1;try{var d=Object.seal({}),e=Object.seal({}),f=new a([d]);if(!f.has(d)||f.has(e))return!1;f.delete(d);f.add(e);return!f.has(d)&&f.has(e)}catch(g){return!1}}if($jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS){if(a&&$jscomp.ES6_CONFORMANCE)return a}else if(b())return a;var c=function(d){this.map_=new WeakMap;if(d){d=$jscomp.makeIterator(d);for(var e;!(e=d.next()).done;)this.add(e.value)}};c.prototype.add=function(d){this.map_.set(d,
!0);return this};c.prototype.has=function(d){return this.map_.has(d)};c.prototype.delete=function(d){return this.map_.delete(d)};return c},"es6","es3");$jscomp.polyfill("Array.prototype.find",function(a){return a?a:function(b,c){return $jscomp.findInternal(this,b,c).v}},"es6","es3");$jscomp.polyfill("Object.entries",function(a){return a?a:function(b){var c=[],d;for(d in b)$jscomp.owns(b,d)&&c.push([d,b[d]]);return c}},"es8","es3");
$jscomp.toObject=function(a){if(a==null)throw new TypeError("No nullish arg");return Object(a)};$jscomp.assign=$jscomp.ASSUME_ES6||$jscomp.TRUST_ES6_POLYFILLS&&typeof Object.assign=="function"?Object.assign:function(a,b){a=$jscomp.toObject(a);for(var c=1;c<arguments.length;c++){var d=arguments[c];if(d)for(var e in d)$jscomp.owns(d,e)&&(a[e]=d[e])}return a};$jscomp.polyfill("Object.assign",function(a){return a||$jscomp.assign},"es6","es3");
$jscomp.polyfill("Math.clz32",function(a){return a?a:function(b){b=Number(b)>>>0;if(b===0)return 32;var c=0;(b&4294901760)===0&&(b<<=16,c+=16);(b&4278190080)===0&&(b<<=8,c+=8);(b&4026531840)===0&&(b<<=4,c+=4);(b&3221225472)===0&&(b<<=2,c+=2);(b&2147483648)===0&&c++;return c}},"es6","es3");$jscomp.polyfill("Object.values",function(a){return a?a:function(b){var c=[],d;for(d in b)$jscomp.owns(b,d)&&c.push(b[d]);return c}},"es8","es3");
$jscomp.polyfill("Promise.prototype.finally",function(a){return a?a:function(b){return this.then(function(c){return Promise.resolve(b()).then(function(){return c})},function(c){return Promise.resolve(b()).then(function(){throw c;})})}},"es9","es3");$jscomp.polyfill("Math.log2",function(a){return a?a:function(b){return Math.log(b)/Math.LN2}},"es6","es3");$jscomp.polyfill("Number.EPSILON",function(a){return 2.220446049250313E-16},"es6","es3");
$jscomp.polyfill("Number.MAX_SAFE_INTEGER",function(){return 9007199254740991},"es6","es3");$jscomp.polyfill("String.prototype.endsWith",function(a){return a?a:function(b,c){var d=$jscomp.checkStringArgs(this,b,"endsWith");b+="";c===void 0&&(c=d.length);c=Math.max(0,Math.min(c|0,d.length));for(var e=b.length;e>0&&c>0;)if(d[--c]!=b[--e])return!1;return e<=0}},"es6","es3");
$jscomp.polyfill("Array.prototype.entries",function(a){return a?a:function(){return $jscomp.iteratorFromArray(this,function(b,c){return[b,c]})}},"es6","es3");$jscomp.polyfill("Number.isNaN",function(a){return a?a:function(b){return typeof b==="number"&&isNaN(b)}},"es6","es3");
$jscomp.polyfill("String.prototype.repeat",function(a){return a?a:function(b){var c=$jscomp.checkStringArgs(this,null,"repeat");if(b<0||b>1342177279)throw new RangeError("Invalid count value");b|=0;for(var d="";b;)if(b&1&&(d+=c),b>>>=1)c+=c;return d}},"es6","es3");$jscomp.polyfill("Number.isFinite",function(a){return a?a:function(b){return typeof b!=="number"?!1:!isNaN(b)&&b!==Infinity&&b!==-Infinity}},"es6","es3");var COMPILED=!0,goog=goog||{};goog.global=this||self;
goog.exportPath_=function(a,b,c,d){a=a.split(".");d=d||goog.global;a[0]in d||typeof d.execScript=="undefined"||d.execScript("var "+a[0]);for(var e;a.length&&(e=a.shift());)if(a.length||b===void 0)d=d[e]&&d[e]!==Object.prototype[e]?d[e]:d[e]={};else if(!c&&goog.isObject(b)&&goog.isObject(d[e]))for(var f in b)b.hasOwnProperty(f)&&(d[e][f]=b[f]);else d[e]=b};
goog.define=function(a,b){if(!COMPILED){var c=goog.global.CLOSURE_UNCOMPILED_DEFINES,d=goog.global.CLOSURE_DEFINES;c&&c.nodeType===void 0&&Object.prototype.hasOwnProperty.call(c,a)?b=c[a]:d&&d.nodeType===void 0&&Object.prototype.hasOwnProperty.call(d,a)&&(b=d[a])}return b};goog.FEATURESET_YEAR=2012;goog.DEBUG=!0;goog.LOCALE="en";goog.TRUSTED_SITE=!0;goog.DISALLOW_TEST_ONLY_CODE=COMPILED&&!goog.DEBUG;goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING=!1;
goog.provide=function(a){if(goog.isInModuleLoader_())throw Error("goog.provide cannot be used within a module.");if(!COMPILED&&goog.isProvided_(a))throw Error('Namespace "'+a+'" already declared.');goog.constructNamespace_(a)};goog.constructNamespace_=function(a,b,c){if(!COMPILED){delete goog.implicitNamespaces_[a];for(var d=a;(d=d.substring(0,d.lastIndexOf(".")))&&!goog.getObjectByName(d);)goog.implicitNamespaces_[d]=!0}goog.exportPath_(a,b,c)};goog.NONCE_PATTERN_=/^[\w+/_-]+[=]{0,2}$/;
goog.getScriptNonce_=function(a){a=(a||goog.global).document;return(a=a.querySelector&&a.querySelector("script[nonce]"))&&(a=a.nonce||a.getAttribute("nonce"))&&goog.NONCE_PATTERN_.test(a)?a:""};goog.VALID_MODULE_RE_=/^[a-zA-Z_$][a-zA-Z0-9._$]*$/;
goog.module=function(a){if(typeof a!=="string"||!a||a.search(goog.VALID_MODULE_RE_)==-1)throw Error("Invalid module identifier");if(!goog.isInGoogModuleLoader_())throw Error("Module "+a+" has been loaded incorrectly. Note, modules cannot be loaded as normal scripts. They require some kind of pre-processing step. You're likely trying to load a module via a script tag or as a part of a concatenated bundle without rewriting the module. For more info see: https://github.com/google/closure-library/wiki/goog.module:-an-ES6-module-like-alternative-to-goog.provide.");if(goog.moduleLoaderState_.moduleName)throw Error("goog.module may only be called once per module.");
goog.moduleLoaderState_.moduleName=a;if(!COMPILED){if(goog.isProvided_(a))throw Error('Namespace "'+a+'" already declared.');delete goog.implicitNamespaces_[a]}};goog.module.get=function(a){return goog.module.getInternal_(a)};goog.module.getInternal_=function(a){if(!COMPILED){if(a in goog.loadedModules_)return goog.loadedModules_[a].exports;if(!goog.implicitNamespaces_[a])return a=goog.getObjectByName(a),a!=null?a:null}return null};goog.ModuleType={ES6:"es6",GOOG:"goog"};goog.moduleLoaderState_=null;
goog.isInModuleLoader_=function(){return goog.isInGoogModuleLoader_()||goog.isInEs6ModuleLoader_()};goog.isInGoogModuleLoader_=function(){return!!goog.moduleLoaderState_&&goog.moduleLoaderState_.type==goog.ModuleType.GOOG};goog.isInEs6ModuleLoader_=function(){if(goog.moduleLoaderState_&&goog.moduleLoaderState_.type==goog.ModuleType.ES6)return!0;var a=goog.global.$jscomp;return a?typeof a.getCurrentModulePath!="function"?!1:!!a.getCurrentModulePath():!1};
goog.module.declareLegacyNamespace=function(){if(!COMPILED&&!goog.isInGoogModuleLoader_())throw Error("goog.module.declareLegacyNamespace must be called from within a goog.module");if(!COMPILED&&!goog.moduleLoaderState_.moduleName)throw Error("goog.module must be called prior to goog.module.declareLegacyNamespace.");goog.moduleLoaderState_.declareLegacyNamespace=!0};
goog.declareModuleId=function(a){if(!COMPILED){if(!goog.isInEs6ModuleLoader_())throw Error("goog.declareModuleId may only be called from within an ES6 module");if(goog.moduleLoaderState_&&goog.moduleLoaderState_.moduleName)throw Error("goog.declareModuleId may only be called once per module.");if(a in goog.loadedModules_)throw Error('Module with namespace "'+a+'" already exists.');}if(goog.moduleLoaderState_)goog.moduleLoaderState_.moduleName=a;else{var b=goog.global.$jscomp;if(!b||typeof b.getCurrentModulePath!=
"function")throw Error('Module with namespace "'+a+'" has been loaded incorrectly.');b=b.require(b.getCurrentModulePath());goog.loadedModules_[a]={exports:b,type:goog.ModuleType.ES6,moduleId:a}}};goog.setTestOnly=function(a){if(goog.DISALLOW_TEST_ONLY_CODE)throw a=a||"",Error("Importing test-only code into non-debug environment"+(a?": "+a:"."));};goog.forwardDeclare=function(a){};
COMPILED||(goog.isProvided_=function(a){return a in goog.loadedModules_||!goog.implicitNamespaces_[a]&&goog.getObjectByName(a)!=null},goog.implicitNamespaces_={"goog.module":!0});goog.getObjectByName=function(a,b){a=a.split(".");b=b||goog.global;for(var c=0;c<a.length;c++)if(b=b[a[c]],b==null)return null;return b};goog.addDependency=function(a,b,c,d){!COMPILED&&goog.DEPENDENCIES_ENABLED&&goog.debugLoader_.addDependency(a,b,c,d)};goog.ENABLE_DEBUG_LOADER=!1;
goog.logToConsole_=function(a){goog.global.console&&goog.global.console.error(a)};goog.require=function(a){if(!COMPILED){goog.ENABLE_DEBUG_LOADER&&goog.debugLoader_.requested(a);if(goog.isProvided_(a)){if(goog.isInModuleLoader_())return goog.module.getInternal_(a)}else if(goog.ENABLE_DEBUG_LOADER){var b=goog.moduleLoaderState_;goog.moduleLoaderState_=null;try{goog.debugLoader_.load_(a)}finally{goog.moduleLoaderState_=b}}return null}};goog.requireType=function(a){return{}};goog.basePath="";
goog.abstractMethod=function(){throw Error("unimplemented abstract method");};goog.addSingletonGetter=function(a){a.instance_=void 0;a.getInstance=function(){if(a.instance_)return a.instance_;goog.DEBUG&&(goog.instantiatedSingletons_[goog.instantiatedSingletons_.length]=a);return a.instance_=new a}};goog.instantiatedSingletons_=[];goog.LOAD_MODULE_USING_EVAL=!0;goog.SEAL_MODULE_EXPORTS=goog.DEBUG;goog.loadedModules_={};goog.DEPENDENCIES_ENABLED=!COMPILED&&goog.ENABLE_DEBUG_LOADER;goog.TRANSPILE="detect";
goog.ASSUME_ES_MODULES_TRANSPILED=!1;goog.TRUSTED_TYPES_POLICY_NAME="goog";goog.hasBadLetScoping=null;
goog.loadModule=function(a){var b=goog.moduleLoaderState_;try{goog.moduleLoaderState_={moduleName:"",declareLegacyNamespace:!1,type:goog.ModuleType.GOOG};var c={},d=c;if(typeof a==="function")d=a.call(void 0,d);else if(typeof a==="string")d=goog.loadModuleFromSource_.call(void 0,d,a);else throw Error("Invalid module definition");var e=goog.moduleLoaderState_.moduleName;if(typeof e==="string"&&e)goog.moduleLoaderState_.declareLegacyNamespace?goog.constructNamespace_(e,d,c!==d):goog.SEAL_MODULE_EXPORTS&&
Object.seal&&typeof d=="object"&&d!=null&&Object.seal(d),goog.loadedModules_[e]={exports:d,type:goog.ModuleType.GOOG,moduleId:goog.moduleLoaderState_.moduleName};else throw Error('Invalid module name "'+e+'"');}finally{goog.moduleLoaderState_=b}};goog.loadModuleFromSource_=function(a){eval(goog.CLOSURE_EVAL_PREFILTER_.createScript(arguments[1]));return a};
goog.normalizePath_=function(a){a=a.split("/");for(var b=0;b<a.length;)a[b]=="."?a.splice(b,1):b&&a[b]==".."&&a[b-1]&&a[b-1]!=".."?a.splice(--b,2):b++;return a.join("/")};goog.loadFileSync_=function(a){if(goog.global.CLOSURE_LOAD_FILE_SYNC)return goog.global.CLOSURE_LOAD_FILE_SYNC(a);try{var b=new goog.global.XMLHttpRequest;b.open("get",a,!1);b.send();return b.status==0||b.status==200?b.responseText:null}catch(c){return null}};
goog.typeOf=function(a){var b=typeof a;return b!="object"?b:a?Array.isArray(a)?"array":b:"null"};goog.isArrayLike=function(a){var b=goog.typeOf(a);return b=="array"||b=="object"&&typeof a.length=="number"};goog.isDateLike=function(a){return goog.isObject(a)&&typeof a.getFullYear=="function"};goog.isObject=function(a){var b=typeof a;return b=="object"&&a!=null||b=="function"};
goog.getUid=function(a){return Object.prototype.hasOwnProperty.call(a,goog.UID_PROPERTY_)&&a[goog.UID_PROPERTY_]||(a[goog.UID_PROPERTY_]=++goog.uidCounter_)};goog.hasUid=function(a){return!!a[goog.UID_PROPERTY_]};goog.removeUid=function(a){a!==null&&"removeAttribute"in a&&a.removeAttribute(goog.UID_PROPERTY_);try{delete a[goog.UID_PROPERTY_]}catch(b){}};goog.UID_PROPERTY_="closure_uid_"+(Math.random()*1E9>>>0);goog.uidCounter_=0;
goog.cloneObject=function(a){var b=goog.typeOf(a);if(b=="object"||b=="array"){if(typeof a.clone==="function")return a.clone();if(typeof Map!=="undefined"&&a instanceof Map)return new Map(a);if(typeof Set!=="undefined"&&a instanceof Set)return new Set(a);b=b=="array"?[]:{};for(var c in a)b[c]=goog.cloneObject(a[c]);return b}return a};goog.bindNative_=function(a,b,c){return a.call.apply(a.bind,arguments)};
goog.bindJs_=function(a,b,c){if(!a)throw Error();if(arguments.length>2){var d=Array.prototype.slice.call(arguments,2);return function(){var e=Array.prototype.slice.call(arguments);Array.prototype.unshift.apply(e,d);return a.apply(b,e)}}return function(){return a.apply(b,arguments)}};goog.bind=function(a,b,c){Function.prototype.bind&&Function.prototype.bind.toString().indexOf("native code")!=-1?goog.bind=goog.bindNative_:goog.bind=goog.bindJs_;return goog.bind.apply(null,arguments)};
goog.partial=function(a,b){var c=Array.prototype.slice.call(arguments,1);return function(){var d=c.slice();d.push.apply(d,arguments);return a.apply(this,d)}};goog.now=function(){return Date.now()};goog.globalEval=function(a){(0,eval)(a)};
goog.getCssName=function(a,b){if(String(a).charAt(0)==".")throw Error('className passed in goog.getCssName must not start with ".". You passed: '+a);var c=function(e){return goog.cssNameMapping_[e]||e},d=function(e){e=e.split("-");for(var f=[],g=0;g<e.length;g++)f.push(c(e[g]));return f.join("-")};d=goog.cssNameMapping_?goog.cssNameMappingStyle_=="BY_WHOLE"?c:d:function(e){return e};a=b?a+"-"+d(b):d(a);return goog.global.CLOSURE_CSS_NAME_MAP_FN?goog.global.CLOSURE_CSS_NAME_MAP_FN(a):a};
goog.setCssNameMapping=function(a,b){goog.cssNameMapping_=a;goog.cssNameMappingStyle_=b};!COMPILED&&goog.global.CLOSURE_CSS_NAME_MAPPING&&(goog.cssNameMapping_=goog.global.CLOSURE_CSS_NAME_MAPPING);goog.GetMsgOptions=function(){};
goog.getMsg=function(a,b,c){c&&c.html&&(a=a.replace(/</g,"&lt;"));c&&c.unescapeHtmlEntities&&(a=a.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&apos;/g,"'").replace(/&quot;/g,'"').replace(/&amp;/g,"&"));b&&(a=a.replace(/\{\$([^}]+)}/g,function(d,e){return b!=null&&e in b?b[e]:d}));return a};goog.getMsgWithFallback=function(a,b){return a};goog.exportSymbol=function(a,b,c){goog.exportPath_(a,b,!0,c)};goog.exportProperty=function(a,b,c){a[b]=c};
goog.inherits=function(a,b){function c(){}c.prototype=b.prototype;a.superClass_=b.prototype;a.prototype=new c;a.prototype.constructor=a;a.base=function(d,e,f){for(var g=Array(arguments.length-2),h=2;h<arguments.length;h++)g[h-2]=arguments[h];return b.prototype[e].apply(d,g)}};goog.scope=function(a){if(goog.isInModuleLoader_())throw Error("goog.scope is not supported within a module.");a.call(goog.global)};COMPILED||(goog.global.COMPILED=COMPILED);
goog.defineClass=function(a,b){var c=b.constructor,d=b.statics;c&&c!=Object.prototype.constructor||(c=function(){throw Error("cannot instantiate an interface (no constructor defined).");});c=goog.defineClass.createSealingConstructor_(c,a);a&&goog.inherits(c,a);delete b.constructor;delete b.statics;goog.defineClass.applyProperties_(c.prototype,b);d!=null&&(d instanceof Function?d(c):goog.defineClass.applyProperties_(c,d));return c};goog.defineClass.SEAL_CLASS_INSTANCES=goog.DEBUG;
goog.defineClass.createSealingConstructor_=function(a,b){return goog.defineClass.SEAL_CLASS_INSTANCES?function(){var c=a.apply(this,arguments)||this;c[goog.UID_PROPERTY_]=c[goog.UID_PROPERTY_];return c}:a};goog.defineClass.OBJECT_PROTOTYPE_FIELDS_="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");
goog.defineClass.applyProperties_=function(a,b){for(var c in b)Object.prototype.hasOwnProperty.call(b,c)&&(a[c]=b[c]);for(var d=0;d<goog.defineClass.OBJECT_PROTOTYPE_FIELDS_.length;d++)c=goog.defineClass.OBJECT_PROTOTYPE_FIELDS_[d],Object.prototype.hasOwnProperty.call(b,c)&&(a[c]=b[c])};goog.identity_=function(a){return a};
goog.createTrustedTypesPolicy=function(a){var b=null,c=goog.global.trustedTypes;if(!c||!c.createPolicy)return b;try{b=c.createPolicy(a,{createHTML:goog.identity_,createScript:goog.identity_,createScriptURL:goog.identity_})}catch(d){goog.logToConsole_(d.message)}return b};
!COMPILED&&goog.DEPENDENCIES_ENABLED&&(goog.isEdge_=function(){return!!(goog.global.navigator&&goog.global.navigator.userAgent?goog.global.navigator.userAgent:"").match(/Edge\/(\d+)(\.\d)*/i)},goog.inHtmlDocument_=function(){var a=goog.global.document;return a!=null&&"write"in a},goog.isDocumentLoading_=function(){var a=goog.global.document;return a.attachEvent?a.readyState!="complete":a.readyState=="loading"},goog.findBasePath_=function(){if(goog.global.CLOSURE_BASE_PATH!=void 0&&typeof goog.global.CLOSURE_BASE_PATH===
"string")goog.basePath=goog.global.CLOSURE_BASE_PATH;else if(goog.inHtmlDocument_()){var a=goog.global.document,b=a.currentScript;a=b?[b]:a.getElementsByTagName("SCRIPT");for(b=a.length-1;b>=0;--b){var c=a[b].src,d=c.lastIndexOf("?");d=d==-1?c.length:d;if(c.slice(d-7,d)=="base.js"){goog.basePath=c.slice(0,d-7);break}}}},goog.findBasePath_(),goog.protectScriptTag_=function(a){return a.replace(/<\/(SCRIPT)/ig,"\\x3c/$1")},goog.DebugLoader_=function(){this.dependencies_={};this.idToPath_={};this.written_=
{};this.loadingDeps_=[];this.depsToLoad_=[];this.paused_=!1;this.factory_=new goog.DependencyFactory;this.deferredCallbacks_={};this.deferredQueue_=[]},goog.DebugLoader_.prototype.bootstrap=function(a,b){function c(){d&&(goog.global.setTimeout(d,0),d=null)}var d=b;if(a.length){b=[];for(var e=0;e<a.length;e++){var f=this.getPathFromDeps_(a[e]);if(!f)throw Error("Unregonized namespace: "+a[e]);b.push(this.dependencies_[f])}f=goog.require;var g=0;for(e=0;e<a.length;e++)f(a[e]),b[e].onLoad(function(){++g==
a.length&&c()})}else c()},goog.DebugLoader_.prototype.loadClosureDeps=function(){this.depsToLoad_.push(this.factory_.createDependency(goog.normalizePath_(goog.basePath+"deps.js"),"deps.js",[],[],{}));this.loadDeps_()},goog.DebugLoader_.prototype.requested=function(a,b){(a=this.getPathFromDeps_(a))&&(b||this.areDepsLoaded_(this.dependencies_[a].requires))&&(b=this.deferredCallbacks_[a])&&(delete this.deferredCallbacks_[a],b())},goog.DebugLoader_.prototype.setDependencyFactory=function(a){this.factory_=
a},goog.DebugLoader_.prototype.load_=function(a){if(this.getPathFromDeps_(a)){var b=this,c=[],d=function(e){var f=b.getPathFromDeps_(e);if(!f)throw Error("Bad dependency path or symbol: "+e);if(!b.written_[f]){b.written_[f]=!0;e=b.dependencies_[f];for(f=0;f<e.requires.length;f++)goog.isProvided_(e.requires[f])||d(e.requires[f]);c.push(e)}};d(a);a=!!this.depsToLoad_.length;this.depsToLoad_=this.depsToLoad_.concat(c);this.paused_||a||this.loadDeps_()}else goog.logToConsole_("goog.require could not find: "+
a)},goog.DebugLoader_.prototype.loadDeps_=function(){for(var a=this,b=this.paused_;this.depsToLoad_.length&&!b;)(function(){var c=!1,d=a.depsToLoad_.shift(),e=!1;a.loading_(d);var f={pause:function(){if(c)throw Error("Cannot call pause after the call to load.");b=!0},resume:function(){c?a.resume_():b=!1},loaded:function(){if(e)throw Error("Double call to loaded.");e=!0;a.loaded_(d)},pending:function(){for(var g=[],h=0;h<a.loadingDeps_.length;h++)g.push(a.loadingDeps_[h]);return g},setModuleState:function(g){goog.moduleLoaderState_=
{type:g,moduleName:"",declareLegacyNamespace:!1}},registerEs6ModuleExports:function(g,h,k){k&&(goog.loadedModules_[k]={exports:h,type:goog.ModuleType.ES6,moduleId:k||""})},registerGoogModuleExports:function(g,h){goog.loadedModules_[g]={exports:h,type:goog.ModuleType.GOOG,moduleId:g}},clearModuleState:function(){goog.moduleLoaderState_=null},defer:function(g){if(c)throw Error("Cannot register with defer after the call to load.");a.defer_(d,g)},areDepsLoaded:function(){return a.areDepsLoaded_(d.requires)}};
try{d.load(f)}finally{c=!0}})();b&&this.pause_()},goog.DebugLoader_.prototype.pause_=function(){this.paused_=!0},goog.DebugLoader_.prototype.resume_=function(){this.paused_&&(this.paused_=!1,this.loadDeps_())},goog.DebugLoader_.prototype.loading_=function(a){this.loadingDeps_.push(a)},goog.DebugLoader_.prototype.loaded_=function(a){for(var b=0;b<this.loadingDeps_.length;b++)if(this.loadingDeps_[b]==a){this.loadingDeps_.splice(b,1);break}for(b=0;b<this.deferredQueue_.length;b++)if(this.deferredQueue_[b]==
a.path){this.deferredQueue_.splice(b,1);break}if(this.loadingDeps_.length==this.deferredQueue_.length&&!this.depsToLoad_.length)for(;this.deferredQueue_.length;)this.requested(this.deferredQueue_.shift(),!0);a.loaded()},goog.DebugLoader_.prototype.areDepsLoaded_=function(a){for(var b=0;b<a.length;b++){var c=this.getPathFromDeps_(a[b]);if(!c||!(c in this.deferredCallbacks_||goog.isProvided_(a[b])))return!1}return!0},goog.DebugLoader_.prototype.getPathFromDeps_=function(a){return a in this.idToPath_?
this.idToPath_[a]:a in this.dependencies_?a:null},goog.DebugLoader_.prototype.defer_=function(a,b){this.deferredCallbacks_[a.path]=b;this.deferredQueue_.push(a.path)},goog.LoadController=function(){},goog.LoadController.prototype.pause=function(){},goog.LoadController.prototype.resume=function(){},goog.LoadController.prototype.loaded=function(){},goog.LoadController.prototype.pending=function(){},goog.LoadController.prototype.registerEs6ModuleExports=function(a,b,c){},goog.LoadController.prototype.setModuleState=
function(a){},goog.LoadController.prototype.clearModuleState=function(){},goog.LoadController.prototype.defer=function(a){},goog.LoadController.prototype.areDepsLoaded=function(){},goog.Dependency=function(a,b,c,d,e){this.path=a;this.relativePath=b;this.provides=c;this.requires=d;this.loadFlags=e;this.loaded_=!1;this.loadCallbacks_=[]},goog.Dependency.prototype.getPathName=function(){var a=this.path,b=a.indexOf("://");b>=0&&(a=a.substring(b+3),b=a.indexOf("/"),b>=0&&(a=a.substring(b+1)));return a},
goog.Dependency.prototype.onLoad=function(a){this.loaded_?a():this.loadCallbacks_.push(a)},goog.Dependency.prototype.loaded=function(){this.loaded_=!0;var a=this.loadCallbacks_;this.loadCallbacks_=[];for(var b=0;b<a.length;b++)a[b]()},goog.Dependency.defer_=!1,goog.Dependency.callbackMap_={},goog.Dependency.registerCallback_=function(a){var b=Math.random().toString(32);goog.Dependency.callbackMap_[b]=a;return b},goog.Dependency.unregisterCallback_=function(a){delete goog.Dependency.callbackMap_[a]},
goog.Dependency.callback_=function(a,b){if(a in goog.Dependency.callbackMap_){for(var c=goog.Dependency.callbackMap_[a],d=[],e=1;e<arguments.length;e++)d.push(arguments[e]);c.apply(void 0,d)}else throw Error("Callback key "+a+" does not exist (was base.js loaded more than once?).");},goog.Dependency.prototype.load=function(a){if(goog.global.CLOSURE_IMPORT_SCRIPT)goog.global.CLOSURE_IMPORT_SCRIPT(this.path)?a.loaded():a.pause();else if(goog.inHtmlDocument_()){var b=goog.global.document;if(b.readyState==
"complete"&&!goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING){if(/\bdeps.js$/.test(this.path)){a.loaded();return}throw Error('Cannot write "'+this.path+'" after document load');}var c=goog.getScriptNonce_();if(!goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING&&goog.isDocumentLoading_()){var d=function(h){h.readyState&&h.readyState!="complete"?h.onload=d:(goog.Dependency.unregisterCallback_(e),a.loaded())};var e=goog.Dependency.registerCallback_(d);c=c?' nonce="'+c+'"':"";var f='<script src="'+this.path+'"'+
c+(goog.Dependency.defer_?" defer":"")+' id="script-'+e+'">\x3c/script>';f+="<script"+c+">";f=goog.Dependency.defer_?f+("document.getElementById('script-"+e+"').onload = function() {\n  goog.Dependency.callback_('"+e+"', this);\n};\n"):f+("goog.Dependency.callback_('"+e+"', document.getElementById('script-"+e+"'));");f+="\x3c/script>";b.write(goog.TRUSTED_TYPES_POLICY_?goog.TRUSTED_TYPES_POLICY_.createHTML(f):f)}else{var g=b.createElement("script");g.defer=goog.Dependency.defer_;g.async=!1;c&&(g.nonce=
c);g.onload=function(){g.onload=null;a.loaded()};g.src=goog.TRUSTED_TYPES_POLICY_?goog.TRUSTED_TYPES_POLICY_.createScriptURL(this.path):this.path;b.head.appendChild(g)}}else goog.logToConsole_("Cannot use default debug loader outside of HTML documents."),this.relativePath=="deps.js"?(goog.logToConsole_("Consider setting CLOSURE_IMPORT_SCRIPT before loading base.js, or setting CLOSURE_NO_DEPS to true."),a.loaded()):a.pause()},goog.Es6ModuleDependency=function(a,b,c,d,e){goog.Dependency.call(this,a,
b,c,d,e)},goog.inherits(goog.Es6ModuleDependency,goog.Dependency),goog.Es6ModuleDependency.prototype.load=function(a){function b(l,m){var n="",p=goog.getScriptNonce_();p&&(n=' nonce="'+p+'"');l=m?'<script type="module" crossorigin'+n+">"+m+"\x3c/script>":'<script type="module" crossorigin src="'+l+'"'+n+">\x3c/script>";d.write(goog.TRUSTED_TYPES_POLICY_?goog.TRUSTED_TYPES_POLICY_.createHTML(l):l)}function c(l,m){var n=d.createElement("script");n.defer=!0;n.async=!1;n.type="module";n.setAttribute("crossorigin",
!0);var p=goog.getScriptNonce_();p&&(n.nonce=p);m?n.text=goog.TRUSTED_TYPES_POLICY_?goog.TRUSTED_TYPES_POLICY_.createScript(m):m:n.src=goog.TRUSTED_TYPES_POLICY_?goog.TRUSTED_TYPES_POLICY_.createScriptURL(l):l;d.head.appendChild(n)}if(goog.global.CLOSURE_IMPORT_SCRIPT)goog.global.CLOSURE_IMPORT_SCRIPT(this.path)?a.loaded():a.pause();else if(goog.inHtmlDocument_()){var d=goog.global.document,e=this;if(goog.isDocumentLoading_()){var f=b;goog.Dependency.defer_=!0}else f=c;var g=goog.Dependency.registerCallback_(function(){goog.Dependency.unregisterCallback_(g);
a.setModuleState(goog.ModuleType.ES6)});f(void 0,'goog.Dependency.callback_("'+g+'")');f(this.path,void 0);var h=goog.Dependency.registerCallback_(function(l){goog.Dependency.unregisterCallback_(h);a.registerEs6ModuleExports(e.path,l,goog.moduleLoaderState_.moduleName)});f(void 0,'import * as m from "'+this.path+'"; goog.Dependency.callback_("'+h+'", m)');var k=goog.Dependency.registerCallback_(function(){goog.Dependency.unregisterCallback_(k);a.clearModuleState();a.loaded()});f(void 0,'goog.Dependency.callback_("'+
k+'")')}else goog.logToConsole_("Cannot use default debug loader outside of HTML documents."),a.pause()},goog.TransformedDependency=function(a,b,c,d,e){goog.Dependency.call(this,a,b,c,d,e);this.contents_=null;this.lazyFetch_=!goog.inHtmlDocument_()||!("noModule"in goog.global.document.createElement("script"))},goog.inherits(goog.TransformedDependency,goog.Dependency),goog.TransformedDependency.prototype.load=function(a){function b(){e.contents_=goog.loadFileSync_(e.path);e.contents_&&(e.contents_=
e.transform(e.contents_),e.contents_&&(e.contents_+="\n//# sourceURL="+e.path))}function c(){e.lazyFetch_&&b();if(e.contents_){f&&a.setModuleState(goog.ModuleType.ES6);try{var l=e.contents_;e.contents_=null;goog.globalEval(goog.CLOSURE_EVAL_PREFILTER_.createScript(l));if(f)var m=goog.moduleLoaderState_.moduleName}finally{f&&a.clearModuleState()}f&&goog.global.$jscomp.require.ensure([e.getPathName()],function(){a.registerEs6ModuleExports(e.path,goog.global.$jscomp.require(e.getPathName()),m)});a.loaded()}}
function d(){var l=goog.global.document,m=goog.Dependency.registerCallback_(function(){goog.Dependency.unregisterCallback_(m);c()}),n=goog.getScriptNonce_();n="<script"+(n?' nonce="'+n+'"':"")+">"+goog.protectScriptTag_('goog.Dependency.callback_("'+m+'");')+"\x3c/script>";l.write(goog.TRUSTED_TYPES_POLICY_?goog.TRUSTED_TYPES_POLICY_.createHTML(n):n)}var e=this;if(goog.global.CLOSURE_IMPORT_SCRIPT)b(),this.contents_&&goog.global.CLOSURE_IMPORT_SCRIPT("",this.contents_)?(this.contents_=null,a.loaded()):
a.pause();else{var f=this.loadFlags.module==goog.ModuleType.ES6;this.lazyFetch_||b();var g=a.pending().length>1;if(goog.Dependency.defer_&&(g||goog.isDocumentLoading_()))a.defer(function(){c()});else{var h=goog.global.document;g=goog.inHtmlDocument_()&&("ActiveXObject"in goog.global||goog.isEdge_());if(f&&goog.inHtmlDocument_()&&goog.isDocumentLoading_()&&!g){goog.Dependency.defer_=!0;a.pause();var k=h.onreadystatechange;h.onreadystatechange=function(){h.readyState=="interactive"&&(h.onreadystatechange=
k,c(),a.resume());typeof k==="function"&&k.apply(void 0,arguments)}}else goog.inHtmlDocument_()&&goog.isDocumentLoading_()?d():c()}}},goog.TransformedDependency.prototype.transform=function(a){},goog.PreTranspiledEs6ModuleDependency=function(a,b,c,d,e){goog.TransformedDependency.call(this,a,b,c,d,e)},goog.inherits(goog.PreTranspiledEs6ModuleDependency,goog.TransformedDependency),goog.PreTranspiledEs6ModuleDependency.prototype.transform=function(a){return a},goog.GoogModuleDependency=function(a,b,
c,d,e){goog.TransformedDependency.call(this,a,b,c,d,e)},goog.inherits(goog.GoogModuleDependency,goog.TransformedDependency),goog.GoogModuleDependency.prototype.transform=function(a){return goog.LOAD_MODULE_USING_EVAL&&goog.global.JSON!==void 0?"goog.loadModule("+goog.global.JSON.stringify(a+"\n//# sourceURL="+this.path+"\n")+");":'goog.loadModule(function(exports) {"use strict";'+a+"\n;return exports});\n//# sourceURL="+this.path+"\n"},goog.DebugLoader_.prototype.addDependency=function(a,b,c,d){b=
b||[];a=a.replace(/\\/g,"/");var e=goog.normalizePath_(goog.basePath+a);d&&typeof d!=="boolean"||(d=d?{module:goog.ModuleType.GOOG}:{});c=this.factory_.createDependency(e,a,b,c,d);this.dependencies_[e]=c;for(c=0;c<b.length;c++)this.idToPath_[b[c]]=e;this.idToPath_[a]=e},goog.DependencyFactory=function(){},goog.DependencyFactory.prototype.createDependency=function(a,b,c,d,e){return e.module==goog.ModuleType.GOOG?new goog.GoogModuleDependency(a,b,c,d,e):e.module==goog.ModuleType.ES6?goog.ASSUME_ES_MODULES_TRANSPILED?
new goog.PreTranspiledEs6ModuleDependency(a,b,c,d,e):new goog.Es6ModuleDependency(a,b,c,d,e):new goog.Dependency(a,b,c,d,e)},goog.debugLoader_=new goog.DebugLoader_,goog.loadClosureDeps=function(){goog.debugLoader_.loadClosureDeps()},goog.setDependencyFactory=function(a){goog.debugLoader_.setDependencyFactory(a)},goog.TRUSTED_TYPES_POLICY_=goog.TRUSTED_TYPES_POLICY_NAME?goog.createTrustedTypesPolicy(goog.TRUSTED_TYPES_POLICY_NAME+"#base"):null,goog.global.CLOSURE_NO_DEPS||goog.debugLoader_.loadClosureDeps(),
goog.bootstrap=function(a,b){goog.debugLoader_.bootstrap(a,b)});if(!COMPILED){var isChrome87=!1;try{isChrome87=eval(goog.global.trustedTypes.emptyScript)!==goog.global.trustedTypes.emptyScript}catch(a){}goog.CLOSURE_EVAL_PREFILTER_=goog.global.trustedTypes&&isChrome87&&goog.createTrustedTypesPolicy("goog#base#devonly#eval")||{createScript:goog.identity_}};/*
 @license
 Shaka Player
 Copyright 2016 Google LLC
 SPDX-License-Identifier: Apache-2.0
*/
goog.asserts=function(){};goog.asserts.assert=function(a,b){};goog.asserts.ENABLE_ASSERTS=!0;goog.asserts.ENABLE_ASSERTS&&console.assert&&console.assert.bind&&(goog.asserts.assert=console.assert.bind(console));var shaka={abr:{}};shaka.abr.Ewma=function(a){goog.asserts.assert(a>0,"expected halfLife to be positive");this.logHalf_=Math.log(.5);this.alpha_=Math.exp(this.logHalf_/a);this.totalWeight_=this.estimate_=0};shaka.abr.Ewma.prototype.updateAlpha=function(a){goog.asserts.assert(a>0,"expected halfLife to be positive");this.alpha_=Math.exp(this.logHalf_/a)};
shaka.abr.Ewma.prototype.sample=function(a,b){var c=Math.pow(this.alpha_,a);b=b*(1-c)+c*this.estimate_;isNaN(b)||(this.estimate_=b,this.totalWeight_+=a)};shaka.abr.Ewma.prototype.getEstimate=function(){return this.estimate_/(1-Math.pow(this.alpha_,this.totalWeight_))};shaka.abr.EwmaBandwidthEstimator=function(){this.fast_=new shaka.abr.Ewma(2);this.slow_=new shaka.abr.Ewma(5);this.bytesSampled_=0;this.minTotalBytes_=128E3;this.minBytes_=16E3};shaka.abr.EwmaBandwidthEstimator.prototype.configure=function(a){this.minTotalBytes_=a.minTotalBytes;this.minBytes_=a.minBytes;this.fast_.updateAlpha(a.fastHalfLife);this.slow_.updateAlpha(a.slowHalfLife)};
shaka.abr.EwmaBandwidthEstimator.prototype.sample=function(a,b){if(!(b<this.minBytes_)){var c=8E3*b/a;a/=1E3;this.bytesSampled_+=b;this.fast_.sample(a,c);this.slow_.sample(a,c)}};shaka.abr.EwmaBandwidthEstimator.prototype.getBandwidthEstimate=function(a){return this.bytesSampled_<this.minTotalBytes_?a:Math.min(this.fast_.getEstimate(),this.slow_.getEstimate())};shaka.abr.EwmaBandwidthEstimator.prototype.hasGoodEstimate=function(){return this.bytesSampled_>=this.minTotalBytes_};shaka.log=function(){};shaka.log.alwaysError=function(){};shaka.log.alwaysWarn=function(){};shaka.log.warnOnce=function(a){var b=$jscomp.getRestArguments.apply(1,arguments);shaka.log.oneTimeWarningIssued_.has(a)||(shaka.log.oneTimeWarningIssued_.add(a),shaka.log.alwaysWarn.apply(shaka.log,(0,$jscomp.arrayFromIterable)(b)))};shaka.log.error=function(){};shaka.log.warning=function(){};shaka.log.info=function(){};shaka.log.debug=function(){};shaka.log.v1=function(){};shaka.log.v2=function(){};
shaka.log.Level={NONE:0,ERROR:1,WARNING:2,INFO:3,DEBUG:4,V1:5,V2:6};shaka.log.MAX_LOG_LEVEL=4;shaka.log.oneTimeWarningIssued_=new Set;
window.console&&(shaka.log.logMap_=(new Map).set(shaka.log.Level.ERROR,function(){var a=$jscomp.getRestArguments.apply(0,arguments);return console.error.apply(console,(0,$jscomp.arrayFromIterable)(a))}).set(shaka.log.Level.WARNING,function(){var a=$jscomp.getRestArguments.apply(0,arguments);return console.warn.apply(console,(0,$jscomp.arrayFromIterable)(a))}).set(shaka.log.Level.INFO,function(){var a=$jscomp.getRestArguments.apply(0,arguments);return console.info.apply(console,(0,$jscomp.arrayFromIterable)(a))}).set(shaka.log.Level.DEBUG,
function(){var a=$jscomp.getRestArguments.apply(0,arguments);return console.log.apply(console,(0,$jscomp.arrayFromIterable)(a))}).set(shaka.log.Level.V1,function(){var a=$jscomp.getRestArguments.apply(0,arguments);return console.debug.apply(console,(0,$jscomp.arrayFromIterable)(a))}).set(shaka.log.Level.V2,function(){var a=$jscomp.getRestArguments.apply(0,arguments);return console.debug.apply(console,(0,$jscomp.arrayFromIterable)(a))}),shaka.log.alwaysWarn=function(){var a=$jscomp.getRestArguments.apply(0,
arguments);return console.warn.apply(console,(0,$jscomp.arrayFromIterable)(a))},shaka.log.alwaysError=function(){var a=$jscomp.getRestArguments.apply(0,arguments);return console.error.apply(console,(0,$jscomp.arrayFromIterable)(a))},goog.DEBUG?(goog.exportSymbol("shaka.log",shaka.log),shaka.log.setLevel=function(a){var b=function(c){return c<=a?(goog.asserts.assert(shaka.log.logMap_.has(c),"Unexpected log level"),shaka.log.logMap_.get(c)):function(){}};shaka.log.currentLevel=a;shaka.log.error=b(shaka.log.Level.ERROR);
shaka.log.warning=b(shaka.log.Level.WARNING);shaka.log.info=b(shaka.log.Level.INFO);shaka.log.debug=b(shaka.log.Level.DEBUG);shaka.log.v1=b(shaka.log.Level.V1);shaka.log.v2=b(shaka.log.Level.V2)},shaka.log.setLevel(shaka.log.MAX_LOG_LEVEL)):(shaka.log.MAX_LOG_LEVEL>=shaka.log.Level.ERROR&&(shaka.log.error=shaka.log.logMap_.get(shaka.log.Level.ERROR)),shaka.log.MAX_LOG_LEVEL>=shaka.log.Level.WARNING&&(shaka.log.warning=shaka.log.logMap_.get(shaka.log.Level.WARNING)),shaka.log.MAX_LOG_LEVEL>=shaka.log.Level.INFO&&
(shaka.log.info=shaka.log.logMap_.get(shaka.log.Level.INFO)),shaka.log.MAX_LOG_LEVEL>=shaka.log.Level.DEBUG&&(shaka.log.debug=shaka.log.logMap_.get(shaka.log.Level.DEBUG)),shaka.log.MAX_LOG_LEVEL>=shaka.log.Level.V1&&(shaka.log.v1=shaka.log.logMap_.get(shaka.log.Level.V1)),shaka.log.MAX_LOG_LEVEL>=shaka.log.Level.V2&&(shaka.log.v2=shaka.log.logMap_.get(shaka.log.Level.V2))));shaka.util={};shaka.util.ArrayUtils=function(){};shaka.util.ArrayUtils.defaultEquals=function(a,b){return typeof a==="number"&&typeof b==="number"&&isNaN(a)&&isNaN(b)?!0:a===b};shaka.util.ArrayUtils.remove=function(a,b){b=a.indexOf(b);b>-1&&a.splice(b,1)};shaka.util.ArrayUtils.count=function(a,b){var c=0;a=(0,$jscomp.makeIterator)(a);for(var d=a.next();!d.done;d=a.next())c+=b(d.value)?1:0;return c};
shaka.util.ArrayUtils.hasSameElements=function(a,b,c){c||(c=shaka.util.ArrayUtils.defaultEquals);if(a.length!=b.length)return!1;b=b.slice();a=(0,$jscomp.makeIterator)(a);for(var d=a.next(),e={};!d.done;e={item$jscomp$29:void 0},d=a.next()){e.item$jscomp$29=d.value;d=b.findIndex(function(f){return function(g){return c(f.item$jscomp$29,g)}}(e));if(d==-1)return!1;b[d]=b[b.length-1];b.pop()}return b.length==0};
shaka.util.ArrayUtils.partition=function(a,b){var c=[],d=[];a=(0,$jscomp.makeIterator)(a);for(var e=a.next();!e.done;e=a.next())e=e.value,b(e)?c.push(e):d.push(e);return[c,d]};shaka.util.ArrayUtils.binarySearch=function(a,b){for(var c=0,d=a.length;c<d;){var e=c+d>>>1;b(a[e])?c=e+1:d=e}return c};
shaka.util.ArrayUtils.equal=function(a,b,c){if(a===b)return!0;if(!a||!b)return a==b;c||(c=shaka.util.ArrayUtils.defaultEquals);if(a.length!=b.length)return!1;for(var d=0;d<a.length;d++)if(!c(a[d],b[d]))return!1;return!0};shaka.util.IReleasable=function(){};shaka.util.IReleasable.prototype.release=function(){};shaka.util.MultiMap=function(){this.map_=new Map};shaka.util.MultiMap.prototype.push=function(a,b){this.map_.has(a)?this.map_.get(a).push(b):this.map_.set(a,[b])};shaka.util.MultiMap.prototype.get=function(a){return this.map_.has(a)?this.map_.get(a).slice():null};shaka.util.MultiMap.prototype.getAll=function(){for(var a=[],b=(0,$jscomp.makeIterator)(this.map_.values()),c=b.next();!c.done;c=b.next())a.push.apply(a,(0,$jscomp.arrayFromIterable)(c.value));return a};
shaka.util.MultiMap.prototype.remove=function(a,b){if(this.map_.has(a)){var c=this.map_.get(a).filter(function(d){return d!=b});this.map_.set(a,c);c.length||this.map_.delete(a)}};shaka.util.MultiMap.prototype.clear=function(){this.map_.clear()};shaka.util.MultiMap.prototype.forEach=function(a){this.map_.forEach(function(b,c){a(c,b)})};shaka.util.MultiMap.prototype.size=function(){return this.map_.size};shaka.util.MultiMap.prototype.keys=function(){return Array.from(this.map_.keys())};shaka.util.EventManager=function(){this.bindingMap_=new shaka.util.MultiMap};shaka.util.EventManager.prototype.release=function(){this.removeAll();this.bindingMap_=null};shaka.util.EventManager.prototype.listen=function(a,b,c,d){this.bindingMap_&&(a=new shaka.util.EventManager.Binding_(a,b,c,d),this.bindingMap_.push(b,a))};shaka.util.EventManager.prototype.listenOnce=function(a,b,c,d){var e=this,f=function(g){e.unlisten(a,b,f);c(g)};this.listen(a,b,f,d)};
shaka.util.EventManager.prototype.unlisten=function(a,b,c){if(this.bindingMap_){var d=this.bindingMap_.get(b)||[];d=(0,$jscomp.makeIterator)(d);for(var e=d.next();!e.done;e=d.next())e=e.value,e.target!=a||c!=e.listener&&c||(e.unlisten(),this.bindingMap_.remove(b,e))}};shaka.util.EventManager.prototype.removeAll=function(){if(this.bindingMap_){var a=this.bindingMap_.getAll();a=(0,$jscomp.makeIterator)(a);for(var b=a.next();!b.done;b=a.next())b.value.unlisten();this.bindingMap_.clear()}};
goog.exportSymbol("shaka.util.EventManager",shaka.util.EventManager);goog.exportProperty(shaka.util.EventManager.prototype,"removeAll",shaka.util.EventManager.prototype.removeAll);goog.exportProperty(shaka.util.EventManager.prototype,"unlisten",shaka.util.EventManager.prototype.unlisten);goog.exportProperty(shaka.util.EventManager.prototype,"listenOnce",shaka.util.EventManager.prototype.listenOnce);goog.exportProperty(shaka.util.EventManager.prototype,"listen",shaka.util.EventManager.prototype.listen);
goog.exportProperty(shaka.util.EventManager.prototype,"release",shaka.util.EventManager.prototype.release);shaka.util.EventManager.Binding_=function(a,b,c,d){this.target=a;this.type=b;this.listener=c;this.options=shaka.util.EventManager.Binding_.convertOptions_(a,d);this.target.addEventListener(b,c,this.options)};
shaka.util.EventManager.Binding_.prototype.unlisten=function(){goog.asserts.assert(this.target,"Missing target");this.target.removeEventListener(this.type,this.listener,this.options);this.listener=this.target=null;this.options=!1};
shaka.util.EventManager.Binding_.convertOptions_=function(a,b){if(b==void 0)return!1;if(typeof b=="boolean")return b;var c=new Set(["passive","capture"]),d=Object.keys(b).filter(function(e){return!c.has(e)});goog.asserts.assert(d.length==0,"Unsupported flag(s) to addEventListener: "+d.join(","));return shaka.util.EventManager.Binding_.doesSupportObject_(a)?b:b.capture||!1};
shaka.util.EventManager.Binding_.doesSupportObject_=function(a){var b=shaka.util.EventManager.Binding_.supportsObject_;if(b==void 0){b=!1;try{var c={},d={get:function(){b=!0;return!1}};Object.defineProperty(c,"passive",d);Object.defineProperty(c,"capture",d);d=function(){};a.addEventListener("test",d,c);a.removeEventListener("test",d,c)}catch(e){b=!1}shaka.util.EventManager.Binding_.supportsObject_=b}return b||!1};shaka.util.EventManager.Binding_.supportsObject_=void 0;shaka.config={};shaka.config.AutoShowText={NEVER:0,ALWAYS:1,IF_PREFERRED_TEXT_LANGUAGE:2,IF_SUBTITLES_MAY_BE_NEEDED:3};goog.exportSymbol("shaka.config.AutoShowText",shaka.config.AutoShowText);shaka.util.Lazy=function(a){this.gen_=a;this.value_=void 0};shaka.util.Lazy.prototype.value=function(){this.value_===void 0&&(this.value_=this.gen_(),goog.asserts.assert(this.value_!==void 0,"Unable to create lazy value"));return this.value_};shaka.util.Lazy.prototype.reset=function(){this.value_=void 0};shaka.device={};shaka.device.DeviceFactory=function(){};shaka.device.DeviceFactory.registerDeviceFactory=function(a){goog.asserts.assert(!shaka.device.DeviceFactory.factory_,"Device Factory should NOT be defined");shaka.device.DeviceFactory.factory_=a};shaka.device.DeviceFactory.registerDefaultDeviceFactory=function(a){goog.asserts.assert(!shaka.device.DeviceFactory.defaultFactory_,"Default device Factory should NOT be defined");shaka.device.DeviceFactory.defaultFactory_=a};
shaka.device.DeviceFactory.getDevice=function(){goog.asserts.assert(shaka.device.DeviceFactory.factory_||shaka.device.DeviceFactory.defaultFactory_,"Device Factory should be defined");return shaka.device.DeviceFactory.device_.value()};shaka.device.DeviceFactory.factory_=null;shaka.device.DeviceFactory.defaultFactory_=null;
shaka.device.DeviceFactory.device_=new shaka.util.Lazy(function(){var a=void 0;shaka.device.DeviceFactory.factory_&&(a=shaka.device.DeviceFactory.factory_());!a&&shaka.device.DeviceFactory.defaultFactory_&&(a=shaka.device.DeviceFactory.defaultFactory_());a&&shaka.log.info(a.toString());return a});shaka.device.IDevice=function(){};shaka.device.IDevice.prototype.supportsMediaSource=function(){};shaka.device.IDevice.prototype.supportsMediaType=function(a){};shaka.device.IDevice.prototype.supportsMediaCapabilities=function(){};shaka.device.IDevice.prototype.getVersion=function(){};shaka.device.IDevice.prototype.getDeviceName=function(){};shaka.device.IDevice.prototype.getDeviceType=function(){};shaka.device.IDevice.prototype.getBrowserEngine=function(){};
shaka.device.IDevice.prototype.requiresEncryptionInfoInAllInitSegments=function(a,b){};shaka.device.IDevice.prototype.requiresClearAndEncryptedInitSegments=function(){};shaka.device.IDevice.prototype.insertEncryptionDataBeforeClear=function(){};shaka.device.IDevice.prototype.requiresTfhdFix=function(a){};shaka.device.IDevice.prototype.requiresEC3InitSegments=function(){};shaka.device.IDevice.prototype.supportsSequenceMode=function(){};shaka.device.IDevice.prototype.supportsSmoothCodecSwitching=function(){};
shaka.device.IDevice.prototype.seekDelay=function(){};shaka.device.IDevice.prototype.detectMaxHardwareResolution=function(){};shaka.device.IDevice.prototype.supportsServerCertificate=function(){};shaka.device.IDevice.prototype.adjustConfig=function(a){};shaka.device.IDevice.prototype.shouldOverrideDolbyVisionCodecs=function(){};shaka.device.IDevice.prototype.shouldAvoidUseTextDecoderEncoder=function(){};shaka.device.IDevice.prototype.supportsOfflineStorage=function(){};
shaka.device.IDevice.prototype.rejectCodecs=function(){};shaka.device.IDevice.prototype.getHdrLevel=function(a){};shaka.device.IDevice.prototype.supportsAirPlay=function(){};shaka.device.IDevice.prototype.misreportAC3UsingDrm=function(){};shaka.device.IDevice.prototype.returnLittleEndianUsingPlayReady=function(){};shaka.device.IDevice.prototype.supportsEncryptionSchemePolyfill=function(){};shaka.device.IDevice.prototype.misreportsSupportForPersistentLicenses=function(){};
shaka.device.IDevice.prototype.supportStandardVP9Checking=function(){};shaka.device.IDevice.prototype.createMediaKeysWhenCheckingSupport=function(){};shaka.device.IDevice.prototype.disableHEVCSupport=function(){};shaka.device.IDevice.prototype.supportsCbcsWithoutEncryptionSchemeSupport=function(){};shaka.device.IDevice.prototype.supportsContainerChangeType=function(){};shaka.device.IDevice.prototype.needWaitForEncryptedEvent=function(a){};
shaka.device.IDevice.DeviceType={DESKTOP:"DESKTOP",MOBILE:"MOBILE",TV:"TV",VR:"VR",APPLE_VR:"APPLE_VR",CONSOLE:"CONSOLE",CAST:"CAST"};shaka.device.IDevice.BrowserEngine={CHROMIUM:"CHROMIUM",EDGE:"EDGE",GECKO:"GECKO",WEBKIT:"WEBKIT",UNKNOWN:"UNKNOWN"};shaka.deprecate={};shaka.deprecate.Version=function(a,b){this.major_=a;this.minor_=b};shaka.deprecate.Version.prototype.major=function(){return this.major_};shaka.deprecate.Version.prototype.minor=function(){return this.minor_};shaka.deprecate.Version.prototype.compareTo=function(a){var b=this.minor_-a.minor_;return this.major_-a.major_||b};shaka.deprecate.Version.prototype.toString=function(){return"v"+this.major_+"."+this.minor_};
shaka.deprecate.Version.parse=function(a){a=a.substring(1).split(".",2);return new shaka.deprecate.Version(Number(a[0]),Number(a[1]))};shaka.deprecate.Enforcer=function(a,b,c){this.libraryVersion_=a;this.onPending_=b;this.onExpired_=c};shaka.deprecate.Enforcer.prototype.enforce=function(a,b,c){(a.compareTo(this.libraryVersion_)>0?this.onPending_:this.onExpired_)(this.libraryVersion_,a,b,c)};shaka.Deprecate=function(){};shaka.Deprecate.init=function(a){goog.asserts.assert(shaka.Deprecate.enforcer_==null,"Deprecate.init should only be called once.");shaka.Deprecate.enforcer_=new shaka.deprecate.Enforcer(shaka.deprecate.Version.parse(a),shaka.Deprecate.onPending_,shaka.Deprecate.onExpired_)};
shaka.Deprecate.deprecateFeature=function(a,b,c){var d=shaka.Deprecate.enforcer_;goog.asserts.assert(d,"Missing deprecation enforcer. Was |init| called?");a=new shaka.deprecate.Version(a,0);d.enforce(a,b,c)};shaka.Deprecate.onPending_=function(a,b,c,d){shaka.log.alwaysWarn([c,"has been deprecated and will be removed in",b,". We are currently at version",a,". Additional information:",d].join(" "))};
shaka.Deprecate.onExpired_=function(a,b,c,d){a=[c,"has been deprecated and has been removed in",b,". We are now at version",a,". Additional information:",d].join(" ");shaka.log.alwaysError(a);goog.asserts.assert(!1,a)};shaka.Deprecate.enforcer_=null;/*
 @license
 Copyright 2006 The Closure Library Authors
 SPDX-License-Identifier: Apache-2.0
*/
goog.uri={};goog.uri.utils={};goog.uri.utils.splitRe_=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^/?#]*)@)?([^/#?]*?)(?::([0-9]+))?(?=[/#?]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#(.*))?$");goog.uri.utils.ComponentIndex={SCHEME:1,USER_INFO:2,DOMAIN:3,PORT:4,PATH:5,QUERY_DATA:6,FRAGMENT:7};goog.uri.utils.split=function(a){return a.match(goog.uri.utils.splitRe_)};goog.Uri=function(a){var b;a instanceof goog.Uri?(this.setScheme(a.getScheme()),this.setUserInfo(a.getUserInfo()),this.setDomain(a.getDomain()),this.setPort(a.getPort()),this.setPath(a.getPath()),this.setQueryData(a.getQueryData().clone()),this.setFragment(a.getFragment())):a&&(b=goog.uri.utils.split(String(a)))?(this.setScheme(b[goog.uri.utils.ComponentIndex.SCHEME]||"",!0),this.setUserInfo(b[goog.uri.utils.ComponentIndex.USER_INFO]||"",!0),this.setDomain(b[goog.uri.utils.ComponentIndex.DOMAIN]||
"",!0),this.setPort(b[goog.uri.utils.ComponentIndex.PORT]),this.setPath(b[goog.uri.utils.ComponentIndex.PATH]||"",!0),this.setQueryData(b[goog.uri.utils.ComponentIndex.QUERY_DATA]||"",!0),this.setFragment(b[goog.uri.utils.ComponentIndex.FRAGMENT]||"",!0)):this.queryData_=new goog.Uri.QueryData(null,null)};goog.Uri.prototype.scheme_="";goog.Uri.prototype.userInfo_="";goog.Uri.prototype.domain_="";goog.Uri.prototype.port_=null;goog.Uri.prototype.path_="";goog.Uri.prototype.fragment_="";
goog.Uri.prototype.toString=function(){var a=[],b=this.getScheme();b&&a.push(goog.Uri.encodeSpecialChars_(b,goog.Uri.reDisallowedInSchemeOrUserInfo_,!0),":");if(b=this.getDomain()){a.push("//");var c=this.getUserInfo();c&&a.push(goog.Uri.encodeSpecialChars_(c,goog.Uri.reDisallowedInSchemeOrUserInfo_,!0),"@");a.push(goog.Uri.removeDoubleEncoding_(encodeURIComponent(b)));b=this.getPort();b!=null&&a.push(":",String(b))}if(b=this.getPath())this.hasDomain()&&b.charAt(0)!="/"&&a.push("/"),a.push(goog.Uri.encodeSpecialChars_(b,
b.charAt(0)=="/"?goog.Uri.reDisallowedInAbsolutePath_:goog.Uri.reDisallowedInRelativePath_,!0));(b=this.getEncodedQuery())&&a.push("?",b);(b=this.getFragment())&&a.push("#",goog.Uri.encodeSpecialChars_(b,goog.Uri.reDisallowedInFragment_));return a.join("")};
goog.Uri.prototype.resolve=function(a){var b=this.clone();b.scheme_==="data"&&(b=new goog.Uri);var c=a.hasScheme();c?b.setScheme(a.getScheme()):c=a.hasUserInfo();c?b.setUserInfo(a.getUserInfo()):c=a.hasDomain();c?b.setDomain(a.getDomain()):c=a.hasPort();var d=a.getPath();if(c)b.setPort(a.getPort());else if(c=a.hasPath()){if(d.charAt(0)!="/")if(this.hasDomain()&&!this.hasPath())d="/"+d;else{var e=b.getPath().lastIndexOf("/");e!=-1&&(d=b.getPath().substr(0,e+1)+d)}d=goog.Uri.removeDotSegments(d)}c?
b.setPath(d):c=a.hasQuery();c?b.setQueryData(a.getQueryData().clone()):c=a.hasFragment();c&&b.setFragment(a.getFragment());return b};goog.Uri.prototype.clone=function(){return new goog.Uri(this)};goog.Uri.prototype.getScheme=function(){return this.scheme_};goog.Uri.prototype.setScheme=function(a,b){if(this.scheme_=b?goog.Uri.decodeOrEmpty_(a,!0):a)this.scheme_=this.scheme_.replace(/:$/,"");return this};goog.Uri.prototype.hasScheme=function(){return!!this.scheme_};goog.Uri.prototype.getUserInfo=function(){return this.userInfo_};
goog.Uri.prototype.setUserInfo=function(a,b){this.userInfo_=b?goog.Uri.decodeOrEmpty_(a):a;return this};goog.Uri.prototype.hasUserInfo=function(){return!!this.userInfo_};goog.Uri.prototype.getDomain=function(){return this.domain_};goog.Uri.prototype.setDomain=function(a,b){this.domain_=b?goog.Uri.decodeOrEmpty_(a,!0):a;return this};goog.Uri.prototype.hasDomain=function(){return!!this.domain_};goog.Uri.prototype.getPort=function(){return this.port_};
goog.Uri.prototype.setPort=function(a){if(a){a=Number(a);if(isNaN(a)||a<0)throw Error("Bad port number "+a);this.port_=a}else this.port_=null;return this};goog.Uri.prototype.hasPort=function(){return this.port_!=null};goog.Uri.prototype.getPath=function(){return this.path_};goog.Uri.prototype.setPath=function(a,b){this.path_=b?goog.Uri.decodeOrEmpty_(a,!0):a;return this};goog.Uri.prototype.hasPath=function(){return!!this.path_};
goog.Uri.prototype.hasQuery=function(){return this.queryData_.toString()!==""};goog.Uri.prototype.setQueryData=function(a,b){a instanceof goog.Uri.QueryData?this.queryData_=a:(b||(a=goog.Uri.encodeSpecialChars_(a,goog.Uri.reDisallowedInQuery_)),this.queryData_=new goog.Uri.QueryData(a,null));return this};goog.Uri.prototype.getEncodedQuery=function(){return this.queryData_.toString()};goog.Uri.prototype.getDecodedQuery=function(){return this.queryData_.toDecodedString()};
goog.Uri.prototype.getQueryData=function(){return this.queryData_};goog.Uri.prototype.getFragment=function(){return this.fragment_};goog.Uri.prototype.setFragment=function(a,b){this.fragment_=b?goog.Uri.decodeOrEmpty_(a):a;return this};goog.Uri.prototype.hasFragment=function(){return!!this.fragment_};
goog.Uri.removeDotSegments=function(a){if(a==".."||a==".")return"";if(a.indexOf("./")==-1&&a.indexOf("/.")==-1)return a;var b=a.lastIndexOf("/",0)==0;a=a.split("/");for(var c=[],d=0;d<a.length;){var e=a[d++];e=="."?b&&d==a.length&&c.push(""):e==".."?((c.length>1||c.length==1&&c[0]!="")&&c.pop(),b&&d==a.length&&c.push("")):(c.push(e),b=!0)}return c.join("/")};goog.Uri.decodeOrEmpty_=function(a,b){return a?b?decodeURI(a):decodeURIComponent(a):""};
goog.Uri.encodeSpecialChars_=function(a,b,c){return a!=null?(a=encodeURI(a).replace(b,goog.Uri.encodeChar_),c&&(a=goog.Uri.removeDoubleEncoding_(a)),a):null};goog.Uri.encodeChar_=function(a){a=a.charCodeAt(0);return"%"+(a>>4&15).toString(16)+(a&15).toString(16)};goog.Uri.removeDoubleEncoding_=function(a){return a.replace(/%25([0-9a-fA-F]{2})/g,"%$1")};goog.Uri.reDisallowedInSchemeOrUserInfo_=/[#\/\?@]/g;goog.Uri.reDisallowedInRelativePath_=/[#\?:]/g;goog.Uri.reDisallowedInAbsolutePath_=/[#\?]/g;
goog.Uri.reDisallowedInQuery_=/[#\?@]/g;goog.Uri.reDisallowedInFragment_=/#/g;goog.Uri.QueryData=function(a,b){this.encodedQuery_=a||null};goog.Uri.QueryData.prototype.ensureKeyMapInitialized_=function(){if(!this.keyMap_&&(this.keyMap_=new Map,this.count_=0,this.encodedQuery_))for(var a=this.encodedQuery_.split("&"),b=0;b<a.length;b++){var c=a[b].indexOf("="),d=null;if(c>=0){var e=a[b].substring(0,c);d=a[b].substring(c+1)}else e=a[b];e=decodeURIComponent(e);d=d||"";this.add(e,decodeURIComponent(d))}};
goog.Uri.QueryData.prototype.keyMap_=null;goog.Uri.QueryData.prototype.count_=null;goog.Uri.QueryData.prototype.getCount=function(){this.ensureKeyMapInitialized_();return this.count_};goog.Uri.QueryData.prototype.add=function(a,b){this.ensureKeyMapInitialized_();this.encodedQuery_=null;var c=this.keyMap_.has(a)?this.keyMap_.get(a):null;c||this.keyMap_.set(a,c=[]);c.push(b);goog.asserts.assert(this.count_!=null,"Should not be null.");this.count_++;return this};
goog.Uri.QueryData.prototype.set=function(a,b){this.ensureKeyMapInitialized_();this.encodedQuery_=null;this.keyMap_.has(a)?this.keyMap_.set(a,[b]):this.add(a,b);return this};goog.Uri.QueryData.prototype.get=function(a){this.ensureKeyMapInitialized_();return this.keyMap_.get(a)||[]};
goog.Uri.QueryData.prototype.toString=function(){if(this.encodedQuery_)return this.encodedQuery_;if(!this.keyMap_||!this.keyMap_.size)return"";for(var a=[],b=(0,$jscomp.makeIterator)(this.keyMap_.keys()),c=b.next();!c.done;c=b.next()){var d=c.value;c=encodeURIComponent(d);d=this.keyMap_.get(d);for(var e=0;e<d.length;e++){var f=c;d[e]!==""&&(f+="="+encodeURIComponent(d[e]));a.push(f)}}return this.encodedQuery_=a.join("&")};goog.Uri.QueryData.prototype.toDecodedString=function(){return goog.Uri.decodeOrEmpty_(this.toString())};
goog.Uri.QueryData.prototype.clone=function(){var a=new goog.Uri.QueryData;a.encodedQuery_=this.encodedQuery_;if(this.keyMap_){for(var b=new Map,c=(0,$jscomp.makeIterator)(this.keyMap_),d=c.next();!d.done;d=c.next()){var e=(0,$jscomp.makeIterator)(d.value);d=e.next().value;e=e.next().value;b.set(d,e.concat())}a.keyMap_=b;a.count_=this.count_}return a};shaka.util.BufferUtils=function(){};shaka.util.BufferUtils.equal=function(a,b){var c=shaka.util.BufferUtils;if(!a&&!b)return!0;if(!a||!b||a.byteLength!=b.byteLength)return!1;if(c.unsafeGetArrayBuffer_(a)==c.unsafeGetArrayBuffer_(b)&&(a.byteOffset||0)==(b.byteOffset||0))return!0;c=shaka.util.BufferUtils.toUint8(a);b=shaka.util.BufferUtils.toUint8(b);for(var d=0;d<a.byteLength;d++)if(c[d]!=b[d])return!1;return!0};
shaka.util.BufferUtils.unsafeGetArrayBuffer_=function(a){return ArrayBuffer.isView(a)?a.buffer:a};shaka.util.BufferUtils.toArrayBuffer=function(a){return ArrayBuffer.isView(a)?a.byteOffset==0&&a.byteLength==a.buffer.byteLength?a.buffer:(new Uint8Array(a)).buffer:a};shaka.util.BufferUtils.toUint8=function(a,b,c){c=c===void 0?Infinity:c;return shaka.util.BufferUtils.view_(a,b===void 0?0:b,c,Uint8Array)};
shaka.util.BufferUtils.toUint16=function(a,b,c){c=c===void 0?Infinity:c;return shaka.util.BufferUtils.view_(a,b===void 0?0:b,c,Uint16Array)};shaka.util.BufferUtils.toDataView=function(a,b,c){c=c===void 0?Infinity:c;return shaka.util.BufferUtils.view_(a,b===void 0?0:b,c,DataView)};
shaka.util.BufferUtils.view_=function(a,b,c,d){var e=shaka.util.BufferUtils.unsafeGetArrayBuffer_(a),f=1;"BYTES_PER_ELEMENT"in d&&(f=d.BYTES_PER_ELEMENT);var g=((a.byteOffset||0)+a.byteLength)/f;a=Math.floor(Math.max(0,Math.min(((a.byteOffset||0)+b)/f,g)));return new d(e,a,Math.floor(Math.min(a+Math.max(c,0),g))-a)};goog.exportSymbol("shaka.util.BufferUtils",shaka.util.BufferUtils);goog.exportProperty(shaka.util.BufferUtils,"toDataView",shaka.util.BufferUtils.toDataView);
goog.exportProperty(shaka.util.BufferUtils,"toUint16",shaka.util.BufferUtils.toUint16);goog.exportProperty(shaka.util.BufferUtils,"toUint8",shaka.util.BufferUtils.toUint8);goog.exportProperty(shaka.util.BufferUtils,"toArrayBuffer",shaka.util.BufferUtils.toArrayBuffer);goog.exportProperty(shaka.util.BufferUtils,"equal",shaka.util.BufferUtils.equal);shaka.drm={};shaka.drm.DrmUtils=function(){};shaka.drm.DrmUtils.isBrowserSupported=function(){return!!window.MediaKeys&&!!window.navigator&&!!window.navigator.requestMediaKeySystemAccess&&!!window.MediaKeySystemAccess&&!!window.MediaKeySystemAccess.prototype.getConfiguration};
shaka.drm.DrmUtils.areDrmCompatible=function(a,b){if(a===b||!a.length||!b.length)return!0;a=(0,$jscomp.makeIterator)(a);for(var c=a.next();!c.done;c=a.next()){c=c.value;if(shaka.drm.DrmUtils.isClearKeyWihRawKey(c))return!0;for(var d=(0,$jscomp.makeIterator)(b),e=d.next();!e.done;e=d.next())if(e=e.value,c.keySystem===e.keySystem||shaka.drm.DrmUtils.isClearKeyWihRawKey(e))return!0}return!1};
shaka.drm.DrmUtils.getCommonDrmInfos=function(a,b){if(!a.length)return b;if(!b.length)return a;var c=[];a=(0,$jscomp.makeIterator)(a);for(var d=a.next();!d.done;d=a.next()){d=d.value;for(var e=(0,$jscomp.makeIterator)(b),f=e.next();!f.done;f=e.next())if(f=f.value,d.keySystem==f.keySystem){e=new Map;var g=(d.initData||[]).concat(f.initData||[]);g=(0,$jscomp.makeIterator)(g);for(var h=g.next();!h.done;h=g.next())h=h.value,e.set(h.keyId,h);e=Array.from(e.values());g=d.keyIds&&f.keyIds?new Set([].concat((0,$jscomp.arrayFromIterable)(d.keyIds),
(0,$jscomp.arrayFromIterable)(f.keyIds))):d.keyIds||f.keyIds;c.push({keySystem:d.keySystem,licenseServerUri:d.licenseServerUri||f.licenseServerUri,distinctiveIdentifierRequired:d.distinctiveIdentifierRequired||f.distinctiveIdentifierRequired,persistentStateRequired:d.persistentStateRequired||f.persistentStateRequired,videoRobustness:d.videoRobustness||f.videoRobustness,audioRobustness:d.audioRobustness||f.audioRobustness,serverCertificate:d.serverCertificate||f.serverCertificate,serverCertificateUri:d.serverCertificateUri||
f.serverCertificateUri,initData:e,keyIds:g});break}else shaka.drm.DrmUtils.isClearKeyWihRawKey(d)?c.push(d):shaka.drm.DrmUtils.isClearKeyWihRawKey(f)&&c.push(f)}return c};shaka.drm.DrmUtils.keySystem=function(a){return a?a.keySystem:""};shaka.drm.DrmUtils.isClearKeySystem=function(a){return a==="org.w3.clearkey"};shaka.drm.DrmUtils.isWidevineKeySystem=function(a){return a?!!a.match(/^com\.widevine\.alpha/):!1};
shaka.drm.DrmUtils.isPlayReadyKeySystem=function(a){return a?!!a.match(/^com\.(microsoft|chromecast)\.playready/):!1};shaka.drm.DrmUtils.isFairPlayKeySystem=function(a){return a?!!a.match(/^com\.apple\.fps/):!1};shaka.drm.DrmUtils.isWisePlayKeySystem=function(a){return a==="com.huawei.wiseplay"};shaka.drm.DrmUtils.isClearKeyWihRawKey=function(a){return(a=a.licenseServerUri)?a.startsWith("data:application/json;base64,"):!1};
shaka.drm.DrmUtils.generateKeySystemCacheKey_=function(a,b,c,d){d=new Set(d);d=[].concat((0,$jscomp.arrayFromIterable)(d)).sort().join("#");return a+"#"+b+"#"+c+"#"+d};shaka.drm.DrmUtils.hasMediaKeySystemAccess=function(a,b,c,d){var e=shaka.drm.DrmUtils;a=e.generateKeySystemCacheKey_(a,b,c,d);return e.memoizedMediaKeySystemAccessRequests_.has(a)};
shaka.drm.DrmUtils.getMediaKeySystemAccess=function(a,b,c,d){var e=shaka.drm.DrmUtils;a=e.generateKeySystemCacheKey_(a,b,c,d);return e.memoizedMediaKeySystemAccessRequests_.get(a)||null};shaka.drm.DrmUtils.setMediaKeySystemAccess=function(a,b,c,d,e){var f=shaka.drm.DrmUtils;a=f.generateKeySystemCacheKey_(a,b,c,d);f.memoizedMediaKeySystemAccessRequests_.set(a,e)};shaka.drm.DrmUtils.clearMediaKeySystemAccessMap=function(){shaka.drm.DrmUtils.memoizedMediaKeySystemAccessRequests_.clear()};
shaka.drm.DrmUtils.isMediaKeysPolyfilled=function(a){return a===window.shakaMediaKeysPolyfill};shaka.drm.DrmUtils.DUMMY_KEY_ID=new shaka.util.Lazy(function(){return shaka.util.BufferUtils.toArrayBuffer(new Uint8Array([0]))});shaka.drm.DrmUtils.memoizedMediaKeySystemAccessRequests_=new Map;shaka.util.Error=function(a,b,c){var d=$jscomp.getRestArguments.apply(3,arguments);this.severity=a;this.category=b;this.code=c;this.data=d;this.handled=!1;d="Shaka Error "+this.code;if(goog.DEBUG){var e=d="UNKNOWN",f;for(f in shaka.util.Error.Category)shaka.util.Error.Category[f]==this.category&&(d=f);for(var g in shaka.util.Error.Code)shaka.util.Error.Code[g]==this.code&&(e=g);d="Shaka Error "+d+"."+e+" ("+this.data.toString()+")"}this.message=d;if(shaka.util.Error.createStack)try{throw Error(this.message||
"Shaka Error");}catch(h){this.stack=h.stack}};shaka.util.Error.prototype.toString=function(){return"shaka.util.Error "+JSON.stringify(this,null,"  ")};goog.exportSymbol("shaka.util.Error",shaka.util.Error);shaka.util.Error.createStack=!0;shaka.util.Error.Severity={RECOVERABLE:1,CRITICAL:2};goog.exportProperty(shaka.util.Error,"Severity",shaka.util.Error.Severity);shaka.util.Error.Category={NETWORK:1,TEXT:2,MEDIA:3,MANIFEST:4,STREAMING:5,DRM:6,PLAYER:7,CAST:8,STORAGE:9,ADS:10};
goog.exportProperty(shaka.util.Error,"Category",shaka.util.Error.Category);
shaka.util.Error.Code={UNSUPPORTED_SCHEME:1E3,BAD_HTTP_STATUS:1001,HTTP_ERROR:1002,TIMEOUT:1003,MALFORMED_DATA_URI:1004,REQUEST_FILTER_ERROR:1006,RESPONSE_FILTER_ERROR:1007,MALFORMED_TEST_URI:1008,UNEXPECTED_TEST_REQUEST:1009,ATTEMPTS_EXHAUSTED:1010,SEGMENT_MISSING:1011,INVALID_TEXT_HEADER:2E3,INVALID_TEXT_CUE:2001,UNABLE_TO_DETECT_ENCODING:2003,BAD_ENCODING:2004,INVALID_XML:2005,INVALID_MP4_TTML:2007,INVALID_MP4_VTT:2008,UNABLE_TO_EXTRACT_CUE_START_TIME:2009,INVALID_MP4_CEA:2010,TEXT_COULD_NOT_GUESS_MIME_TYPE:2011,
CANNOT_ADD_EXTERNAL_TEXT_TO_SRC_EQUALS:2012,TEXT_ONLY_WEBVTT_SRC_EQUALS:2013,MISSING_TEXT_PLUGIN:2014,UNSUPPORTED_EXTERNAL_THUMBNAILS_URI:2017,BUFFER_READ_OUT_OF_BOUNDS:3E3,JS_INTEGER_OVERFLOW:3001,EBML_OVERFLOW:3002,EBML_BAD_FLOATING_POINT_SIZE:3003,MP4_SIDX_WRONG_BOX_TYPE:3004,MP4_SIDX_INVALID_TIMESCALE:3005,MP4_SIDX_TYPE_NOT_SUPPORTED:3006,WEBM_CUES_ELEMENT_MISSING:3007,WEBM_EBML_HEADER_ELEMENT_MISSING:3008,WEBM_SEGMENT_ELEMENT_MISSING:3009,WEBM_INFO_ELEMENT_MISSING:3010,WEBM_DURATION_ELEMENT_MISSING:3011,
WEBM_CUE_TRACK_POSITIONS_ELEMENT_MISSING:3012,WEBM_CUE_TIME_ELEMENT_MISSING:3013,MEDIA_SOURCE_OPERATION_FAILED:3014,MEDIA_SOURCE_OPERATION_THREW:3015,VIDEO_ERROR:3016,QUOTA_EXCEEDED_ERROR:3017,TRANSMUXING_FAILED:3018,CONTENT_TRANSFORMATION_FAILED:3019,MSS_MISSING_DATA_FOR_TRANSMUXING:3020,MSS_TRANSMUXING_FAILED:3022,TRANSMUXING_NO_VIDEO_DATA:3023,STREAMING_NOT_ALLOWED:3024,UNABLE_TO_GUESS_MANIFEST_TYPE:4E3,DASH_INVALID_XML:4001,DASH_NO_SEGMENT_INFO:4002,DASH_EMPTY_ADAPTATION_SET:4003,DASH_EMPTY_PERIOD:4004,
DASH_WEBM_MISSING_INIT:4005,DASH_UNSUPPORTED_CONTAINER:4006,DASH_PSSH_BAD_ENCODING:4007,DASH_NO_COMMON_KEY_SYSTEM:4008,DASH_MULTIPLE_KEY_IDS_NOT_SUPPORTED:4009,DASH_CONFLICTING_KEY_IDS:4010,RESTRICTIONS_CANNOT_BE_MET:4012,HLS_PLAYLIST_HEADER_MISSING:4015,INVALID_HLS_TAG:4016,HLS_INVALID_PLAYLIST_HIERARCHY:4017,DASH_DUPLICATE_REPRESENTATION_ID:4018,HLS_MULTIPLE_MEDIA_INIT_SECTIONS_FOUND:4020,HLS_REQUIRED_ATTRIBUTE_MISSING:4023,HLS_REQUIRED_TAG_MISSING:4024,HLS_COULD_NOT_GUESS_CODECS:4025,HLS_KEYFORMATS_NOT_SUPPORTED:4026,
DASH_UNSUPPORTED_XLINK_ACTUATE:4027,DASH_XLINK_DEPTH_LIMIT:4028,CONTENT_UNSUPPORTED_BY_BROWSER:4032,CANNOT_ADD_EXTERNAL_TEXT_TO_LIVE_STREAM:4033,NO_VARIANTS:4036,PERIOD_FLATTENING_FAILED:4037,INCONSISTENT_DRM_ACROSS_PERIODS:4038,HLS_VARIABLE_NOT_FOUND:4039,HLS_MSE_ENCRYPTED_MP2T_NOT_SUPPORTED:4040,HLS_MSE_ENCRYPTED_LEGACY_APPLE_MEDIA_KEYS_NOT_SUPPORTED:4041,NO_WEB_CRYPTO_API:4042,CANNOT_ADD_EXTERNAL_THUMBNAILS_TO_LIVE_STREAM:4045,MSS_INVALID_XML:4046,MSS_LIVE_CONTENT_NOT_SUPPORTED:4047,AES_128_INVALID_IV_LENGTH:4048,
AES_128_INVALID_KEY_LENGTH:4049,DASH_CONFLICTING_AES_128:4050,DASH_UNSUPPORTED_AES_128:4051,DASH_INVALID_PATCH:4052,HLS_EMPTY_MEDIA_PLAYLIST:4053,DASH_MSE_ENCRYPTED_LEGACY_APPLE_MEDIA_KEYS_NOT_SUPPORTED:4054,CANNOT_ADD_EXTERNAL_CHAPTERS_TO_LIVE_STREAM:4055,STREAMING_ENGINE_STARTUP_INVALID_STATE:5006,NO_RECOGNIZED_KEY_SYSTEMS:6E3,REQUESTED_KEY_SYSTEM_CONFIG_UNAVAILABLE:6001,FAILED_TO_CREATE_CDM:6002,FAILED_TO_ATTACH_TO_VIDEO:6003,INVALID_SERVER_CERTIFICATE:6004,FAILED_TO_CREATE_SESSION:6005,FAILED_TO_GENERATE_LICENSE_REQUEST:6006,
LICENSE_REQUEST_FAILED:6007,LICENSE_RESPONSE_REJECTED:6008,ENCRYPTED_CONTENT_WITHOUT_DRM_INFO:6010,NO_LICENSE_SERVER_GIVEN:6012,OFFLINE_SESSION_REMOVED:6013,EXPIRED:6014,SERVER_CERTIFICATE_REQUIRED:6015,INIT_DATA_TRANSFORM_ERROR:6016,SERVER_CERTIFICATE_REQUEST_FAILED:6017,MIN_HDCP_VERSION_NOT_MATCH:6018,ERROR_CHECKING_HDCP_VERSION:6019,MISSING_EME_SUPPORT:6020,LOAD_INTERRUPTED:7E3,OPERATION_ABORTED:7001,NO_VIDEO_ELEMENT:7002,OBJECT_DESTROYED:7003,CONTENT_NOT_LOADED:7004,SRC_EQUALS_PRELOAD_NOT_SUPPORTED:7005,
PRELOAD_DESTROYED:7006,QUEUE_INDEX_OUT_OF_BOUNDS:7007,CAST_API_UNAVAILABLE:8E3,NO_CAST_RECEIVERS:8001,ALREADY_CASTING:8002,UNEXPECTED_CAST_ERROR:8003,CAST_CANCELED_BY_USER:8004,CAST_CONNECTION_TIMED_OUT:8005,CAST_RECEIVER_APP_UNAVAILABLE:8006,STORAGE_NOT_SUPPORTED:9E3,INDEXED_DB_ERROR:9001,DEPRECATED_OPERATION_ABORTED:9002,REQUESTED_ITEM_NOT_FOUND:9003,MALFORMED_OFFLINE_URI:9004,CANNOT_STORE_LIVE_OFFLINE:9005,NO_INIT_DATA_FOR_OFFLINE:9007,LOCAL_PLAYER_INSTANCE_REQUIRED:9008,NEW_KEY_OPERATION_NOT_SUPPORTED:9011,
KEY_NOT_FOUND:9012,MISSING_STORAGE_CELL:9013,STORAGE_LIMIT_REACHED:9014,DOWNLOAD_SIZE_CALLBACK_ERROR:9015,MODIFY_OPERATION_NOT_SUPPORTED:9016,INDEXED_DB_INIT_TIMED_OUT:9017,CS_IMA_SDK_MISSING:1E4,CS_AD_MANAGER_NOT_INITIALIZED:10001,SS_IMA_SDK_MISSING:10002,SS_AD_MANAGER_NOT_INITIALIZED:10003,CURRENT_DAI_REQUEST_NOT_FINISHED:10004,MT_AD_MANAGER_NOT_INITIALIZED:10005,INTERSTITIAL_AD_MANAGER_NOT_INITIALIZED:10006,VAST_INVALID_XML:10007};goog.exportProperty(shaka.util.Error,"Code",shaka.util.Error.Code);shaka.util.StringUtils=function(){};
shaka.util.StringUtils.fromUTF8=function(a){if(!a)return"";a=shaka.util.BufferUtils.toUint8(a);a[0]==239&&a[1]==187&&a[2]==191&&(a=a.subarray(3));if(window.TextDecoder&&!shaka.device.DeviceFactory.getDevice().shouldAvoidUseTextDecoderEncoder())return a=(new TextDecoder).decode(a),a.includes("\ufffd")&&shaka.log.alwaysError('Decoded string contains an "unknown character" codepoint.  That probably means the UTF8 encoding was incorrect!'),a;for(var b="",c=0;c<a.length;++c){var d=65533;(a[c]&128)==0?
d=a[c]:a.length>=c+2&&(a[c]&224)==192&&(a[c+1]&192)==128?(d=(a[c]&31)<<6|a[c+1]&63,c+=1):a.length>=c+3&&(a[c]&240)==224&&(a[c+1]&192)==128&&(a[c+2]&192)==128?(d=(a[c]&15)<<12|(a[c+1]&63)<<6|a[c+2]&63,c+=2):a.length>=c+4&&(a[c]&241)==240&&(a[c+1]&192)==128&&(a[c+2]&192)==128&&(a[c+3]&192)==128&&(d=(a[c]&7)<<18|(a[c+1]&63)<<12|(a[c+2]&63)<<6|a[c+3]&63,c+=3);if(d<=65535)b+=String.fromCharCode(d);else{d-=65536;var e=d&1023;b+=String.fromCharCode(55296+(d>>10));b+=String.fromCharCode(56320+e)}}return b};
shaka.util.StringUtils.fromUTF16=function(a,b,c){if(!a)return"";if(!c&&a.byteLength%2!=0)throw shaka.log.error("Data has an incorrect length, must be even."),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.BAD_ENCODING);c=Math.floor(a.byteLength/2);var d=new Uint16Array(c);a=shaka.util.BufferUtils.toDataView(a);for(var e=0;e<c;e++)d[e]=a.getUint16(e*2,b);return shaka.util.StringUtils.fromCharCode(d)};
shaka.util.StringUtils.fromBytesAutoDetect=function(a){var b=shaka.util.StringUtils;if(!a)return"";var c=shaka.util.BufferUtils.toUint8(a);if(c[0]==239&&c[1]==187&&c[2]==191)return b.fromUTF8(c);if(c[0]==254&&c[1]==255)return b.fromUTF16(c.subarray(2),!1);if(c[0]==255&&c[1]==254)return b.fromUTF16(c.subarray(2),!0);var d=function(e){return c.byteLength<=e||c[e]>=9&&c[e]<=126};shaka.log.debug("Unable to find byte-order-mark, making an educated guess.");if(c[0]==0&&c[2]==0)return b.fromUTF16(a,!1);
if(c[1]==0&&c[3]==0)return b.fromUTF16(a,!0);if(d(0)&&d(1)&&d(2)&&d(3))return b.fromUTF8(a);throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.UNABLE_TO_DETECT_ENCODING);};
shaka.util.StringUtils.toUTF8=function(a){if(window.TextEncoder&&!shaka.device.DeviceFactory.getDevice().shouldAvoidUseTextDecoderEncoder()){var b=new TextEncoder;return shaka.util.BufferUtils.toArrayBuffer(b.encode(a))}a=encodeURIComponent(a);a=unescape(a);b=new Uint8Array(a.length);for(var c=0;c<a.length;c++)b[c]=a[c].charCodeAt(0);return shaka.util.BufferUtils.toArrayBuffer(b)};
shaka.util.StringUtils.toUTF16=function(a,b){for(var c=new ArrayBuffer(a.length*2),d=new DataView(c),e=0;e<a.length;++e){var f=a.charCodeAt(e);d.setUint16(e*2,f,b)}return c};shaka.util.StringUtils.fromCharCode=function(a){return shaka.util.StringUtils.fromCharCodeImpl_.value()(a)};shaka.util.StringUtils.resetFromCharCode=function(){shaka.util.StringUtils.fromCharCodeImpl_.reset()};
shaka.util.StringUtils.htmlUnescape=function(a){var b={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&apos;":"'","&nbsp;":"\u00a0","&lrm;":"\u200e","&rlm;":"\u200f"},c=/&(?:amp|lt|gt|quot|apos|nbsp|lrm|rlm|#[xX]?[0-9a-fA-F]+);/g,d=RegExp(c.source);return a&&d.test(a)?a.replace(c,function(e){return e[1]=="#"?(e=e[2]=="x"||e[2]=="X"?parseInt(e.substring(3),16):parseInt(e.substring(2),10),e>=0&&e<=1114111?String.fromCodePoint(e):""):b[e]||"'"}):a||""};goog.exportSymbol("shaka.util.StringUtils",shaka.util.StringUtils);
goog.exportProperty(shaka.util.StringUtils,"resetFromCharCode",shaka.util.StringUtils.resetFromCharCode);goog.exportProperty(shaka.util.StringUtils,"toUTF16",shaka.util.StringUtils.toUTF16);goog.exportProperty(shaka.util.StringUtils,"toUTF8",shaka.util.StringUtils.toUTF8);goog.exportProperty(shaka.util.StringUtils,"fromBytesAutoDetect",shaka.util.StringUtils.fromBytesAutoDetect);goog.exportProperty(shaka.util.StringUtils,"fromUTF16",shaka.util.StringUtils.fromUTF16);
goog.exportProperty(shaka.util.StringUtils,"fromUTF8",shaka.util.StringUtils.fromUTF8);
shaka.util.StringUtils.fromCharCodeImpl_=new shaka.util.Lazy(function(){for(var a=function(c){try{var d=new Uint8Array(c),e=String.fromCharCode.apply(null,d);goog.asserts.assert(e,"Should get value");return e.length>0}catch(f){return!1}},b={size$jscomp$22:65536};b.size$jscomp$22>0;b={size$jscomp$22:b.size$jscomp$22},b.size$jscomp$22/=2)if(a(b.size$jscomp$22))return function(c){return function(d){for(var e="",f=0;f<d.length;f+=c.size$jscomp$22){var g=d.subarray(f,f+c.size$jscomp$22);e+=String.fromCharCode.apply(null,
g)}return e}}(b);goog.asserts.assert(!1,"Unable to create a fromCharCode method");return null});shaka.util.Uint8ArrayUtils=function(){};shaka.util.Uint8ArrayUtils.toStandardBase64=function(a){a=shaka.util.BufferUtils.toUint8(a);return Uint8Array.prototype.toBase64?a.toBase64({alphabet:"base64",omitPadding:!1}):(a=shaka.util.StringUtils.fromCharCode(a),btoa(a))};
shaka.util.Uint8ArrayUtils.toBase64=function(a,b){b=b==void 0?!0:b;return Uint8Array.prototype.toBase64?shaka.util.BufferUtils.toUint8(a).toBase64({alphabet:"base64url",omitPadding:!b}):(a=shaka.util.Uint8ArrayUtils.toStandardBase64(a).replace(/\+/g,"-").replace(/\//g,"_"),b?a:a.replace(/[=]*$/,""))};
shaka.util.Uint8ArrayUtils.fromBase64=function(a){if(!("fromBase64"in Uint8Array)){a=window.atob(a.replace(/-/g,"+").replace(/_/g,"/"));for(var b=new Uint8Array(a.length),c=0;c<a.length;++c)b[c]=a.charCodeAt(c);return b}a=a.replace(/\s+/g,"");b=/[-_]/.test(a);return Uint8Array.fromBase64(a,{alphabet:b?"base64url":"base64"})};shaka.util.Uint8ArrayUtils.fromHex=function(a){if(!("fromHex"in Uint8Array)){for(var b=a.length/2,c=new Uint8Array(b),d=0;d<b;d++)c[d]=window.parseInt(a.substr(d*2,2),16);return c}return Uint8Array.fromHex(a)};
shaka.util.Uint8ArrayUtils.toHex=function(a){var b=shaka.util.BufferUtils.toUint8(a);if(!Uint8Array.prototype.toHex){a="";b=(0,$jscomp.makeIterator)(b);for(var c=b.next();!c.done;c=b.next())c=c.value,c=c.toString(16),c.length==1&&(c="0"+c),a+=c;return a}return b.toHex()};shaka.util.Uint8ArrayUtils.concat=function(){var a=$jscomp.getRestArguments.apply(0,arguments);return shaka.util.Uint8ArrayUtils.concatRange(a,0,a.length)};
shaka.util.Uint8ArrayUtils.concatRange=function(a,b,c){b=b===void 0?0:b;c=c===void 0?a.length:c;for(var d=shaka.util.BufferUtils,e=0,f=b;f<c;++f)e+=a[f].byteLength;e=new Uint8Array(e);for(f=0;b<c;++b){var g=a[b];ArrayBuffer.isView(g)&&g.BYTES_PER_ELEMENT===1?e.set(g,f):e.set(d.toUint8(g),f);f+=g.byteLength}return e};goog.exportSymbol("shaka.util.Uint8ArrayUtils",shaka.util.Uint8ArrayUtils);goog.exportProperty(shaka.util.Uint8ArrayUtils,"concat",shaka.util.Uint8ArrayUtils.concat);
goog.exportProperty(shaka.util.Uint8ArrayUtils,"toHex",shaka.util.Uint8ArrayUtils.toHex);goog.exportProperty(shaka.util.Uint8ArrayUtils,"fromHex",shaka.util.Uint8ArrayUtils.fromHex);goog.exportProperty(shaka.util.Uint8ArrayUtils,"fromBase64",shaka.util.Uint8ArrayUtils.fromBase64);goog.exportProperty(shaka.util.Uint8ArrayUtils,"toBase64",shaka.util.Uint8ArrayUtils.toBase64);goog.exportProperty(shaka.util.Uint8ArrayUtils,"toStandardBase64",shaka.util.Uint8ArrayUtils.toStandardBase64);shaka.util.ManifestParserUtils=function(){};
shaka.util.ManifestParserUtils.resolveUris=function(a,b,c){c=c===void 0?"":c;if(b.length==0)return a;if(a.length==1&&b.length==1){var d=new goog.Uri(a[0]);b=new goog.Uri(b[0]);b=d.resolve(b);c&&b.setQueryData(c);return[b.toString()]}b=b.map(function(h){return new goog.Uri(h)});d=[];a=(0,$jscomp.makeIterator)(a);for(var e=a.next();!e.done;e=a.next()){e=new goog.Uri(e.value);for(var f=(0,$jscomp.makeIterator)(b),g=f.next();!g.done;g=f.next())g=e.resolve(g.value),c&&g.setQueryData(c),d.push(g.toString())}return d};
shaka.util.ManifestParserUtils.createDrmInfo=function(a,b,c,d,e){b={keySystem:a,encryptionScheme:b,licenseServerUri:"",distinctiveIdentifierRequired:!1,persistentStateRequired:!1,audioRobustness:"",videoRobustness:"",serverCertificate:null,serverCertificateUri:"",sessionType:"",initData:c||[],keyIds:new Set,mediaTypes:e};d&&(b.keySystemUris=new Set([d]));!c&&shaka.drm.DrmUtils.isFairPlayKeySystem(a)&&b.initData.push({initDataType:"sinf",initData:new Uint8Array(0),keyId:null});return b};
shaka.util.ManifestParserUtils.createDrmInfoFromClearKeys=function(a,b){b=b===void 0?"cenc":b;var c=shaka.util.StringUtils,d=shaka.util.Uint8ArrayUtils,e=[],f=[],g=[];a.forEach(function(k,l){var m=l;m.length!=22&&(m=d.toBase64(d.fromHex(l),!1));var n=k;n.length!=22&&(n=d.toBase64(d.fromHex(k),!1));k={kty:"oct",kid:m,k:n};e.push(k);f.push(k.kid);g.push(l)});a=JSON.stringify({keys:e});var h=JSON.stringify({kids:f});c=[{initData:shaka.util.BufferUtils.toUint8(c.toUTF8(h)),initDataType:"keyids"}];return{keySystem:"org.w3.clearkey",
encryptionScheme:b,licenseServerUri:"data:application/json;base64,"+window.btoa(a),distinctiveIdentifierRequired:!1,persistentStateRequired:!1,audioRobustness:"",videoRobustness:"",serverCertificate:null,serverCertificateUri:"",sessionType:"",initData:c,keyIds:new Set(g)}};
shaka.util.ManifestParserUtils.guessCodecs=function(a,b){if(b.length==1)return b[0];a=shaka.util.ManifestParserUtils.guessCodecsSafe(a,b);if(a!=null)return a;throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.HLS_COULD_NOT_GUESS_CODECS,b);};
shaka.util.ManifestParserUtils.guessCodecsSafe=function(a,b){var c=shaka.util.ManifestParserUtils.CODEC_REGEXPS_BY_CONTENT_TYPE_.get(a);c=(0,$jscomp.makeIterator)(c);for(var d=c.next();!d.done;d=c.next()){d=d.value;for(var e=(0,$jscomp.makeIterator)(b),f=e.next();!f.done;f=e.next())if(f=f.value,d.test(f.trim()))return f.trim()}return a==shaka.util.ManifestParserUtils.ContentType.TEXT?"":null};
shaka.util.ManifestParserUtils.guessAllCodecsSafe=function(a,b){var c=[];a=shaka.util.ManifestParserUtils.CODEC_REGEXPS_BY_CONTENT_TYPE_.get(a);a=(0,$jscomp.makeIterator)(a);for(var d=a.next();!d.done;d=a.next()){d=d.value;for(var e=(0,$jscomp.makeIterator)(b),f=e.next();!f.done;f=e.next())f=f.value,d.test(f.trim())&&c.push(f.trim())}return c};shaka.util.ManifestParserUtils.ContentType={VIDEO:"video",AUDIO:"audio",TEXT:"text",IMAGE:"image",APPLICATION:"application"};
shaka.util.ManifestParserUtils.TextStreamKind={SUBTITLE:"subtitle",CLOSED_CAPTION:"caption"};shaka.util.ManifestParserUtils.GAP_OVERLAP_TOLERANCE_SECONDS=1/15;shaka.util.ManifestParserUtils.VIDEO_CODEC_REGEXPS=[/^avc/,/^hev/,/^hvc/,/^vvc/,/^vvi/,/^vp0?[89]/,/^av01/,/^mp2v/,/^dvh/,/^dva/,/^dav/];shaka.util.ManifestParserUtils.AUDIO_CODEC_REGEXPS=[/^vorbis$/,/^Opus$/,/^opus$/,/^fLaC$/,/^flac$/,/^mp4a/,/^[ae]c-3$/,/^ac-4/,/^dts[cehx]?$/,/^iamf/,/^mhm[12]/,/^ac3$/,/^eac3$/,/^apac$/];
shaka.util.ManifestParserUtils.TEXT_CODEC_REGEXPS=[/^vtt$/,/^wvtt/,/^stpp/];shaka.util.ManifestParserUtils.CODEC_REGEXPS_BY_CONTENT_TYPE_=(new Map).set("audio",shaka.util.ManifestParserUtils.AUDIO_CODEC_REGEXPS).set("video",shaka.util.ManifestParserUtils.VIDEO_CODEC_REGEXPS).set("text",shaka.util.ManifestParserUtils.TEXT_CODEC_REGEXPS);shaka.lcevc={};shaka.lcevc.Dec=function(a,b,c,d){this.dec_=null;this.media_=a;this.canvas_=b;this.decConfig_=c;this.isDualTrack_=d;this.toBeDeprecated_=!1;this.create_()};shaka.lcevc.Dec.prototype.appendBuffer=function(a,b,c){c.type!==shaka.util.ManifestParserUtils.ContentType.VIDEO||this.isDualTrack_&&!c.baseOriginalId||this.dec_&&this.dec_.appendBuffer(a,"video",c.id,-b,!this.isDualTrack_)};
shaka.lcevc.Dec.prototype.removeBuffer=function(a,b,c){a===shaka.util.ManifestParserUtils.ContentType.VIDEO&&this.dec_&&this.dec_.flushBuffer(b,c)};shaka.lcevc.Dec.prototype.hideCanvas=function(){this.dec_&&this.canvas_.classList.add("shaka-hidden")};
shaka.lcevc.Dec.prototype.create_=function(){this.isSupported_()&&!this.dec_&&this.lcevcLib_.SupportObject.webGLSupport(this.canvas_)&&(this.canvas_.classList.remove("shaka-hidden"),this.dec_=this.toBeDeprecated_?new this.lcevcLib_.LcevcDil(this.media_,this.canvas_,this.decConfig_):new this.lcevcLib_.LCEVCdec(this.media_,this.canvas_,this.decConfig_))};shaka.lcevc.Dec.prototype.release=function(){this.dec_&&(this.dec_.close(),this.dec_=null)};
shaka.lcevc.Dec.prototype.isSupported_=function(){typeof libDPIModule==="undefined"&&shaka.log.alwaysWarn("Could not find LCEVC Library dependencies on this page");if(typeof LCEVCdec!=="undefined")this.lcevcLib_=LCEVCdec;else if(typeof LcevcDil!=="undefined")this.lcevcLib_=LcevcDil,this.toBeDeprecated_=!0,shaka.Deprecate.deprecateFeature(5,"LcevcDil","lcevc_dil.js is deprecated, please use lcevc_dec.js instead");else return shaka.log.alwaysWarn("Could not find LCEVC Library on this page"),!1;if(typeof this.lcevcLib_.SupportObject===
"undefined")return shaka.log.alwaysWarn("Could not find LCEVC Library on this page"),!1;this.lcevcLib_.SupportObject.SupportStatus||shaka.log.alwaysWarn(this.lcevcLib_.SupportObject.SupportError);return typeof this.lcevcLib_!=="undefined"&&typeof libDPIModule!=="undefined"&&this.canvas_ instanceof HTMLCanvasElement&&this.lcevcLib_.SupportObject.SupportStatus};
shaka.lcevc.Dec.prototype.updateVariant=function(a,b){if(a=a.video){a.dependencyStream&&(a=a.dependencyStream);var c=shaka.lcevc.Dec.ContainerFormat.MPEG2_TS,d=shaka.lcevc.Dec.StreamingFormat.OTHER;switch(a.mimeType){case "video/webm":c=shaka.lcevc.Dec.ContainerFormat.WEBM;break;case "video/mp4":c=shaka.lcevc.Dec.ContainerFormat.MP4}switch(b){case "DASH":d=shaka.lcevc.Dec.StreamingFormat.DASH;break;case "HLS":d=shaka.lcevc.Dec.StreamingFormat.HLS}this.dec_&&(this.dec_.setLevelSwitching(a.id,!0),this.dec_.setContainerFormat(c),
this.toBeDeprecated_||this.dec_.setStreamingFormat(d))}};shaka.lcevc.Dec.isStreamSupported=function(a){return a&&typeof LCEVCdec!=="undefined"?a.codecs=="lvc1":!1};goog.exportSymbol("shaka.lcevc.Dec",shaka.lcevc.Dec);goog.exportProperty(shaka.lcevc.Dec.prototype,"release",shaka.lcevc.Dec.prototype.release);shaka.lcevc.Dec.ContainerFormat={MPEG2_TS:0,WEBM:1,MP4:2};shaka.lcevc.Dec.StreamingFormat={HLS:0,DASH:1,OTHER:-1};shaka.media={};shaka.media.ManifestParser=function(){};shaka.media.ManifestParser.registerParserByExtension=function(a,b){shaka.Deprecate.deprecateFeature(5,"ManifestParser.registerParserByExtension","Please use an ManifestParser with registerParserByMime function.")};shaka.media.ManifestParser.registerParserByMime=function(a,b){shaka.media.ManifestParser.parsersByMime.set(a,b)};shaka.media.ManifestParser.unregisterParserByMime=function(a){shaka.media.ManifestParser.parsersByMime.delete(a)};
shaka.media.ManifestParser.probeSupport=function(){var a=shaka.media.ManifestParser,b={},c=shaka.device.DeviceFactory.getDevice();if(c.supportsMediaSource())for(var d=(0,$jscomp.makeIterator)(a.parsersByMime.keys()),e=d.next();!e.done;e=d.next())b[e.value]=!0;d=(0,$jscomp.makeIterator)(["application/dash+xml","application/x-mpegurl","application/vnd.apple.mpegurl","audio/x-mpegurl","application/vnd.ms-sstr+xml"]);for(e=d.next();!e.done;e=d.next())e=e.value,c.supportsMediaSource()?b[e]=a.parsersByMime.has(e):
b[e]=c.supportsMediaType(e);return b};shaka.media.ManifestParser.getFactory=function(a,b){var c=shaka.media.ManifestParser;if(b){if(c=c.parsersByMime.get(b))return c;shaka.log.warning("Could not determine manifest type using MIME type ",b)}throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.UNABLE_TO_GUESS_MANIFEST_TYPE,a,b);};
shaka.media.ManifestParser.isSupported=function(a){return shaka.device.DeviceFactory.getDevice().supportsMediaSource()?shaka.media.ManifestParser.parsersByMime.has(a):!1};goog.exportSymbol("shaka.media.ManifestParser",shaka.media.ManifestParser);goog.exportProperty(shaka.media.ManifestParser,"unregisterParserByMime",shaka.media.ManifestParser.unregisterParserByMime);goog.exportProperty(shaka.media.ManifestParser,"registerParserByMime",shaka.media.ManifestParser.registerParserByMime);
goog.exportProperty(shaka.media.ManifestParser,"registerParserByExtension",shaka.media.ManifestParser.registerParserByExtension);shaka.media.ManifestParser.HLS="HLS";shaka.media.ManifestParser.DASH="DASH";shaka.media.ManifestParser.MSS="MSS";shaka.media.ManifestParser.UNKNOWN="UNKNOWN";shaka.media.ManifestParser.AccessibilityPurpose={VISUALLY_IMPAIRED:"visually impaired",HARD_OF_HEARING:"hard of hearing",SPOKEN_SUBTITLES:"spoken subtitles"};
goog.exportProperty(shaka.media.ManifestParser,"AccessibilityPurpose",shaka.media.ManifestParser.AccessibilityPurpose);shaka.media.ManifestParser.parsersByMime=new Map;shaka.cea={};shaka.cea.DummyCaptionDecoder=function(){};shaka.cea.DummyCaptionDecoder.prototype.extract=function(a,b){};shaka.cea.DummyCaptionDecoder.prototype.decode=function(){return[]};shaka.cea.DummyCaptionDecoder.prototype.clear=function(){};shaka.cea.DummyCaptionDecoder.prototype.getStreams=function(){return[]};shaka.cea.DummyCeaParser=function(){};shaka.cea.DummyCeaParser.prototype.init=function(a){};shaka.cea.DummyCeaParser.prototype.parse=function(a){return[]};shaka.media.ClosedCaptionParser=function(a){this.decoderCache_=new Map;this.currentContinuityTimeline_=0;this.ceaParser_=new shaka.cea.DummyCeaParser;if(a=shaka.media.ClosedCaptionParser.findParser(a.toLowerCase()))this.ceaParser_=a();this.ceaDecoder_=new shaka.cea.DummyCaptionDecoder;if(a=shaka.media.ClosedCaptionParser.findDecoder())this.ceaDecoder_=a(),this.decoderCache_.set(this.currentContinuityTimeline_,this.ceaDecoder_)};
shaka.media.ClosedCaptionParser.prototype.init=function(a,b,c){b=b===void 0?!1:b;c=c===void 0?-1:c;shaka.log.debug("Passing new init segment to CEA parser");c!=-1&&this.currentContinuityTimeline_!=c?this.updateDecoder_(c):b||this.reset();this.ceaParser_.init(a);c!=-1&&(this.currentContinuityTimeline_=c)};
shaka.media.ClosedCaptionParser.prototype.parseFrom=function(a){a=this.ceaParser_.parse(a);a=(0,$jscomp.makeIterator)(a);for(var b=a.next();!b.done;b=a.next()){b=b.value;var c=shaka.util.BufferUtils.toUint8(b.packet);c.length>0&&this.ceaDecoder_.extract(c,b.pts)}return this.ceaDecoder_.decode()};
shaka.media.ClosedCaptionParser.prototype.updateDecoder_=function(a){var b=this.decoderCache_.get(a);this.decoderCache_.set(this.currentContinuityTimeline_,this.ceaDecoder_);if(b)this.ceaDecoder_=b;else{if(b=shaka.media.ClosedCaptionParser.findDecoder())this.ceaDecoder_=b();this.decoderCache_.set(a,this.ceaDecoder_)}};shaka.media.ClosedCaptionParser.prototype.reset=function(){this.ceaDecoder_.clear()};
shaka.media.ClosedCaptionParser.prototype.remove=function(a){a=a===void 0?[]:a;a=new Set(a);for(var b=(0,$jscomp.makeIterator)(this.decoderCache_.keys()),c=b.next();!c.done;c=b.next())if(c=c.value,!a.has(c)){var d=this.decoderCache_.get(c);d&&d.clear();this.decoderCache_.delete(c)}};shaka.media.ClosedCaptionParser.prototype.getStreams=function(){return this.ceaDecoder_.getStreams()};shaka.media.ClosedCaptionParser.registerParser=function(a,b){shaka.media.ClosedCaptionParser.parserMap_.set(a,b)};
shaka.media.ClosedCaptionParser.unregisterParser=function(a){shaka.media.ClosedCaptionParser.parserMap_.delete(a)};shaka.media.ClosedCaptionParser.findParser=function(a){return shaka.media.ClosedCaptionParser.parserMap_.get(a)};shaka.media.ClosedCaptionParser.registerDecoder=function(a){shaka.media.ClosedCaptionParser.decoderFactory_=a};shaka.media.ClosedCaptionParser.unregisterDecoder=function(){shaka.media.ClosedCaptionParser.decoderFactory_=null};shaka.media.ClosedCaptionParser.findDecoder=function(){return shaka.media.ClosedCaptionParser.decoderFactory_};
goog.exportSymbol("shaka.media.ClosedCaptionParser",shaka.media.ClosedCaptionParser);goog.exportProperty(shaka.media.ClosedCaptionParser,"findDecoder",shaka.media.ClosedCaptionParser.findDecoder);goog.exportProperty(shaka.media.ClosedCaptionParser,"unregisterDecoder",shaka.media.ClosedCaptionParser.unregisterDecoder);goog.exportProperty(shaka.media.ClosedCaptionParser,"registerDecoder",shaka.media.ClosedCaptionParser.registerDecoder);
goog.exportProperty(shaka.media.ClosedCaptionParser,"findParser",shaka.media.ClosedCaptionParser.findParser);goog.exportProperty(shaka.media.ClosedCaptionParser,"unregisterParser",shaka.media.ClosedCaptionParser.unregisterParser);goog.exportProperty(shaka.media.ClosedCaptionParser,"registerParser",shaka.media.ClosedCaptionParser.registerParser);shaka.media.ClosedCaptionParser.parserMap_=new Map;shaka.media.ClosedCaptionParser.decoderFactory_=null;shaka.text={};shaka.text.CueRegion=function(){var a=shaka.text.CueRegion;this.id="";this.regionAnchorY=this.regionAnchorX=this.viewportAnchorY=this.viewportAnchorX=0;this.height=this.width=100;this.viewportAnchorUnits=this.widthUnits=this.heightUnits=a.units.PERCENTAGE;this.scroll=a.scrollMode.NONE};goog.exportSymbol("shaka.text.CueRegion",shaka.text.CueRegion);shaka.text.CueRegion.units={PX:0,PERCENTAGE:1,LINES:2};goog.exportProperty(shaka.text.CueRegion,"units",shaka.text.CueRegion.units);
shaka.text.CueRegion.scrollMode={NONE:"",UP:"up"};goog.exportProperty(shaka.text.CueRegion,"scrollMode",shaka.text.CueRegion.scrollMode);shaka.util.TextParser=function(a){this.data_=a||"";this.position_=0};shaka.util.TextParser.prototype.atEnd=function(){return this.position_==this.data_.length};shaka.util.TextParser.prototype.readLine=function(){return this.readRegexReturnCapture_(/(.*?)(\n|$)/gm,1)};shaka.util.TextParser.prototype.readWord=function(){return this.readRegexReturnCapture_(/[^ \t\n]*/gm,0)};shaka.util.TextParser.prototype.skipWhitespace=function(){this.readRegex(/[ \t]+/gm)};
shaka.util.TextParser.prototype.readRegex=function(a){a=this.indexOf_(a);if(this.atEnd()||a==null||a.position!=this.position_)return null;this.position_+=a.length;return a.results};shaka.util.TextParser.prototype.readRegexReturnCapture_=function(a,b){return this.atEnd()?null:(a=this.readRegex(a))?a[b]:null};
shaka.util.TextParser.prototype.indexOf_=function(a){goog.asserts.assert(a.global,"global flag should be set");a.lastIndex=this.position_;a=a.exec(this.data_);return a==null?null:{position:a.index,length:a[0].length,results:a}};shaka.util.TextParser.prototype.parseTime=function(){var a=this.readRegex(shaka.util.TextParser.timeFormat_);if(a==null)return null;var b=Number(a[2]),c=Number(a[3]);return b>59||c>59?null:(Number(a[6])||0)/1E3+c+b*60+(Number(a[1])||0)*3600};
shaka.util.TextParser.parseTime=function(a){return a?(new shaka.util.TextParser(a)).parseTime():null};shaka.util.TextParser.timeFormat_=/(?:(\d{1,}):)?(\d{2}):(\d{2})((\.(\d{1,3})))?/g;shaka.util.ObjectUtils=function(){};shaka.util.ObjectUtils.cloneObject=function(a){var b=new WeakSet,c=function(d){switch(typeof d){case "undefined":case "boolean":case "number":case "string":case "symbol":case "function":return d;default:if(!d||ArrayBuffer.isView(d))return d;if(b.has(d))return null;var e=Array.isArray(d);if(d.constructor!=Object&&!e)return null;b.add(d);var f=e?[]:{},g;for(g in d)f[g]=c(d[g]);e&&(f.length=d.length);return f}};return c(a)};
shaka.util.ObjectUtils.shallowCloneObject=function(a){var b={},c;for(c in a)b[c]=a[c];return b};shaka.util.ObjectUtils.alphabeticalKeyOrderStringify=function(a){return Array.isArray(a)?shaka.util.ObjectUtils.arrayStringify_(a):typeof a=="function"?"":a instanceof Object?shaka.util.ObjectUtils.objectStringify_(a):JSON.stringify(a)};
shaka.util.ObjectUtils.objectStringify_=function(a){var b=Object.keys(a);b.sort();var c=[];b=(0,$jscomp.makeIterator)(b);for(var d=b.next();!d.done;d=b.next()){var e=d.value;d=JSON.stringify(e);e=a[e];e!==void 0&&(e=shaka.util.ObjectUtils.alphabeticalKeyOrderStringify(e))&&c.push(d+":"+e)}return"{"+c.join(",")+"}"};
shaka.util.ObjectUtils.arrayStringify_=function(a){for(var b=[],c=0;c<a.length;c++){var d=c.toString(),e=a[c];e!==void 0&&(e=shaka.util.ObjectUtils.alphabeticalKeyOrderStringify(e))&&b.push(d+":"+e)}return"["+b.join(",")+"]"};goog.exportSymbol("shaka.util.ObjectUtils",shaka.util.ObjectUtils);goog.exportProperty(shaka.util.ObjectUtils,"alphabeticalKeyOrderStringify",shaka.util.ObjectUtils.alphabeticalKeyOrderStringify);goog.exportProperty(shaka.util.ObjectUtils,"shallowCloneObject",shaka.util.ObjectUtils.shallowCloneObject);
goog.exportProperty(shaka.util.ObjectUtils,"cloneObject",shaka.util.ObjectUtils.cloneObject);/*
 @license
 tXml
 Copyright 2015 Tobias Nickel
 SPDX-License-Identifier: MIT
*/
shaka.util.TXml=function(){};shaka.util.TXml.parseXml=function(a,b,c){c=c===void 0?!1:c;a=shaka.util.StringUtils.fromBytesAutoDetect(a);return shaka.util.TXml.parseXmlString(a,b,c)};shaka.util.TXml.parseXmlString=function(a,b,c){a=shaka.util.TXml.parse(a,c===void 0?!1:c);if(!b&&a.length)return a[0];var d=b.split(",");if(b=a.find(function(e){return d.includes(e.tagName)}))return b;shaka.log.error("parseXml root element not found!");return null};
shaka.util.TXml.getKnownNameSpace=function(a){return shaka.util.TXml.uriToNameSpace_.has(a)?shaka.util.TXml.uriToNameSpace_.get(a):""};shaka.util.TXml.getKnownSchema=function(a){return shaka.util.TXml.nameSpaceToUri_.has(a)?shaka.util.TXml.nameSpaceToUri_.get(a):""};shaka.util.TXml.setKnownNameSpace=function(a,b){shaka.util.TXml.uriToNameSpace_.set(a,b);shaka.util.TXml.nameSpaceToUri_.set(b,a)};
shaka.util.TXml.parse=function(a,b){function c(g,h){h=h===void 0?!1:h;for(var k=[];a[e];)if(a.charCodeAt(e)==60){if(a.charCodeAt(e+1)===47){h=e+2;e=a.indexOf(">",e);h=a.substring(h,e);var l=h.indexOf(g);if(l==-1){var m=g.indexOf(".");m>0&&(g=g.substring(0,m),l=h.indexOf(g))}if(l==-1)throw k=a.substring(0,e).split("\n"),Error("Unexpected close tag\nLine: "+(k.length-1)+"\nColumn: "+(k[k.length-1].length+1)+"\nChar: "+a[e]);e+1&&(e+=1);break}else if(a.charCodeAt(e+1)===33){if(a.charCodeAt(e+2)==45){for(;e!==
-1&&(a.charCodeAt(e)!==62||a.charCodeAt(e-1)!=45||a.charCodeAt(e-2)!=45||e==-1);)e=a.indexOf(">",e+1);e===-1&&(e=a.length)}else if(a.charCodeAt(e+2)===91&&a.charCodeAt(e+8)===91&&a.substr(e+3,5).toLowerCase()==="cdata"){l=a.indexOf("]]\x3e",e);l==-1?(k.push(a.substr(e+9)),e=a.length):(k.push(a.substring(e+9,l)),e=l+3);continue}e++;continue}if(f>512)throw Error("XML is too deeply nested");f++;a:{m=h;e++;var n=d(),p={};for(l=[];a.charCodeAt(e)!==62&&a[e];){var q=a.charCodeAt(e);if(q>64&&q<91||q>96&&
q<123){q=d();for(var r=a.charCodeAt(e);r&&r!==39&&r!==34&&!(r>64&&r<91||r>96&&r<123)&&r!==62;)e++,r=a.charCodeAt(e);var t=e+1;e=a.indexOf(a[e],t);t=(" "+a.slice(t,e)).slice(1);if(r===39||r===34){if(e===-1){m={tagName:n,attributes:p,children:l,parent:null};if(b)for(n=0;n<l.length;n++)typeof l[n]!=="string"&&(l[n].parent=m);l=m;break a}}else t=null,e--;q.startsWith("xmlns:")&&(r=q.split(":"),shaka.util.TXml.setKnownNameSpace(t,r[1]));n==="tt"&&q==="xml:space"&&t==="preserve"&&(m=!0);p[q]=t}e++}a.charCodeAt(e-
1)!==47?(e++,l=c(n,m)):e++;m={tagName:n,attributes:p,children:l,parent:null};n=l.length;for(p=0;p<n;p++)q=l[p],typeof q!=="string"?b&&(q.parent=m):p==n-1&&q=="\n"&&l.pop();l=m}f--;k.push(l);if(typeof l==="string")break;l.tagName[0]==="?"&&l.children&&(k.push.apply(k,(0,$jscomp.arrayFromIterable)(l.children)),l.children=[])}else l=e,e=a.indexOf("<",e)-1,e===-2&&(e=a.length),l=(" "+a.slice(l,e+1)).slice(1),h?l.length>0&&k.push(l):k.length&&l.length==1&&l[0]=="\n"?k.push(l):l.trim().length>0&&k.push(l),
e++;return k}function d(){for(var g=e;"\r\n\t>/= ".indexOf(a[e])===-1&&a[e];)e++;return(" "+a.slice(g,e)).slice(1)}var e=0,f=0;return c("")};shaka.util.TXml.isNode=function(a){return!!a.tagName};shaka.util.TXml.isText=function(a){return typeof a==="string"};shaka.util.TXml.getChildNodes=function(a){var b=[];if(!a.children)return[];a=(0,$jscomp.makeIterator)(a.children);for(var c=a.next();!c.done;c=a.next())c=c.value,typeof c!=="string"&&b.push(c);return b};
shaka.util.TXml.findChildren=function(a,b){var c=[];if(!a.children)return[];a=(0,$jscomp.makeIterator)(a.children);for(var d=a.next();!d.done;d=a.next())d=d.value,d.tagName===b&&c.push(d);return c};shaka.util.TXml.getTextContents=function(a){var b=shaka.util.StringUtils;if(typeof a==="string")return b.htmlUnescape(a);var c=[];a=(0,$jscomp.makeIterator)(a.children);for(var d=a.next();!d.done;d=a.next())d=d.value,typeof d==="string"&&c.push(d);c=c.join("");return c===""?null:b.htmlUnescape(c)};
shaka.util.TXml.getContents=function(a){for(var b=(0,$jscomp.makeIterator)(a.children),c=b.next();!c.done;c=b.next())if(typeof c.value!=="string")return null;(a=shaka.util.TXml.getTextContents(a))&&(a=a.trim());return a};shaka.util.TXml.getElementsByTagName=function(a,b,c){c=c===void 0?[]:c;a.tagName===b&&c.push(a);if(a.children){a=(0,$jscomp.makeIterator)(a.children);for(var d=a.next();!d.done;d=a.next())shaka.util.TXml.getElementsByTagName(d.value,b,c)}return c};
shaka.util.TXml.findChild=function(a,b){a=shaka.util.TXml.findChildren(a,b);return a.length!=1?null:a[0]};shaka.util.TXml.findChildNS=function(a,b,c){a=shaka.util.TXml.findChildrenNS(a,b,c);return a.length!=1?null:a[0]};shaka.util.TXml.parseAttr=function(a,b,c,d){d=d===void 0?null:d;var e=null;a=a.attributes[b];a==null||a===""&&d!==null||(e=c(a));return e==null?d:e};shaka.util.TXml.getAttributeNS=function(a,b,c){b=shaka.util.TXml.getKnownNameSpace(b);return a.attributes[b+":"+c]||null};
shaka.util.TXml.findChildrenNS=function(a,b,c){var d=shaka.util.TXml.getKnownNameSpace(b);b=[];if(a.children)for(c=d?d+":"+c:c,a=(0,$jscomp.makeIterator)(a.children),d=a.next();!d.done;d=a.next())(d=d.value)&&d.tagName===c&&b.push(d);return b};shaka.util.TXml.getAttributeNSList=function(a,b,c){b=(0,$jscomp.makeIterator)(b);for(var d=b.next();!d.done;d=b.next())if(d=shaka.util.TXml.getAttributeNS(a,d.value,c))return d;return null};
shaka.util.TXml.parseDate=function(a){if(!a)return null;/^\d+-\d+-\d+T\d+:\d+:\d+(\.\d+)?$/.test(a)&&(a+="Z");a=Date.parse(a);return isNaN(a)?null:a/1E3};
shaka.util.TXml.parseDuration=function(a){if(!a)return null;var b=RegExp("^P(?:([0-9]*)Y)?(?:([0-9]*)M)?(?:([0-9]*)D)?(?:T(?:([0-9]*)H)?(?:([0-9]*)M)?(?:([0-9.]*)S)?)?$","i").exec(a);if(!b)return shaka.log.warning("Invalid duration string:",a),null;a=31536E3*Number(b[1]||null)+2592E3*Number(b[2]||null)+86400*Number(b[3]||null)+3600*Number(b[4]||null)+60*Number(b[5]||null)+Number(b[6]||null);return isFinite(a)?a:null};
shaka.util.TXml.parseRange=function(a){var b=/([0-9]+)-([0-9]+)/.exec(a);if(!b)return null;a=Number(b[1]);if(!isFinite(a))return null;b=Number(b[2]);return isFinite(b)?{start:a,end:b}:null};shaka.util.TXml.parseInt=function(a){a=Number(a);return a%1===0?a:null};shaka.util.TXml.parsePositiveInt=function(a){a=Number(a);return a%1===0&&a>0?a:null};shaka.util.TXml.parseNonNegativeInt=function(a){a=Number(a);return a%1===0&&a>=0?a:null};
shaka.util.TXml.parseFloat=function(a){a=Number(a);return isNaN(a)?null:a};shaka.util.TXml.parseBoolean=function(a){return a?a.toLowerCase()==="true":!1};shaka.util.TXml.evalDivision=function(a){var b;var c=(b=a.match(/^(\d+)\/(\d+)$/))?Number(b[1])/Number(b[2]):Number(a);return isNaN(c)?null:c};
shaka.util.TXml.parseXpath=function(a){var b=[];a=shaka.util.StringUtils.htmlUnescape(a).split(/\/+(?=(?:[^'"]*['"][^'"]*['"])*[^'"]*$)/);a=(0,$jscomp.makeIterator)(a);for(var c=a.next();!c.done;c=a.next()){c=c.value;var d=c.match(/^([\w]+)/);if(d){var e=c.match(/(@id='(.*?)')/),f=c.match(/(@t='(\d+)')/),g=c.match(/(@n='(\d+)')/),h=c.match(/\[(\d+)\]/);b.push({name:d[0],id:e?e[0].match(/'(.*?)'/)[0].replace(/'/gm,""):null,t:f?Number(f[0].match(/'(.*?)'/)[0].replace(/'/gm,"")):null,n:g?Number(g[0].match(/'(.*?)'/)[0].replace(/'/gm,
"")):null,position:h?Number(h[1])-1:null,attribute:c.split("/@")[1]||null})}else c.startsWith("@")&&b.length&&(b[b.length-1].attribute=c.slice(1))}return b};
shaka.util.TXml.modifyNodes=function(a,b){var c=shaka.util.TXml,d=c.parseXpath(b.attributes.sel||"");if(d.length){var e=d[d.length-1],f=b.attributes.pos||null;d=e.position;d==null&&(e.t!==null&&(d=c.nodePositionByAttribute_(a,"t",e.t)),e.n!==null&&(d=c.nodePositionByAttribute_(a,"n",e.n)));d===null?d=f==="prepend"?0:a.length:f==="prepend"?--d:f==="after"&&++d;f=b.tagName;(e=e.attribute)&&a[d]?c.modifyNodeAttribute(a[d],f,e,c.getContents(b)||""):(f!=="remove"&&f!=="replace"||a.splice(d,1),f!=="add"&&
f!=="replace"||a.splice.apply(a,[d,0].concat((0,$jscomp.arrayFromIterable)(b.children))))}};shaka.util.TXml.nodePositionByAttribute_=function(a,b,c){var d=0;a=(0,$jscomp.makeIterator)(a);for(var e=a.next();!e.done;e=a.next()){if(Number(e.value.attributes[b])===c)return d;d++}return null};shaka.util.TXml.modifyNodeAttribute=function(a,b,c,d){if(b==="remove")delete a.attributes[c];else if(b==="add"||b==="replace")a.attributes[c]=d};
shaka.util.TXml.txmlNodeToDomElement=function(a){var b=shaka.util.TXml,c="",d=a.tagName.split(":");d.length>0&&(c=b.getKnownSchema(d[0]));c=document.createElementNS(c,a.tagName);for(var e in a.attributes)c.setAttribute(e,a.attributes[e]);a=(0,$jscomp.makeIterator)(a.children);for(e=a.next();!e.done;e=a.next())e=e.value,e=typeof e=="string"?new Text(e):b.txmlNodeToDomElement(e),c.appendChild(e);return c};
shaka.util.TXml.cloneNode=function(a){if(!a)return null;var b={tagName:a.tagName,attributes:shaka.util.ObjectUtils.shallowCloneObject(a.attributes),children:[],parent:null};a=(0,$jscomp.makeIterator)(a.children);for(var c=a.next();!c.done;c=a.next())c=c.value,typeof c==="string"?b.children.push(c):(c=shaka.util.TXml.cloneNode(c),c.parent=b,b.children.push(c));return b};shaka.util.TXml.uriToNameSpace_=new Map;shaka.util.TXml.nameSpaceToUri_=new Map;shaka.text.Cue=function(a,b,c){var d=shaka.text.Cue;this.startTime=a;this.endTime=b;this.payload=c;this.region=new shaka.text.CueRegion;this.position=null;this.positionAlign=d.positionAlign.AUTO;this.size=0;this.textAlign=d.textAlign.CENTER;this.direction=d.direction.HORIZONTAL_LEFT_TO_RIGHT;this.writingMode=d.writingMode.HORIZONTAL_TOP_TO_BOTTOM;this.lineInterpretation=d.lineInterpretation.LINE_NUMBER;this.line=null;this.lineHeight="";this.lineAlign=d.lineAlign.START;this.displayAlign=d.displayAlign.AFTER;
this.fontSize=this.border=this.backgroundImage=this.backgroundColor=this.color="";this.fontWeight=d.fontWeight.NORMAL;this.fontStyle=d.fontStyle.NORMAL;this.linePadding=this.letterSpacing=this.fontFamily="";this.opacity=1;this.textCombineUpright="";this.textDecoration=[];this.textStrokeWidth=this.textStrokeColor=this.textShadow="";this.wrapLine=!0;this.id="";this.nestedCues=[];this.lineBreak=this.isContainer=!1;this.rubyTag=null;this.cellResolution={columns:32,rows:15}};
shaka.text.Cue.lineBreak=function(a,b){a=new shaka.text.Cue(a,b,"");a.lineBreak=!0;return a};shaka.text.Cue.prototype.clone=function(){var a=new shaka.text.Cue(0,0,""),b;for(b in this)a[b]=this[b],Array.isArray(a[b])&&(a[b]=a[b].slice());return a};
shaka.text.Cue.equal=function(a,b){if(a.payload!=b.payload||!(Math.abs(a.startTime-b.startTime)<.001&&Math.abs(a.endTime-b.endTime)<.001))return!1;for(var c in a)if(c!="startTime"&&c!="endTime"&&c!="payload")if(c=="nestedCues"){if(!shaka.util.ArrayUtils.equal(a.nestedCues,b.nestedCues,shaka.text.Cue.equal))return!1}else if(c=="region"||c=="cellResolution")for(var d in a[c]){if(a[c][d]!=b[c][d])return!1}else if(Array.isArray(a[c])){if(!shaka.util.ArrayUtils.equal(a[c],b[c]))return!1}else if(a[c]!=
b[c])return!1;return!0};
shaka.text.Cue.parseCuePayload=function(a,b){b=b===void 0?new Map:b;var c=shaka.util.StringUtils,d=shaka.util.TXml,e=a.payload;if(e.includes("<")){b.size===0&&shaka.text.Cue.addDefaultTextColor(b);e=shaka.text.Cue.replaceKaraokeStylePayload_(e);e=shaka.text.Cue.replaceVoiceStylePayload_(e);e=shaka.text.Cue.escapeInvalidChevrons_(e);a.payload="";var f="<span>"+e.replace(/\n/g,"<br />")+"</span>";try{var g=d.parseXmlString(f,"span")}catch(h){shaka.log.warning("cue parse fail: ",h)}if(g)if(f=g.children,
f.length!=1||d.isNode(f[0]))for(c=(0,$jscomp.makeIterator)(f),d=c.next();!d.done;d=c.next())shaka.text.Cue.generateCueFromElement_(d.value,a,b);else a.payload=c.htmlUnescape(e);else shaka.log.warning("The cue's markup could not be parsed: ",e),a.payload=c.htmlUnescape(e)}else a.payload=c.htmlUnescape(e)};
shaka.text.Cue.addDefaultTextColor=function(a){for(var b=(0,$jscomp.makeIterator)(Object.entries(shaka.text.Cue.defaultTextColor)),c=b.next();!c.done;c=b.next()){var d=(0,$jscomp.makeIterator)(c.value);c=d.next().value;d=d.next().value;var e=new shaka.text.Cue(0,0,"");e.color=d;a.set("."+c,e)}b=(0,$jscomp.makeIterator)(Object.entries(shaka.text.Cue.defaultTextBackgroundColor));for(c=b.next();!c.done;c=b.next())d=(0,$jscomp.makeIterator)(c.value),c=d.next().value,d=d.next().value,e=new shaka.text.Cue(0,
0,""),e.backgroundColor=d,a.set("."+c,e)};shaka.text.Cue.replaceKaraokeStylePayload_=function(a){for(var b=[],c=-1,d=0;d<a.length;d++)a[d]==="<"?c=d+1:a[d]===">"&&c>0&&(c=a.substr(c,d-c),c.match(shaka.text.Cue.timeFormat_)&&b.push(c),c=-1);b=(0,$jscomp.makeIterator)(b);for(d=b.next();!d.done;d=b.next())d=d.value,a=a.replace("<"+d+">",'<div time="'+d+'">'),a+="</div>";return a};
shaka.text.Cue.replaceVoiceStylePayload_=function(a){for(var b=[],c=-1,d="",e=!1,f=0;f<a.length;f++)if(a[f]==="/"){var g=a.indexOf(">",f);if(g===-1)return a;if((g=a.substring(f+1,g))&&g=="v"){e=!0;var h=null;b.length&&(h=b[b.length-1]);if(h){if(h===g)d+="/"+g+">";else{if(!h.startsWith("v")){d+=a[f];continue}d+="/"+h+">"}f+=g.length+1}else d+=a[f]}else d+=a[f]}else a[f]==="<"?(c=f+1,a[c]!="v"&&(c=-1)):a[f]===">"&&c>0&&(b.push(a.substr(c,f-c)),c=-1),d+=a[f];a=(0,$jscomp.makeIterator)(b);for(b=a.next();!b.done;b=
a.next())b=b.value,c=b.replace(" ",".voice-"),d=d.replace("<"+b+">","<"+c+">"),d=d.replace("</"+b+">","</"+c+">"),e||(d+="</"+c+">");return d};shaka.text.Cue.escapeInvalidChevrons_=function(a){var b={"< ":""," >":" &gt;"},c=/(< +>|<\s|\s>)/g,d=RegExp(c.source);return a&&d.test(a)?a.replace(c,function(e){return b[e]||""}):a||""};
shaka.text.Cue.generateCueFromElement_=function(a,b,c){var d=shaka.util.TXml,e=b.clone();e.nestedCues=[];e.payload="";e.rubyTag="";e.line=null;e.region=new shaka.text.CueRegion;e.position=null;e.size=0;e.textAlign=shaka.text.Cue.textAlign.CENTER;if(d.isNode(a)){var f=shaka.text.Cue.fontWeight.BOLD,g=shaka.text.Cue.fontStyle.ITALIC,h=shaka.text.Cue.textDecoration.UNDERLINE,k=a.tagName.split(/(?=[ .])+/g);k=(0,$jscomp.makeIterator)(k);for(var l=k.next();!l.done;l=k.next()){var m=l=l.value;if(m.startsWith(".voice-")){var n=
m.split("-").pop();m='v[voice="'+n+'"]';c.has(m)||(m="v[voice="+n+"]")}c.has(m)&&shaka.text.Cue.mergeStyle_(e,c.get(m));switch(l){case "br":e=shaka.text.Cue.lineBreak(e.startTime,e.endTime);b.nestedCues.push(e);return;case "b":e.fontWeight=f;break;case "i":e.fontStyle=g;break;case "u":e.textDecoration.push(h);break;case "font":if(l=a.attributes.color)e.color=l;break;case "div":l=a.attributes.time;if(!l)break;if(l=shaka.util.TextParser.parseTime(l))e.startTime=l;break;case "ruby":case "rp":case "rt":e.rubyTag=
l}}}f=a.children;if(d.isText(a)||f.length==1&&d.isText(f[0]))for(c=d.getTextContents(a).split("\n"),a=!0,c=(0,$jscomp.makeIterator)(c),d=c.next();!d.done;d=c.next())d=d.value,a||(a=shaka.text.Cue.lineBreak(e.startTime,e.endTime),b.nestedCues.push(a)),d.length>0&&(a=e.clone(),a.payload=shaka.util.StringUtils.htmlUnescape(d),b.nestedCues.push(a)),a=!1;else for(b.nestedCues.push(e),b=(0,$jscomp.makeIterator)(f),a=b.next();!a.done;a=b.next())shaka.text.Cue.generateCueFromElement_(a.value,e,c)};
shaka.text.Cue.mergeStyle_=function(a,b){b&&(a.backgroundColor=shaka.text.Cue.getOrDefault_(b.backgroundColor,a.backgroundColor),a.color=shaka.text.Cue.getOrDefault_(b.color,a.color),a.fontFamily=shaka.text.Cue.getOrDefault_(b.fontFamily,a.fontFamily),a.fontSize=shaka.text.Cue.getOrDefault_(b.fontSize,a.fontSize),a.textShadow=shaka.text.Cue.getOrDefault_(b.textShadow,a.textShadow),a.fontWeight=b.fontWeight,a.fontStyle=b.fontStyle,a.opacity=b.opacity,a.rubyTag=b.rubyTag,a.textCombineUpright=b.textCombineUpright,
a.wrapLine=b.wrapLine)};shaka.text.Cue.getOrDefault_=function(a,b){return a&&a.length>0?a:b};goog.exportSymbol("shaka.text.Cue",shaka.text.Cue);goog.exportProperty(shaka.text.Cue,"parseCuePayload",shaka.text.Cue.parseCuePayload);goog.exportProperty(shaka.text.Cue,"equal",shaka.text.Cue.equal);goog.exportProperty(shaka.text.Cue.prototype,"clone",shaka.text.Cue.prototype.clone);shaka.text.Cue.positionAlign={LEFT:"line-left",RIGHT:"line-right",CENTER:"center",AUTO:"auto"};
goog.exportProperty(shaka.text.Cue,"positionAlign",shaka.text.Cue.positionAlign);shaka.text.Cue.textAlign={LEFT:"left",RIGHT:"right",CENTER:"center",START:"start",END:"end"};goog.exportProperty(shaka.text.Cue,"textAlign",shaka.text.Cue.textAlign);shaka.text.Cue.displayAlign={BEFORE:"before",CENTER:"center",AFTER:"after"};goog.exportProperty(shaka.text.Cue,"displayAlign",shaka.text.Cue.displayAlign);shaka.text.Cue.direction={HORIZONTAL_LEFT_TO_RIGHT:"ltr",HORIZONTAL_RIGHT_TO_LEFT:"rtl"};
goog.exportProperty(shaka.text.Cue,"direction",shaka.text.Cue.direction);shaka.text.Cue.writingMode={HORIZONTAL_TOP_TO_BOTTOM:"horizontal-tb",VERTICAL_LEFT_TO_RIGHT:"vertical-lr",VERTICAL_RIGHT_TO_LEFT:"vertical-rl"};goog.exportProperty(shaka.text.Cue,"writingMode",shaka.text.Cue.writingMode);shaka.text.Cue.lineInterpretation={LINE_NUMBER:0,PERCENTAGE:1};goog.exportProperty(shaka.text.Cue,"lineInterpretation",shaka.text.Cue.lineInterpretation);
shaka.text.Cue.lineAlign={CENTER:"center",START:"start",END:"end"};goog.exportProperty(shaka.text.Cue,"lineAlign",shaka.text.Cue.lineAlign);shaka.text.Cue.defaultTextColor={white:"white",lime:"lime",cyan:"cyan",red:"red",yellow:"yellow",magenta:"magenta",blue:"blue",black:"black"};goog.exportProperty(shaka.text.Cue,"defaultTextColor",shaka.text.Cue.defaultTextColor);
shaka.text.Cue.defaultTextBackgroundColor={bg_white:"white",bg_lime:"lime",bg_cyan:"cyan",bg_red:"red",bg_yellow:"yellow",bg_magenta:"magenta",bg_blue:"blue",bg_black:"black"};goog.exportProperty(shaka.text.Cue,"defaultTextBackgroundColor",shaka.text.Cue.defaultTextBackgroundColor);shaka.text.Cue.fontWeight={NORMAL:400,BOLD:700};goog.exportProperty(shaka.text.Cue,"fontWeight",shaka.text.Cue.fontWeight);shaka.text.Cue.fontStyle={NORMAL:"normal",ITALIC:"italic",OBLIQUE:"oblique"};
goog.exportProperty(shaka.text.Cue,"fontStyle",shaka.text.Cue.fontStyle);shaka.text.Cue.textDecoration={UNDERLINE:"underline",LINE_THROUGH:"lineThrough",OVERLINE:"overline"};goog.exportProperty(shaka.text.Cue,"textDecoration",shaka.text.Cue.textDecoration);shaka.text.Cue.timeFormat_=/(?:(\d{1,}):)?(\d{2}):(\d{2})\.(\d{2,3})/g;shaka.util.IDestroyable=function(){};shaka.util.IDestroyable.prototype.destroy=function(){};shaka.transmuxer={};shaka.transmuxer.TransmuxerEngine=function(){};shaka.transmuxer.TransmuxerEngine.prototype.destroy=function(){};shaka.transmuxer.TransmuxerEngine.registerTransmuxer=function(a,b,c){var d=shaka.transmuxer.TransmuxerEngine;a=d.normalizeMimeType_(a);d.transmuxerMap_.set(a+"-"+c,{priority:c,plugin:b})};shaka.transmuxer.TransmuxerEngine.unregisterTransmuxer=function(a,b){var c=shaka.transmuxer.TransmuxerEngine;a=c.normalizeMimeType_(a);c.transmuxerMap_.delete(a+"-"+b)};
shaka.transmuxer.TransmuxerEngine.findTransmuxer=function(a,b){for(var c=shaka.transmuxer.TransmuxerEngine,d=c.normalizeMimeType_(a),e=(0,$jscomp.makeIterator)([c.PluginPriority.APPLICATION,c.PluginPriority.PREFERRED,c.PluginPriority.PREFERRED_SECONDARY,c.PluginPriority.FALLBACK]),f=e.next();!f.done;f=e.next())if(f=c.transmuxerMap_.get(d+"-"+f.value)){var g=f.plugin(),h=g.isSupported(a,b);g.destroy();if(h)return f.plugin}return null};shaka.transmuxer.TransmuxerEngine.normalizeMimeType_=function(a){return a.toLowerCase().split(";")[0]};
shaka.transmuxer.TransmuxerEngine.isSupported=function(a,b){return shaka.transmuxer.TransmuxerEngine.findTransmuxer(a)?!0:!1};shaka.transmuxer.TransmuxerEngine.convertCodecs=function(a,b){var c=shaka.transmuxer.TransmuxerEngine.findTransmuxer(b);if(!c)return b;c=c();a=c.convertCodecs(a,b);c.destroy();return a};goog.exportSymbol("shaka.transmuxer.TransmuxerEngine",shaka.transmuxer.TransmuxerEngine);goog.exportProperty(shaka.transmuxer.TransmuxerEngine,"findTransmuxer",shaka.transmuxer.TransmuxerEngine.findTransmuxer);
goog.exportProperty(shaka.transmuxer.TransmuxerEngine,"unregisterTransmuxer",shaka.transmuxer.TransmuxerEngine.unregisterTransmuxer);goog.exportProperty(shaka.transmuxer.TransmuxerEngine,"registerTransmuxer",shaka.transmuxer.TransmuxerEngine.registerTransmuxer);goog.exportProperty(shaka.transmuxer.TransmuxerEngine.prototype,"destroy",shaka.transmuxer.TransmuxerEngine.prototype.destroy);shaka.transmuxer.TransmuxerEngine.transmuxerMap_=new Map;
shaka.transmuxer.TransmuxerEngine.PluginPriority={FALLBACK:1,PREFERRED_SECONDARY:2,PREFERRED:3,APPLICATION:4};goog.exportProperty(shaka.transmuxer.TransmuxerEngine,"PluginPriority",shaka.transmuxer.TransmuxerEngine.PluginPriority);shaka.util.MimeUtils=function(){};shaka.util.MimeUtils.getFullType=function(a,b){var c=a;b&&!shaka.util.MimeUtils.RAW_FORMATS.includes(a)&&(c+='; codecs="'+b+'"');return c};shaka.util.MimeUtils.getFullTypeWithAllCodecs=function(a,b){b&&(a+='; codecs="'+b+'"');return a};
shaka.util.MimeUtils.getFullOrConvertedType=function(a,b,c){var d=shaka.util.MimeUtils,e=d.getFullType(a,b);b=d.getFullTypeWithAllCodecs(a,b);d=shaka.util.ManifestParserUtils.ContentType;var f=shaka.transmuxer.TransmuxerEngine;return f.isSupported(b,c)?f.convertCodecs(c,b):a!="video/mp2t"&&c==d.AUDIO?e.replace("video","audio"):e};
shaka.util.MimeUtils.getExtendedType=function(a,b,c){var d=[b];shaka.util.MimeUtils.EXTENDED_MIME_PARAMETERS_.forEach(function(e,f){var g=a[f];f=="codecs"?shaka.util.MimeUtils.RAW_FORMATS.includes(a.mimeType)||d.push('codecs="'+c+'"'):g&&d.push(e+'="'+g+'"')});a.hdr=="PQ"&&d.push('eotf="smpte2084"');return d.join(";")};shaka.util.MimeUtils.getContainerType=function(a){return a.split(";")[0].split("/")[1]};shaka.util.MimeUtils.splitCodecs=function(a){return a.split(",")};
shaka.util.MimeUtils.getNormalizedCodec=function(a){var b=shaka.util.MimeUtils.getCodecParts_(a);a=b[0].toLowerCase();b=b[1].toLowerCase();switch(!0){case a==="mp4a"&&b==="69":case a==="mp4a"&&b==="6b":case a==="mp4a"&&b==="40.34":return"mp3";case a==="mp4a"&&b==="66":case a==="mp4a"&&b==="67":case a==="mp4a"&&b==="68":case a==="mp4a"&&b==="40.2":case a==="mp4a"&&b==="40.02":case a==="mp4a"&&b==="40.5":case a==="mp4a"&&b==="40.05":case a==="mp4a"&&b==="40.29":case a==="mp4a"&&b==="40.42":return"aac";
case a==="mp4a"&&b==="a5":case a==="ac3":case a==="ac-3":return"ac-3";case a==="mp4a"&&b==="a6":case a==="eac3":case a==="ec-3":return"ec-3";case a==="ac-4":return"ac-4";case a==="mp4a"&&b==="b2":return"dtsx";case a==="mp4a"&&b==="a9":return"dtsc";case a==="vp09":case a==="vp9":return"vp9";case a==="avc1":case a==="avc3":return"avc";case a==="hvc1":case a==="hev1":return"hevc";case a==="vvc1":case a==="vvi1":return"vvc";case a==="dvh1":case a==="dvhe":return b&&b.startsWith("05")?"dovi-p5":"dovi-hevc";
case a==="dvav":case a==="dva1":return"dovi-avc";case a==="dav1":return"dovi-av1";case a==="dvc1":case a==="dvi1":return"dovi-vvc";case a==="lvc1":return"lcevc"}return a};shaka.util.MimeUtils.getCodecBase=function(a){var b=[];a=(0,$jscomp.makeIterator)(a.split(","));for(var c=a.next();!c.done;c=a.next())c=shaka.util.MimeUtils.getCodecParts_(c.value),b.push(c[0]);return b.sort().join(",")};shaka.util.MimeUtils.getBasicType=function(a){return a.split(";")[0]};
shaka.util.MimeUtils.getCodecs=function(a){a=a.split(/ *; */);a.shift();return(a=a.find(function(b){return b.startsWith("codecs=")}))?a.split("=")[1].replace(/^"|"$/g,""):""};shaka.util.MimeUtils.isHlsType=function(a){return a==="application/x-mpegurl"||a==="application/vnd.apple.mpegurl"||a==="audio/x-mpegurl"};shaka.util.MimeUtils.isDashType=function(a){return a==="application/dash+xml"||a==="video/vnd.mpeg.dash.mpd"};
shaka.util.MimeUtils.getCodecParts_=function(a){var b=a.split(".");a=b[0];b.shift();b=b.join(".");return[a,b]};goog.exportSymbol("shaka.util.MimeUtils",shaka.util.MimeUtils);goog.exportProperty(shaka.util.MimeUtils,"getFullTypeWithAllCodecs",shaka.util.MimeUtils.getFullTypeWithAllCodecs);goog.exportProperty(shaka.util.MimeUtils,"getFullType",shaka.util.MimeUtils.getFullType);
shaka.util.MimeUtils.EXTENDED_MIME_PARAMETERS_=(new Map).set("codecs","codecs").set("frameRate","framerate").set("bandwidth","bitrate").set("width","width").set("height","height").set("channelsCount","channels");shaka.util.MimeUtils.CEA608_CLOSED_CAPTION_MIMETYPE="application/cea-608";shaka.util.MimeUtils.CEA708_CLOSED_CAPTION_MIMETYPE="application/cea-708";shaka.util.MimeUtils.RAW_FORMATS=["audio/aac","audio/ac3","audio/ec3","audio/mpeg"];shaka.text.TextEngine=function(a){this.parser_=null;this.displayer_=a;this.external_=this.segmentRelativeVttTiming_=!1;this.appendWindowStart_=this.timestampOffset_=0;this.appendWindowEnd_=Infinity;this.bufferEnd_=this.bufferStart_=null;this.selectedClosedCaptionId_="";this.modifyCueCallback_=function(b,c){};this.closedCaptionsMap_=new Map};shaka.text.TextEngine.registerParser=function(a,b){shaka.text.TextEngine.parserMap_.set(a,b)};shaka.text.TextEngine.unregisterParser=function(a){shaka.text.TextEngine.parserMap_.delete(a)};
shaka.text.TextEngine.findParser=function(a){return shaka.text.TextEngine.parserMap_.get(a)};shaka.text.TextEngine.isTypeSupported=function(a){return shaka.text.TextEngine.parserMap_.has(a)?!0:a==shaka.util.MimeUtils.CEA608_CLOSED_CAPTION_MIMETYPE||a==shaka.util.MimeUtils.CEA708_CLOSED_CAPTION_MIMETYPE?!!shaka.media.ClosedCaptionParser.findDecoder():!1};shaka.text.TextEngine.prototype.destroy=function(){this.displayer_=this.parser_=null;this.closedCaptionsMap_.clear();return Promise.resolve()};
shaka.text.TextEngine.prototype.setDisplayer=function(a){this.displayer_=a};
shaka.text.TextEngine.prototype.initParser=function(a,b,c,d,e){a==shaka.util.MimeUtils.CEA608_CLOSED_CAPTION_MIMETYPE||a==shaka.util.MimeUtils.CEA708_CLOSED_CAPTION_MIMETYPE?this.parser_=null:(a=shaka.text.TextEngine.parserMap_.get(a),goog.asserts.assert(a,"Text type negotiation should have happened already"),this.parser_=a(),this.parser_.setSequenceMode?this.parser_.setSequenceMode(b):shaka.Deprecate.deprecateFeature(5,"Text parsers w/ setSequenceMode",'Text parsers should have a "setSequenceMode" method!'),
this.parser_.setManifestType?this.parser_.setManifestType(e):shaka.Deprecate.deprecateFeature(5,"Text parsers w/ setManifestType",'Text parsers should have a "setManifestType" method!'),this.segmentRelativeVttTiming_=d,this.external_=c)};shaka.text.TextEngine.prototype.setModifyCueCallback=function(a){this.modifyCueCallback_=a};
shaka.text.TextEngine.prototype.appendBuffer=function(a,b,c,d){var e=this,f,g,h,k,l,m,n,p;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(q){if(q.getNextAddressJsc()==1)return goog.asserts.assert(e.parser_,"The parser should already be initialized"),q.yield(Promise.resolve(),2);if(!e.parser_||!e.displayer_)return q.return();if(b==null||c==null)return e.parser_.parseInit(shaka.util.BufferUtils.toUint8(a)),q.return();f=e.external_?0:e.timestampOffset_;g=e.segmentRelativeVttTiming_||e.external_?
b:e.timestampOffset_;h={periodStart:f,segmentStart:b,segmentEnd:c,vttOffset:g};k=e.parser_.parseMedia(shaka.util.BufferUtils.toUint8(a),h,d,[]);l=(0,$jscomp.makeIterator)(k);for(m=l.next();!m.done;m=l.next())n=m.value,e.modifyCueCallback_(n,d||null,h);p=k.filter(function(r){return r.startTime>=e.appendWindowStart_&&r.startTime<e.appendWindowEnd_});e.displayer_.append(p);e.bufferStart_==null?e.bufferStart_=Math.max(b,e.appendWindowStart_):(goog.asserts.assert(e.bufferEnd_!=null,"There should already be a buffered range end."),
goog.asserts.assert(b-e.bufferEnd_<=1,"There should not be a gap in text references >1s"));e.bufferEnd_=Math.min(c,e.appendWindowEnd_);q.jumpToEnd()})};
shaka.text.TextEngine.prototype.remove=function(a,b,c){c=c===void 0?!1:c;var d=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(e){if(e.getNextAddressJsc()==1)return e.yield(Promise.resolve(),2);if(a>=b||c&&(d.removeClosedCaptions_(a,b),d.selectedClosedCaptionId_===""))return e.return();d.displayer_&&d.displayer_.remove(a,b)&&(d.bufferStart_==null?goog.asserts.assert(d.bufferEnd_==null,"end must be null if startTime is null"):(goog.asserts.assert(d.bufferEnd_!=null,"end must be non-null if startTime is non-null"),
b<=d.bufferStart_||a>=d.bufferEnd_||(a<=d.bufferStart_&&b>=d.bufferEnd_?d.bufferStart_=d.bufferEnd_=null:a<=d.bufferStart_&&b<d.bufferEnd_?d.bufferStart_=b:a>d.bufferStart_&&b>=d.bufferEnd_?d.bufferEnd_=a:goog.asserts.assert(!1,"removal from the middle is not supported by TextEngine")),d.updateRangesWithClosedCaptions_()));e.jumpToEnd()})};shaka.text.TextEngine.prototype.setTimestampOffset=function(a){this.timestampOffset_=a};
shaka.text.TextEngine.prototype.setAppendWindow=function(a,b){this.appendWindowStart_=a;this.appendWindowEnd_=b};shaka.text.TextEngine.prototype.bufferStart=function(){return this.bufferStart_};shaka.text.TextEngine.prototype.bufferEnd=function(){return this.bufferEnd_};shaka.text.TextEngine.prototype.isBuffered=function(a){return this.bufferStart_==null||this.bufferEnd_==null?!1:a>=this.bufferStart_&&a<this.bufferEnd_};
shaka.text.TextEngine.prototype.bufferedAheadOf=function(a){if(this.bufferEnd_==null||this.bufferEnd_<a)return 0;goog.asserts.assert(this.bufferStart_!=null,"start should not be null if end is not null");return this.bufferEnd_-Math.max(a,this.bufferStart_)};shaka.text.TextEngine.prototype.setSelectedClosedCaptionId=function(a,b){this.selectedClosedCaptionId_=a;if(a=this.closedCaptionsMap_.get(a))a=a.filter(function(c){return c.endTime<=b}),a.length&&this.displayer_.append(a)};
shaka.text.TextEngine.prototype.applyVideoTimestampOffsetRecursive_=function(a,b){a.startTime+=b;a.endTime+=b;a=(0,$jscomp.makeIterator)(a.nestedCues);for(var c=a.next();!c.done;c=a.next())this.applyVideoTimestampOffsetRecursive_(c.value,b)};
shaka.text.TextEngine.prototype.storeAndAppendClosedCaptions=function(a,b){var c=new Map;a=(0,$jscomp.makeIterator)(a);for(var d=a.next();!d.done;d=a.next()){var e=d.value;d=e.stream;e=e.cue;c.has(d)||c.set(d,[]);this.applyVideoTimestampOffsetRecursive_(e,b);e.startTime>=this.appendWindowStart_&&e.startTime<this.appendWindowEnd_&&(c.get(d).push(e),d==this.selectedClosedCaptionId_&&this.displayer_.append([e]))}b=(0,$jscomp.makeIterator)(c.keys());for(a=b.next();!a.done;a=b.next())for(a=a.value,this.closedCaptionsMap_.has(a)||
this.closedCaptionsMap_.set(a,[]),d=(0,$jscomp.makeIterator)(c.get(a)),e=d.next();!e.done;e=d.next())e=e.value,this.closedCaptionsMap_.get(a).push(e);this.updateRangesWithClosedCaptions_()};shaka.text.TextEngine.prototype.removeClosedCaptions_=function(a,b){for(var c=(0,$jscomp.makeIterator)(this.closedCaptionsMap_.keys()),d=c.next();!d.done;d=c.next()){d=d.value;var e=this.closedCaptionsMap_.get(d);e=e.filter(function(f){return f.startTime<a||f.endTime>=b});this.closedCaptionsMap_.set(d,e)}};
shaka.text.TextEngine.prototype.updateRangesWithClosedCaptions_=function(){for(var a=Infinity,b=-Infinity,c=(0,$jscomp.makeIterator)(this.closedCaptionsMap_.values()),d=c.next();!d.done;d=c.next()){d=(0,$jscomp.makeIterator)(d.value);for(var e=d.next();!e.done;e=d.next())e=e.value,a=Math.min(a,e.startTime),b=Math.max(b,e.endTime)}a!==Infinity&&b!==-Infinity&&(this.bufferStart_=this.bufferStart_==null?Math.max(a,this.appendWindowStart_):Math.min(this.bufferStart_,Math.max(a,this.appendWindowStart_)),
this.bufferEnd_=Math.max(this.bufferEnd_,Math.min(b,this.appendWindowEnd_)))};shaka.text.TextEngine.prototype.getNumberOfClosedCaptionChannels=function(){return this.closedCaptionsMap_.size};shaka.text.TextEngine.prototype.getNumberOfClosedCaptionsInChannel=function(a){return(a=this.closedCaptionsMap_.get(a))?a.length:0};goog.exportSymbol("shaka.text.TextEngine",shaka.text.TextEngine);goog.exportProperty(shaka.text.TextEngine.prototype,"destroy",shaka.text.TextEngine.prototype.destroy);
goog.exportProperty(shaka.text.TextEngine,"findParser",shaka.text.TextEngine.findParser);goog.exportProperty(shaka.text.TextEngine,"unregisterParser",shaka.text.TextEngine.unregisterParser);goog.exportProperty(shaka.text.TextEngine,"registerParser",shaka.text.TextEngine.registerParser);shaka.text.TextEngine.parserMap_=new Map;shaka.util.Timer=function(a){this.onTick_=a;this.cancelPending_=null};shaka.util.Timer.prototype.tickNow=function(){this.stop();this.onTick_();return this};shaka.util.Timer.prototype.tickAfter=function(a){var b=this;this.stop();this.schedule_(function(){b.onTick_()},a);return this};shaka.util.Timer.prototype.tickEvery=function(a){this.stop();goog.DEBUG&&shaka.util.Timer.activeTimers.set(this,Error("Timer created").stack);this.scheduleRepeating_(a);return this};
shaka.util.Timer.prototype.stop=function(){var a;(a=this.cancelPending_)==null||a.call(this);this.cancelPending_=null;goog.DEBUG&&shaka.util.Timer.activeTimers.delete(this)};shaka.util.Timer.prototype.schedule_=function(a,b){var c=!0,d=null;this.cancelPending_=function(){clearTimeout(d);c=!1};d=setTimeout(function(){c&&a()},b*1E3)};shaka.util.Timer.prototype.scheduleRepeating_=function(a){var b=this;this.schedule_(function(){b.scheduleRepeating_(a);b.onTick_()},a)};
goog.exportSymbol("shaka.util.Timer",shaka.util.Timer);goog.exportProperty(shaka.util.Timer.prototype,"stop",shaka.util.Timer.prototype.stop);goog.exportProperty(shaka.util.Timer.prototype,"tickEvery",shaka.util.Timer.prototype.tickEvery);goog.exportProperty(shaka.util.Timer.prototype,"tickAfter",shaka.util.Timer.prototype.tickAfter);goog.exportProperty(shaka.util.Timer.prototype,"tickNow",shaka.util.Timer.prototype.tickNow);goog.DEBUG&&(shaka.util.Timer.activeTimers=new Map);shaka.util.Functional=function(){};shaka.util.Functional.createFallbackPromiseChain=function(a,b){return a.reduce(function(c,d){return c.catch(function(){return b(d)})},Promise.reject())};shaka.util.Functional.collapseArrays=function(a,b){return a.concat(b)};shaka.util.Functional.ignored=function(){};shaka.util.Functional.noop=function(){};shaka.util.Functional.isNotNull=function(a){return a!=null};
shaka.util.Functional.promiseWithTimeout=function(a,b){return Promise.race([b,new Promise(function(c,d){(new shaka.util.Timer(d)).tickAfter(a)})])};shaka.util.LanguageUtils=function(){};shaka.util.LanguageUtils.areLocaleCompatible=function(a,b){var c=shaka.util.LanguageUtils;a=c.normalize(a);b=c.normalize(b);return a==b};shaka.util.LanguageUtils.areLanguageCompatible=function(a,b){var c=shaka.util.LanguageUtils;a=c.normalize(a);b=c.normalize(b);a=c.disassembleLocale_(a);b=c.disassembleLocale_(b);return a[0]==b[0]};
shaka.util.LanguageUtils.isParentOf=function(a,b){var c=shaka.util.LanguageUtils;a=c.normalize(a);b=c.normalize(b);a=c.disassembleLocale_(a);b=c.disassembleLocale_(b);return a[0]==b[0]&&a.length==1&&b.length==2};shaka.util.LanguageUtils.isSiblingOf=function(a,b){var c=shaka.util.LanguageUtils;a=c.normalize(a);b=c.normalize(b);a=c.disassembleLocale_(a);b=c.disassembleLocale_(b);return a.length==2&&b.length==2&&a[0]==b[0]};
shaka.util.LanguageUtils.normalize=function(a){var b=shaka.util.LanguageUtils;a=(0,$jscomp.makeIterator)(a.split("-x-"));var c=a.next().value;c=c===void 0?"":c;a=a.next().value;a=a===void 0?"":a;var d=(0,$jscomp.makeIterator)(c.split("-"));c=d.next().value;c=c===void 0?"":c;d=d.next().value;d=d===void 0?"":d;a=a?"x-"+a:"";c=c.toLowerCase();c=b.isoMap_.get(c)||c;b=d.toUpperCase();return""+(b?c+"-"+b:c)+(a?"-"+a:"")};
shaka.util.LanguageUtils.areSiblings=function(a,b){var c=shaka.util.LanguageUtils,d=c.getBase(a);c=c.getBase(b);return a!=d&&b!=c&&d==c};shaka.util.LanguageUtils.relatedness=function(a,b){var c=shaka.util.LanguageUtils;a=c.normalize(a);b=c.normalize(b);return b==a?4:c.isParentOf(b,a)?3:c.isSiblingOf(b,a)?2:c.isParentOf(a,b)?1:0};shaka.util.LanguageUtils.getBase=function(a){var b=shaka.util.LanguageUtils,c=a.indexOf("-");a=c>=0?a.substring(0,c):a;a=a.toLowerCase();return a=b.isoMap_.get(a)||a};
shaka.util.LanguageUtils.getLocaleForText=function(a){var b=shaka.util.LanguageUtils;goog.asserts.assert(a.type==shaka.util.ManifestParserUtils.ContentType.TEXT,"Can only get language from text streams");return b.normalize(a.language||"und")};shaka.util.LanguageUtils.getLocaleForVariant=function(a){var b=shaka.util.LanguageUtils;return a.language?b.normalize(a.language):a.audio&&a.audio.language?b.normalize(a.audio.language):a.video&&a.video.language?b.normalize(a.video.language):"und"};
shaka.util.LanguageUtils.findClosestLocale=function(a,b){var c=shaka.util.LanguageUtils;a=c.normalize(a);var d=new Set;b=(0,$jscomp.makeIterator)(b);for(var e=b.next();!e.done;e=b.next())d.add(c.normalize(e.value));b=(0,$jscomp.makeIterator)(d);for(e=b.next();!e.done;e=b.next())if(e=e.value,e==a)return e;b=(0,$jscomp.makeIterator)(d);for(e=b.next();!e.done;e=b.next())if(e=e.value,c.isParentOf(e,a))return e;b=(0,$jscomp.makeIterator)(d);for(e=b.next();!e.done;e=b.next())if(e=e.value,c.isSiblingOf(e,
a))return e;d=(0,$jscomp.makeIterator)(d);for(b=d.next();!b.done;b=d.next())if(b=b.value,c.isParentOf(a,b))return b;return null};shaka.util.LanguageUtils.disassembleLocale_=function(a){var b=a.split("-");goog.asserts.assert(b.length<=2,["Locales should not have more than 2 components. ",a," has too many components."].join());return b};goog.exportSymbol("shaka.util.LanguageUtils",shaka.util.LanguageUtils);goog.exportProperty(shaka.util.LanguageUtils,"findClosestLocale",shaka.util.LanguageUtils.findClosestLocale);
goog.exportProperty(shaka.util.LanguageUtils,"getLocaleForVariant",shaka.util.LanguageUtils.getLocaleForVariant);goog.exportProperty(shaka.util.LanguageUtils,"getLocaleForText",shaka.util.LanguageUtils.getLocaleForText);goog.exportProperty(shaka.util.LanguageUtils,"getBase",shaka.util.LanguageUtils.getBase);goog.exportProperty(shaka.util.LanguageUtils,"relatedness",shaka.util.LanguageUtils.relatedness);goog.exportProperty(shaka.util.LanguageUtils,"areSiblings",shaka.util.LanguageUtils.areSiblings);
goog.exportProperty(shaka.util.LanguageUtils,"normalize",shaka.util.LanguageUtils.normalize);goog.exportProperty(shaka.util.LanguageUtils,"isSiblingOf",shaka.util.LanguageUtils.isSiblingOf);goog.exportProperty(shaka.util.LanguageUtils,"isParentOf",shaka.util.LanguageUtils.isParentOf);goog.exportProperty(shaka.util.LanguageUtils,"areLanguageCompatible",shaka.util.LanguageUtils.areLanguageCompatible);goog.exportProperty(shaka.util.LanguageUtils,"areLocaleCompatible",shaka.util.LanguageUtils.areLocaleCompatible);
shaka.util.LanguageUtils.isoMap_=new Map([["aar","aa"],["abk","ab"],["afr","af"],["aka","ak"],["alb","sq"],["amh","am"],["ara","ar"],["arg","an"],["arm","hy"],["asm","as"],["ava","av"],["ave","ae"],["aym","ay"],["aze","az"],["bak","ba"],["bam","bm"],["baq","eu"],["bel","be"],["ben","bn"],["bih","bh"],["bis","bi"],["bod","bo"],["bos","bs"],["bre","br"],["bul","bg"],["bur","my"],["cat","ca"],["ces","cs"],["cha","ch"],["che","ce"],["chi","zh"],["chu","cu"],["chv","cv"],["cor","kw"],["cos","co"],["cre",
"cr"],["cym","cy"],["cze","cs"],["dan","da"],["deu","de"],["div","dv"],["dut","nl"],["dzo","dz"],["ell","el"],["eng","en"],["epo","eo"],["est","et"],["eus","eu"],["ewe","ee"],["fao","fo"],["fas","fa"],["fij","fj"],["fin","fi"],["fra","fr"],["fre","fr"],["fry","fy"],["ful","ff"],["geo","ka"],["ger","de"],["gla","gd"],["gle","ga"],["glg","gl"],["glv","gv"],["gre","el"],["grn","gn"],["guj","gu"],["hat","ht"],["hau","ha"],["heb","he"],["her","hz"],["hin","hi"],["hmo","ho"],["hrv","hr"],["hun","hu"],["hye",
"hy"],["ibo","ig"],["ice","is"],["ido","io"],["iii","ii"],["iku","iu"],["ile","ie"],["ina","ia"],["ind","id"],["ipk","ik"],["isl","is"],["ita","it"],["jav","jv"],["jpn","ja"],["kal","kl"],["kan","kn"],["kas","ks"],["kat","ka"],["kau","kr"],["kaz","kk"],["khm","km"],["kik","ki"],["kin","rw"],["kir","ky"],["kom","kv"],["kon","kg"],["kor","ko"],["kua","kj"],["kur","ku"],["lao","lo"],["lat","la"],["lav","lv"],["lim","li"],["lin","ln"],["lit","lt"],["ltz","lb"],["lub","lu"],["lug","lg"],["mac","mk"],["mah",
"mh"],["mal","ml"],["mao","mi"],["mar","mr"],["may","ms"],["mkd","mk"],["mlg","mg"],["mlt","mt"],["mon","mn"],["mri","mi"],["msa","ms"],["mya","my"],["nau","na"],["nav","nv"],["nbl","nr"],["nde","nd"],["ndo","ng"],["nep","ne"],["nld","nl"],["nno","nn"],["nob","nb"],["nor","no"],["nya","ny"],["oci","oc"],["oji","oj"],["ori","or"],["orm","om"],["oss","os"],["pan","pa"],["per","fa"],["pli","pi"],["pol","pl"],["por","pt"],["pus","ps"],["que","qu"],["roh","rm"],["ron","ro"],["rum","ro"],["run","rn"],["rus",
"ru"],["sag","sg"],["san","sa"],["sin","si"],["slk","sk"],["slo","sk"],["slv","sl"],["sme","se"],["smo","sm"],["sna","sn"],["snd","sd"],["som","so"],["sot","st"],["spa","es"],["sqi","sq"],["srd","sc"],["srp","sr"],["ssw","ss"],["sun","su"],["swa","sw"],["swe","sv"],["tah","ty"],["tam","ta"],["tat","tt"],["tel","te"],["tgk","tg"],["tgl","tl"],["tha","th"],["tib","bo"],["tir","ti"],["ton","to"],["tsn","tn"],["tso","ts"],["tuk","tk"],["tur","tr"],["twi","tw"],["uig","ug"],["ukr","uk"],["urd","ur"],["uzb",
"uz"],["ven","ve"],["vie","vi"],["vol","vo"],["wel","cy"],["wln","wa"],["wol","wo"],["xho","xh"],["yid","yi"],["yor","yo"],["zha","za"],["zho","zh"],["zul","zu"]]);shaka.util.StreamUtils=function(){};
shaka.util.StreamUtils.chooseCodecsAndFilterManifest=function(a,b,c,d,e){var f=shaka.util.StreamUtils,g=shaka.util.MimeUtils;if(e.length){var h=a.textStreams;e=(0,$jscomp.makeIterator)(e);for(var k=e.next(),l={};!k.done;l={textFormat:void 0},k=e.next())if(l.textFormat=k.value,k=h.filter(function(t){return function(u){return u.codecs.startsWith(t.textFormat)||u.mimeType.startsWith(t.textFormat)?!0:!1}}(l)),k.length){h=k;break}a.textStreams=h}h=a.variants;if(b.length||c.length)h=f.choosePreferredCodecs(h,
b,c);if(d.length){b=new shaka.util.MultiMap;h=(0,$jscomp.makeIterator)(h);for(c=h.next();!c.done;c=h.next())c=c.value,b.push(String(c.video.width||0),c);var m=[];b.forEach(function(t,u){t=0;var v=[];u=(0,$jscomp.makeIterator)(u);for(var w=u.next(),x={};!w.done;x={variant$jscomp$4:void 0},w=u.next())x.variant$jscomp$4=w.value,w=d.filter(function(y){return function(C){return y.variant$jscomp$4.decodingInfos[0][C]}}(x)).length,w>t?(t=w,v=[x.variant$jscomp$4]):w==t&&v.push(x.variant$jscomp$4);m.push.apply(m,
(0,$jscomp.arrayFromIterable)(v))});h=m}b=new Set;c=(0,$jscomp.makeIterator)(h);for(f=c.next();!f.done;f=c.next())f=f.value,f.video&&b.add(f.video);if(b.size){var n={vp8:1,avc:1,"dovi-avc":.95,vp9:.9,vp09:.9,hevc:.85,"dovi-hevc":.8,"dovi-p5":.75,av01:.7,"dovi-av1":.65,vvc:.6};f=Array.from(b).sort(function(t,u){return t.bandwidth&&u.bandwidth&&t.bandwidth!=u.bandwidth?t.bandwidth-u.bandwidth:t.width!=u.width?t.width-u.width:t.codecs&&u.codecs?(t=g.getNormalizedCodec(t.codecs),u=g.getNormalizedCodec(u.codecs),
(n[t]||1)-(n[u]||1)):0});var p=[];b=new Map;c=function(t){var u=[String(t.width||""),String(t.height||""),String(Math.round(t.frameRate||0)),t.hdr||"",t.fastSwitching];t.dependencyStream&&u.push(t.dependencyStream.baseOriginalId||"");t.roles&&u.push(t.roles.sort().join("_"));return u.join(";")};f=(0,$jscomp.makeIterator)(f);for(e=f.next();!e.done;e=f.next()){e=e.value;k=c(e);l=b.get(k)||[];if(l.length){var q=g.getNormalizedCodec(l[l.length-1].codecs),r=g.getNormalizedCodec(e.codecs);q==r&&(l.push(e),
p.push(e.id))}else l.push(e),p.push(e.id);b.set(k,l)}a.variants=h.filter(function(t){var u=t.video;return u&&!p.includes(u.id)?(shaka.log.debug("Dropping Variant (better codec available)",t),!1):!0})}else a.variants=h};
shaka.util.StreamUtils.choosePreferredCodecs=function(a,b,c){b=(0,$jscomp.makeIterator)(b);for(var d=b.next(),e={};!d.done;e={videoCodec$jscomp$4:void 0},d=b.next())if(e.videoCodec$jscomp$4=d.value,d=a.filter(function(f){return function(g){return g.video&&g.video.codecs.startsWith(f.videoCodec$jscomp$4)}}(e)),d.length){a=d;break}c=(0,$jscomp.makeIterator)(c);b=c.next();for(d={};!b.done;d={audioCodec$jscomp$4:void 0},b=c.next())if(d.audioCodec$jscomp$4=b.value,b=a.filter(function(f){return function(g){return g.audio&&
g.audio.codecs.startsWith(f.audioCodec$jscomp$4)}}(d)),b.length){a=b;break}return a};shaka.util.StreamUtils.filterByRestrictions=function(a,b,c){a.variants=a.variants.filter(function(d){return shaka.util.StreamUtils.meetsRestrictions(d,b,c)})};
shaka.util.StreamUtils.meetsRestrictions=function(a,b,c){var d=function(g,h,k){return g>=h&&g<=k};if(a&&a.video&&a.video.width&&a.video.height){var e=a.video.width,f=a.video.height;f>e&&(f=(0,$jscomp.makeIterator)([f,e]),e=f.next().value,f=f.next().value);if(!d(e,b.minWidth,Math.min(b.maxWidth,c.width))||!d(f,b.minHeight,Math.min(b.maxHeight,c.height))||!d(e*f,b.minPixels,b.maxPixels))return!1}return a&&a.video&&a.video.frameRate&&!d(a.video.frameRate,b.minFrameRate,b.maxFrameRate)||a&&a.audio&&a.audio.channelsCount&&
!d(a.audio.channelsCount,b.minChannelsCount,b.maxChannelsCount)||!d(a.bandwidth,b.minBandwidth,b.maxBandwidth)?!1:!0};shaka.util.StreamUtils.applyRestrictions=function(a,b,c){var d=!1;a=(0,$jscomp.makeIterator)(a);for(var e=a.next();!e.done;e=a.next()){e=e.value;var f=e.allowedByApplication;e.allowedByApplication=shaka.util.StreamUtils.meetsRestrictions(e,b,c);f!=e.allowedByApplication&&(d=!0)}return d};
shaka.util.StreamUtils.filterManifest=function(a,b,c,d){c=c===void 0?[]:c;d=d===void 0?{}:d;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(e){if(e.getNextAddressJsc()==1)return e.yield(shaka.util.StreamUtils.filterManifestByMediaCapabilities(a,b,b.offlineSessionIds.length>0,c,d),2);shaka.util.StreamUtils.filterTextStreams_(b);return e.yield(shaka.util.StreamUtils.filterImageStreams_(b),0)})};
shaka.util.StreamUtils.filterManifestByMediaCapabilities=function(a,b,c,d,e){var f,g,h;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(k){if(k.getNextAddressJsc()==1)return goog.asserts.assert(navigator.mediaCapabilities,"MediaCapabilities should be valid."),shaka.device.DeviceFactory.getDevice().shouldOverrideDolbyVisionCodecs()&&shaka.util.StreamUtils.overrideDolbyVisionCodecs(b.variants),k.yield(shaka.util.StreamUtils.getDecodingInfosForVariants(b.variants,c,!1,d),2);f=null;a&&(g=
a.getDrmInfo())&&(f=g.keySystem);h=shaka.util.StreamUtils;b.variants=b.variants.filter(function(l){var m=h.checkVariantSupported_(l,f,e);m||shaka.log.debug("Dropping variant - not compatible with platform",h.getVariantSummaryString_(l));return m});k.jumpToEnd()})};
shaka.util.StreamUtils.overrideDolbyVisionCodecs=function(a){var b=(new Map).set("dvav","avc3").set("dva1","avc1").set("dvhe","hev1").set("dvh1","hvc1").set("dvc1","vvc1").set("dvi1","vvi1"),c=new Set;a=(0,$jscomp.makeIterator)(a);for(var d=a.next();!d.done;d=a.next())d=d.value,d.video&&c.add(d.video);c=(0,$jscomp.makeIterator)(c);for(a=c.next();!a.done;a=c.next()){a=a.value;d=(0,$jscomp.makeIterator)(b);for(var e=d.next();!e.done;e=d.next()){var f=(0,$jscomp.makeIterator)(e.value);e=f.next().value;
f=f.next().value;if(a.codecs.includes(e)){a.codecs=a.codecs.replace(e,f);break}}}};
shaka.util.StreamUtils.checkVariantSupported_=function(a,b,c){if(!a.decodingInfos.some(function(k){return!k.supported||b&&(k=k.keySystemAccess)&&(c[k.keySystem]||k.keySystem)!=b?!1:!0}))return!1;var d=shaka.device.DeviceFactory.getDevice(),e=d.getDeviceName()==="Xbox";d=d.getDeviceType()===shaka.device.IDevice.DeviceType.MOBILE&&d.getBrowserEngine()===shaka.device.IDevice.BrowserEngine.GECKO;var f=a.video,g=f&&f.width||0,h=f&&f.height||0;if(e&&f&&(g>1920||h>1080)&&(f.codecs.includes("avc1.")||f.codecs.includes("avc3."))||
(e=f&&f.dependencyStream)&&!shaka.lcevc.Dec.isStreamSupported(e))return!1;a=a.audio;return d&&a&&a.encrypted&&a.codecs.toLowerCase().includes("opus")||a&&a.dependencyStream?!1:!0};
shaka.util.StreamUtils.getDecodingInfosForVariant_=function(a,b){var c,d,e,f,g,h,k,l;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(m){if(m.getNextAddressJsc()==1){c=function(n,p){if(n){var q=shaka.util.ObjectUtils.shallowCloneObject(n);q.supported=n.supported&&p.supported;q.powerEfficient=n.powerEfficient&&p.powerEfficient;q.smooth=n.smooth&&p.smooth;p.keySystemAccess&&!q.keySystemAccess&&(q.keySystemAccess=p.keySystemAccess);return q}return p};d=shaka.util.StreamUtils;e=null;f=[];
g=(0,$jscomp.makeIterator)(b);h=g.next();for(k={};!h.done;k={cache:void 0,cacheKey:void 0},h=g.next())l=h.value,k.cacheKey=shaka.util.ObjectUtils.alphabeticalKeyOrderStringify(l),k.cache=d.decodingConfigCache_,k.cache.has(k.cacheKey)?(shaka.log.v2("Using cached results of mediaCapabilities.decodingInfo","for key",k.cacheKey),e=c(e,k.cache.get(k.cacheKey))):f.push(d.checkEachDecodingConfigCombination_(l).then(function(n){return function(p){var q=null;p=(0,$jscomp.makeIterator)(p||[]);for(var r=p.next();!r.done;r=
p.next())q=c(q,r.value);q&&(n.cache.set(n.cacheKey,q),e=c(e,q))}}(k)));return m.yield(Promise.all(f),2)}e&&a.decodingInfos.push(e);m.jumpToEnd()})};
shaka.util.StreamUtils.checkEachDecodingConfigCombination_=function(a){var b=[""];a.video&&(b=shaka.util.MimeUtils.getCodecs(a.video.contentType).split(","));var c=[""];a.audio&&(c=shaka.util.MimeUtils.getCodecs(a.audio.contentType).split(","));var d=[];b=(0,$jscomp.makeIterator)(b);for(var e=b.next();!e.done;e=b.next()){e=e.value;for(var f=(0,$jscomp.makeIterator)(c),g=f.next(),h={};!g.done;h={copy$jscomp$1:void 0},g=f.next()){g=g.value;h.copy$jscomp$1=shaka.util.ObjectUtils.cloneObject(a);if(a.video){var k=
shaka.util.MimeUtils.getBasicType(h.copy$jscomp$1.video.contentType);h.copy$jscomp$1.video.contentType=shaka.util.MimeUtils.getFullType(k,e)}a.audio&&(k=shaka.util.MimeUtils.getBasicType(h.copy$jscomp$1.audio.contentType),h.copy$jscomp$1.audio.contentType=shaka.util.MimeUtils.getFullType(k,g));d.push(new Promise(function(l){return function(m,n){(shaka.device.DeviceFactory.getDevice().getDeviceType()==shaka.device.IDevice.DeviceType.MOBILE?shaka.util.Functional.promiseWithTimeout(5,navigator.mediaCapabilities.decodingInfo(l.copy$jscomp$1)):
navigator.mediaCapabilities.decodingInfo(l.copy$jscomp$1)).then(function(p){m(p)}).catch(n)}}(h)))}}return Promise.all(d).catch(function(l){shaka.log.info("MediaCapabilities.decodingInfo() failed.",JSON.stringify(a),l);return null})};
shaka.util.StreamUtils.getDecodingInfosForVariants=function(a,b,c,d){var e,f,g,h,k,l,m,n,p,q,r,t,u,v,w,x,y,C,D;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(A){switch(A.getNextAddressJsc()){case 1:if(e=a.some(function(z){return z.decodingInfos.length}))return shaka.log.debug("Already got the variants' decodingInfo."),A.return();f=(0,$jscomp.makeIterator)(d);g=f.next();h={};case 2:if(g.done){A.jumpTo(4);break}h.preferredKeySystem=g.value;k=!1;l=(0,$jscomp.makeIterator)(a);m=l.next();
case 5:if(m.done){A.jumpTo(7);break}n=m.value;p=shaka.util.StreamUtils.getDecodingConfigs_(n,b,c).filter(function(z){return function(B){B=B[0];B=B.keySystemConfiguration&&B.keySystemConfiguration.keySystem;return!B||B===z.preferredKeySystem}}(h));q=(0,$jscomp.makeIterator)(p);r=q.next();case 8:if(r.done){A.jumpTo(10);break}t=r.value;return A.yield(shaka.util.StreamUtils.getDecodingInfosForVariant_(n,t),9);case 9:r=q.next();A.jumpTo(8);break;case 10:n.decodingInfos.some(function(z){return z.supported})&&
(k=!0);m=l.next();A.jumpTo(5);break;case 7:if(k)return A.return();h={preferredKeySystem:void 0};g=f.next();A.jumpTo(2);break;case 4:u=(0,$jscomp.makeIterator)(a),v=u.next();case 12:if(v.done){A.jumpTo(0);break}w=v.value;x=shaka.util.StreamUtils.getDecodingConfigs_(w,b,c).filter(function(z){z=z[0];z=z.keySystemConfiguration&&z.keySystemConfiguration.keySystem;return!z||!d.includes(z)});y=(0,$jscomp.makeIterator)(x);C=y.next();case 15:if(C.done){v=u.next();A.jumpTo(12);break}D=C.value;return A.yield(shaka.util.StreamUtils.getDecodingInfosForVariant_(w,
D),16);case 16:C=y.next(),A.jumpTo(15)}})};
shaka.util.StreamUtils.getDecodingConfigs_=function(a,b,c){var d=a.audio,e=a.video,f=shaka.util.ManifestParserUtils.ContentType,g=shaka.util.ManifestParserUtils,h=shaka.util.MimeUtils,k=shaka.util.StreamUtils,l=[],m=[];if(e)for(var n=(0,$jscomp.makeIterator)(e.fullMimeTypes),p=n.next();!p.done;p=n.next()){p=p.value;var q=h.getCodecs(p);if(q.includes(",")&&!d){var r=q.split(","),t=h.getBasicType(p);q=g.guessCodecs(f.VIDEO,r);r=g.guessCodecs(f.AUDIO,r);r=k.getCorrectAudioCodecs(r,t);t=h.getFullOrConvertedType(t,
r,f.AUDIO);m.push({contentType:t,channels:2,bitrate:a.bandwidth||1,samplerate:1,spatialRendering:!1})}q=k.getCorrectVideoCodecs(q);p={contentType:h.getFullOrConvertedType(h.getBasicType(p),q,f.VIDEO),width:e.width||64,height:e.height||64,bitrate:e.bandwidth||a.bandwidth||1,framerate:e.frameRate||30};if(e.hdr)switch(e.hdr){case "PQ":p.transferFunction="pq";break;case "HLG":p.transferFunction="hlg"}e.colorGamut&&(p.colorGamut=e.colorGamut);l.push(p)}if(d)for(g=(0,$jscomp.makeIterator)(d.fullMimeTypes),
n=g.next();!n.done;n=g.next())p=n.value,n=h.getBasicType(p),p=k.getCorrectAudioCodecs(h.getCodecs(p),n),n=h.getFullOrConvertedType(n,p,f.AUDIO),m.push({contentType:n,channels:d.channelsCount||2,bitrate:d.bandwidth||a.bandwidth||1,samplerate:d.audioSamplingRate||1,spatialRendering:d.spatialAudio});f=[];l.length==0&&l.push(null);m.length==0&&m.push(null);l=(0,$jscomp.makeIterator)(l);for(h=l.next();!h.done;h=l.next())for(h=h.value,k=(0,$jscomp.makeIterator)(m),g=k.next();!g.done;g=k.next())g=g.value,
n={type:c?"file":"media-source"},h&&(n.video=h),g&&(n.audio=g),f.push(n);m=(a.video?a.video.drmInfos:[]).concat(a.audio?a.audio.drmInfos:[]);if(!m.length)return[f];a=[];c=new Map;m=(0,$jscomp.makeIterator)(m);for(l=m.next();!l.done;l=m.next())l=l.value,c.get(l.keySystem)||c.set(l.keySystem,[]),c.get(l.keySystem).push(l);m=b?"required":"optional";b=b?["persistent-license"]:["temporary"];l=(0,$jscomp.makeIterator)(c.keys());for(h=l.next();!h.done;h=l.next()){h=h.value;g=c.get(h);k=new Map;g=(0,$jscomp.makeIterator)(g);
for(n=g.next();!n.done;n=g.next())n=n.value,p=n.videoRobustness+","+n.audioRobustness,k.get(p)||k.set(p,[]),k.get(p).push(n);k=(0,$jscomp.makeIterator)(k.values());for(g=k.next();!g.done;g=k.next()){g=g.value;n=[];p=(0,$jscomp.makeIterator)(f);for(q=p.next();!q.done;q=p.next()){q=Object.assign({},q.value);t={keySystem:h,initDataType:"cenc",persistentState:m,distinctiveIdentifier:"optional",sessionTypes:b};r=(0,$jscomp.makeIterator)(g);for(var u=r.next();!u.done;u=r.next()){u=u.value;if(u.initData&&
u.initData.length){for(var v=new Set,w=(0,$jscomp.makeIterator)(u.initData),x=w.next();!x.done;x=w.next())v.add(x.value.initDataType);v.size>1&&shaka.log.v2("DrmInfo contains more than one initDataType,","and we use the initDataType of the first initData.",u);t.initDataType=u.initData[0].initDataType}u.distinctiveIdentifierRequired&&(t.distinctiveIdentifier="required");u.persistentStateRequired&&(t.persistentState="required");u.sessionType&&(t.sessionTypes=[u.sessionType]);d&&(t.audio?(u.encryptionScheme&&
(t.audio.encryptionScheme=t.audio.encryptionScheme||u.encryptionScheme),t.audio.robustness=t.audio.robustness||u.audioRobustness):(t.audio={robustness:u.audioRobustness},u.encryptionScheme&&(t.audio.encryptionScheme=u.encryptionScheme)),t.audio.robustness==""&&delete t.audio.robustness);e&&(t.video?(u.encryptionScheme&&(t.video.encryptionScheme=t.video.encryptionScheme||u.encryptionScheme),t.video.robustness=t.video.robustness||u.videoRobustness):(t.video={robustness:u.videoRobustness},u.encryptionScheme&&
(t.video.encryptionScheme=u.encryptionScheme)),t.video.robustness==""&&delete t.video.robustness)}q.keySystemConfiguration=t;n.push(q)}a.push(n)}}return a};
shaka.util.StreamUtils.getCorrectAudioCodecs=function(a,b){var c=shaka.device.DeviceFactory.getDevice(),d=shaka.device.IDevice.BrowserEngine.WEBKIT;return a.toLowerCase()=="flac"?c.getBrowserEngine()!=d?"flac":"fLaC":a.toLowerCase()==="opus"?c.getBrowserEngine()!=d?"opus":shaka.util.MimeUtils.getContainerType(b)=="mp4"?"Opus":"opus":a.toLowerCase()=="ac-3"&&c.requiresEC3InitSegments()?"ec-3":a};
shaka.util.StreamUtils.getCorrectVideoCodecs=function(a){if(a.includes("avc1")){var b=a.split(".");if(b.length==3)return a=b.shift()+".",a+=parseInt(b.shift(),10).toString(16),a+=("000"+parseInt(b.shift(),10).toString(16)).slice(-4)}else if(a=="vp9")return"vp09.00.41.08";return a};
shaka.util.StreamUtils.filterManifestByCurrentVariant=function(a,b){var c=shaka.util.StreamUtils;b.variants=b.variants.filter(function(d){var e=d.audio;d=d.video;return e&&a&&a.audio&&!c.areStreamsCompatible_(e,a.audio)?(shaka.log.debug("Dropping variant - not compatible with active audio","active audio",c.getStreamSummaryString_(a.audio),"variant.audio",c.getStreamSummaryString_(e)),!1):d&&a&&a.video&&!c.areStreamsCompatible_(d,a.video)?(shaka.log.debug("Dropping variant - not compatible with active video",
"active video",c.getStreamSummaryString_(a.video),"variant.video",c.getStreamSummaryString_(d)),!1):!0})};shaka.util.StreamUtils.filterTextStreams_=function(a){a.textStreams=a.textStreams.filter(function(b){var c=shaka.util.MimeUtils.getFullType(b.mimeType,b.codecs);(c=shaka.text.TextEngine.isTypeSupported(c))||shaka.log.debug("Dropping text stream. Is not supported by the platform.",b);return c})};
shaka.util.StreamUtils.filterImageStreams_=function(a){var b,c,d,e,f,g,h,k;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(l){switch(l.getNextAddressJsc()){case 1:b=[],c=(0,$jscomp.makeIterator)(a.imageStreams),d=c.next();case 2:if(d.done){l.jumpTo(4);break}e=d.value;f=e.mimeType;f=="application/mp4"&&e.codecs=="mjpg"&&(f="image/jpg");if(shaka.util.StreamUtils.supportedImageMimeTypes_.has(f)){l.jumpTo(5);break}g=shaka.util.StreamUtils.minImage_.get(f);if(!g){shaka.util.StreamUtils.supportedImageMimeTypes_.set(f,
!1);l.jumpTo(5);break}return l.yield(shaka.util.StreamUtils.isImageSupported_(g),7);case 7:h=l.getYieldResultJsc(),shaka.util.StreamUtils.supportedImageMimeTypes_.set(f,h);case 5:(k=shaka.util.StreamUtils.supportedImageMimeTypes_.get(f))?b.push(e):shaka.log.debug("Dropping image stream. Is not supported by the platform.",e);d=c.next();l.jumpTo(2);break;case 4:a.imageStreams=b,l.jumpToEnd()}})};
shaka.util.StreamUtils.isImageSupported_=function(a){return new Promise(function(b){var c=new Image;c.src=a;"decode"in c?c.decode().then(function(){b(!0)}).catch(function(){b(!1)}):c.onload=c.onerror=function(){b(c.height===2)}})};shaka.util.StreamUtils.areStreamsCompatible_=function(a,b){return a.mimeType!=b.mimeType||a.codecs.split(".")[0]!=b.codecs.split(".")[0]?!1:!0};
shaka.util.StreamUtils.variantToTrack=function(a){var b=shaka.util.ManifestParserUtils,c=shaka.util.ManifestParserUtils.ContentType,d=a.audio,e=a.video,f=d?d.mimeType:null,g=e?e.mimeType:null,h=d?d.codecs:null,k=e?e.codecs:null,l=d?d.groupId:null,m=[];e&&m.push(e.mimeType);d&&m.push(d.mimeType);m=m[0]||null;var n=[];d&&n.push(d.kind);e&&n.push(e.kind);n=n[0]||null;var p=new Set;if(d)for(var q=(0,$jscomp.makeIterator)(d.roles),r=q.next();!r.done;r=q.next())p.add(r.value);if(e)for(q=(0,$jscomp.makeIterator)(e.roles),
r=q.next();!r.done;r=q.next())p.add(r.value);a={id:a.id,active:!1,type:"variant",bandwidth:a.bandwidth,language:a.language,label:null,videoLabel:null,kind:n,width:null,height:null,frameRate:null,pixelAspectRatio:null,hdr:null,colorGamut:null,videoLayout:null,mimeType:m,audioMimeType:f,videoMimeType:g,codecs:"",audioCodec:h,videoCodec:k,primary:a.primary,roles:Array.from(p),audioRoles:null,videoRoles:null,forced:!1,videoId:null,audioId:null,audioGroupId:l,channelsCount:null,audioSamplingRate:null,
spatialAudio:!1,tilesLayout:null,audioBandwidth:null,videoBandwidth:null,originalVideoId:null,originalAudioId:null,originalTextId:null,originalImageId:null,accessibilityPurpose:null,originalLanguage:null};if(e){a.videoId=e.id;a.originalVideoId=e.originalId;a.width=e.width||null;a.height=e.height||null;a.frameRate=e.frameRate||null;a.pixelAspectRatio=e.pixelAspectRatio||null;a.videoBandwidth=e.bandwidth||null;a.hdr=e.hdr||null;a.colorGamut=e.colorGamut||null;a.videoLayout=e.videoLayout||null;a.videoRoles=
e.roles;a.videoLabel=e.label;if(f=e.dependencyStream)a.width=f.width||a.width,a.height=f.height||a.height,a.videoCodec=f.codecs||a.videoCodec,a.pixelAspectRatio=f.pixelAspectRatio||a.pixelAspectRatio,a.videoBandwidth&&f.bandwidth&&(a.videoBandwidth+=f.bandwidth);if(k.includes(",")){a.channelsCount=e.channelsCount;a.audioSamplingRate=e.audioSamplingRate;a.spatialAudio=e.spatialAudio;a.originalLanguage=e.originalLanguage;a.audioMimeType=g;g=k.split(",");try{a.videoCodec=b.guessCodecs(c.VIDEO,g),a.audioCodec=
b.guessCodecs(c.AUDIO,g)}catch(t){}}}d&&(a.audioId=d.id,a.originalAudioId=d.originalId,a.channelsCount=d.channelsCount,a.audioSamplingRate=d.audioSamplingRate,a.audioBandwidth=d.bandwidth||null,a.spatialAudio=d.spatialAudio,a.label=d.label,a.audioRoles=d.roles,a.accessibilityPurpose=d.accessibilityPurpose,a.originalLanguage=d.originalLanguage,b=d.dependencyStream)&&(a.audioCodec=b.codecs||a.audioCodec,a.audioBandwidth&&b.bandwidth&&(a.audioBandwidth+=b.bandwidth));e&&!a.videoBandwidth&&(d?a.audioBandwidth&&
(a.videoBandwidth=a.bandwidth-a.audioBandwidth):a.videoBandwidth=a.bandwidth);d&&!a.audioBandwidth&&(e?a.videoBandwidth&&(a.audioBandwidth=a.bandwidth-a.videoBandwidth):a.audioBandwidth=a.bandwidth);d=[];a.videoCodec&&d.push(a.videoCodec);a.audioCodec&&d.push(a.audioCodec);a.codecs=d.join(", ");return a};
shaka.util.StreamUtils.textStreamToTrack=function(a){return{id:a.id,active:!1,type:shaka.util.ManifestParserUtils.ContentType.TEXT,bandwidth:a.bandwidth||0,language:a.language,label:a.label,kind:a.kind||null,mimeType:a.mimeType,codecs:a.codecs||null,primary:a.primary,roles:a.roles,accessibilityPurpose:a.accessibilityPurpose,forced:a.forced,originalTextId:a.originalId,originalLanguage:a.originalLanguage}};
shaka.util.StreamUtils.imageStreamToTrack=function(a){var b=shaka.util.ManifestParserUtils.ContentType,c=a.width||null,d=a.height||null,e=null;a.segmentIndex&&(e=a.segmentIndex.earliestReference());var f=a.tilesLayout;e&&(f=e.getTilesLayout()||f);f&&c!=null&&(c/=Number(f.split("x")[0]));f&&d!=null&&(d/=Number(f.split("x")[1]));return{id:a.id,type:b.IMAGE,bandwidth:a.bandwidth||0,width:c,height:d,mimeType:a.mimeType,codecs:a.codecs||null,tilesLayout:f||null,originalImageId:a.originalId}};
shaka.util.StreamUtils.html5TrackId=function(a){a.__shaka_id||(a.__shaka_id=shaka.util.StreamUtils.nextTrackId_++);return a.__shaka_id};
shaka.util.StreamUtils.html5TextTrackToTrack=function(a){var b=shaka.util.ManifestParserUtils.ContentType;b={id:shaka.util.StreamUtils.html5TrackId(a),active:a.mode!="disabled",type:b.TEXT,bandwidth:0,language:shaka.util.LanguageUtils.normalize(a.language||"und"),label:a.label,kind:a.kind,mimeType:null,codecs:null,primary:!1,roles:[],accessibilityPurpose:null,forced:a.kind=="forced",originalTextId:a.id,originalLanguage:a.language};a.kind=="captions"&&(b.mimeType="unknown");a.kind=="subtitles"&&(b.mimeType=
"text/vtt");a.kind&&(b.roles=[a.kind]);return b};
shaka.util.StreamUtils.html5AudioTrackToTrack=function(a){var b=a.language;b={active:a.enabled,language:shaka.util.LanguageUtils.normalize(b||"und"),label:a.label,mimeType:null,codecs:null,primary:a.kind=="main",roles:[],accessibilityPurpose:null,channelsCount:null,audioSamplingRate:null,spatialAudio:!1,originalLanguage:b};a.kind&&(a.kind=="description"&&(b.accessibilityPurpose=shaka.media.ManifestParser.AccessibilityPurpose.VISUALLY_IMPAIRED),b.roles.push(a.kind));a.configuration&&(a.configuration.codec&&
(b.codecs=a.configuration.codec),a.configuration.sampleRate&&(b.audioSamplingRate=a.configuration.sampleRate),a.configuration.numberOfChannels&&(b.channelsCount=a.configuration.numberOfChannels));return b};
shaka.util.StreamUtils.html5TrackToShakaTrack=function(a,b){goog.asserts.assert(a||b,"There must be at least audioTrack or videoTrack.");var c=shaka.util.LanguageUtils,d=a?a.language:null;c={id:shaka.util.StreamUtils.html5TrackId(a||b),active:a?a.enabled:b.selected,type:"variant",bandwidth:0,language:c.normalize(d||"und"),label:a?a.label:null,videoLabel:null,kind:a?a.kind:null,width:null,height:null,frameRate:null,pixelAspectRatio:null,hdr:null,colorGamut:null,videoLayout:null,mimeType:null,audioMimeType:null,
videoMimeType:null,codecs:null,audioCodec:null,videoCodec:null,primary:a?a.kind=="main":!1,roles:[],forced:!1,audioRoles:null,videoRoles:null,videoId:null,audioId:null,audioGroupId:null,channelsCount:null,audioSamplingRate:null,spatialAudio:!1,tilesLayout:null,audioBandwidth:null,videoBandwidth:null,originalVideoId:b?b.id:null,originalAudioId:a?a.id:null,originalTextId:null,originalImageId:null,accessibilityPurpose:null,originalLanguage:d};a&&a.kind&&(c.roles=[a.kind],c.audioRoles=[a.kind]);a&&a.configuration&&
(a.configuration.codec&&(c.audioCodec=a.configuration.codec,c.codecs=c.audioCodec),a.configuration.bitrate&&(c.audioBandwidth=a.configuration.bitrate,c.bandwidth+=c.audioBandwidth),a.configuration.sampleRate&&(c.audioSamplingRate=a.configuration.sampleRate),a.configuration.numberOfChannels&&(c.channelsCount=a.configuration.numberOfChannels));if(b&&b.configuration&&(b.configuration.codec&&(c.videoCodec=b.configuration.codec,c.codecs=c.codecs?c.codecs+(","+c.videoCodec):c.videoCodec),b.configuration.bitrate&&
(c.videoBandwidth=b.configuration.bitrate,c.bandwidth+=c.videoBandwidth),b.configuration.framerate&&(c.frameRate=b.configuration.framerate),b.configuration.width&&(c.width=b.configuration.width),b.configuration.height&&(c.height=b.configuration.height),b.configuration.colorSpace&&b.configuration.colorSpace.transfer))switch(b.configuration.colorSpace.transfer){case "pq":c.hdr="PQ";break;case "hlg":c.hdr="HLG";break;case "bt709":c.hdr="SDR"}return c};
shaka.util.StreamUtils.isPlayable=function(a){return a.allowedByApplication&&a.allowedByKeySystem&&a.disabledUntilTime==0};shaka.util.StreamUtils.getPlayableVariants=function(a){return a.filter(function(b){return shaka.util.StreamUtils.isPlayable(b)})};
shaka.util.StreamUtils.filterStreamsByLanguageAndRole=function(a,b,c,d){var e=shaka.util.LanguageUtils,f=a,g=a.filter(function(l){return l.primary});g.length&&(f=g);var h=f.length?f[0].language:"";f=f.filter(function(l){return l.language==h});if(b){var k=e.findClosestLocale(e.normalize(b),a.map(function(l){return l.language}));k&&(f=a.filter(function(l){return e.normalize(l.language)==k}))}f=f.filter(function(l){return l.forced==d});if(c){a=shaka.util.StreamUtils.filterStreamsByRole_(f,c);if(a.length)return a;
shaka.log.warning("No exact match for the text role could be found.")}else if(a=f.filter(function(l){return l.roles.length==0}),a.length)return a;a=f.map(function(l){return l.roles}).reduce(shaka.util.Functional.collapseArrays,[]);return a.length?shaka.util.StreamUtils.filterStreamsByRole_(f,a[0]):f};shaka.util.StreamUtils.filterStreamsByRole_=function(a,b){return a.filter(function(c){return c.roles.includes(b)})};shaka.util.StreamUtils.isAudio=function(a){return a.type==shaka.util.ManifestParserUtils.ContentType.AUDIO};
shaka.util.StreamUtils.isVideo=function(a){return a.type==shaka.util.ManifestParserUtils.ContentType.VIDEO};shaka.util.StreamUtils.getVariantStreams=function(a){var b=[];a.audio&&b.push(a.audio);a.video&&b.push(a.video);return b};shaka.util.StreamUtils.isFastSwitching=function(a){return a.audio&&a.audio.fastSwitching||a.video&&a.video.fastSwitching?!0:!1};
shaka.util.StreamUtils.setBetterIFrameStream=function(a,b){b.length&&(b=b.filter(function(c){return shaka.util.MimeUtils.getNormalizedCodec(a.codecs)==shaka.util.MimeUtils.getNormalizedCodec(c.codecs)}).sort(function(c,d){return c.bandwidth&&d.bandwidth&&c.bandwidth!=d.bandwidth?c.bandwidth-d.bandwidth:(c.width||0)-(d.width||0)}),a.trickModeVideo=b[0],b.length>1&&(b=b.find(function(c){return a.width==c.width&&a.height==c.height})))&&(a.trickModeVideo=b)};
shaka.util.StreamUtils.getVariantSummaryString_=function(a){var b=[];a.audio&&b.push(shaka.util.StreamUtils.getStreamSummaryString_(a.audio));a.video&&b.push(shaka.util.StreamUtils.getStreamSummaryString_(a.video));return b.join(", ")};
shaka.util.StreamUtils.getStreamSummaryString_=function(a){return shaka.util.StreamUtils.isAudio(a)?"type=audio codecs="+a.codecs+" bandwidth="+a.bandwidth+" channelsCount="+a.channelsCount+" audioSamplingRate="+a.audioSamplingRate:shaka.util.StreamUtils.isVideo(a)?"type=video codecs="+a.codecs+" bandwidth="+a.bandwidth+" frameRate="+a.frameRate+" width="+a.width+" height="+a.height:"unexpected stream type"};shaka.util.StreamUtils.clearDecodingConfigCache=function(){shaka.util.StreamUtils.decodingConfigCache_.clear()};
shaka.util.StreamUtils.shouldInitiallyShowText=function(a,b,c){var d=shaka.config.AutoShowText;if(c.autoShowText==d.NEVER)return!1;if(c.autoShowText==d.ALWAYS)return!0;var e=shaka.util.LanguageUtils,f=e.normalize(c.preferredTextLanguage);b=e.normalize(b.language);if(c.autoShowText==d.IF_PREFERRED_TEXT_LANGUAGE)return e.areLanguageCompatible(b,f);if(c.autoShowText==d.IF_SUBTITLES_MAY_BE_NEEDED){if(!a)return!1;a=e.normalize(a.language);return e.areLanguageCompatible(b,f)&&!e.areLanguageCompatible(a,
b)}shaka.log.alwaysWarn("Invalid autoShowText setting!");return!1};
shaka.util.StreamUtils.createEmptyVariant=function(a){var b=shaka.util.ManifestParserUtils.ContentType,c={id:0,language:"und",disabledUntilTime:0,primary:!1,audio:null,video:null,bandwidth:100,allowedByApplication:!0,allowedByKeySystem:!0,decodingInfos:[]};a=(0,$jscomp.makeIterator)(a);for(var d=a.next();!d.done;d=a.next()){d=d.value;var e={id:0,originalId:null,groupId:null,createSegmentIndex:function(){return Promise.resolve()},segmentIndex:null,mimeType:d?shaka.util.MimeUtils.getBasicType(d):"",
codecs:d?shaka.util.MimeUtils.getCodecs(d):"",encrypted:!0,drmInfos:[],keyIds:new Set,language:"und",originalLanguage:null,label:null,type:b.VIDEO,primary:!1,trickModeVideo:null,dependencyStream:null,emsgSchemeIdUris:null,roles:[],forced:!1,channelsCount:null,audioSamplingRate:null,spatialAudio:!1,closedCaptions:null,accessibilityPurpose:null,external:!1,fastSwitching:!1,fullMimeTypes:new Set,isAudioMuxedInVideo:!1,baseOriginalId:null};e.fullMimeTypes.add(shaka.util.MimeUtils.getFullType(e.mimeType,
e.codecs));d.startsWith("audio/")?(e.type=b.AUDIO,c.audio=e):c.video=e}return c};goog.exportSymbol("shaka.util.StreamUtils",shaka.util.StreamUtils);goog.exportProperty(shaka.util.StreamUtils,"meetsRestrictions",shaka.util.StreamUtils.meetsRestrictions);shaka.util.StreamUtils.decodingConfigCache_=new Map;shaka.util.StreamUtils.nextTrackId_=0;shaka.util.StreamUtils.DecodingAttributes={SMOOTH:"smooth",POWER:"powerEfficient"};
shaka.util.StreamUtils.supportedImageMimeTypes_=(new Map).set("image/svg+xml",!0).set("image/png",!0).set("image/jpeg",!0).set("image/jpg",!0);shaka.util.StreamUtils.minWebPImage_="data:image/webp;base64,UklGRjoAAABXRUJQVlA4IC4AAACyAgCdASoCAAIALmk0mk0iIiIiIgBoSygABc6WWgAA/veff/0PP8bA//LwYAAA";shaka.util.StreamUtils.minAvifImage_="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A=";
shaka.util.StreamUtils.minImage_=(new Map).set("image/webp",shaka.util.StreamUtils.minWebPImage_).set("image/avif",shaka.util.StreamUtils.minAvifImage_);shaka.abr.SimpleAbrManager=function(){var a=this;this.switch_=null;this.enabled_=!1;this.bandwidthEstimator_=new shaka.abr.EwmaBandwidthEstimator;this.eventManager_=new shaka.util.EventManager;navigator.connection&&navigator.connection.addEventListener&&this.eventManager_.listen(navigator.connection,"change",function(){a.config_.useNetworkInformation&&navigator.onLine&&(a.bandwidthEstimator_=new shaka.abr.EwmaBandwidthEstimator,a.config_&&a.bandwidthEstimator_.configure(a.config_.advanced),a.trySuggestStreams())});
this.variants_=[];this.playbackRate_=1;this.startupComplete_=!1;this.resizeObserver_=this.mediaElement_=this.config_=this.lastTimeChosenMs_=null;this.resizeObserverTimer_=new shaka.util.Timer(function(){if(a.enabled_&&(a.config_.restrictToElementSize||a.config_.restrictToScreenSize)){var b=a.chooseVariant();b&&a.switch_&&a.switch_(b,a.config_.clearBufferSwitch,a.config_.safeMarginSwitch)}});this.windowToCheck_=window;"documentPictureInPicture"in window&&this.eventManager_.listen(window.documentPictureInPicture,
"enter",function(){a.windowToCheck_=window.documentPictureInPicture.window;a.resizeObserverTimer_&&a.resizeObserverTimer_.tickNow();a.eventManager_.listenOnce(a.windowToCheck_,"pagehide",function(){a.windowToCheck_=window;a.resizeObserverTimer_&&a.resizeObserverTimer_.tickNow()})});this.cmsdManager_=this.pictureInPictureWindow_=null};
shaka.abr.SimpleAbrManager.prototype.stop=function(){this.switch_=null;this.enabled_=!1;this.variants_=[];this.playbackRate_=1;this.mediaElement_=this.lastTimeChosenMs_=null;this.resizeObserver_&&(this.resizeObserver_.disconnect(),this.resizeObserver_=null);this.resizeObserverTimer_&&this.resizeObserverTimer_.stop();this.cmsdManager_=this.pictureInPictureWindow_=null};shaka.abr.SimpleAbrManager.prototype.release=function(){this.stop();this.eventManager_.release();this.resizeObserverTimer_=null};
shaka.abr.SimpleAbrManager.prototype.init=function(a){this.switch_=a};
shaka.abr.SimpleAbrManager.prototype.chooseVariant=function(a){a=a===void 0?!1:a;var b=Infinity,c=Infinity;this.config_.restrictToScreenSize&&(c=this.config_.ignoreDevicePixelRatio?1:this.windowToCheck_.devicePixelRatio,b=this.windowToCheck_.screen.height*c,c*=this.windowToCheck_.screen.width);if(this.resizeObserver_&&this.config_.restrictToElementSize){var d=this.config_.ignoreDevicePixelRatio?1:this.windowToCheck_.devicePixelRatio,e=this.mediaElement_.clientHeight,f=this.mediaElement_.clientWidth;
this.pictureInPictureWindow_&&document.pictureInPictureElement&&document.pictureInPictureElement==this.mediaElement_&&(e=this.pictureInPictureWindow_.height,f=this.pictureInPictureWindow_.width);b=Math.min(b,e*d);c=Math.min(c,f*d)}e=this.variants_.filter(function(m){return m&&!shaka.util.StreamUtils.isFastSwitching(m)});e.length||(e=this.variants_);d=e;a&&e.length!=this.variants_.length&&(d=this.variants_.filter(function(m){return m&&shaka.util.StreamUtils.isFastSwitching(m)}));a=this.filterAndSortVariants_(this.config_.restrictions,
d,Infinity,Infinity);if(b!=Infinity||c!=Infinity){a=this.getResolutionList_(a);a=(0,$jscomp.makeIterator)(a);for(e=a.next();!e.done;e=a.next())if(e=e.value,e.height>=b&&e.width>=c){b=e.height;c=e.width;break}a=this.filterAndSortVariants_(this.config_.restrictions,d,b,c)}b=this.getBandwidthEstimate();d.length&&!a.length&&(shaka.log.warning("No variants met the ABR restrictions. Choosing a variant by lowest bandwidth."),a=this.filterAndSortVariants_(null,d,Infinity,Infinity),a=[a[0]]);c=a[0]||null;
for(d=0;d<a.length;d++){e=a[d];var g=isNaN(this.playbackRate_)?1:Math.abs(this.playbackRate_);f=g*e.bandwidth;for(var h=f/this.config_.bandwidthDowngradeTarget,k={bandwidth:Infinity},l=d+1;l<a.length;l++)if(e.bandwidth!=a[l].bandwidth){k=a[l];break}g=g*k.bandwidth/this.config_.bandwidthUpgradeTarget;shaka.log.v2("Bandwidth ranges:",(f/1E6).toFixed(3),(h/1E6).toFixed(3),(g/1E6).toFixed(3));c&&e&&b>=h&&b<=g&&(c.bandwidth!=e.bandwidth||this.isSameBandwidthAndHigherResolution_(c,e))&&(c=e)}this.lastTimeChosenMs_=
Date.now();return c};shaka.abr.SimpleAbrManager.prototype.enable=function(){this.enabled_=!0;this.variants_.length&&this.trySuggestStreams()};shaka.abr.SimpleAbrManager.prototype.disable=function(){this.enabled_=!1};
shaka.abr.SimpleAbrManager.prototype.segmentDownloaded=function(a,b,c,d,e){e=a;this.config_.removeLatencyFromFirstPacketTime&&d&&d.packetNumber===1&&d.timeToFirstByte&&(e=a-d.timeToFirstByte);e>=this.config_.cacheLoadThreshold&&(shaka.log.v2("Segment downloaded:","contentType="+(d&&d.contentType),"deltaTimeMs="+e,"numBytes="+b,"lastTimeChosenMs="+this.lastTimeChosenMs_,"enabled="+this.enabled_),goog.asserts.assert(e>=0,"expected a non-negative duration"),this.bandwidthEstimator_.sample(e,b));c&&this.lastTimeChosenMs_!=
null&&this.enabled_&&this.suggestStreams_()};shaka.abr.SimpleAbrManager.prototype.trySuggestStreams=function(){this.enabled_&&(this.lastTimeChosenMs_=Date.now(),this.suggestStreams_(!0))};
shaka.abr.SimpleAbrManager.prototype.getBandwidthEstimate=function(){var a=this.getDefaultBandwidth_();if(navigator.connection&&navigator.connection.downlink&&this.config_.useNetworkInformation&&this.config_.preferNetworkInformationBandwidth)return a;a=this.bandwidthEstimator_.getBandwidthEstimate(a);return this.cmsdManager_?this.cmsdManager_.getBandwidthEstimate(a):a};
shaka.abr.SimpleAbrManager.prototype.setVariants=function(a){if(shaka.util.ArrayUtils.hasSameElements(a,this.variants_))return!1;this.variants_=a;return!0};shaka.abr.SimpleAbrManager.prototype.playbackRateChanged=function(a){this.playbackRate_=a};
shaka.abr.SimpleAbrManager.prototype.setMediaElement=function(a){var b=this;this.mediaElement_=a;this.resizeObserver_&&(this.resizeObserver_.disconnect(),this.resizeObserver_=null);var c=function(){b.resizeObserverTimer_.tickAfter(shaka.abr.SimpleAbrManager.RESIZE_OBSERVER_BATCH_TIME)};this.mediaElement_&&"ResizeObserver"in window&&(this.resizeObserver_=new ResizeObserver(c),this.resizeObserver_.observe(this.mediaElement_));this.eventManager_.listen(a,"enterpictureinpicture",function(d){d.pictureInPictureWindow&&
(b.pictureInPictureWindow_=d.pictureInPictureWindow,b.eventManager_.listen(b.pictureInPictureWindow_,"resize",c))});this.eventManager_.listen(a,"leavepictureinpicture",function(){b.pictureInPictureWindow_&&b.eventManager_.unlisten(b.pictureInPictureWindow_,"resize",c);b.pictureInPictureWindow_=null})};shaka.abr.SimpleAbrManager.prototype.setCmsdManager=function(a){this.cmsdManager_=a};
shaka.abr.SimpleAbrManager.prototype.configure=function(a){this.config_=a;this.bandwidthEstimator_&&this.config_&&this.bandwidthEstimator_.configure(this.config_.advanced)};
shaka.abr.SimpleAbrManager.prototype.suggestStreams_=function(a){a=a===void 0?!1:a;shaka.log.v2("Suggesting Streams...");goog.asserts.assert(this.lastTimeChosenMs_!=null,"lastTimeChosenMs_ should not be null");if(!a){if(!this.startupComplete_){if(!this.bandwidthEstimator_.hasGoodEstimate()){shaka.log.v2("Still waiting for a good estimate...");return}this.startupComplete_=!0;this.lastTimeChosenMs_-=(this.config_.switchInterval-this.config_.minTimeToSwitch)*1E3}if(Date.now()-this.lastTimeChosenMs_<
this.config_.switchInterval*1E3){shaka.log.v2("Still within switch interval...");return}}a=this.chooseVariant();var b=this.getBandwidthEstimate();b=Math.round(b/1E3);a&&this.switch_&&(shaka.log.debug("Calling switch_(), bandwidth="+b+" kbps"),this.switch_(a,this.config_.clearBufferSwitch,this.config_.safeMarginSwitch))};
shaka.abr.SimpleAbrManager.prototype.getDefaultBandwidth_=function(){var a=this.config_.defaultBandwidthEstimate;navigator.connection&&navigator.connection.downlink&&this.config_.useNetworkInformation&&(a=navigator.connection.downlink*1E6);return a};
shaka.abr.SimpleAbrManager.prototype.filterAndSortVariants_=function(a,b,c,d){if(this.cmsdManager_){var e=this.cmsdManager_.getMaxBitrate();e&&(b=b.filter(function(f){return f.bandwidth&&e?f.bandwidth<=e:!0}))}a&&(b=b.filter(function(f){goog.asserts.assert(a,"Restrictions should exist!");return shaka.util.StreamUtils.meetsRestrictions(f,a,{width:d,height:c})}));return b.sort(function(f,g){return f.bandwidth-g.bandwidth})};
shaka.abr.SimpleAbrManager.prototype.getResolutionList_=function(a){var b=[];a=(0,$jscomp.makeIterator)(a);for(var c=a.next();!c.done;c=a.next())(c=c.value)&&(c=c.video)&&c.height&&c.width&&b.push({height:c.height,width:c.width});return b.sort(function(d,e){return d.width-e.width})};shaka.abr.SimpleAbrManager.prototype.isSameBandwidthAndHigherResolution_=function(a,b){return a.bandwidth==b.bandwidth&&a.video&&b.video?a.video.width<b.video.width||a.video.height<b.video.height:!1};
goog.exportSymbol("shaka.abr.SimpleAbrManager",shaka.abr.SimpleAbrManager);goog.exportProperty(shaka.abr.SimpleAbrManager.prototype,"configure",shaka.abr.SimpleAbrManager.prototype.configure);goog.exportProperty(shaka.abr.SimpleAbrManager.prototype,"setCmsdManager",shaka.abr.SimpleAbrManager.prototype.setCmsdManager);goog.exportProperty(shaka.abr.SimpleAbrManager.prototype,"setMediaElement",shaka.abr.SimpleAbrManager.prototype.setMediaElement);
goog.exportProperty(shaka.abr.SimpleAbrManager.prototype,"playbackRateChanged",shaka.abr.SimpleAbrManager.prototype.playbackRateChanged);goog.exportProperty(shaka.abr.SimpleAbrManager.prototype,"setVariants",shaka.abr.SimpleAbrManager.prototype.setVariants);goog.exportProperty(shaka.abr.SimpleAbrManager.prototype,"getBandwidthEstimate",shaka.abr.SimpleAbrManager.prototype.getBandwidthEstimate);goog.exportProperty(shaka.abr.SimpleAbrManager.prototype,"trySuggestStreams",shaka.abr.SimpleAbrManager.prototype.trySuggestStreams);
goog.exportProperty(shaka.abr.SimpleAbrManager.prototype,"segmentDownloaded",shaka.abr.SimpleAbrManager.prototype.segmentDownloaded);goog.exportProperty(shaka.abr.SimpleAbrManager.prototype,"disable",shaka.abr.SimpleAbrManager.prototype.disable);goog.exportProperty(shaka.abr.SimpleAbrManager.prototype,"enable",shaka.abr.SimpleAbrManager.prototype.enable);goog.exportProperty(shaka.abr.SimpleAbrManager.prototype,"chooseVariant",shaka.abr.SimpleAbrManager.prototype.chooseVariant);
goog.exportProperty(shaka.abr.SimpleAbrManager.prototype,"init",shaka.abr.SimpleAbrManager.prototype.init);goog.exportProperty(shaka.abr.SimpleAbrManager.prototype,"release",shaka.abr.SimpleAbrManager.prototype.release);goog.exportProperty(shaka.abr.SimpleAbrManager.prototype,"stop",shaka.abr.SimpleAbrManager.prototype.stop);shaka.abr.SimpleAbrManager.RESIZE_OBSERVER_BATCH_TIME=1;shaka.cea.CeaUtils=function(){};
shaka.cea.CeaUtils.getParsedCaption=function(a,b,c,d,e){if(d>=e)return null;for(var f=-1,g=-1,h=0;h<c.length;h++)if(c[h].some(function(y){return y!=null&&y.getChar().trim()!=""})){f=h;break}for(h=c.length-1;h>=0;h--)if(c[h].some(function(y){return y!=null&&y.getChar().trim()!=""})){g=h;break}if(f===-1||g===-1)return null;for(var k=h=!1,l=shaka.cea.CeaUtils.DEFAULT_TXT_COLOR,m=shaka.cea.CeaUtils.DEFAULT_BG_COLOR,n=shaka.cea.CeaUtils.createStyledCue(d,e,h,k,l,m);f<=g;f++){for(var p=c[f],q=-1,r=-1,t=
0;t<p.length;t++)if(p[t]!=null&&p[t].getChar().trim()!==""){q=t;break}for(t=p.length-1;t>=0;t--)if(p[t]!=null&&p[t].getChar().trim()!==""){r=t;break}if(q===-1||r===-1)p=shaka.cea.CeaUtils.createLineBreakCue(d,e),a.nestedCues.push(p);else{for(;q<=r;q++)if(t=p[q]){var u=t.isUnderlined(),v=t.isItalicized(),w=t.getTextColor(),x=t.getBackgroundColor();if(u!=h||v!=k||w!=l||x!=m)n.payload&&a.nestedCues.push(n),n=shaka.cea.CeaUtils.createStyledCue(d,e,u,v,w,x),h=u,k=v,l=w,m=x;n.payload+=t.getChar()}else n.payload+=
" ";n.payload&&a.nestedCues.push(n);f!==g&&(n=shaka.cea.CeaUtils.createLineBreakCue(d,e),a.nestedCues.push(n));n=shaka.cea.CeaUtils.createStyledCue(d,e,h,k,l,m)}}return a.nestedCues.length?{cue:a,stream:b}:null};shaka.cea.CeaUtils.createStyledCue=function(a,b,c,d,e,f){a=new shaka.text.Cue(a,b,"");c&&a.textDecoration.push(shaka.text.Cue.textDecoration.UNDERLINE);d&&(a.fontStyle=shaka.text.Cue.fontStyle.ITALIC);a.color=e;a.backgroundColor=f;return a};
shaka.cea.CeaUtils.createLineBreakCue=function(a,b){a=new shaka.text.Cue(a,b,"");a.lineBreak=!0;return a};shaka.cea.CeaUtils.StyledChar=function(a,b,c,d,e){this.character_=a;this.underline_=b;this.italics_=c;this.backgroundColor_=d;this.textColor_=e};shaka.cea.CeaUtils.StyledChar.prototype.getChar=function(){return this.character_};shaka.cea.CeaUtils.StyledChar.prototype.isUnderlined=function(){return this.underline_};shaka.cea.CeaUtils.StyledChar.prototype.isItalicized=function(){return this.italics_};
shaka.cea.CeaUtils.StyledChar.prototype.getBackgroundColor=function(){return this.backgroundColor_};shaka.cea.CeaUtils.StyledChar.prototype.getTextColor=function(){return this.textColor_};shaka.cea.CeaUtils.DEFAULT_BG_COLOR="black";shaka.cea.CeaUtils.DEFAULT_TXT_COLOR="white";shaka.cea.CeaUtils.H264_NALU_TYPE_SEI=6;shaka.cea.CeaUtils.H265_PREFIX_NALU_TYPE_SEI=39;shaka.cea.CeaUtils.H265_SUFFIX_NALU_TYPE_SEI=40;shaka.cea.CeaUtils.H266_PREFIX_NALU_TYPE_SEI=23;
shaka.cea.CeaUtils.H266_SUFFIX_NALU_TYPE_SEI=24;shaka.cea.CeaUtils.DEFAULT_TIMESCALE_VALUE=9E4;shaka.cea.Cea608Memory=function(a,b){this.rows_=[];this.row_=1;this.scrollRows_=0;this.fieldNum_=a;this.channelNum_=b;this.italics_=this.underline_=!1;this.textColor_=shaka.cea.CeaUtils.DEFAULT_TXT_COLOR;this.backgroundColor_=shaka.cea.CeaUtils.DEFAULT_BG_COLOR;this.indent_=this.offset_=null;this.reset()};
shaka.cea.Cea608Memory.prototype.forceEmit=function(a,b){var c=shaka.cea.Cea608Memory,d="CC"+((this.fieldNum_<<1|this.channelNum_)+1),e=new shaka.text.Cue(a,b,"");e.lineInterpretation=shaka.text.Cue.lineInterpretation.PERCENTAGE;var f=c.ROW_TO_LINE_CONVERSION_.get(this.row_);f&&(e.line=f);this.indent_!=null&&this.offset_!=null&&(e.position=10+Math.min(70,this.indent_*10)+this.offset_*2.5);(a=shaka.cea.CeaUtils.getParsedCaption(e,d,this.rows_,a,b))&&this.row_+a.cue.nestedCues.length-3>15&&(f=c.ROW_TO_LINE_CONVERSION_.get(this.row_+
3-a.cue.nestedCues.length))&&(e.line=f);return a};shaka.cea.Cea608Memory.prototype.reset=function(){this.resetAllRows();this.row_=1};shaka.cea.Cea608Memory.prototype.getRow=function(){return this.row_};shaka.cea.Cea608Memory.prototype.setRow=function(a){this.row_=a};shaka.cea.Cea608Memory.prototype.getScrollSize=function(){return this.scrollRows_};shaka.cea.Cea608Memory.prototype.setScrollSize=function(a){this.scrollRows_=a};
shaka.cea.Cea608Memory.prototype.addChar=function(a,b){if(!(b<32||b>127)){var c="";switch(a){case shaka.cea.Cea608Memory.CharSet.BASIC_NORTH_AMERICAN:c=shaka.cea.Cea608Memory.CharSet.BasicNorthAmericanChars.has(b)?shaka.cea.Cea608Memory.CharSet.BasicNorthAmericanChars.get(b):String.fromCharCode(b);break;case shaka.cea.Cea608Memory.CharSet.SPECIAL_NORTH_AMERICAN:c=shaka.cea.Cea608Memory.CharSet.SpecialNorthAmericanChars.get(b);break;case shaka.cea.Cea608Memory.CharSet.SPANISH_FRENCH:this.eraseChar();
c=shaka.cea.Cea608Memory.CharSet.ExtendedSpanishFrench.get(b);break;case shaka.cea.Cea608Memory.CharSet.PORTUGUESE_GERMAN:this.eraseChar(),c=shaka.cea.Cea608Memory.CharSet.ExtendedPortugueseGerman.get(b)}c&&(a=new shaka.cea.CeaUtils.StyledChar(c,this.underline_,this.italics_,this.backgroundColor_,this.textColor_),this.rows_[this.row_].push(a))}};shaka.cea.Cea608Memory.prototype.eraseChar=function(){this.rows_[this.row_].pop()};
shaka.cea.Cea608Memory.prototype.moveRows=function(a,b,c){if(!(b<0||a<0))if(a>=b)for(--c;c>=0;c--)this.rows_[a+c]=this.rows_[b+c].map(function(e){return e});else for(var d=0;d<c;d++)this.rows_[a+d]=this.rows_[b+d].map(function(e){return e})};shaka.cea.Cea608Memory.prototype.resetRows=function(a,b){for(var c=0;c<=b;c++)this.rows_[a+c]=[]};shaka.cea.Cea608Memory.prototype.resetAllRows=function(){this.resetRows(0,shaka.cea.Cea608Memory.CC_ROWS)};
shaka.cea.Cea608Memory.prototype.eraseBuffer=function(){this.row_=this.scrollRows_>0?this.scrollRows_:0;this.resetAllRows()};shaka.cea.Cea608Memory.prototype.setUnderline=function(a){this.underline_=a};shaka.cea.Cea608Memory.prototype.setItalics=function(a){this.italics_=a};shaka.cea.Cea608Memory.prototype.setTextColor=function(a){this.textColor_=a};shaka.cea.Cea608Memory.prototype.setBackgroundColor=function(a){this.backgroundColor_=a};
shaka.cea.Cea608Memory.prototype.setOffset=function(a){this.offset_=a};shaka.cea.Cea608Memory.prototype.setIndent=function(a){this.indent_=a};shaka.cea.Cea608Memory.CC_ROWS=15;shaka.cea.Cea608Memory.CharSet={BASIC_NORTH_AMERICAN:0,SPECIAL_NORTH_AMERICAN:1,SPANISH_FRENCH:2,PORTUGUESE_GERMAN:3};
shaka.cea.Cea608Memory.CharSet.BasicNorthAmericanChars=new Map([[39,"\u2019"],[42,"\u00e1"],[92,"\u00e9"],[92,"\u00e9"],[94,"\u00ed"],[95,"\u00f3"],[96,"\u00fa"],[123,"\u00e7"],[124,"\u00f7"],[125,"\u00d1"],[126,"\u00f1"],[127,"\u2588"]]);
shaka.cea.Cea608Memory.CharSet.SpecialNorthAmericanChars=new Map([[48,"\u00ae"],[49,"\u00b0"],[50,"\u00bd"],[51,"\u00bf"],[52,"\u2122"],[53,"\u00a2"],[54,"\u00a3"],[55,"\u266a"],[56,"\u00e0"],[57," "],[58,"\u00e8"],[59,"\u00e2"],[60,"\u00ea"],[61,"\u00ee"],[62,"\u00f4"],[63,"\u00fb"]]);
shaka.cea.Cea608Memory.CharSet.ExtendedSpanishFrench=new Map([[32,"\u00c1"],[33,"\u00c9"],[34,"\u00d3"],[35,"\u00da"],[36,"\u00dc"],[37,"\u00fc"],[38,"\u2018"],[39,"\u00a1"],[40,"*"],[41,"'"],[42,"\u2500"],[43,"\u00a9"],[44,"\u2120"],[45,"\u00b7"],[46,"\u201c"],[47,"\u201d"],[48,"\u00c0"],[49,"\u00c2"],[50,"\u00c7"],[51,"\u00c8"],[52,"\u00ca"],[53,"\u00cb"],[54,"\u00eb"],[55,"\u00ce"],[56,"\u00cf"],[57,"\u00ef"],[58,"\u00d4"],[59,"\u00d9"],[60,"\u00f9"],[61,"\u00db"],[62,"\u00ab"],[63,"\u00bb"]]);
shaka.cea.Cea608Memory.CharSet.ExtendedPortugueseGerman=new Map([[32,"\u00c3"],[33,"\u00e3"],[34,"\u00cd"],[35,"\u00cc"],[36,"\u00ec"],[37,"\u00d2"],[38,"\u00f2"],[39,"\u00d5"],[40,"\u00f5"],[41,"{"],[42,"}"],[43,"\\"],[44,"^"],[45,"_"],[46,"|"],[47,"~"],[48,"\u00c4"],[49,"\u00e4"],[50,"\u00d6"],[51,"\u00f6"],[52,"\u00df"],[53,"\u00a5"],[54,"\u00a4"],[55,"\u2502"],[56,"\u00c5"],[57,"\u00e5"],[58,"\u00d8"],[59,"\u00f8"],[60,"\u250c"],[61,"\u2510"],[62,"\u2514"],[63,"\u2518"]]);
shaka.cea.Cea608Memory.ROW_TO_LINE_CONVERSION_=new Map([[1,10],[2,15.33],[3,20.66],[4,26],[5,31.33],[6,36.66],[7,42],[8,47.33],[9,52.66],[10,58],[11,63.33],[12,68.66],[13,74],[14,79.33],[15,84.66]]);shaka.cea.Cea608DataChannel=function(a,b){this.type_=shaka.cea.Cea608DataChannel.CaptionType.NONE;this.text_=new shaka.cea.Cea608Memory(a,b);this.displayedMemory_=new shaka.cea.Cea608Memory(a,b);this.curBuf_=this.nonDisplayedMemory_=new shaka.cea.Cea608Memory(a,b);this.prevEndTime_=0;this.lastCp_=null};
shaka.cea.Cea608DataChannel.prototype.reset=function(){this.type_=shaka.cea.Cea608DataChannel.CaptionType.NONE;this.curBuf_=this.nonDisplayedMemory_;this.lastCp_=null;this.displayedMemory_.reset();this.nonDisplayedMemory_.reset();this.text_.reset()};shaka.cea.Cea608DataChannel.prototype.firstPts=function(a){this.prevEndTime_=a};shaka.cea.Cea608DataChannel.prototype.pacToRow_=function(a,b){return[11,11,1,2,3,4,12,13,14,15,5,6,7,8,9,10][(a&7)<<1|b>>5&1]};
shaka.cea.Cea608DataChannel.prototype.controlPac_=function(a,b){a=this.pacToRow_(a,b);var c=shaka.cea.CeaUtils.DEFAULT_TXT_COLOR,d=!1,e=null;var f=b>95?b-96:b-64;f<=13?c=shaka.cea.Cea608DataChannel.TEXT_COLORS[Math.floor(f/2)]:f<=15?d=!0:e=Math.floor((f-16)/2);b=(b&1)===1;if(this.type_!==shaka.cea.Cea608DataChannel.CaptionType.TEXT){f=this.curBuf_;if(this.type_===shaka.cea.Cea608DataChannel.CaptionType.ROLLUP&&a!==f.getRow()){var g=1+f.getRow()-f.getScrollSize(),h=1+a-f.getScrollSize();f.moveRows(h,
g,f.getScrollSize());f.resetRows(0,h-1);f.resetRows(a+1,shaka.cea.Cea608Memory.CC_ROWS-a)}f.setRow(a);f.setUnderline(b);f.setItalics(d);f.setTextColor(c);f.setIndent(e);f.setBackgroundColor(shaka.cea.CeaUtils.DEFAULT_BG_COLOR)}};
shaka.cea.Cea608DataChannel.prototype.controlMidrow_=function(a){this.curBuf_.setUnderline(!1);this.curBuf_.setItalics(!1);this.curBuf_.setTextColor(shaka.cea.CeaUtils.DEFAULT_TXT_COLOR);this.curBuf_.addChar(shaka.cea.Cea608Memory.CharSet.BASIC_NORTH_AMERICAN,32);var b=!1;var c=shaka.cea.Cea608DataChannel.TEXT_COLORS[(a&14)>>1];c==="white_italics"&&(c="white",b=!0);this.curBuf_.setUnderline((a&1)===1);this.curBuf_.setItalics(b);this.curBuf_.setTextColor(c)};
shaka.cea.Cea608DataChannel.prototype.controlBackgroundAttribute_=function(a,b){var c=shaka.cea.CeaUtils.DEFAULT_BG_COLOR;(a&7)===0&&(c=shaka.cea.Cea608DataChannel.BG_COLORS[(b&14)>>1]);this.curBuf_.setBackgroundColor(c)};
shaka.cea.Cea608DataChannel.prototype.controlMiscellaneous_=function(a){var b=shaka.cea.Cea608DataChannel.MiscCmd_,c=a.pts,d=null;switch(a.ccData2){case b.RCL:this.controlRcl_();break;case b.BS:this.controlBs_();break;case b.AOD:case b.AON:break;case b.DER:break;case b.RU2:d=this.controlRu_(2,c);break;case b.RU3:d=this.controlRu_(3,c);break;case b.RU4:d=this.controlRu_(4,c);break;case b.FON:this.controlFon_();break;case b.RDC:this.controlRdc_(c);break;case b.TR:this.controlTr_();break;case b.RTD:this.controlRtd_();
break;case b.EDM:d=this.controlEdm_(c);break;case b.CR:d=this.controlCr_(c);break;case b.ENM:this.controlEnm_();break;case b.EOC:d=this.controlEoc_(c)}return d};
shaka.cea.Cea608DataChannel.prototype.controlCr_=function(a){var b=this.curBuf_;if(this.type_!==shaka.cea.Cea608DataChannel.CaptionType.ROLLUP)return null;var c=b.forceEmit(this.prevEndTime_,a),d=b.getRow()-b.getScrollSize()+1;b.moveRows(d-1,d,b.getScrollSize());b.resetRows(0,d-1);b.resetRows(b.getRow(),shaka.cea.Cea608Memory.CC_ROWS-b.getRow());this.prevEndTime_=a;return c};
shaka.cea.Cea608DataChannel.prototype.controlRu_=function(a,b){var c=this.curBuf_=this.displayedMemory_,d=null;this.type_!==shaka.cea.Cea608DataChannel.CaptionType.ROLLUP&&this.type_!==shaka.cea.Cea608DataChannel.CaptionType.TEXT&&(d=c.forceEmit(this.prevEndTime_,b),this.displayedMemory_.eraseBuffer(),this.nonDisplayedMemory_.eraseBuffer(),c.setRow(shaka.cea.Cea608Memory.CC_ROWS));this.type_=shaka.cea.Cea608DataChannel.CaptionType.ROLLUP;c.setScrollSize(a);return d};
shaka.cea.Cea608DataChannel.prototype.controlFon_=function(){this.curBuf_.addChar(shaka.cea.Cea608Memory.CharSet.BASIC_NORTH_AMERICAN,32)};shaka.cea.Cea608DataChannel.prototype.controlEdm_=function(a){var b=this.displayedMemory_,c=null;this.type_!==shaka.cea.Cea608DataChannel.CaptionType.TEXT&&(c=b.forceEmit(this.prevEndTime_,a));b.resetAllRows();return c};
shaka.cea.Cea608DataChannel.prototype.controlRdc_=function(a){this.type_=shaka.cea.Cea608DataChannel.CaptionType.PAINTON;this.curBuf_=this.displayedMemory_;this.curBuf_.setScrollSize(0);this.prevEndTime_=a};shaka.cea.Cea608DataChannel.prototype.controlEnm_=function(){this.nonDisplayedMemory_.resetAllRows()};
shaka.cea.Cea608DataChannel.prototype.controlEoc_=function(a){var b=null;this.type_!==shaka.cea.Cea608DataChannel.CaptionType.TEXT&&(b=this.displayedMemory_.forceEmit(this.prevEndTime_,a));var c=this.nonDisplayedMemory_;this.nonDisplayedMemory_=this.displayedMemory_;this.displayedMemory_=c;this.controlRcl_();this.prevEndTime_=a;return b};shaka.cea.Cea608DataChannel.prototype.controlRcl_=function(){this.type_=shaka.cea.Cea608DataChannel.CaptionType.POPON;this.curBuf_=this.nonDisplayedMemory_;this.curBuf_.setScrollSize(0)};
shaka.cea.Cea608DataChannel.prototype.controlBs_=function(){this.curBuf_.eraseChar()};shaka.cea.Cea608DataChannel.prototype.controlTr_=function(){this.text_.reset();this.controlRtd_()};shaka.cea.Cea608DataChannel.prototype.controlRtd_=function(){shaka.log.warnOnce("Cea608DataChannel","CEA-608 text mode entered, but is unsupported");this.curBuf_=this.text_;this.type_=shaka.cea.Cea608DataChannel.CaptionType.TEXT};
shaka.cea.Cea608DataChannel.prototype.handleBasicNorthAmericanChar=function(a,b){this.curBuf_.addChar(shaka.cea.Cea608Memory.CharSet.BASIC_NORTH_AMERICAN,a);this.curBuf_.addChar(shaka.cea.Cea608Memory.CharSet.BASIC_NORTH_AMERICAN,b)};shaka.cea.Cea608DataChannel.prototype.handleExtendedWesternEuropeanChar_=function(a,b){this.curBuf_.addChar(a&1?shaka.cea.Cea608Memory.CharSet.PORTUGUESE_GERMAN:shaka.cea.Cea608Memory.CharSet.SPANISH_FRENCH,b)};shaka.cea.Cea608DataChannel.prototype.handleOffset_=function(a){this.curBuf_.setOffset(a)};
shaka.cea.Cea608DataChannel.prototype.handleControlCode=function(a){var b=a.ccData1,c=a.ccData2;if(this.lastCp_===(b<<8|c))return this.lastCp_=null;this.lastCp_=b<<8|c;if(this.isPAC_(b,c))this.controlPac_(b,c);else if(this.isMidrowStyleChange_(b,c))this.controlMidrow_(c);else if(this.isBackgroundAttribute_(b,c))this.controlBackgroundAttribute_(b,c);else if(this.isSpecialNorthAmericanChar_(b,c))this.curBuf_.addChar(shaka.cea.Cea608Memory.CharSet.SPECIAL_NORTH_AMERICAN,c);else if(this.isExtendedWesternEuropeanChar_(b,
c))this.handleExtendedWesternEuropeanChar_(b,c);else{if(this.isMiscellaneous_(b,c))return this.controlMiscellaneous_(a);this.isOffset_(b,c)&&this.handleOffset_(c-32)}return null};shaka.cea.Cea608DataChannel.prototype.isMiscellaneous_=function(a,b){return(a&246)===20&&(b&240)===32};shaka.cea.Cea608DataChannel.prototype.isOffset_=function(a,b){return(a==23||a==31)&&b>=33&&b<=35};shaka.cea.Cea608DataChannel.prototype.isPAC_=function(a,b){return(a&240)===16&&(b&192)===64};
shaka.cea.Cea608DataChannel.prototype.isMidrowStyleChange_=function(a,b){return(a&247)===17&&(b&240)===32};shaka.cea.Cea608DataChannel.prototype.isBackgroundAttribute_=function(a,b){return(a&247)===16&&(b&240)===32||(a&247)===23&&(b&255)===45};shaka.cea.Cea608DataChannel.prototype.isSpecialNorthAmericanChar_=function(a,b){return(a&247)===17&&(b&240)===48};shaka.cea.Cea608DataChannel.prototype.isExtendedWesternEuropeanChar_=function(a,b){return(a&246)===18&&(b&224)===32};
shaka.cea.Cea608DataChannel.isControlCode=function(a){return(a&112)===16};shaka.cea.Cea608DataChannel.isXdsControlCode=function(a){return a>=1&&a<=15};shaka.cea.Cea608DataChannel.MiscCmd_={RCL:32,BS:33,AOD:34,AON:35,DER:36,RU2:37,RU3:38,RU4:39,FON:40,RDC:41,TR:42,RTD:43,EDM:44,CR:45,ENM:46,EOC:47};shaka.cea.Cea608DataChannel.CaptionType={NONE:0,POPON:1,PAINTON:2,ROLLUP:3,TEXT:4};shaka.cea.Cea608DataChannel.BG_COLORS="black green blue cyan red yellow magenta black".split(" ");
shaka.cea.Cea608DataChannel.TEXT_COLORS="white green blue cyan red yellow magenta white_italics".split(" ");shaka.cea.Cea708Window=function(a,b){this.parentService_=b;this.windowNum_=a;this.relativeToggle_=this.visible_=!1;this.colCount_=this.rowCount_=this.anchorId_=this.verticalAnchor_=this.horizontalAnchor_=0;this.justification_=shaka.cea.Cea708Window.TextJustification.CENTER;this.memory_=[];this.col_=this.row_=this.startTime_=0;this.underline_=this.italics_=!1;this.textColor_=shaka.cea.CeaUtils.DEFAULT_TXT_COLOR;this.backgroundColor_=shaka.cea.CeaUtils.DEFAULT_BG_COLOR;this.resetMemory()};
shaka.cea.Cea708Window.prototype.defineWindow=function(a,b,c,d,e,f,g){this.visible_=a;this.verticalAnchor_=b;this.horizontalAnchor_=c;this.anchorId_=d;this.relativeToggle_=e;this.rowCount_=f;this.colCount_=g};shaka.cea.Cea708Window.prototype.resetMemory=function(){this.memory_=[];for(var a=0;a<shaka.cea.Cea708Window.MAX_ROWS;a++)this.memory_.push(this.createNewRow_())};shaka.cea.Cea708Window.prototype.createNewRow_=function(){for(var a=[],b=0;b<shaka.cea.Cea708Window.MAX_COLS;b++)a.push(null);return a};
shaka.cea.Cea708Window.prototype.setCharacter=function(a){this.isPenInBounds_()&&(a=new shaka.cea.CeaUtils.StyledChar(a,this.underline_,this.italics_,this.backgroundColor_,this.textColor_),this.memory_[this.row_][this.col_]=a,this.col_++)};shaka.cea.Cea708Window.prototype.backspace=function(){!this.isPenInBounds_()||this.col_<=0&&this.row_<=0||(this.col_<=0?(this.col_=this.colCount_-1,this.row_--):this.col_--,this.memory_[this.row_][this.col_]=null)};
shaka.cea.Cea708Window.prototype.isPenInBounds_=function(){var a=this.col_<this.colCount_&&this.col_>=0;return this.row_<this.rowCount_&&this.row_>=0&&a};shaka.cea.Cea708Window.prototype.isVisible=function(){return this.visible_};shaka.cea.Cea708Window.prototype.moveUpRows_=function(a){for(var b=0,c=a;c<shaka.cea.Cea708Window.MAX_ROWS;c++,b++)this.memory_[b]=this.memory_[c];for(c=0;c<a;c++,b++)this.memory_[b]=this.createNewRow_()};
shaka.cea.Cea708Window.prototype.carriageReturn=function(){this.row_+1>=this.rowCount_?this.moveUpRows_(1):this.row_++;this.col_=0};shaka.cea.Cea708Window.prototype.horizontalCarriageReturn=function(){this.memory_[this.row_]=this.createNewRow_();this.col_=0};
shaka.cea.Cea708Window.prototype.forceEmit=function(a,b){b="svc"+b;var c=shaka.cea.Cea708Window.TextJustification,d=new shaka.text.Cue(this.startTime_,a,"");d.textAlign=this.justification_===c.LEFT?shaka.text.Cue.textAlign.LEFT:this.justification_===c.RIGHT?shaka.text.Cue.textAlign.RIGHT:shaka.text.Cue.textAlign.CENTER;this.adjustRegion_(d.region);(b=shaka.cea.CeaUtils.getParsedCaption(d,b,this.memory_,this.startTime_,a))&&this.setStartTime(a);return b};
shaka.cea.Cea708Window.prototype.setPenLocation=function(a,b){this.row_=a;this.col_=b};shaka.cea.Cea708Window.prototype.setPenBackgroundColor=function(a){this.backgroundColor_=a};shaka.cea.Cea708Window.prototype.setPenTextColor=function(a){this.textColor_=a};shaka.cea.Cea708Window.prototype.setPenUnderline=function(a){this.underline_=a};shaka.cea.Cea708Window.prototype.setPenItalics=function(a){this.italics_=a};
shaka.cea.Cea708Window.prototype.resetPen=function(){this.col_=this.row_=0;this.italics_=this.underline_=!1;this.textColor_=shaka.cea.CeaUtils.DEFAULT_TXT_COLOR;this.backgroundColor_=shaka.cea.CeaUtils.DEFAULT_BG_COLOR};shaka.cea.Cea708Window.prototype.setJustification=function(a){this.justification_=a};shaka.cea.Cea708Window.prototype.display=function(){this.visible_=!0};shaka.cea.Cea708Window.prototype.hide=function(){this.visible_=!1};
shaka.cea.Cea708Window.prototype.toggle=function(){this.visible_=!this.visible_};shaka.cea.Cea708Window.prototype.setStartTime=function(a){this.startTime_=a};
shaka.cea.Cea708Window.prototype.adjustRegion_=function(a){this.parentService_&&(a.id+="svc"+this.parentService_);a.id+="win"+this.windowNum_;a.height=this.rowCount_;a.width=this.colCount_;a.heightUnits=shaka.text.CueRegion.units.LINES;a.widthUnits=shaka.text.CueRegion.units.LINES;a.viewportAnchorX=this.horizontalAnchor_;a.viewportAnchorY=this.verticalAnchor_;a.viewportAnchorUnits=this.relativeToggle_?shaka.text.CueRegion.units.PERCENTAGE:shaka.text.CueRegion.units.LINES;var b=shaka.cea.Cea708Window.AnchorId;
switch(this.anchorId_){case b.UPPER_LEFT:a.regionAnchorX=0;a.regionAnchorY=0;break;case b.UPPER_CENTER:a.regionAnchorX=50;a.regionAnchorY=0;break;case b.UPPER_RIGHT:a.regionAnchorX=100;a.regionAnchorY=0;break;case b.MIDDLE_LEFT:a.regionAnchorX=0;a.regionAnchorY=50;break;case b.MIDDLE_CENTER:a.regionAnchorX=50;a.regionAnchorY=50;break;case b.MIDDLE_RIGHT:a.regionAnchorX=100;a.regionAnchorY=50;break;case b.LOWER_LEFT:a.regionAnchorX=0;a.regionAnchorY=100;break;case b.LOWER_CENTER:a.regionAnchorX=50;
a.regionAnchorY=100;break;case b.LOWER_RIGHT:a.regionAnchorX=100,a.regionAnchorY=100}};shaka.cea.Cea708Window.TextJustification={LEFT:0,RIGHT:1,CENTER:2,FULL:3};shaka.cea.Cea708Window.AnchorId={UPPER_LEFT:0,UPPER_CENTER:1,UPPER_RIGHT:2,MIDDLE_LEFT:3,MIDDLE_CENTER:4,MIDDLE_RIGHT:5,LOWER_LEFT:6,LOWER_CENTER:7,LOWER_RIGHT:8};shaka.cea.Cea708Window.MAX_COLS=42;shaka.cea.Cea708Window.MAX_ROWS=16;shaka.cea.DtvccPacketBuilder=function(){this.builtPackets_=[];this.currentPacketBeingBuilt_=null;this.bytesLeftToAddInCurrentPacket_=0};
shaka.cea.DtvccPacketBuilder.prototype.addByte=function(a){a.type===shaka.cea.DtvccPacketBuilder.DTVCC_PACKET_START?(this.bytesLeftToAddInCurrentPacket_=(a.value&63)*2-1,this.currentPacketBeingBuilt_=[]):this.currentPacketBeingBuilt_&&(this.bytesLeftToAddInCurrentPacket_>0&&(this.currentPacketBeingBuilt_.push(a),this.bytesLeftToAddInCurrentPacket_--),this.bytesLeftToAddInCurrentPacket_===0&&(a=new shaka.cea.DtvccPacket(this.currentPacketBeingBuilt_),this.builtPackets_.push(a),this.currentPacketBeingBuilt_=
null,this.bytesLeftToAddInCurrentPacket_=0))};shaka.cea.DtvccPacketBuilder.prototype.getBuiltPackets=function(){return this.builtPackets_};shaka.cea.DtvccPacketBuilder.prototype.clearBuiltPackets=function(){this.builtPackets_=[]};shaka.cea.DtvccPacketBuilder.prototype.clear=function(){this.builtPackets_=[];this.currentPacketBeingBuilt_=[];this.bytesLeftToAddInCurrentPacket_=0};shaka.cea.DtvccPacket=function(a){this.pos_=0;this.packetData_=a};
shaka.cea.DtvccPacket.prototype.hasMoreData=function(){return this.pos_<this.packetData_.length};shaka.cea.DtvccPacket.prototype.getPosition=function(){return this.pos_};shaka.cea.DtvccPacket.prototype.readByte=function(){if(!this.hasMoreData())throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.BUFFER_READ_OUT_OF_BOUNDS);return this.packetData_[this.pos_++]};
shaka.cea.DtvccPacket.prototype.skip=function(a){if(this.pos_+a>this.packetData_.length)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.BUFFER_READ_OUT_OF_BOUNDS);this.pos_+=a};shaka.cea.DtvccPacket.prototype.rewind=function(a){if(this.pos_-a<0)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.BUFFER_READ_OUT_OF_BOUNDS);this.pos_-=a};
shaka.cea.DtvccPacketBuilder.DTVCC_PACKET_DATA=2;shaka.cea.DtvccPacketBuilder.DTVCC_PACKET_START=3;shaka.cea.Cea708Service=function(a){this.serviceNumber_=a;this.windows_=[null,null,null,null,null,null,null,null];this.currentWindow_=null};
shaka.cea.Cea708Service.prototype.handleCea708ControlCode=function(a){var b=a.readByte(),c=b.value;b=b.pts;if(c===shaka.cea.Cea708Service.EXT_CEA708_CTRL_CODE_BYTE1){var d=a.readByte();c=c<<16|d.value}if(c>=0&&c<=31)return this.handleC0_(a,c,b);if(c>=128&&c<=159)return this.handleC1_(a,c,b);c>=4096&&c<=4127?this.handleC2_(a,c&255):c>=4224&&c<=4255?this.handleC3_(a,c&255):c>=32&&c<=127?this.handleG0_(c):c>=160&&c<=255?this.handleG1_(c):c>=4128&&c<=4223?this.handleG2_(c&255):c>=4256&&c<=4351&&this.handleG3_(c&
255);return[]};shaka.cea.Cea708Service.prototype.handleG0_=function(a){this.currentWindow_&&(a===127?this.currentWindow_.setCharacter("\u266a"):this.currentWindow_.setCharacter(String.fromCharCode(a)))};shaka.cea.Cea708Service.prototype.handleG1_=function(a){this.currentWindow_&&this.currentWindow_.setCharacter(String.fromCharCode(a))};
shaka.cea.Cea708Service.prototype.handleG2_=function(a){this.currentWindow_&&(shaka.cea.Cea708Service.G2Charset.has(a)?(a=shaka.cea.Cea708Service.G2Charset.get(a),this.currentWindow_.setCharacter(a)):this.currentWindow_.setCharacter("_"))};shaka.cea.Cea708Service.prototype.handleG3_=function(a){this.currentWindow_&&(a!=160?this.currentWindow_.setCharacter("_"):this.currentWindow_.setCharacter("[CC]"))};
shaka.cea.Cea708Service.prototype.handleC0_=function(a,b,c){if(!this.currentWindow_)return[];if(b==24)return b=a.readByte().value,c=a.readByte().value,b=function(e){return e.map(function(f){return("0"+(f&255).toString(16)).slice(-2)}).join("")}([b,c]),b=String.fromCharCode(parseInt(b,16)),this.currentWindow_.setCharacter(b),[];a=this.currentWindow_;var d=null;switch(b){case shaka.cea.Cea708Service.ASCII_BACKSPACE:a.backspace();break;case shaka.cea.Cea708Service.ASCII_CARRIAGE_RETURN:a.isVisible()&&
(d=a.forceEmit(c,this.serviceNumber_));a.carriageReturn();break;case shaka.cea.Cea708Service.ASCII_HOR_CARRIAGE_RETURN:a.isVisible()&&(d=a.forceEmit(c,this.serviceNumber_));a.horizontalCarriageReturn();break;case shaka.cea.Cea708Service.ASCII_FORM_FEED:a.isVisible()&&(d=a.forceEmit(c,this.serviceNumber_)),a.resetMemory(),a.setPenLocation(0,0)}return d?[d]:[]};
shaka.cea.Cea708Service.prototype.handleC1_=function(a,b,c){if(b>=128&&b<=135)this.setCurrentWindow_(b&7);else{if(b===136)return a=a.readByte().value,this.clearWindows_(a,c);if(b===137)a=a.readByte().value,this.displayWindows_(a,c);else{if(b===138)return a=a.readByte().value,this.hideWindows_(a,c);if(b===139)return a=a.readByte().value,this.toggleWindows_(a,c);if(b===140)return a=a.readByte().value,this.deleteWindows_(a,c);if(b===143)return this.reset_(c);b===144?this.setPenAttributes_(a):b===145?
this.setPenColor_(a):b===146?this.setPenLocation_(a):b===151?this.setWindowAttributes_(a):b>=152&&b<=159&&this.defineWindow_(a,(b&15)-8,c)}}return[]};shaka.cea.Cea708Service.prototype.handleC2_=function(a,b){b>=8&&b<=15?a.skip(1):b>=16&&b<=23?a.skip(2):b>=24&&b<=31&&a.skip(3)};shaka.cea.Cea708Service.prototype.handleC3_=function(a,b){b>=128&&b<=135?a.skip(4):b>=136&&b<=143&&a.skip(5)};shaka.cea.Cea708Service.prototype.setCurrentWindow_=function(a){this.windows_[a]&&(this.currentWindow_=this.windows_[a])};
shaka.cea.Cea708Service.prototype.getSpecifiedWindowIds_=function(a){for(var b=[],c=0;c<8;c++)(a&1)===1&&this.windows_[c]&&b.push(c),a>>=1;return b};shaka.cea.Cea708Service.prototype.clearWindows_=function(a,b){var c=[];a=(0,$jscomp.makeIterator)(this.getSpecifiedWindowIds_(a));for(var d=a.next();!d.done;d=a.next()){d=this.windows_[d.value];if(d.isVisible()){var e=d.forceEmit(b,this.serviceNumber_);e&&c.push(e)}d.resetMemory()}return c};
shaka.cea.Cea708Service.prototype.displayWindows_=function(a,b){a=(0,$jscomp.makeIterator)(this.getSpecifiedWindowIds_(a));for(var c=a.next();!c.done;c=a.next())c=this.windows_[c.value],c.isVisible()||c.setStartTime(b),c.display()};
shaka.cea.Cea708Service.prototype.hideWindows_=function(a,b){var c=null;a=(0,$jscomp.makeIterator)(this.getSpecifiedWindowIds_(a));for(var d=a.next();!d.done;d=a.next())d=this.windows_[d.value],d.isVisible()&&(c=d.forceEmit(b,this.serviceNumber_)),d.hide();return c?[c]:[]};
shaka.cea.Cea708Service.prototype.toggleWindows_=function(a,b){var c=null;a=(0,$jscomp.makeIterator)(this.getSpecifiedWindowIds_(a));for(var d=a.next();!d.done;d=a.next())d=this.windows_[d.value],d.isVisible()?c=d.forceEmit(b,this.serviceNumber_):d.setStartTime(b),d.toggle();return c?[c]:[]};
shaka.cea.Cea708Service.prototype.deleteWindows_=function(a,b){var c=[];a=(0,$jscomp.makeIterator)(this.getSpecifiedWindowIds_(a));for(var d=a.next();!d.done;d=a.next()){d=d.value;var e=this.windows_[d];e.isVisible()&&(e=e.forceEmit(b,this.serviceNumber_))&&c.push(e);this.windows_[d]=null}return c};shaka.cea.Cea708Service.prototype.reset_=function(a){a=this.deleteWindows_(255,a);this.clear();return a};
shaka.cea.Cea708Service.prototype.clear=function(){this.currentWindow_=null;this.windows_=[null,null,null,null,null,null,null,null]};shaka.cea.Cea708Service.prototype.setPenAttributes_=function(a){a.skip(1);a=a.readByte().value;if(this.currentWindow_){var b=(a&64)>0;this.currentWindow_.setPenItalics((a&128)>0);this.currentWindow_.setPenUnderline(b)}};
shaka.cea.Cea708Service.prototype.setPenColor_=function(a){var b=a.readByte().value,c=a.readByte().value;a.skip(1);if(this.currentWindow_){a=c&3;var d=(c&12)>>2;c=(c&48)>>4;b=this.rgbColorToHex_((b&48)>>4,(b&12)>>2,b&3);a=this.rgbColorToHex_(c,d,a);this.currentWindow_.setPenTextColor(b);this.currentWindow_.setPenBackgroundColor(a)}};
shaka.cea.Cea708Service.prototype.setPenLocation_=function(a){var b=a.readByte().value;a=a.readByte().value;this.currentWindow_&&this.currentWindow_.setPenLocation(b&15,a&63)};shaka.cea.Cea708Service.prototype.setWindowAttributes_=function(a){a.skip(1);a.skip(1);var b=a.readByte().value;a.skip(1);this.currentWindow_&&this.currentWindow_.setJustification(b&3)};
shaka.cea.Cea708Service.prototype.defineWindow_=function(a,b,c){var d=this.windows_[b]!==null;if(!d){var e=new shaka.cea.Cea708Window(b,this.serviceNumber_);e.setStartTime(c);this.windows_[b]=e}var f=a.readByte().value,g=a.readByte().value;c=a.readByte().value;var h=a.readByte().value;e=a.readByte().value;a=a.readByte().value;f=(f&32)>0;var k=g&127;g=(g&128)>0;var l=(h&15)+1;h=(h&240)>>4;e=(e&63)+1;d&&(a&7)===0||this.windows_[b].resetPen();this.windows_[b].defineWindow(f,k,c,h,g,l,e);this.currentWindow_=
this.windows_[b]};shaka.cea.Cea708Service.prototype.rgbColorToHex_=function(a,b,c){var d={0:0,1:0,2:1,3:1};a=d[a];b=d[b];c=d[c];return shaka.cea.Cea708Service.Colors[a<<2|b<<1|c]};shaka.cea.Cea708Service.ASCII_BACKSPACE=8;shaka.cea.Cea708Service.ASCII_FORM_FEED=12;shaka.cea.Cea708Service.ASCII_CARRIAGE_RETURN=13;shaka.cea.Cea708Service.ASCII_HOR_CARRIAGE_RETURN=14;shaka.cea.Cea708Service.EXT_CEA708_CTRL_CODE_BYTE1=16;
shaka.cea.Cea708Service.G2Charset=new Map([[32," "],[33,"\u00a0"],[37,"\u2026"],[42,"\u0160"],[44,"\u0152"],[48,"\u2588"],[49,"\u2018"],[50,"\u2019"],[51,"\u201c"],[52,"\u201d"],[53,"\u2022"],[57,"\u2122"],[58,"\u0161"],[60,"\u0153"],[61,"\u2120"],[63,"\u0178"],[118,"\u215b"],[119,"\u215c"],[120,"\u215d"],[121,"\u215e"],[122,"\u2502"],[123,"\u2510"],[124,"\u2514"],[125,"\u2500"],[126,"\u2518"],[127,"\u250c"]]);shaka.cea.Cea708Service.Colors="black blue green cyan red magenta yellow white".split(" ");shaka.util.DataViewReader=function(a,b){this.dataView_=shaka.util.BufferUtils.toDataView(a);this.littleEndian_=b==shaka.util.DataViewReader.Endianness.LITTLE_ENDIAN;this.position_=0};shaka.util.DataViewReader.prototype.getDataView=function(){return this.dataView_};shaka.util.DataViewReader.prototype.hasMoreData=function(){return this.position_<this.dataView_.byteLength};shaka.util.DataViewReader.prototype.getPosition=function(){return this.position_};
shaka.util.DataViewReader.prototype.getLength=function(){return this.dataView_.byteLength};shaka.util.DataViewReader.prototype.readUint8=function(){try{var a=this.dataView_.getUint8(this.position_);this.position_+=1;return a}catch(b){throw this.outOfBounds_();}};shaka.util.DataViewReader.prototype.readUint16=function(){try{var a=this.dataView_.getUint16(this.position_,this.littleEndian_);this.position_+=2;return a}catch(b){throw this.outOfBounds_();}};
shaka.util.DataViewReader.prototype.readUint32=function(){try{var a=this.dataView_.getUint32(this.position_,this.littleEndian_);this.position_+=4;return a}catch(b){throw this.outOfBounds_();}};shaka.util.DataViewReader.prototype.readInt32=function(){try{var a=this.dataView_.getInt32(this.position_,this.littleEndian_);this.position_+=4;return a}catch(b){throw this.outOfBounds_();}};
shaka.util.DataViewReader.prototype.readUint64=function(){try{if(this.littleEndian_){var a=this.dataView_.getUint32(this.position_,!0);var b=this.dataView_.getUint32(this.position_+4,!0)}else b=this.dataView_.getUint32(this.position_,!1),a=this.dataView_.getUint32(this.position_+4,!1)}catch(c){throw this.outOfBounds_();}if(b>2097151)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.JS_INTEGER_OVERFLOW);this.position_+=8;return b*4294967296+
a};shaka.util.DataViewReader.prototype.readBytes=function(a,b){goog.asserts.assert(a>=0,"Bad call to DataViewReader.readBytes");if(this.position_+a>this.dataView_.byteLength)throw this.outOfBounds_();var c=shaka.util.BufferUtils.toUint8(this.dataView_,this.position_,a);this.position_+=a;return b?new Uint8Array(c):c};
shaka.util.DataViewReader.prototype.skip=function(a){goog.asserts.assert(a>=0,"Bad call to DataViewReader.skip");if(this.position_+a>this.dataView_.byteLength)throw this.outOfBounds_();this.position_+=a};shaka.util.DataViewReader.prototype.rewind=function(a){goog.asserts.assert(a>=0,"Bad call to DataViewReader.rewind");if(this.position_<a)throw this.outOfBounds_();this.position_-=a};
shaka.util.DataViewReader.prototype.seek=function(a){goog.asserts.assert(a>=0,"Bad call to DataViewReader.seek");if(a<0||a>this.dataView_.byteLength)throw this.outOfBounds_();this.position_=a};shaka.util.DataViewReader.prototype.readTerminatedString=function(){for(var a=this.position_;this.hasMoreData()&&this.dataView_.getUint8(this.position_)!=0;)this.position_+=1;a=shaka.util.BufferUtils.toUint8(this.dataView_,a,this.position_-a);this.position_+=1;return shaka.util.StringUtils.fromUTF8(a)};
shaka.util.DataViewReader.prototype.outOfBounds_=function(){return new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.BUFFER_READ_OUT_OF_BOUNDS)};goog.exportSymbol("shaka.util.DataViewReader",shaka.util.DataViewReader);goog.exportProperty(shaka.util.DataViewReader.prototype,"readTerminatedString",shaka.util.DataViewReader.prototype.readTerminatedString);goog.exportProperty(shaka.util.DataViewReader.prototype,"seek",shaka.util.DataViewReader.prototype.seek);
goog.exportProperty(shaka.util.DataViewReader.prototype,"rewind",shaka.util.DataViewReader.prototype.rewind);goog.exportProperty(shaka.util.DataViewReader.prototype,"skip",shaka.util.DataViewReader.prototype.skip);goog.exportProperty(shaka.util.DataViewReader.prototype,"readBytes",shaka.util.DataViewReader.prototype.readBytes);goog.exportProperty(shaka.util.DataViewReader.prototype,"readUint64",shaka.util.DataViewReader.prototype.readUint64);
goog.exportProperty(shaka.util.DataViewReader.prototype,"readInt32",shaka.util.DataViewReader.prototype.readInt32);goog.exportProperty(shaka.util.DataViewReader.prototype,"readUint32",shaka.util.DataViewReader.prototype.readUint32);goog.exportProperty(shaka.util.DataViewReader.prototype,"readUint16",shaka.util.DataViewReader.prototype.readUint16);goog.exportProperty(shaka.util.DataViewReader.prototype,"readUint8",shaka.util.DataViewReader.prototype.readUint8);
goog.exportProperty(shaka.util.DataViewReader.prototype,"getLength",shaka.util.DataViewReader.prototype.getLength);goog.exportProperty(shaka.util.DataViewReader.prototype,"getPosition",shaka.util.DataViewReader.prototype.getPosition);goog.exportProperty(shaka.util.DataViewReader.prototype,"hasMoreData",shaka.util.DataViewReader.prototype.hasMoreData);shaka.util.DataViewReader.Endianness={BIG_ENDIAN:0,LITTLE_ENDIAN:1};goog.exportProperty(shaka.util.DataViewReader,"Endianness",shaka.util.DataViewReader.Endianness);shaka.cea.CeaDecoder=function(){this.cea608DataArray_=[];this.cea708DataArray_=[];this.dtvccPacketBuilder_=new shaka.cea.DtvccPacketBuilder;this.badFrames_=0;this.cea608ModeToStream_=new Map([["CC1",new shaka.cea.Cea608DataChannel(0,0)],["CC2",new shaka.cea.Cea608DataChannel(0,1)],["CC3",new shaka.cea.Cea608DataChannel(1,0)],["CC4",new shaka.cea.Cea608DataChannel(1,1)]]);this.currentField2Channel_=this.currentField1Channel_=0;this.serviceNumberToService_=new Map;this.waitingForFirstPacket_=!0;this.streams_=
new Set;this.reset()};shaka.cea.CeaDecoder.prototype.clear=function(){shaka.log.debug("Clearing CEA decoder");this.badFrames_=0;this.cea608DataArray_=[];this.cea708DataArray_=[];this.dtvccPacketBuilder_.clear();this.reset();for(var a=(0,$jscomp.makeIterator)(this.serviceNumberToService_.values()),b=a.next();!b.done;b=a.next())b.value.clear()};
shaka.cea.CeaDecoder.prototype.reset=function(){shaka.log.debug("Resetting CEA decoder");this.currentField2Channel_=this.currentField1Channel_=0;for(var a=(0,$jscomp.makeIterator)(this.cea608ModeToStream_.values()),b=a.next();!b.done;b=a.next())b.value.reset();this.waitingForFirstPacket_=!0};
shaka.cea.CeaDecoder.prototype.extract=function(a,b){if(this.waitingForFirstPacket_){shaka.log.debug("Setting first pts value to",b);for(var c=(0,$jscomp.makeIterator)(this.cea608ModeToStream_.values()),d=c.next();!d.done;d=c.next())d.value.firstPts(b);this.waitingForFirstPacket_=!1}a=new shaka.util.DataViewReader(a,shaka.util.DataViewReader.Endianness.BIG_ENDIAN);if(!(a.getLength()<shaka.cea.CeaDecoder.MIN_LENGTH)&&a.readUint8()===shaka.cea.CeaDecoder.USA_COUNTRY_CODE&&a.readUint16()===shaka.cea.CeaDecoder.ATSC_PROVIDER_CODE&&
a.readUint32()===shaka.cea.CeaDecoder.ATSC1_USER_IDENTIFIER&&a.readUint8()===3&&(c=a.readUint8(),(c&64)!==0))for(c&=31,a.skip(1),d=0;d<c;d++){var e=a.readUint8(),f=(e&4)>>2,g=a.readUint8(),h=a.readUint8();f&&(e&=3,e===shaka.cea.CeaDecoder.NTSC_CC_FIELD_1||e===shaka.cea.CeaDecoder.NTSC_CC_FIELD_2?this.cea608DataArray_.push({pts:b,type:e,ccData1:g,ccData2:h,order:this.cea608DataArray_.length}):(this.cea708DataArray_.push({pts:b,type:e,value:g,order:this.cea708DataArray_.length}),this.cea708DataArray_.push({pts:b,
type:shaka.cea.DtvccPacketBuilder.DTVCC_PACKET_DATA,value:h,order:this.cea708DataArray_.length})))}};
shaka.cea.CeaDecoder.prototype.decode=function(){var a=[],b=function(d,e){return d.pts-e.pts||d.order-e.order};this.cea608DataArray_.sort(b);this.cea708DataArray_.sort(b);b=(0,$jscomp.makeIterator)(this.cea608DataArray_);for(var c=b.next();!c.done;c=b.next())(c=this.decodeCea608_(c.value))&&a.push(c);b=(0,$jscomp.makeIterator)(this.cea708DataArray_);for(c=b.next();!c.done;c=b.next())this.dtvccPacketBuilder_.addByte(c.value);b=this.dtvccPacketBuilder_.getBuiltPackets();b=(0,$jscomp.makeIterator)(b);
for(c=b.next();!c.done;c=b.next())c=this.decodeCea708_(c.value),a.push.apply(a,(0,$jscomp.arrayFromIterable)(c));this.dtvccPacketBuilder_.clearBuiltPackets();this.cea608DataArray_=[];this.cea708DataArray_=[];return a};
shaka.cea.CeaDecoder.prototype.decodeCea608_=function(a){var b=a.type;if(shaka.cea.Cea608DataChannel.isControlCode(a.ccData1)){var c=a.ccData1>>3&1;b===0?this.currentField1Channel_=c:this.currentField2Channel_=c}b="CC"+((b<<1|(b?this.currentField2Channel_:this.currentField1Channel_))+1);c=this.cea608ModeToStream_.get(b);if(a.ccData1===255&&a.ccData2===255||!a.ccData1&&!a.ccData2||!this.isOddParity_(a.ccData1)||!this.isOddParity_(a.ccData2))return++this.badFrames_>=45&&this.reset(),null;this.badFrames_=
0;a.ccData1&=127;a.ccData2&=127;if(shaka.cea.Cea608DataChannel.isXdsControlCode(a.ccData1)||!a.ccData1&&!a.ccData2)return null;var d=null;shaka.cea.Cea608DataChannel.isControlCode(a.ccData1)?(this.streams_.add(b),d=c.handleControlCode(a)):c.handleBasicNorthAmericanChar(a.ccData1,a.ccData2);return d};
shaka.cea.CeaDecoder.prototype.decodeCea708_=function(a){var b=[];try{for(;a.hasMoreData();){var c=a.readByte().value,d=(c&224)>>5,e=c&31;d===7&&e!=0&&(d=a.readByte().value&63);if(d!=0){this.streams_.add("svc"+d);if(!this.serviceNumberToService_.has(d)){var f=new shaka.cea.Cea708Service(d);this.serviceNumberToService_.set(d,f)}for(var g=this.serviceNumberToService_.get(d),h=a.getPosition();a.getPosition()-h<e;){var k=g.handleCea708ControlCode(a);b.push.apply(b,(0,$jscomp.arrayFromIterable)(k))}}}}catch(l){if(l instanceof
shaka.util.Error&&l.code===shaka.util.Error.Code.BUFFER_READ_OUT_OF_BOUNDS)shaka.log.warnOnce("CEA708_INVALID_DATA","Buffer read out of bounds / invalid CEA-708 Data.");else throw l;}return b};shaka.cea.CeaDecoder.prototype.isOddParity_=function(a){for(var b=0;a;)b^=a&1,a>>=1;return b===1};shaka.cea.CeaDecoder.prototype.getStreams=function(){return Array.from(this.streams_)};goog.exportSymbol("shaka.cea.CeaDecoder",shaka.cea.CeaDecoder);shaka.cea.CeaDecoder.ATSC_PROVIDER_CODE=49;
shaka.cea.CeaDecoder.ATSC1_USER_IDENTIFIER=1195456820;shaka.cea.CeaDecoder.NTSC_CC_FIELD_1=0;shaka.cea.CeaDecoder.NTSC_CC_FIELD_2=1;shaka.cea.CeaDecoder.USA_COUNTRY_CODE=181;shaka.cea.CeaDecoder.MIN_LENGTH=8;shaka.media.ClosedCaptionParser.registerDecoder(function(){return new shaka.cea.CeaDecoder});shaka.cea.SeiProcessor=function(){};shaka.cea.SeiProcessor.prototype.process=function(a){var b=[];a=this.removeEmu(a);for(var c=0;c<a.length;){for(var d=0;a[c]==255;)d+=255,c++;d+=a[c++];for(var e=0;a[c]==255;)e+=255,c++;e+=a[c++];d==4&&b.push(a.subarray(c,c+e));c+=e}return b};shaka.cea.SeiProcessor.prototype.removeEmu=function(a){for(var b=a,c=a=0;c<b.length;)a==2&&b[c]==3?(a=0,b=[].concat((0,$jscomp.arrayFromIterable)(b)),b.splice(c,1),b=new Uint8Array(b)):b[c]==0?a++:a=0,c++;return b};shaka.util.Mp4Parser=function(){this.headers_=new Map;this.boxDefinitions_=new Map;this.done_=!1};shaka.util.Mp4Parser.prototype.box=function(a,b){a=shaka.util.Mp4Parser.typeFromString_(a);this.headers_.set(a,shaka.util.Mp4Parser.BoxType_.BASIC_BOX);this.boxDefinitions_.set(a,b);return this};shaka.util.Mp4Parser.prototype.boxes=function(a,b){a=(0,$jscomp.makeIterator)(a);for(var c=a.next();!c.done;c=a.next())this.box(c.value,b);return this};
shaka.util.Mp4Parser.prototype.fullBox=function(a,b){a=shaka.util.Mp4Parser.typeFromString_(a);this.headers_.set(a,shaka.util.Mp4Parser.BoxType_.FULL_BOX);this.boxDefinitions_.set(a,b);return this};shaka.util.Mp4Parser.prototype.stop=function(){this.done_=!0};shaka.util.Mp4Parser.prototype.parse=function(a,b,c){a=new shaka.util.DataViewReader(a,shaka.util.DataViewReader.Endianness.BIG_ENDIAN);for(this.done_=!1;a.hasMoreData()&&!this.done_;)this.parseNext(0,a,b,c)};
shaka.util.Mp4Parser.prototype.parseNext=function(a,b,c,d){var e=b.getPosition();if(d&&e+8>b.getLength())this.done_=!0;else{var f=b.readUint32(),g=b.readUint32(),h=shaka.util.Mp4Parser.typeToString(g),k=!1;shaka.log.v2("Parsing MP4 box",h);switch(f){case 0:f=b.getLength()-e;break;case 1:if(d&&b.getPosition()+8>b.getLength()){this.done_=!0;return}f=b.readUint64();k=!0}var l=this.boxDefinitions_.get(g);if(l){var m=null,n=null;if(this.headers_.get(g)==shaka.util.Mp4Parser.BoxType_.FULL_BOX){if(d&&b.getPosition()+
4>b.getLength()){this.done_=!0;return}n=b.readUint32();m=n>>>24;n&=16777215}g=e+f;c&&g>b.getLength()&&(g=b.getLength());d&&g>b.getLength()?this.done_=!0:(g-=b.getPosition(),b=g>0?b.readBytes(g,!1):new Uint8Array(0),b=new shaka.util.DataViewReader(b,shaka.util.DataViewReader.Endianness.BIG_ENDIAN),l({name:h,parser:this,partialOkay:c||!1,stopOnPartial:d||!1,version:m,flags:n,reader:b,size:f,start:e+a,has64BitSize:k}))}else a=Math.min(e+f-b.getPosition(),b.getLength()-b.getPosition()),b.skip(a)}};
shaka.util.Mp4Parser.children=function(a){for(var b=shaka.util.Mp4Parser.headerSize(a);a.reader.hasMoreData()&&!a.parser.done_;)a.parser.parseNext(a.start+b,a.reader,a.partialOkay,a.stopOnPartial)};shaka.util.Mp4Parser.sampleDescription=function(a){for(var b=shaka.util.Mp4Parser.headerSize(a),c=a.reader.readUint32(),d=0;d<c&&(a.parser.parseNext(a.start+b,a.reader,a.partialOkay,a.stopOnPartial),!a.parser.done_);d++);};
shaka.util.Mp4Parser.visualSampleEntry=function(a){var b=shaka.util.Mp4Parser.headerSize(a);for(a.reader.skip(78);a.reader.hasMoreData()&&!a.parser.done_;)a.parser.parseNext(a.start+b,a.reader,a.partialOkay,a.stopOnPartial)};
shaka.util.Mp4Parser.audioSampleEntry=function(a){var b=shaka.util.Mp4Parser.headerSize(a);a.reader.skip(8);var c=a.reader.readUint16();a.reader.skip(6);c==2?a.reader.skip(48):a.reader.skip(12);for(c==1&&a.reader.skip(16);a.reader.hasMoreData()&&!a.parser.done_;)a.parser.parseNext(a.start+b,a.reader,a.partialOkay,a.stopOnPartial)};shaka.util.Mp4Parser.allData=function(a,b){return function(c){var d=c.reader.getLength()-c.reader.getPosition();a(c.reader.readBytes(d,b))}};
shaka.util.Mp4Parser.typeFromString_=function(a){goog.asserts.assert(a.length==4,"Mp4 box names must be 4 characters long");var b=0;a=(0,$jscomp.makeIterator)(a);for(var c=a.next();!c.done;c=a.next())b=b<<8|c.value.charCodeAt(0);return b};shaka.util.Mp4Parser.typeToString=function(a){return String.fromCharCode(a>>24&255,a>>16&255,a>>8&255,a&255)};shaka.util.Mp4Parser.headerSize=function(a){return 8+(a.has64BitSize?8:0)+(a.flags!=null?4:0)};goog.exportSymbol("shaka.util.Mp4Parser",shaka.util.Mp4Parser);
goog.exportProperty(shaka.util.Mp4Parser,"headerSize",shaka.util.Mp4Parser.headerSize);goog.exportProperty(shaka.util.Mp4Parser,"typeToString",shaka.util.Mp4Parser.typeToString);goog.exportProperty(shaka.util.Mp4Parser,"allData",shaka.util.Mp4Parser.allData);goog.exportProperty(shaka.util.Mp4Parser,"audioSampleEntry",shaka.util.Mp4Parser.audioSampleEntry);goog.exportProperty(shaka.util.Mp4Parser,"visualSampleEntry",shaka.util.Mp4Parser.visualSampleEntry);
goog.exportProperty(shaka.util.Mp4Parser,"sampleDescription",shaka.util.Mp4Parser.sampleDescription);goog.exportProperty(shaka.util.Mp4Parser,"children",shaka.util.Mp4Parser.children);goog.exportProperty(shaka.util.Mp4Parser.prototype,"parseNext",shaka.util.Mp4Parser.prototype.parseNext);goog.exportProperty(shaka.util.Mp4Parser.prototype,"parse",shaka.util.Mp4Parser.prototype.parse);goog.exportProperty(shaka.util.Mp4Parser.prototype,"stop",shaka.util.Mp4Parser.prototype.stop);
goog.exportProperty(shaka.util.Mp4Parser.prototype,"fullBox",shaka.util.Mp4Parser.prototype.fullBox);goog.exportProperty(shaka.util.Mp4Parser.prototype,"boxes",shaka.util.Mp4Parser.prototype.boxes);goog.exportProperty(shaka.util.Mp4Parser.prototype,"box",shaka.util.Mp4Parser.prototype.box);shaka.util.Mp4Parser.BoxType_={BASIC_BOX:0,FULL_BOX:1};shaka.util.Mp4BoxParsers=function(){};shaka.util.Mp4BoxParsers.parseTFHD=function(a,b){var c=null,d=null,e=null,f=null,g=a.readUint32();b&1&&(e=a.readUint64());b&2&&(f=a.readUint32());b&8&&(c=a.readUint32());b&16&&(d=a.readUint32());return{trackId:g,defaultSampleDuration:c,defaultSampleSize:d,baseDataOffset:e,sampleDescriptionIndex:f}};shaka.util.Mp4BoxParsers.parseTFDT=function(a,b){return{baseMediaDecodeTime:b==1?a.readUint64():a.readUint32()}};
shaka.util.Mp4BoxParsers.parseTFDTInaccurate=function(a,b){return b==1?(b=a.readUint32(),a=a.readUint32(),{baseMediaDecodeTime:b*4294967296+a}):{baseMediaDecodeTime:a.readUint32()}};shaka.util.Mp4BoxParsers.parsePRFTInaccurate=function(a,b){a.readUint32();var c=a.readUint32(),d=a.readUint32();c=c*1E3+d/4294967296*1E3;b===0?a=a.readUint32():(b=a.readUint32(),a=a.readUint32(),a=b*4294967296+a);return{mediaTime:a,ntpTimestamp:c}};
shaka.util.Mp4BoxParsers.parseMDHD=function(a,b){b==1?(a.skip(8),a.skip(8)):(a.skip(4),a.skip(4));b=a.readUint32();a.skip(4);a=a.readUint16();a=String.fromCharCode((a>>10)+96)+String.fromCharCode(((a&960)>>5)+96)+String.fromCharCode((a&31)+96);return{timescale:b,language:a}};shaka.util.Mp4BoxParsers.parseTREX=function(a){a.skip(4);a.skip(4);var b=a.readUint32();a=a.readUint32();return{defaultSampleDuration:b,defaultSampleSize:a}};
shaka.util.Mp4BoxParsers.parseTRUN=function(a,b,c){var d=a.readUint32(),e=[],f=null;c&1&&(f=a.readInt32());c&4&&a.skip(4);for(var g=0;g<d;g++){var h={sampleDuration:null,sampleSize:null,sampleCompositionTimeOffset:null};c&256&&(h.sampleDuration=a.readUint32());c&512&&(h.sampleSize=a.readUint32());c&1024&&a.skip(4);c&2048&&(h.sampleCompositionTimeOffset=b==0?a.readUint32():a.readInt32());e.push(h)}return{sampleCount:d,sampleData:e,dataOffset:f}};
shaka.util.Mp4BoxParsers.parseTKHD=function(a,b){b==1?(a.skip(8),a.skip(8)):(a.skip(4),a.skip(4));var c=a.readUint32();b==1?a.skip(8):a.skip(4);a.skip(4);a.skip(8);a.skip(2);a.skip(2);a.skip(2);a.skip(2);a.skip(36);b=a.readUint16()+a.readUint16()/16;a=a.readUint16()+a.readUint16()/16;return{trackId:c,width:b,height:a}};shaka.util.Mp4BoxParsers.visualSampleEntry=function(a){a.skip(24);var b=a.readUint16(),c=a.readUint16();a.skip(50);return{width:b,height:c}};
shaka.util.Mp4BoxParsers.audioSampleEntry=function(a){a.skip(6);a.skip(2);a.skip(8);var b=a.readUint16();a.skip(2);a.skip(2);a.skip(2);a=a.readUint16()+a.readUint16()/65536;return{channelCount:b,sampleRate:a}};
shaka.util.Mp4BoxParsers.parseESDS=function(a){for(var b="mp4a",c,d;a.hasMoreData();){c=a.readUint8();for(var e=a.readUint8();e&128;)e=a.readUint8();if(c==3)a.readUint16(),e=a.readUint8(),e&128&&a.readUint16(),e&64&&a.skip(a.readUint8()),e&32&&a.readUint16();else if(c==4)d=a.readUint8(),a.skip(12);else if(c==5)break}d&&(b+="."+shaka.util.Mp4BoxParsers.toHex_(d),c==5&&a.hasMoreData()&&(c=a.readUint8(),d=(c&248)>>3,d===31&&a.hasMoreData()&&(d=32+((c&7)<<3)+((a.readUint8()&224)>>5)),b+="."+d));return{codec:b}};
shaka.util.Mp4BoxParsers.parseAVCC=function(a,b){var c=shaka.util.Mp4BoxParsers;b.skip(1);return{codec:a+"."+c.toHex_(b.readUint8())+c.toHex_(b.readUint8())+c.toHex_(b.readUint8())}};
shaka.util.Mp4BoxParsers.parseHVCC=function(a,b){var c=shaka.util.Mp4BoxParsers;b.skip(1);var d=b.readUint8(),e=["","A","B","C"][d>>6],f=d&31,g=b.readUint32(),h=(d&32)>>5?"H":"L";d=[b.readUint8(),b.readUint8(),b.readUint8(),b.readUint8(),b.readUint8(),b.readUint8()];b=b.readUint8();a=a+("."+e+f)+("."+c.toHex_(c.reverseBits_(g),!0));a+="."+h+b;c="";for(e=d.length;e--;)if((f=d[e])||c)c="."+f.toString(16).toUpperCase()+c;a+=c;return{codec:a}};
shaka.util.Mp4BoxParsers.parseDVCC=function(a,b){var c=shaka.util.Mp4BoxParsers;b.skip(2);var d=b.readUint8();b=b.readUint8();b=d<<5&32|b>>3&31;return{codec:a+"."+c.addLeadingZero_(d>>1&127)+"."+c.addLeadingZero_(b)}};shaka.util.Mp4BoxParsers.parseDVVC=function(a,b){var c=shaka.util.Mp4BoxParsers;b.skip(2);var d=b.readUint8();b=b.readUint8();b=d<<5&32|b>>3&31;return{codec:a+"."+c.addLeadingZero_(d>>1&127)+"."+c.addLeadingZero_(b)}};
shaka.util.Mp4BoxParsers.parseVPCC=function(a,b){var c=shaka.util.Mp4BoxParsers,d=b.readUint8(),e=b.readUint8();b=b.readUint8()>>4&15;return{codec:a+"."+c.addLeadingZero_(d)+"."+c.addLeadingZero_(e)+"."+c.addLeadingZero_(b)}};
shaka.util.Mp4BoxParsers.parseAV1C=function(a,b){var c=shaka.util.Mp4BoxParsers;b.skip(1);var d=b.readUint8(),e=b.readUint8();b=d>>>5;var f=e>>>7?"H":"M",g=(e&64)>>6;g=b===2&&g?(e&32)>>5?12:10:g?10:8;var h=(e&16)>>4,k=(e&8)>>3,l=(e&4)>>2;e&=3;return{codec:a+"."+b+"."+c.addLeadingZero_(d&31)+f+"."+c.addLeadingZero_(g)+"."+h+"."+k+l+e+"."+c.addLeadingZero_(1)+"."+c.addLeadingZero_(1)+"."+c.addLeadingZero_(1)+".0"}};shaka.util.Mp4BoxParsers.parseFRMA=function(a){a=a.readUint32();return{codec:shaka.util.Mp4Parser.typeToString(a)}};
shaka.util.Mp4BoxParsers.parseTENC=function(a){var b=shaka.util.Uint8ArrayUtils;a.readUint8();a.readUint8();a.readUint8();a.readUint8();a=a.readBytes(16,!1);return{defaultKID:b.toHex(a)}};shaka.util.Mp4BoxParsers.parseHDLR=function(a){a.skip(4);a=a.readBytes(4,!1);return{handlerType:String.fromCharCode(a[0],a[1],a[2],a[3])}};shaka.util.Mp4BoxParsers.parsePRJI=function(a){return{projection:a.readTerminatedString()}};shaka.util.Mp4BoxParsers.parseHFOV=function(a){return{hfov:a.readUint32()/1E3}};
shaka.util.Mp4BoxParsers.parseCOLR=function(a){var b=null,c=null,d=a.readBytes(4,!1);var e=""+String.fromCharCode(d[0]);e+=String.fromCharCode(d[1]);e+=String.fromCharCode(d[2]);e+=String.fromCharCode(d[3]);if(e==="nclx"){switch(a.readUint16()){case 1:case 5:case 6:case 7:b="srgb";break;case 9:b="rec2020";break;case 11:case 12:b="p3"}d=a.readUint16();a.readUint16();switch(d){case 1:case 6:case 13:case 14:case 15:c="SDR";break;case 16:c="PQ";break;case 18:c="HLG"}}return{colorGamut:b,videoRange:c}};
shaka.util.Mp4BoxParsers.updateAV1CodecWithCOLRBox=function(a,b){var c=shaka.util.Mp4BoxParsers,d=b.getPosition(),e=b.readBytes(4,!1);var f=""+String.fromCharCode(e[0]);f+=String.fromCharCode(e[1]);f+=String.fromCharCode(e[2]);f+=String.fromCharCode(e[3]);if(f==="nclx"){e=b.readUint16();f=b.readUint16();var g=b.readUint16(),h=b.readUint8()>>7,k=a.split(".");k.length==10&&(k[6]=c.addLeadingZero_(e),k[7]=c.addLeadingZero_(f),k[8]=c.addLeadingZero_(g),k[9]=String(h),a=k.join("."))}b.seek(d);return a};
shaka.util.Mp4BoxParsers.toHex_=function(a,b){b=b===void 0?!1:b;a=a.toString(16).toUpperCase();return b?a:("0"+a).slice(-2)};shaka.util.Mp4BoxParsers.reverseBits_=function(a){for(var b=0,c=0;c<32;c++){b|=a&1;if(c==31)break;b<<=1;a>>=1}return b};shaka.util.Mp4BoxParsers.addLeadingZero_=function(a){return(a<10?"0":"")+a};shaka.cea.Mp4CeaParser=function(){this.seiProcessor_=new shaka.cea.SeiProcessor;this.trackIdToTimescale_=new Map;this.defaultSampleSize_=this.defaultSampleDuration_=0;this.bitstreamFormat_=shaka.cea.Mp4CeaParser.BitstreamFormat.UNKNOWN};
shaka.cea.Mp4CeaParser.prototype.init=function(a){var b=this,c=shaka.util.Mp4Parser,d=shaka.cea.Mp4CeaParser.BitstreamFormat,e=[],f=[];(new c).boxes("moov trak mdia minf stbl mvex".split(" "),c.children).fullBox("trex",function(g){g=shaka.util.Mp4BoxParsers.parseTREX(g.reader);b.defaultSampleDuration_=g.defaultSampleDuration;b.defaultSampleSize_=g.defaultSampleSize}).fullBox("tkhd",function(g){goog.asserts.assert(g.version!=null,"TKHD is a full box and should have a valid version.");g=shaka.util.Mp4BoxParsers.parseTKHD(g.reader,
g.version);e.push(g.trackId)}).fullBox("mdhd",function(g){goog.asserts.assert(g.version!=null,"MDHD is a full box and should have a valid version.");g=shaka.util.Mp4BoxParsers.parseMDHD(g.reader,g.version);f.push(g.timescale)}).fullBox("stsd",c.sampleDescription).boxes("avc1 avc3 dvav dva1 hev1 hvc1 dvh1 dvhe vvc1 vvi1 dvc1 dvi1".split(" "),function(g){return b.setBitstreamFormat_(g.name)}).box("encv",c.visualSampleEntry).box("sinf",c.children).box("frma",function(g){g=shaka.util.Mp4BoxParsers.parseFRMA(g.reader).codec;
b.setBitstreamFormat_(g)}).parse(a,!0,!0);if(!e.length||!f.length||e.length!=f.length)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.INVALID_MP4_CEA);this.bitstreamFormat_==d.UNKNOWN&&shaka.log.alwaysWarn("Unable to determine bitstream format for CEA parsing!");e.forEach(function(g,h){b.trackIdToTimescale_.set(g,f[h])})};
shaka.cea.Mp4CeaParser.prototype.parse=function(a){var b=this,c=shaka.util.Mp4Parser;if(this.bitstreamFormat_==shaka.cea.Mp4CeaParser.BitstreamFormat.UNKNOWN)return[];var d=[],e=0,f=[];(new c).box("moof",function(g){e=g.start;f=[];c.children(g)}).box("traf",function(g){f.push({baseMediaDecodeTime:null,defaultSampleDuration:b.defaultSampleDuration_,defaultSampleSize:b.defaultSampleSize_,parsedTRUNs:[],timescale:shaka.cea.CeaUtils.DEFAULT_TIMESCALE_VALUE});c.children(g)}).fullBox("trun",function(g){goog.asserts.assert(g.version!=
null&&g.flags!=null,"TRUN is a full box and should have a valid version & flags.");var h=f[f.length-1];g=shaka.util.Mp4BoxParsers.parseTRUN(g.reader,g.version,g.flags);h.parsedTRUNs.push(g)}).fullBox("tfhd",function(g){goog.asserts.assert(g.flags!=null,"TFHD is a full box and should have valid flags.");var h=f[f.length-1];g=shaka.util.Mp4BoxParsers.parseTFHD(g.reader,g.flags);h.defaultSampleDuration=g.defaultSampleDuration||b.defaultSampleDuration_;h.defaultSampleSize=g.defaultSampleSize||b.defaultSampleSize_;
g=g.trackId;b.trackIdToTimescale_.has(g)&&(h.timescale=b.trackIdToTimescale_.get(g))}).fullBox("tfdt",function(g){goog.asserts.assert(g.version!=null,"TFDT is a full box and should have a valid version.");var h=f[f.length-1];g=shaka.util.Mp4BoxParsers.parseTFDTInaccurate(g.reader,g.version);h.baseMediaDecodeTime=g.baseMediaDecodeTime}).box("mdat",function(g){for(var h=e-g.start-8,k=g.reader.getPosition(),l=(0,$jscomp.makeIterator)(f),m=l.next();!m.done;m=l.next())m=m.value,m.baseMediaDecodeTime===
null?shaka.log.alwaysWarn("Unable to find base media decode time for CEA captions!"):(g.reader.seek(k),b.parseMdat_(g.reader,m.baseMediaDecodeTime,m.timescale,m.defaultSampleDuration,m.defaultSampleSize,h,m.parsedTRUNs,d))}).parse(a,!1,!0);return d};
shaka.cea.Mp4CeaParser.prototype.parseMdat_=function(a,b,c,d,e,f,g,h){var k=shaka.cea.Mp4CeaParser.BitstreamFormat,l=shaka.cea.CeaUtils,m=0,n=e,p=g.map(function(t){return t.sampleData});p=[].concat.apply([],(0,$jscomp.arrayFromIterable)(p));p.length&&(n=p[0].sampleSize||e);for(a.skip(f+g[0].dataOffset);a.hasMoreData();){f=a.readUint32();var q=a.readUint8(),r=null;r=!1;g=1;goog.asserts.assert(this.bitstreamFormat_!=k.UNKNOWN,"Bitstream format should have been checked before now!");switch(this.bitstreamFormat_){case k.H264:r=
q&31;r=r==l.H264_NALU_TYPE_SEI;break;case k.H265:g=2;a.skip(1);r=q>>1&63;r=r==l.H265_PREFIX_NALU_TYPE_SEI||r==l.H265_SUFFIX_NALU_TYPE_SEI;break;case k.H266:g=2;a.skip(1);r=q>>1&63;r=r==l.H266_PREFIX_NALU_TYPE_SEI||r==l.H266_SUFFIX_NALU_TYPE_SEI;break;default:return}if(r)for(q=0,m<p.length&&(q=p[m].sampleCompositionTimeOffset||0),q=(b+q)/c,g=a.readBytes(f-g,!1),g=(0,$jscomp.makeIterator)(this.seiProcessor_.process(g)),r=g.next();!r.done;r=g.next())h.push({packet:r.value,pts:q});else try{a.skip(f-g)}catch(t){break}n-=
f+4;n==0&&(b=m<p.length?b+(p[m].sampleDuration||d):b+d,m++,n=m<p.length?p[m].sampleSize||e:e)}};shaka.cea.Mp4CeaParser.prototype.setBitstreamFormat_=function(a){shaka.cea.Mp4CeaParser.CodecBitstreamMap_.has(a)&&(this.bitstreamFormat_=shaka.cea.Mp4CeaParser.CodecBitstreamMap_.get(a))};goog.exportSymbol("shaka.cea.Mp4CeaParser",shaka.cea.Mp4CeaParser);shaka.cea.Mp4CeaParser.BitstreamFormat={UNKNOWN:0,H264:1,H265:2,H266:3};
shaka.cea.Mp4CeaParser.CodecBitstreamMap_=(new Map).set("avc1",shaka.cea.Mp4CeaParser.BitstreamFormat.H264).set("avc3",shaka.cea.Mp4CeaParser.BitstreamFormat.H264).set("dvav",shaka.cea.Mp4CeaParser.BitstreamFormat.H264).set("dva1",shaka.cea.Mp4CeaParser.BitstreamFormat.H264).set("hev1",shaka.cea.Mp4CeaParser.BitstreamFormat.H265).set("hvc1",shaka.cea.Mp4CeaParser.BitstreamFormat.H265).set("dvh1",shaka.cea.Mp4CeaParser.BitstreamFormat.H265).set("dvhe",shaka.cea.Mp4CeaParser.BitstreamFormat.H265).set("vvc1",
shaka.cea.Mp4CeaParser.BitstreamFormat.H266).set("vvi1",shaka.cea.Mp4CeaParser.BitstreamFormat.H266).set("dvc1",shaka.cea.Mp4CeaParser.BitstreamFormat.H266).set("dvi1",shaka.cea.Mp4CeaParser.BitstreamFormat.H266);shaka.media.ClosedCaptionParser.registerParser("video/mp4",function(){return new shaka.cea.Mp4CeaParser});/*

 Copyright Brightcove, Inc.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
*/
shaka.util.ExpGolomb=function(a,b){this.data_=a;if(b===void 0?0:b)this.data_=this.ebsp2rbsp_(a);this.workingBytesAvailable_=this.data_.byteLength;this.workingBitsAvailable_=this.workingWord_=0};shaka.util.ExpGolomb.prototype.ebsp2rbsp_=function(a){for(var b=new Uint8Array(a.byteLength),c=0,d=0;d<a.byteLength;d++)d>=2&&a[d]==3&&a[d-1]==0&&a[d-2]==0||(b[c]=a[d],c++);return shaka.util.BufferUtils.toUint8(b,0,c)};
shaka.util.ExpGolomb.prototype.loadWord_=function(){var a=this.data_.byteLength-this.workingBytesAvailable_,b=Math.min(4,this.workingBytesAvailable_);if(b!==0){for(var c=0,d=0;d<b;d++)c=c<<8|this.data_[a+d];this.workingWord_=c<<(4-b)*8;this.workingBitsAvailable_=b*8;this.workingBytesAvailable_-=b}};
shaka.util.ExpGolomb.prototype.skipBits=function(a){if(this.workingBitsAvailable_<=a){a-=this.workingBitsAvailable_;var b=Math.floor(a/8);a-=b*8;this.workingBitsAvailable_-=b;this.loadWord_()}this.workingWord_<<=a;this.workingBitsAvailable_-=a};
shaka.util.ExpGolomb.prototype.readBits=function(a){var b=Math.min(this.workingBitsAvailable_,a),c=this.workingWord_>>>32-b;this.workingBitsAvailable_-=b;this.workingBitsAvailable_>0?this.workingWord_<<=b:this.workingBytesAvailable_>0&&this.loadWord_();b=a-b;return b>0?c<<b|this.readBits(b):c};
shaka.util.ExpGolomb.prototype.skipLeadingZeros_=function(){for(var a=0;this.workingBitsAvailable_===0;){if(this.workingBytesAvailable_===0)return a;this.loadWord_()}for(;;){var b=Math.clz32(this.workingWord_);b>this.workingBitsAvailable_&&(b=this.workingBitsAvailable_);a+=b;this.workingWord_<<=b;this.workingBitsAvailable_-=b;if(this.workingBitsAvailable_>0||this.workingBytesAvailable_===0)break;this.loadWord_()}return a};shaka.util.ExpGolomb.prototype.skipExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros_())};
shaka.util.ExpGolomb.prototype.readUnsignedExpGolomb=function(){var a=this.skipLeadingZeros_();return this.readBits(a+1)-1};shaka.util.ExpGolomb.prototype.readExpGolomb=function(){var a=this.readUnsignedExpGolomb();return 1&a?1+a>>>1:-1*(a>>>1)};shaka.util.ExpGolomb.prototype.readBoolean=function(){return this.readBits(1)===1};shaka.util.ExpGolomb.prototype.readUnsignedByte=function(){return this.readBits(8)};
shaka.util.ExpGolomb.prototype.skipScalingList=function(a){for(var b=8,c=8,d=0;d<a;d++)c!==0&&(c=this.readExpGolomb(),c=(b+c+256)%256),b=c===0?b:c};shaka.util.ExpGolomb.prototype.readSliceType=function(){this.readUnsignedByte();this.readUnsignedExpGolomb();return this.readUnsignedExpGolomb()};goog.exportSymbol("shaka.util.ExpGolomb",shaka.util.ExpGolomb);shaka.util.Id3Utils=function(){};shaka.util.Id3Utils.isHeader_=function(a,b){return b+10<=a.length&&a[b]===73&&a[b+1]===68&&a[b+2]===51&&a[b+3]<255&&a[b+4]<255&&a[b+6]<128&&a[b+7]<128&&a[b+8]<128&&a[b+9]<128?!0:!1};shaka.util.Id3Utils.isFooter_=function(a,b){return b+10<=a.length&&a[b]===51&&a[b+1]===68&&a[b+2]===73&&a[b+3]<255&&a[b+4]<255&&a[b+6]<128&&a[b+7]<128&&a[b+8]<128&&a[b+9]<128?!0:!1};
shaka.util.Id3Utils.readSize_=function(a,b){var c=(a[b]&127)<<21;c|=(a[b+1]&127)<<14;c|=(a[b+2]&127)<<7;return c|=a[b+3]&127};shaka.util.Id3Utils.getFrameData_=function(a){var b=String.fromCharCode(a[0],a[1],a[2],a[3]),c=shaka.util.Id3Utils.readSize_(a,4);return{type:b,size:c,data:a.subarray(10,10+c)}};
shaka.util.Id3Utils.decodeFrame_=function(a){var b=shaka.util.BufferUtils,c=shaka.util.StringUtils,d={key:a.type,description:"",data:"",mimeType:null,pictureType:null};if(a.type==="APIC"){if(a.size<2)return null;if(a.data[0]!==shaka.util.Id3Utils.UTF8_encoding)return shaka.log.warning("Ignore frame with unrecognized character encoding"),null;var e=a.data.subarray(1).indexOf(0);if(e===-1)return null;var f=c.fromUTF8(b.toUint8(a.data,1,e)),g=a.data[2+e],h=a.data.subarray(3+e).indexOf(0);if(h===-1)return null;
var k=c.fromUTF8(b.toUint8(a.data,3+e,h));a=f==="--\x3e"?c.fromUTF8(b.toUint8(a.data,4+e+h)):b.toArrayBuffer(a.data.subarray(4+e+h));d.mimeType=f;d.pictureType=g;d.description=k;d.data=a;return d}if(a.type==="TXXX"){if(a.size<2)return null;if(a.data[0]!==shaka.util.Id3Utils.UTF8_encoding)return shaka.log.warning("Ignore frame with unrecognized character encoding"),null;g=a.data.subarray(1).indexOf(0);if(g===-1)return null;f=c.fromUTF8(b.toUint8(a.data,1,g));a=c.fromUTF8(b.toUint8(a.data,2+g)).replace(/\0*$/,
"");d.description=f;d.data=a;return d}if(a.type==="WXXX"){if(a.size<2)return null;if(a.data[0]!==shaka.util.Id3Utils.UTF8_encoding)return shaka.log.warning("Ignore frame with unrecognized character encoding"),null;g=a.data.subarray(1).indexOf(0);if(g===-1)return null;f=c.fromUTF8(b.toUint8(a.data,1,g));a=c.fromUTF8(b.toUint8(a.data,2+g)).replace(/\0*$/,"");d.description=f;d.data=a;return d}if(a.type==="PRIV"){if(a.size<2)return null;f=a.data.indexOf(0);if(f===-1)return null;c=c.fromUTF8(b.toUint8(a.data,
0,f));d.description=c;c=="com.apple.streaming.transportStreamTimestamp"?(b=a.data.subarray(c.length+1),a=b[3]&1,b=(b[4]<<23)+(b[5]<<15)+(b[6]<<7)+b[7],b/=45,a&&(b+=4.772185884E7),d.data=b):(a=b.toArrayBuffer(a.data.subarray(c.length+1)),d.data=a);return d}if(a.type[0]==="T"){if(a.size<2)return null;if(a.data[0]!==shaka.util.Id3Utils.UTF8_encoding)return shaka.log.warning("Ignore frame with unrecognized character encoding"),null;a=c.fromUTF8(a.data.subarray(1)).replace(/\0*$/,"");d.data=a;return d}return a.type[0]===
"W"?(a=c.fromUTF8(a.data).replace(/\0*$/,""),d.data=a,d):a.data?(shaka.log.warning("Unrecognized ID3 frame type:",a.type),d.data=b.toArrayBuffer(a.data),d):null};shaka.util.Id3Utils.getID3Frames=function(a){for(var b=shaka.util.Id3Utils,c=0,d=[];b.isHeader_(a,c);){var e=b.readSize_(a,c+6);a[c+5]>>6&1&&(c+=10);c+=10;for(e=c+e;c+10<e;){var f=b.getFrameData_(a.subarray(c)),g=b.decodeFrame_(f);g&&d.push(g);c+=f.size+10}b.isFooter_(a,c)&&(c+=10)}return d};
shaka.util.Id3Utils.getID3Data=function(a,b){b=b===void 0?0:b;for(var c=shaka.util.Id3Utils,d=b,e=0;c.isHeader_(a,b);){a[b+5]>>6&1&&(e+=10);e+=10;var f=c.readSize_(a,b+6);e+=f;c.isFooter_(a,b+10)&&(e+=10);b+=e}return e>0?a.subarray(d,d+e):new Uint8Array([])};goog.exportSymbol("shaka.util.Id3Utils",shaka.util.Id3Utils);goog.exportProperty(shaka.util.Id3Utils,"getID3Data",shaka.util.Id3Utils.getID3Data);goog.exportProperty(shaka.util.Id3Utils,"getID3Frames",shaka.util.Id3Utils.getID3Frames);
shaka.util.Id3Utils.UTF8_encoding=3;shaka.util.TsParser=function(){this.pmtId_=null;this.pmtParsed_=!1;this.videoCodec_=this.videoPid_=null;this.videoData_=[];this.videoDataPesIndices_=[];this.videoPes_=[];this.audioCodec_=this.audioPid_=null;this.audioData_=[];this.audioDataPesIndices_=[];this.audioPes_=[];this.id3Pid_=null;this.id3Data_=[];this.id3DataPesIndices_=[];this.discontinuitySequence_=this.opusMetadata_=this.referenceDts_=this.referencePts_=null};
shaka.util.TsParser.prototype.clearData=function(){this.videoData_=[];this.videoDataPesIndices_=[];this.videoPes_=[];this.audioData_=[];this.audioDataPesIndices_=[];this.audioPes_=[];this.id3Data_=[];this.id3DataPesIndices_=[]};shaka.util.TsParser.prototype.setDiscontinuitySequence=function(a){this.discontinuitySequence_!=null&&this.discontinuitySequence_!=a&&(this.referenceDts_=this.referencePts_=null);this.discontinuitySequence_=a};
shaka.util.TsParser.prototype.parse=function(a){var b=shaka.util.TsParser.PacketLength_;if(a.length<3*b)return this;for(var c=Math.max(0,shaka.util.TsParser.syncOffset(a)),d=a.length-(a.length+c)%b,e=!1,f=c;f<d;f+=b)if(a[f]==71){var g=!!(a[f+1]&64),h=((a[f+1]&31)<<8)+a[f+2];if((a[f+3]&48)>>4>1){var k=f+5+a[f+4];if(k==f+b)continue}else k=f+4;switch(h){case 0:g&&(k+=a[k]+1);this.pmtId_=this.getPmtId_(a,k);break;case 17:case 8191:break;case this.pmtId_:g&&(k+=a[k]+1);g=this.parsePMT_(a,k);g.video!=-1&&
(this.videoPid_=g.video,this.videoCodec_=g.videoCodec);g.audio!=-1&&(this.audioPid_=g.audio,this.audioCodec_=g.audioCodec);g.id3!=-1&&(this.id3Pid_=g.id3);e&&!this.pmtParsed_&&(shaka.log.debug("reparse from beginning"),e=!1,f=c-b);this.pmtParsed_=!0;break;case this.videoPid_:h=a.subarray(k,f+b);g?(this.videoDataPesIndices_.push(this.videoData_.length),this.videoData_.push(h)):this.videoDataPesIndices_.length&&this.videoData_.push(h);break;case this.audioPid_:h=a.subarray(k,f+b);g?(this.audioDataPesIndices_.push(this.audioData_.length),
this.audioData_.push(h)):this.audioDataPesIndices_.length&&this.audioData_.push(h);break;case this.id3Pid_:h=a.subarray(k,f+b);g?(this.id3DataPesIndices_.push(this.id3Data_.length),this.id3Data_.push(h)):this.id3DataPesIndices_.length&&this.id3Data_.push(h);break;default:e=!0}}else shaka.log.warning("Found TS packet that do not start with 0x47");return this};shaka.util.TsParser.prototype.getPmtId_=function(a,b){return(a[b+10]&31)<<8|a[b+11]};
shaka.util.TsParser.prototype.parsePMT_=function(a,b){var c={audio:-1,video:-1,id3:-1,audioCodec:"",videoCodec:""},d=b+3+((a[b+1]&15)<<8|a[b+2])-4;for(b+=12+((a[b+10]&15)<<8|a[b+11]);b<d;){var e=(a[b+1]&31)<<8|a[b+2],f=(a[b+3]&15)<<8|a[b+4];switch(a[b]){case 6:if(f>0)for(var g=b+5,h=f;h>2;){var k=a[g+1]+2;switch(a[g]){case 5:var l=g+2;l=a[l]<<24|a[l+1]<<16|a[l+2]<<8|a[l+3];c.audio==-1&&l===1332770163?(c.audio=e,c.audioCodec="opus"):c.video==-1&&l===1096167473&&(c.video=e,c.videoCodec="av1");break;
case 106:c.audio==-1&&(c.audio=e,c.audioCodec="ac3");break;case 122:c.audio==-1&&(c.audio=e,c.audioCodec="ec3");break;case 124:c.audio==-1&&(c.audio=e,c.audioCodec="aac");break;case 127:c.audioCodec=="opus"&&(l=null,a[g+2]===128&&(l=a[g+3]),l!=null&&(this.opusMetadata_={channelCount:(l&15)===0?2:l&15,channelConfigCode:l,sampleRate:48E3}))}g+=k;h-=k}break;case 15:c.audio==-1&&(c.audio=e,c.audioCodec="aac");break;case 17:c.audio==-1&&(c.audio=e,c.audioCodec="aac-loas");break;case 21:c.id3==-1&&(c.id3=
e);break;case 27:c.video==-1&&(c.video=e,c.videoCodec="avc");break;case 3:case 4:c.audio==-1&&(c.audio=e,c.audioCodec="mp3");break;case 36:c.video==-1&&(c.video=e,c.videoCodec="hvc");break;case 129:c.audio==-1&&(c.audio=e,c.audioCodec="ac3");break;case 132:case 135:c.audio==-1&&(c.audio=e,c.audioCodec="ec3")}b+=f+5}return c};shaka.util.TsParser.prototype.concatPesPackets_=function(a,b,c){return shaka.util.Uint8ArrayUtils.concatRange(a,b[c],c+1<b.length?b[c+1]:a.length)};
shaka.util.TsParser.prototype.parsePES_=function(a){if((a[0]<<16|a[1]<<8|a[2])!==1)return null;var b=a[4]<<8|a[5];if(b&&b>a.byteLength-6)return null;var c=null,d=null,e=a[7];if(e&192){var f=(a[9]&14)*536870912+(a[10]&255)*4194304+(a[11]&254)*16384+(a[12]&255)*128+(a[13]&254)/2;this.referencePts_==null&&(this.referencePts_=f);d=this.referencePts_=c=this.handleRollover_(f,this.referencePts_);e&64&&(d=(a[14]&14)*536870912+(a[15]&255)*4194304+(a[16]&254)*16384+(a[17]&255)*128+(a[18]&254)/2,this.referenceDts_==
null&&(this.referenceDts_=d),d=c!=f?this.handleRollover_(d,this.referenceDts_):d);this.referenceDts_=d}f=a[8]+9;return a.byteLength<=f?null:{data:a.subarray(f),packetLength:b,pts:c,dts:d,nalus:[]}};shaka.util.TsParser.prototype.parseAvcNalus=function(a,b){shaka.Deprecate.deprecateFeature(5,"TsParser.parseAvcNalus","Please use parseNalus function instead.");return this.parseNalus(a,{nalu:null,state:null})};
shaka.util.TsParser.prototype.parseNalus=function(a,b){var c=shaka.util.TsParser.Timescale,d=a.pts?a.pts/c:null;a=a.data;var e=a.byteLength,f=1;this.videoCodec_=="hvc"&&(f=2);var g=b.state||0,h=g,k=0;c=[];var l=-1,m=0,n=this.videoCodec_==="hvc";g==-1&&(l=0,m=n?a[0]>>1&63:a[0]&31,g=0,k=1);for(;k<e;){var p=a[k++];if(g)if(g===1)g=p?0:2;else if(p)if(p==1){p=k-g-1;if(l>=0)g={data:a.subarray(l+f,p),fullData:a.subarray(l,p),type:m,time:d,state:null},c.push(g);else if(g=c.length?c[c.length-1]:b.nalu)h&&k<=
4-h&&g.state&&(g.data=g.data.subarray(0,g.data.byteLength-h),g.fullData=g.fullData.subarray(0,g.fullData.byteLength-h)),p>0&&(p=a.subarray(0,p),g.data=shaka.util.Uint8ArrayUtils.concat(g.data,p),g.fullData=shaka.util.Uint8ArrayUtils.concat(g.fullData,p),g.state=0);k<e?(m=n?a[k]>>1&63:a[k]&31,l=k,g=0):g=-1}else g=0;else g=3;else g=p?0:1}l>=0&&g>=0&&(d={data:a.subarray(l+f,e),fullData:a.subarray(l,e),type:m,time:d,state:g},c.push(d));!c.length&&b.nalu&&(d=c.length?c[c.length-1]:b.nalu)&&(d.data=shaka.util.Uint8ArrayUtils.concat(d.data,
a),d.fullData=shaka.util.Uint8ArrayUtils.concat(d.fullData,a));b.state=g;return c};shaka.util.TsParser.prototype.getMetadata=function(){for(var a=shaka.util.TsParser.Timescale,b=[],c=0;c<this.id3DataPesIndices_.length;c++){var d=this.concatPesPackets_(this.id3Data_,this.id3DataPesIndices_,c);(d=this.parsePES_(d))&&b.push({cueTime:d.pts?d.pts/a:null,data:d.data,frames:shaka.util.Id3Utils.getID3Frames(d.data),dts:d.dts,pts:d.pts})}return b};
shaka.util.TsParser.prototype.getAudioData=function(){if(this.audioDataPesIndices_.length&&!this.audioPes_.length)for(var a=0;a<this.audioDataPesIndices_.length;a++){var b=this.concatPesPackets_(this.audioData_,this.audioDataPesIndices_,a),c=this.parsePES_(b),d=this.audioPes_.length?this.audioPes_[this.audioPes_.length-1]:null;c&&c.pts!=null&&c.dts!=null&&(!d||d.pts!=c.pts&&d.dts!=c.dts)?this.audioPes_.push(c):this.audioPes_.length&&(b=c?c.data:b)&&(d=this.audioPes_[this.audioPes_.length-1],d.data=
shaka.util.Uint8ArrayUtils.concat(d.data,b))}return this.audioPes_};
shaka.util.TsParser.prototype.getVideoData=function(a){a=a===void 0?!0:a;if(this.videoDataPesIndices_.length&&!this.videoPes_.length){for(var b=0;b<this.videoDataPesIndices_.length;b++){var c=this.concatPesPackets_(this.videoData_,this.videoDataPesIndices_,b),d=this.parsePES_(c),e=this.videoPes_.length?this.videoPes_[this.videoPes_.length-1]:null;d&&d.pts!=null&&d.dts!=null&&(!e||e.pts!=d.pts&&e.dts!=d.dts)?this.videoPes_.push(d):this.videoPes_.length&&(c=d?d.data:c)&&(e=this.videoPes_[this.videoPes_.length-
1],e.data=shaka.util.Uint8ArrayUtils.concat(e.data,c))}if(a){b={nalu:null,state:null};e=[];c=(0,$jscomp.makeIterator)(this.videoPes_);for(d=c.next();!d.done;d=c.next())d=d.value,d.nalus=this.parseNalus(d,b),d.nalus.length&&(e.push(d),b.nalu=d.nalus[d.nalus.length-1]);this.videoPes_=e}}return a?this.videoPes_:(a=this.videoPes_,this.videoPes_=[],a)};
shaka.util.TsParser.prototype.getStartTime=function(a){var b=shaka.util.TsParser.Timescale;if(a=="audio"){a=null;var c=this.getAudioData();c.length&&(a=c[0],a=Math.min(a.dts,a.pts)/b);return a}return a=="video"?(a=null,c=this.getVideoData(!1),c.length&&(a=c[0],a=Math.min(a.dts,a.pts)/b),a):null};shaka.util.TsParser.prototype.getCodecs=function(){return{audio:this.audioCodec_,video:this.videoCodec_}};
shaka.util.TsParser.prototype.getVideoNalus=function(){for(var a=[],b=(0,$jscomp.makeIterator)(this.getVideoData()),c=b.next();!c.done;c=b.next())a.push.apply(a,(0,$jscomp.arrayFromIterable)(c.value.nalus));return a};shaka.util.TsParser.prototype.getVideoResolution=function(){shaka.Deprecate.deprecateFeature(5,"TsParser.getVideoResolution","Please use getVideoInfo function instead.");var a=this.getVideoInfo();return{height:a.height,width:a.width}};
shaka.util.TsParser.prototype.getVideoInfo=function(){return this.videoCodec_=="hvc"?this.getHvcInfo_():this.getAvcInfo_()};shaka.util.TsParser.prototype.getFrameRate_=function(){var a=shaka.util.TsParser.Timescale,b=this.getVideoData();if(b.length>1){var c=b[0].pts;goog.asserts.assert(typeof c=="number","Should be an number!");b=b[1].pts;goog.asserts.assert(typeof b=="number","Should be an number!");if(!isNaN(b-c))return String(Math.abs(1/(b-c)*a))}return null};
shaka.util.TsParser.prototype.getAvcInfo_=function(){var a=shaka.util.TsParser,b={height:null,width:null,codec:null,frameRate:null},c=this.getVideoNalus();if(!c.length)return b;c=c.find(function(q){return q.type==a.H264_NALU_TYPE_SPS_});if(!c)return b;c=new shaka.util.ExpGolomb(c.data);var d=c.readUnsignedByte(),e=c.readUnsignedByte(),f=c.readUnsignedByte();c.skipExpGolomb();if(a.PROFILES_WITH_OPTIONAL_SPS_DATA_.includes(d)){var g=c.readUnsignedExpGolomb();g===3&&c.skipBits(1);c.skipExpGolomb();c.skipExpGolomb();
c.skipBits(1);if(c.readBoolean()){g=g!==3?8:12;for(var h=0;h<g;h++)c.readBoolean()&&(h<6?c.skipScalingList(16):c.skipScalingList(64))}}c.skipExpGolomb();g=c.readUnsignedExpGolomb();if(g===0)c.readUnsignedExpGolomb();else if(g===1)for(c.skipBits(1),c.skipExpGolomb(),c.skipExpGolomb(),g=c.readUnsignedExpGolomb(),h=0;h<g;h++)c.skipExpGolomb();c.skipExpGolomb();c.skipBits(1);g=c.readUnsignedExpGolomb();h=c.readUnsignedExpGolomb();var k=c.readBits(1);k===0&&c.skipBits(1);c.skipBits(1);var l=0,m=0,n=0,
p=0;c.readBoolean()&&(l=c.readUnsignedExpGolomb(),m=c.readUnsignedExpGolomb(),n=c.readUnsignedExpGolomb(),p=c.readUnsignedExpGolomb());b.height=String((2-k)*(h+1)*16-n*2-p*2);b.width=String((g+1)*16-l*2-m*2);b.codec="avc1."+this.byteToHex_(d)+this.byteToHex_(e)+this.byteToHex_(f);b.frameRate=this.getFrameRate_();return b};
shaka.util.TsParser.prototype.getHvcInfo_=function(){var a=shaka.util.TsParser,b={height:null,width:null,codec:null,frameRate:null},c=this.getVideoNalus();if(!c.length)return b;c=c.find(function(C){return C.type==a.H265_NALU_TYPE_SPS_});if(!c)return b;var d=new shaka.util.ExpGolomb(c.fullData,!0);d.readUnsignedByte();d.readUnsignedByte();d.readBits(4);var e=d.readBits(3);d.readBoolean();var f=d.readBits(2),g=d.readBits(1),h=d.readBits(5),k=d.readBits(32);c=d.readUnsignedByte();for(var l=d.readUnsignedByte(),
m=d.readUnsignedByte(),n=d.readUnsignedByte(),p=d.readUnsignedByte(),q=d.readUnsignedByte(),r=d.readUnsignedByte(),t=[],u=[],v=0;v<e;v++)t.push(d.readBoolean()),u.push(d.readBoolean());if(e>0)for(v=e;v<8;v++)d.readBits(2);for(v=0;v<e;v++)t[v]&&d.readBits(88),u[v]&&d.readUnsignedByte();d.readUnsignedExpGolomb();e=d.readUnsignedExpGolomb();e==3&&d.readBits(1);t=d.readUnsignedExpGolomb();u=d.readUnsignedExpGolomb();var w=v=0,x=0,y=0;d.readBoolean()&&(v+=d.readUnsignedExpGolomb(),w+=d.readUnsignedExpGolomb(),
x+=d.readUnsignedExpGolomb(),y+=d.readUnsignedExpGolomb());b.width=String(t-(v+w)*(e===1||e===2?2:1));b.height=String(u-(x+y)*(e===1?2:1));d=["","A","B","C"][f];k=function(C){for(var D=0,A=0;A<32;A++)D|=(C>>A&1)<<31-A;return D>>>0}(k);g=g==1?"H":"L";h="hvc1"+("."+d+h)+("."+k.toString(16).toUpperCase());h+="."+g+r;q&&(h+="."+q.toString(16).toUpperCase());p&&(h+="."+p.toString(16).toUpperCase());n&&(h+="."+n.toString(16).toUpperCase());m&&(h+="."+m.toString(16).toUpperCase());l&&(h+="."+l.toString(16).toUpperCase());
c&&(h+="."+c.toString(16).toUpperCase());b.codec=h;b.frameRate=this.getFrameRate_();return b};shaka.util.TsParser.prototype.getOpusMetadata=function(){return this.opusMetadata_};shaka.util.TsParser.prototype.byteToHex_=function(a){return("0"+a.toString(16).toUpperCase()).slice(-2)};shaka.util.TsParser.prototype.handleRollover_=function(a,b){var c=1;for(a>b&&(c=-1);Math.abs(b-a)>4294967296;)a+=c*8589934592;return a};
shaka.util.TsParser.probe=function(a){a=shaka.util.TsParser.syncOffset(a);if(a<0)return!1;a>0&&shaka.log.warning("MPEG2-TS detected but first sync word found @ offset "+a+", junk ahead ?");return!0};shaka.util.TsParser.syncOffset=function(a){for(var b=shaka.util.TsParser.PacketLength_,c=Math.min(1E3,a.length-3*b),d=0;d<c;){if(a[d]==71&&a[d+b]==71&&a[d+2*b]==71)return d;var e=a.indexOf(71,d+1);d=e>=0&&e<c?e:d+1}return-1};goog.exportSymbol("shaka.util.TsParser",shaka.util.TsParser);
goog.exportProperty(shaka.util.TsParser,"syncOffset",shaka.util.TsParser.syncOffset);goog.exportProperty(shaka.util.TsParser,"probe",shaka.util.TsParser.probe);goog.exportProperty(shaka.util.TsParser.prototype,"getVideoInfo",shaka.util.TsParser.prototype.getVideoInfo);goog.exportProperty(shaka.util.TsParser.prototype,"getVideoResolution",shaka.util.TsParser.prototype.getVideoResolution);goog.exportProperty(shaka.util.TsParser.prototype,"getVideoNalus",shaka.util.TsParser.prototype.getVideoNalus);
goog.exportProperty(shaka.util.TsParser.prototype,"getCodecs",shaka.util.TsParser.prototype.getCodecs);goog.exportProperty(shaka.util.TsParser.prototype,"getStartTime",shaka.util.TsParser.prototype.getStartTime);goog.exportProperty(shaka.util.TsParser.prototype,"getVideoData",shaka.util.TsParser.prototype.getVideoData);goog.exportProperty(shaka.util.TsParser.prototype,"getAudioData",shaka.util.TsParser.prototype.getAudioData);goog.exportProperty(shaka.util.TsParser.prototype,"getMetadata",shaka.util.TsParser.prototype.getMetadata);
goog.exportProperty(shaka.util.TsParser.prototype,"parseNalus",shaka.util.TsParser.prototype.parseNalus);goog.exportProperty(shaka.util.TsParser.prototype,"parseAvcNalus",shaka.util.TsParser.prototype.parseAvcNalus);goog.exportProperty(shaka.util.TsParser.prototype,"parse",shaka.util.TsParser.prototype.parse);goog.exportProperty(shaka.util.TsParser.prototype,"setDiscontinuitySequence",shaka.util.TsParser.prototype.setDiscontinuitySequence);
goog.exportProperty(shaka.util.TsParser.prototype,"clearData",shaka.util.TsParser.prototype.clearData);shaka.util.TsParser.Timescale=9E4;goog.exportProperty(shaka.util.TsParser,"Timescale",shaka.util.TsParser.Timescale);shaka.util.TsParser.PacketLength_=188;shaka.util.TsParser.H264_NALU_TYPE_SPS_=7;shaka.util.TsParser.H265_NALU_TYPE_SPS_=33;shaka.util.TsParser.PROFILES_WITH_OPTIONAL_SPS_DATA_=[100,110,122,244,44,83,86,118,128,138,139,134];shaka.cea.TsCeaParser=function(){this.seiProcessor_=new shaka.cea.SeiProcessor;this.tsParser_=null};shaka.cea.TsCeaParser.prototype.init=function(a){};
shaka.cea.TsCeaParser.prototype.parse=function(a){var b=shaka.cea.CeaUtils;this.tsParser_?this.tsParser_.clearData():this.tsParser_=new shaka.util.TsParser;var c=[];a=shaka.util.BufferUtils.toUint8(a);if(!shaka.util.TsParser.probe(a))return c;a=this.tsParser_.parse(a);var d=a.getCodecs(),e=a.getVideoNalus();a=[];switch(d.video){case "avc":a.push(b.H264_NALU_TYPE_SEI);break;case "hvc":a.push(b.H265_PREFIX_NALU_TYPE_SEI),a.push(b.H265_SUFFIX_NALU_TYPE_SEI)}if(!a.length)return c;b=(0,$jscomp.makeIterator)(e);
for(d=b.next();!d.done;d=b.next())if(d=d.value,a.includes(d.type)&&d.time!=null){e=(0,$jscomp.makeIterator)(this.seiProcessor_.process(d.data));for(var f=e.next();!f.done;f=e.next())c.push({packet:f.value,pts:d.time})}return c};goog.exportSymbol("shaka.cea.TsCeaParser",shaka.cea.TsCeaParser);shaka.media.ClosedCaptionParser.registerParser("video/mp2t",function(){return new shaka.cea.TsCeaParser});shaka.config.CodecSwitchingStrategy={RELOAD:"reload",SMOOTH:"smooth"};goog.exportSymbol("shaka.config.CodecSwitchingStrategy",shaka.config.CodecSwitchingStrategy);shaka.config.CrossBoundaryStrategy={KEEP:"keep",RESET:"reset",RESET_TO_ENCRYPTED:"reset_to_encrypted",RESET_ON_ENCRYPTION_CHANGE:"RESET_ON_ENCRYPTION_CHANGE"};goog.exportSymbol("shaka.config.CrossBoundaryStrategy",shaka.config.CrossBoundaryStrategy);shaka.config.RepeatMode={OFF:0,ALL:1,SINGLE:2};goog.exportSymbol("shaka.config.RepeatMode",shaka.config.RepeatMode);shaka.drm.PlayReady=function(){};shaka.drm.PlayReady.parseMsProRecords_=function(a,b){for(var c=[];b<a.byteLength-1;){var d=a.getUint16(b,!0);b+=2;var e=a.getUint16(b,!0);b+=2;if((e&1)!=0||e+b>a.byteLength)return shaka.log.warning("Malformed MS PRO object"),[];var f=shaka.util.BufferUtils.toUint8(a,b,e);c.push({type:d,value:f});b+=e}return c};
shaka.drm.PlayReady.parseMsPro_=function(a){var b=0,c=shaka.util.BufferUtils.toDataView(a),d=c.getUint32(b,!0);b+=4;return d!=a.byteLength?(shaka.log.warning("PlayReady Object with invalid length encountered."),[]):shaka.drm.PlayReady.parseMsProRecords_(c,b+2)};
shaka.drm.PlayReady.getLaurl_=function(a){a=(0,$jscomp.makeIterator)(shaka.util.TXml.getElementsByTagName(a,"DATA"));for(var b=a.next();!b.done;b=a.next())if(b=b.value,b.children){b=(0,$jscomp.makeIterator)(b.children);for(var c=b.next();!c.done;c=b.next())if(c=c.value,c.tagName=="LA_URL")return shaka.util.TXml.getTextContents(c)}return""};
shaka.drm.PlayReady.getPlayReadyHeaderObject_=function(a){var b=shaka.drm.PlayReady.PLAYREADY_RECORD_TYPES;a=shaka.util.Uint8ArrayUtils.fromBase64(shaka.util.TXml.getTextContents(a));a=shaka.drm.PlayReady.parseMsPro_(a).filter(function(c){return c.type===b.RIGHTS_MANAGEMENT})[0];if(!a)return null;a=shaka.util.StringUtils.fromUTF16(a.value,!0);return(a=shaka.util.TXml.parseXmlString(a,"WRMHEADER"))?a:null};
shaka.drm.PlayReady.getLicenseUrl=function(a){try{var b=shaka.drm.PlayReady.getPlayReadyHeaderObject_(a);return b?shaka.drm.PlayReady.getLaurl_(b):""}catch(c){return""}};
shaka.drm.PlayReady.getPlayReadyKID=function(a){var b=shaka.drm.PlayReady.getPlayReadyHeaderObject_(a);if(!b)return null;a=shaka.util.TXml;b=(0,$jscomp.makeIterator)(a.getElementsByTagName(b,"DATA"));for(var c=b.next();!c.done;c=b.next())if(c=a.findChild(c.value,"KID"))return a=shaka.util.Uint8ArrayUtils.fromBase64(shaka.util.TXml.getTextContents(c)),a=new Uint8Array([a[3],a[2],a[1],a[0],a[5],a[4],a[7],a[6]].concat((0,$jscomp.arrayFromIterable)(a.slice(8)))),shaka.util.Uint8ArrayUtils.toHex(a);return null};
shaka.drm.PlayReady.PLAYREADY_RECORD_TYPES={RIGHTS_MANAGEMENT:1,RESERVED:2,EMBEDDED_LICENSE:3};shaka.util.Pssh=function(a){var b=this;this.systemIds=[];this.data=[];(new shaka.util.Mp4Parser).boxes(["moov","moof"],shaka.util.Mp4Parser.children).fullBox("pssh",function(c){return b.parsePsshBox_(c)}).parse(a);this.data.length==0&&shaka.log.v2("No pssh box found!")};
shaka.util.Pssh.prototype.parsePsshBox_=function(a){goog.asserts.assert(a.version!=null,"PSSH boxes are full boxes and must have a valid version");goog.asserts.assert(a.flags!=null,"PSSH boxes are full boxes and must have a valid flag");if(a.version>1)shaka.log.warning("Unrecognized PSSH version found!");else{var b=a.reader.getDataView();goog.asserts.assert(b.byteOffset>=12,"DataView at incorrect position");b=shaka.util.BufferUtils.toUint8(b,-12,a.size);this.data.push(b);a=a.reader.readBytes(16,!1);
this.systemIds.push(shaka.util.Uint8ArrayUtils.toHex(a))}};
shaka.util.Pssh.createPssh=function(a,b,c,d){goog.asserts.assert(b.byteLength==16,"Invalid system ID length");var e=a.length,f=12+b.length+4+e;d>0&&(f+=4+16*c.size);var g=new Uint8Array(f),h=shaka.util.BufferUtils.toDataView(g),k=0;h.setUint32(k,f);k+=4;h.setUint32(k,1886614376);k+=4;d<1?h.setUint32(k,0):h.setUint32(k,16777216);k+=4;g.set(b,k);k+=b.length;if(d>0)for(h.setUint32(k,c.size),k+=4,b=shaka.util.Uint8ArrayUtils,c=(0,$jscomp.makeIterator)(c),d=c.next();!d.done;d=c.next())d=b.fromHex(d.value),
g.set(d,k),k+=d.length;h.setUint32(k,e);k+=4;g.set(a,k);goog.asserts.assert(k+e===f,"PSSH invalid length.");return g};shaka.util.Pssh.getPsshData=function(a){var b=8;a=shaka.util.BufferUtils.toDataView(a);var c=a.getUint8(b);b+=20;c>0&&(b+=4+16*a.getUint32(b));return shaka.util.BufferUtils.toUint8(a,b+4)};
shaka.util.Pssh.normaliseInitData=function(a){if(!a)return a;var b=new shaka.util.Pssh(a);if(b.data.length<=1)return a;a=[];b=(0,$jscomp.makeIterator)(b.data);for(var c=b.next(),d={};!c.done;d={initData$jscomp$9:void 0},c=b.next())d.initData$jscomp$9=c.value,a.some(function(e){return function(f){return shaka.util.BufferUtils.equal(f,e.initData$jscomp$9)}}(d))||a.push(d.initData$jscomp$9);return shaka.util.Uint8ArrayUtils.concat.apply(shaka.util.Uint8ArrayUtils,(0,$jscomp.arrayFromIterable)(a))};shaka.dash={};shaka.dash.ContentProtection=function(){this.psshToInitData_=new Map};shaka.dash.ContentProtection.prototype.release=function(){this.psshToInitData_.clear()};
shaka.dash.ContentProtection.prototype.parseFromAdaptationSet=function(a,b,c){var d=shaka.dash.ContentProtection,e=shaka.util.ManifestParserUtils,f=this.parseElements_(a),g=null;a=[];var h=[],k=null,l=new Set(f.map(function(n){return n.keyId}));l.delete(null);var m="cenc";if(l.size>1)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_CONFLICTING_KEY_IDS);if(!b){h=f.filter(function(n){return n.schemeUri==d.Aes128Protection_});
if(h.length>1)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_CONFLICTING_AES_128);h.length&&(k=d.parseAes128_(h[0]));(h=f.find(function(n){return n.schemeUri==d.MP4Protection_}))&&h.encryptionScheme&&(m=h.encryptionScheme);h=f.filter(function(n){return n.schemeUri==d.MP4Protection_?(goog.asserts.assert(!n.init||n.init.length,"Init data must be null or non-empty."),g=n.init||g,!1):n.schemeUri!=d.Aes128Protection_});h.length&&
(a=d.convertElements_(g,m,h,c,l),a.length==0&&(a=[e.createDrmInfo("",m,g)]))}if(f.length&&!k&&(b||!h.length))for(a=[],b=(0,$jscomp.makeIterator)(Object.values(c)),c=b.next();!c.done;c=b.next())c=c.value,shaka.drm.DrmUtils.isClearKeySystem(c)||(c=e.createDrmInfo(c,m,g),a.push(c));if(e=Array.from(l)[0]||null)for(l=(0,$jscomp.makeIterator)(a),m=l.next();!m.done;m=l.next())for(m=(0,$jscomp.makeIterator)(m.value.initData),b=m.next();!b.done;b=m.next())b.value.keyId=e;return{defaultKeyId:e,defaultInit:g,
drmInfos:a,aes128Info:k,firstRepresentation:!0}};
shaka.dash.ContentProtection.prototype.parseFromRepresentation=function(a,b,c,d){var e=this.parseFromAdaptationSet(a,c,d);if(b.firstRepresentation){a=b.drmInfos.length==1&&!b.drmInfos[0].keySystem;c=e.drmInfos.length==0;if(b.drmInfos.length==0||a&&!c)b.drmInfos=e.drmInfos;b.firstRepresentation=!1}else if(e.drmInfos.length>0&&(b.drmInfos=b.drmInfos.filter(function(f){return e.drmInfos.some(function(g){return g.keySystem==f.keySystem})}),b.drmInfos.length==0))throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_NO_COMMON_KEY_SYSTEM);return e.defaultKeyId||b.defaultKeyId};
shaka.dash.ContentProtection.getFairPlayLicenseUrl=function(a){if(shaka.drm.DrmUtils.isMediaKeysPolyfilled("apple"))throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_MSE_ENCRYPTED_LEGACY_APPLE_MEDIA_KEYS_NOT_SUPPORTED);if(a=shaka.util.TXml.findChildNS(a.node,shaka.dash.ContentProtection.DashIfNamespaceUri_,"Laurl"))if(a=shaka.util.TXml.getTextContents(a))return a;return""};
shaka.dash.ContentProtection.getWidevineLicenseUrl=function(a){var b=shaka.util.StringUtils,c=shaka.util.TXml.findChildNS(a.node,shaka.dash.ContentProtection.DashIfNamespaceUri_,"Laurl");return c&&(c=shaka.util.TXml.getTextContents(c))?c:(a=shaka.util.TXml.findChildNS(a.node,"urn:microsoft","laurl"))?b.htmlUnescape(a.attributes.licenseUrl)||"":""};
shaka.dash.ContentProtection.getClearKeyLicenseUrl=function(a){var b=shaka.util.TXml.findChildNS(a.node,shaka.dash.ContentProtection.DashIfNamespaceUri_,"Laurl");return b&&(b=shaka.util.TXml.getTextContents(b))?b:(a=shaka.util.TXml.findChildNS(a.node,shaka.dash.ContentProtection.ClearKeyNamespaceUri_,"Laurl"))&&a.attributes.Lic_type==="EME-1.0"&&a&&(a=shaka.util.TXml.getTextContents(a))?a:""};
shaka.dash.ContentProtection.getPlayReadyLicenseUrl=function(a){var b=shaka.util.TXml,c=b.findChildNS(a.node,shaka.dash.ContentProtection.DashIfNamespaceUri_,"Laurl");if(c&&(c=b.getTextContents(c)))return c;if((c=b.findChildNS(a.node,"urn:microsoft:playready","pro"))&&b.getTextContents(c))return shaka.drm.PlayReady.getLicenseUrl(c);if(a=b.findChildNS(a.node,shaka.dash.ContentProtection.CencNamespaceUri_,"pssh"))if(a=b.getTextContents(a))return a=shaka.util.Pssh.getPsshData(shaka.util.Uint8ArrayUtils.fromBase64(a)),
a=shaka.util.Uint8ArrayUtils.toStandardBase64(a),b=b.parseXmlString("<pro>"+a+"</pro>"),goog.asserts.assert(b,"Must have pro node"),shaka.drm.PlayReady.getLicenseUrl(b);return""};
shaka.dash.ContentProtection.getInitDataFromPro_=function(a){var b=shaka.util.TXml.findChildNS(a.node,"urn:microsoft:playready","pro");if(!b||!shaka.util.TXml.getTextContents(b))return null;var c=shaka.util.Uint8ArrayUtils;b=shaka.util.TXml.getTextContents(b);c=c.fromBase64(b);b=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);var d=new Set;return[{initData:shaka.util.Pssh.createPssh(c,b,d,0),initDataType:"cenc",keyId:a.keyId}]};
shaka.dash.ContentProtection.getInitDataClearKey_=function(a,b){if(b.size==0)return null;var c=new Uint8Array([16,119,239,236,192,178,77,2,172,227,60,30,82,226,251,75]),d=new Uint8Array([]);return[{initData:shaka.util.Pssh.createPssh(d,c,b,1),initDataType:"cenc",keyId:a.keyId}]};
shaka.dash.ContentProtection.convertElements_=function(a,b,c,d,e){var f=shaka.dash.ContentProtection,g=shaka.util.ManifestParserUtils,h=f.licenseUrlParsers_,k=[];c=(0,$jscomp.makeIterator)(c);for(var l=c.next();!l.done;l=c.next()){l=l.value;var m=d[l.schemeUri];if(m){goog.asserts.assert(!l.init||l.init.length,"Init data must be null or non-empty.");var n=f.getInitDataFromPro_(l),p=null;l.schemeUri===shaka.dash.ContentProtection.ClearKeySchemeUri_&&(p=f.getInitDataClearKey_(l,e));n=g.createDrmInfo(m,
b,l.init||a||n||p);if(m=h.get(m))n.licenseServerUri=m(l);n.serverCertificateUri=f.getServerCertificateUri(l);k.push(n)}}return k};shaka.dash.ContentProtection.getServerCertificateUri=function(a){if(a=shaka.util.TXml.findChildNS(a.node,shaka.dash.ContentProtection.DashIfNamespaceUri_,"Certurl"))if(a=shaka.util.TXml.getTextContents(a))return a;return""};
shaka.dash.ContentProtection.prototype.parseElements_=function(a){var b=[];a=(0,$jscomp.makeIterator)(a);for(var c=a.next();!c.done;c=a.next())(c=this.parseElement_(c.value))&&b.push(c);return b};
shaka.dash.ContentProtection.prototype.parseElement_=function(a){var b=this,c=shaka.dash.ContentProtection.CencNamespaceUri_,d=shaka.util.TXml,e=a.attributes.schemeIdUri,f=d.getAttributeNS(a,c,"default_KID");c=d.findChildrenNS(a,c,"pssh").map(d.getContents);d=a.attributes.value;if(!e)return shaka.log.error("Missing required schemeIdUri attribute on","ContentProtection element",a),null;e=e.toLowerCase();if(f&&(f=f.replace(/-/g,"").toLowerCase(),f.includes(" ")))throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_MULTIPLE_KEY_IDS_NOT_SUPPORTED);var g=[];try{g=c.map(function(h){if(!b.psshToInitData_.has(h)){var k=shaka.util.Uint8ArrayUtils.fromBase64(h);b.psshToInitData_.set(h,k)}return{initDataType:"cenc",initData:b.psshToInitData_.get(h),keyId:null}})}catch(h){throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_PSSH_BAD_ENCODING);}return{node:a,schemeUri:e,keyId:f,init:g.length>
0?g:null,encryptionScheme:d}};
shaka.dash.ContentProtection.parseAes128_=function(a){if(!window.crypto||!window.crypto.subtle)throw shaka.log.alwaysWarn("Web Crypto API is not available to decrypt AES-128. (Web Crypto only exists in secure origins like https)"),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.NO_WEB_CRYPTO_API);var b=shaka.util.TXml.findChildNS(a.node,"urn:mpeg:dash:schema:sea:2012","SegmentEncryption");if(!b)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,
shaka.util.Error.Code.DASH_UNSUPPORTED_AES_128);if(b.attributes.schemeIdUri!="urn:mpeg:dash:sea:aes128-cbc:2013")throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_UNSUPPORTED_AES_128);b=shaka.util.TXml.findChildNS(a.node,"urn:mpeg:dash:schema:sea:2012","CryptoPeriod");if(!b)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_UNSUPPORTED_AES_128);a=b.attributes.IV;
b=shaka.util.StringUtils.htmlUnescape(b.attributes.keyUriTemplate);if(!a||!b)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_UNSUPPORTED_AES_128);a=shaka.util.Uint8ArrayUtils.fromHex(a.substr(2));if(a.byteLength!=16)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.AES_128_INVALID_IV_LENGTH);return{keyUri:b,iv:a}};
shaka.dash.ContentProtection.licenseUrlParsers_=(new Map).set("com.apple.fps",shaka.dash.ContentProtection.getFairPlayLicenseUrl).set("com.widevine.alpha",shaka.dash.ContentProtection.getWidevineLicenseUrl).set("com.microsoft.playready",shaka.dash.ContentProtection.getPlayReadyLicenseUrl).set("com.microsoft.playready.recommendation",shaka.dash.ContentProtection.getPlayReadyLicenseUrl).set("com.microsoft.playready.software",shaka.dash.ContentProtection.getPlayReadyLicenseUrl).set("com.microsoft.playready.hardware",
shaka.dash.ContentProtection.getPlayReadyLicenseUrl).set("org.w3.clearkey",shaka.dash.ContentProtection.getClearKeyLicenseUrl);shaka.dash.ContentProtection.MP4Protection_="urn:mpeg:dash:mp4protection:2011";shaka.dash.ContentProtection.Aes128Protection_="urn:mpeg:dash:sea:2012";shaka.dash.ContentProtection.CencNamespaceUri_="urn:mpeg:cenc:2013";shaka.dash.ContentProtection.ClearKeyNamespaceUri_="http://dashif.org/guidelines/clearKey";shaka.dash.ContentProtection.ClearKeySchemeUri_="urn:uuid:e2719d58-a985-b3c9-781a-b030af78d30e";
shaka.dash.ContentProtection.DashIfNamespaceUri_="https://dashif.org/CPS";shaka.net={};
shaka.net.Backoff=function(a,b){b=b===void 0?!1:b;var c=shaka.net.Backoff.defaultRetryParameters();this.maxAttempts_=a.maxAttempts==null?c.maxAttempts:a.maxAttempts;goog.asserts.assert(this.maxAttempts_>=1,"maxAttempts should be >= 1");this.baseDelay_=a.baseDelay==null?c.baseDelay:a.baseDelay;goog.asserts.assert(this.baseDelay_>=0,"baseDelay should be >= 0");this.fuzzFactor_=a.fuzzFactor==null?c.fuzzFactor:a.fuzzFactor;goog.asserts.assert(this.fuzzFactor_>=0,"fuzzFactor should be >= 0");this.backoffFactor_=
a.backoffFactor==null?c.backoffFactor:a.backoffFactor;goog.asserts.assert(this.backoffFactor_>=0,"backoffFactor should be >= 0");this.numAttempts_=0;this.nextUnfuzzedDelay_=this.baseDelay_;if(this.autoReset_=b)goog.asserts.assert(this.maxAttempts_>=2,"maxAttempts must be >= 2 for autoReset == true"),this.numAttempts_=1};
shaka.net.Backoff.prototype.attempt=function(){var a=this,b,c;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(d){if(d.getNextAddressJsc()==1){if(a.numAttempts_>=a.maxAttempts_)if(a.autoReset_)a.reset_();else throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.PLAYER,shaka.util.Error.Code.ATTEMPTS_EXHAUSTED);b=a.numAttempts_;a.numAttempts_++;if(b==0)return goog.asserts.assert(!a.autoReset_,"Failed to delay with auto-reset!"),d.return();c=shaka.net.Backoff.fuzz_(a.nextUnfuzzedDelay_,
a.fuzzFactor_);return d.yield(new Promise(function(e){shaka.net.Backoff.defer(c,e)}),2)}a.nextUnfuzzedDelay_*=a.backoffFactor_;d.jumpToEnd()})};shaka.net.Backoff.defaultRetryParameters=function(){return{maxAttempts:2,baseDelay:1E3,backoffFactor:2,fuzzFactor:.5,timeout:3E4,stallTimeout:5E3,connectionTimeout:1E4}};shaka.net.Backoff.fuzz_=function(a,b){return a*(1+(Math.random()*2-1)*b)};
shaka.net.Backoff.prototype.reset_=function(){goog.asserts.assert(this.autoReset_,"Should only be used for auto-reset!");this.numAttempts_=1;this.nextUnfuzzedDelay_=this.baseDelay_};shaka.net.Backoff.defer=function(a,b){(new shaka.util.Timer(b)).tickAfter(a/1E3)};shaka.util.PublicPromise=function(){var a,b,c=new Promise(function(d,e){a=d;b=e});c.resolve=a;c.reject=b;return c};shaka.util.PublicPromise.prototype.resolve=function(a){};shaka.util.PublicPromise.prototype.reject=function(a){};shaka.util.AbortableOperation=function(a,b){this.promise=a;this.onAbort_=b;this.abortPromise_=null};shaka.util.AbortableOperation.failed=function(a){return new shaka.util.AbortableOperation(Promise.reject(a),function(){return Promise.resolve()})};shaka.util.AbortableOperation.aborted=function(){var a=Promise.reject(shaka.util.AbortableOperation.abortError());a.catch(function(){});return new shaka.util.AbortableOperation(a,function(){return Promise.resolve()})};
shaka.util.AbortableOperation.abortError=function(){return new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.PLAYER,shaka.util.Error.Code.OPERATION_ABORTED)};shaka.util.AbortableOperation.completed=function(a){return new shaka.util.AbortableOperation(Promise.resolve(a),function(){return Promise.resolve()})};shaka.util.AbortableOperation.notAbortable=function(a){return new shaka.util.AbortableOperation(a,function(){return a.catch(function(){})})};
shaka.util.AbortableOperation.prototype.abort=function(){this.abortPromise_||(this.abortPromise_=this.onAbort_());return this.abortPromise_};shaka.util.AbortableOperation.all=function(a){return new shaka.util.AbortableOperation(Promise.all(a.map(function(b){return b.promise})),function(){return Promise.all(a.map(function(b){return b.abort()}))})};shaka.util.AbortableOperation.prototype.finally=function(a){this.promise.then(function(b){return a(!0)},function(b){return a(!1)});return this};
shaka.util.AbortableOperation.prototype.chain=function(a,b){var c=this,d=new shaka.util.PublicPromise;d.catch(function(){});var e=shaka.util.AbortableOperation.abortError(),f=function(){d.reject(e);return c.abort()},g=function(h){return function(k){if(c.abortPromise_&&h)d.reject(e);else{var l=h?a:b;l?f=shaka.util.AbortableOperation.wrapChainCallback_(l,k,d):(h?d.resolve:d.reject)(k)}}};this.promise.then(g(!0),g(!1));return new shaka.util.AbortableOperation(d,function(){return f()})};
shaka.util.AbortableOperation.wrapChainCallback_=function(a,b,c){try{var d=a(b);if(d&&d.promise&&d.abort)return c.resolve(d.promise),function(){return d.abort()};c.resolve(d);return function(){return Promise.resolve(d).then(function(){},function(){})}}catch(e){return c.reject(e),function(){return Promise.resolve()}}};$jscomp.global.Object.defineProperties(shaka.util.AbortableOperation.prototype,{aborted:{configurable:!0,enumerable:!0,get:function(){return this.abortPromise_!==null}}});
goog.exportSymbol("shaka.util.AbortableOperation",shaka.util.AbortableOperation);goog.exportProperty(shaka.util.AbortableOperation.prototype,"chain",shaka.util.AbortableOperation.prototype.chain);goog.exportProperty(shaka.util.AbortableOperation.prototype,"finally",shaka.util.AbortableOperation.prototype.finally);goog.exportProperty(shaka.util.AbortableOperation,"all",shaka.util.AbortableOperation.all);goog.exportProperty(shaka.util.AbortableOperation.prototype,"abort",shaka.util.AbortableOperation.prototype.abort);
goog.exportProperty(shaka.util.AbortableOperation,"notAbortable",shaka.util.AbortableOperation.notAbortable);goog.exportProperty(shaka.util.AbortableOperation,"completed",shaka.util.AbortableOperation.completed);goog.exportProperty(shaka.util.AbortableOperation,"aborted",shaka.util.AbortableOperation.aborted);goog.exportProperty(shaka.util.AbortableOperation,"failed",shaka.util.AbortableOperation.failed);shaka.util.FakeEvent=function(a,b){if(b)if(b instanceof Map)for(var c=(0,$jscomp.makeIterator)(b.keys()),d=c.next();!d.done;d=c.next())d=d.value,Object.defineProperty(this,d,{value:b.get(d),writable:!0,enumerable:!0});else for(c in b=shaka.util.FakeEvent.recastDictAsObject_(b),b)Object.defineProperty(this,c,{value:b[c],writable:!0,enumerable:!0});this.defaultPrevented=this.cancelable=this.bubbles=!1;this.timeStamp=window.performance&&window.performance.now?window.performance.now():Date.now();this.type=
a;this.isTrusted=!1;this.target=this.currentTarget=null;this.stopped=!1};shaka.util.FakeEvent.fromRealEvent=function(a){var b=new shaka.util.FakeEvent(a.type),c;for(c in a)Object.defineProperty(b,c,{value:a[c],writable:!0,enumerable:!0});return b};shaka.util.FakeEvent.recastDictAsObject_=function(a){goog.asserts.assert(!(a instanceof Map),"dict should not be a map");return a};shaka.util.FakeEvent.prototype.preventDefault=function(){this.cancelable&&(this.defaultPrevented=!0)};
shaka.util.FakeEvent.prototype.stopImmediatePropagation=function(){this.stopped=!0};shaka.util.FakeEvent.prototype.stopPropagation=function(){};goog.exportSymbol("shaka.util.FakeEvent",shaka.util.FakeEvent);
shaka.util.FakeEvent.EventName={AbrStatusChanged:"abrstatuschanged",Adaptation:"adaptation",AudioTrackChanged:"audiotrackchanged",AudioTracksChanged:"audiotrackschanged",BoundaryCrossed:"boundarycrossed",Buffering:"buffering",CanUpdateStartTime:"canupdatestarttime",Complete:"complete",CurrentItemChanged:"currentitemchanged",DownloadCompleted:"downloadcompleted",DownloadFailed:"downloadfailed",DownloadHeadersReceived:"downloadheadersreceived",DrmSessionUpdate:"drmsessionupdate",Emsg:"emsg",ItemsInserted:"itemsinserted",
ItemsRemoved:"itemsremoved",Prft:"prft",Error:"error",ExpirationUpdated:"expirationupdated",FirstQuartile:"firstquartile",GapJumped:"gapjumped",KeyStatusChanged:"keystatuschanged",Loaded:"loaded",Loading:"loading",ManifestParsed:"manifestparsed",ManifestUpdated:"manifestupdated",MediaQualityChanged:"mediaqualitychanged",MediaSourceRecovered:"mediasourcerecovered",MetadataAdded:"metadataadded",Metadata:"metadata",Midpoint:"midpoint",NoSpatialVideoInfoEvent:"nospatialvideoinfo",OnStateChange:"onstatechange",
RateChange:"ratechange",SegmentAppended:"segmentappended",SessionDataEvent:"sessiondata",SpatialVideoInfoEvent:"spatialvideoinfo",StallDetected:"stalldetected",Started:"started",StateChanged:"statechanged",Streaming:"streaming",TextChanged:"textchanged",TextTrackVisibility:"texttrackvisibility",ThirdQuartile:"thirdquartile",TimelineRegionAdded:"timelineregionadded",TimelineRegionEnter:"timelineregionenter",TimelineRegionExit:"timelineregionexit",TracksChanged:"trackschanged",Unloading:"unloading",
VariantChanged:"variantchanged"};shaka.util.FakeEventTarget=function(){this.listeners_=new shaka.util.MultiMap;this.dispatchTarget=this};shaka.util.FakeEventTarget.prototype.addEventListener=function(a,b,c){this.listeners_&&this.listeners_.push(a,b)};shaka.util.FakeEventTarget.prototype.listenToAllEvents=function(a){this.addEventListener(shaka.util.FakeEventTarget.ALL_EVENTS_,a)};shaka.util.FakeEventTarget.prototype.removeEventListener=function(a,b,c){this.listeners_&&this.listeners_.remove(a,b)};
shaka.util.FakeEventTarget.prototype.dispatchEvent=function(a){goog.asserts.assert(a instanceof shaka.util.FakeEvent,"FakeEventTarget can only dispatch FakeEvents!");if(!this.listeners_)return!0;var b=this.listeners_.get(a.type)||[],c=this.listeners_.get(shaka.util.FakeEventTarget.ALL_EVENTS_);c&&(b=b.concat(c));b=(0,$jscomp.makeIterator)(b);for(c=b.next();!c.done;c=b.next()){c=c.value;a.target=this.dispatchTarget;a.currentTarget=this.dispatchTarget;try{c.handleEvent?c.handleEvent(a):c.call(this,
a)}catch(d){shaka.log.error("Uncaught exception in event handler",d,d?d.message:null,d?d.stack:null)}if(a.stopped)break}return a.defaultPrevented};shaka.util.FakeEventTarget.prototype.release=function(){this.listeners_=null};shaka.util.FakeEventTarget.ALL_EVENTS_="All";shaka.util.OperationManager=function(){this.operations_=[]};shaka.util.OperationManager.prototype.manage=function(a){var b=this;this.operations_.push(a.finally(function(){shaka.util.ArrayUtils.remove(b.operations_,a)}))};shaka.util.OperationManager.prototype.destroy=function(){for(var a=[],b=(0,$jscomp.makeIterator)(this.operations_),c=b.next();!c.done;c=b.next())c=c.value,c.promise.catch(function(){}),a.push(c.abort());this.operations_=[];return Promise.all(a)};shaka.net.NetworkingEngine=function(a,b,c,d,e,f,g){shaka.util.FakeEventTarget.call(this);this.config_=null;this.destroyed_=!1;this.operationManager_=new shaka.util.OperationManager;this.requestFilters_=new Set;this.responseFilters_=new Set;this.onProgressUpdated_=a||null;this.onHeadersReceived_=b||null;this.onDownloadCompleted_=c||null;this.onDownloadFailed_=d||null;this.onRequest_=e||null;this.onRetry_=f||null;this.onResponse_=g||null;this.hostCommonAccessTokenMap_=new Map};
$jscomp.inherits(shaka.net.NetworkingEngine,shaka.util.FakeEventTarget);shaka.net.NetworkingEngine.prototype.configure=function(a){this.config_=a};shaka.net.NetworkingEngine.registerScheme=function(a,b,c,d){d=d===void 0?!1:d;goog.asserts.assert(c==void 0||c>0,"explicit priority must be > 0");c=c||shaka.net.NetworkingEngine.PluginPriority.APPLICATION;var e=shaka.net.NetworkingEngine.schemes_.get(a);(!e||c>=e.priority)&&shaka.net.NetworkingEngine.schemes_.set(a,{priority:c,plugin:b,progressSupport:d})};
shaka.net.NetworkingEngine.unregisterScheme=function(a){shaka.net.NetworkingEngine.schemes_.delete(a)};shaka.net.NetworkingEngine.prototype.copyFiltersInto=function(a){for(var b=(0,$jscomp.makeIterator)(this.requestFilters_),c=b.next();!c.done;c=b.next())a.requestFilters_.add(c.value);b=(0,$jscomp.makeIterator)(this.responseFilters_);for(c=b.next();!c.done;c=b.next())a.responseFilters_.add(c.value)};shaka.net.NetworkingEngine.prototype.registerRequestFilter=function(a){this.requestFilters_.add(a)};
shaka.net.NetworkingEngine.prototype.unregisterRequestFilter=function(a){this.requestFilters_.delete(a)};shaka.net.NetworkingEngine.prototype.clearAllRequestFilters=function(){this.requestFilters_.clear()};shaka.net.NetworkingEngine.prototype.registerResponseFilter=function(a){this.responseFilters_.add(a)};shaka.net.NetworkingEngine.prototype.unregisterResponseFilter=function(a){this.responseFilters_.delete(a)};shaka.net.NetworkingEngine.prototype.clearAllResponseFilters=function(){this.responseFilters_.clear()};
shaka.net.NetworkingEngine.prototype.clearCommonAccessTokenMap=function(){this.hostCommonAccessTokenMap_.clear()};shaka.net.NetworkingEngine.defaultRetryParameters=function(){return shaka.net.Backoff.defaultRetryParameters()};shaka.net.NetworkingEngine.makeRequest=function(a,b,c){return{uris:a,method:"GET",body:null,headers:{},allowCrossSiteCredentials:!1,retryParameters:b,licenseRequestType:null,sessionId:null,drmInfo:null,initData:null,initDataType:null,streamDataCallback:c===void 0?null:c}};
shaka.net.NetworkingEngine.prototype.destroy=function(){this.destroyed_=!0;this.requestFilters_.clear();this.responseFilters_.clear();this.hostCommonAccessTokenMap_.clear();shaka.util.FakeEventTarget.prototype.release.call(this);return this.operationManager_.destroy()};
shaka.net.NetworkingEngine.prototype.request=function(a,b,c){var d=this,e=shaka.util.ObjectUtils,f=new shaka.net.NetworkingEngine.NumBytesRemainingClass;if(this.destroyed_)return e=Promise.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.PLAYER,shaka.util.Error.Code.OPERATION_ABORTED)),e.catch(function(){}),new shaka.net.NetworkingEngine.PendingRequest(e,function(){return Promise.resolve()},f);goog.asserts.assert(b.uris&&b.uris.length,"Request without URIs!");
b.method=b.method||"GET";b.headers=b.headers||{};b.retryParameters=b.retryParameters?e.cloneObject(b.retryParameters):shaka.net.NetworkingEngine.defaultRetryParameters();b.uris=e.cloneObject(b.uris);e=this.filterRequest_(a,b,c);var g=e.chain(function(){return d.makeRequestWithRetry_(a,b,c,f)}),h=g.chain(function(p){return d.filterResponse_(a,p,c)}),k=Date.now(),l=0;e.promise.then(function(){l=Date.now()-k},function(){});var m=0;g.promise.then(function(){m=Date.now()},function(){});var n=h.chain(function(p){var q=
Date.now()-m,r=p.response;r.timeMs+=l;r.timeMs+=q;p.gotProgress||!d.onProgressUpdated_||r.fromCache||b.method=="HEAD"||a!=shaka.net.NetworkingEngine.RequestType.SEGMENT||(p=d.allowSwitch_(c),d.onProgressUpdated_(r.timeMs,r.data.byteLength,p,b,c));if(d.onResponse_)d.onResponse_(a,r,c);return r},function(p){p&&(goog.asserts.assert(p instanceof shaka.util.Error,"Wrong error type"),p.severity=shaka.util.Error.Severity.CRITICAL);throw p;});e=new shaka.net.NetworkingEngine.PendingRequest(n.promise,function(){return n.abort()},
f);this.operationManager_.manage(e);return e};
shaka.net.NetworkingEngine.prototype.filterRequest_=function(a,b,c){var d=shaka.util.AbortableOperation.completed(void 0),e=function(h){d=d.chain(function(){b.body&&(b.body=shaka.util.BufferUtils.toArrayBuffer(b.body));return h(a,b,c)})};this.onRequest_&&e(this.onRequest_);for(var f=(0,$jscomp.makeIterator)(this.requestFilters_),g=f.next();!g.done;g=f.next())e(g.value);return d.chain(void 0,function(h){if(h instanceof shaka.util.Error&&h.code==shaka.util.Error.Code.OPERATION_ABORTED)throw h;throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.NETWORK,shaka.util.Error.Code.REQUEST_FILTER_ERROR,h);})};shaka.net.NetworkingEngine.prototype.makeRequestWithRetry_=function(a,b,c,d){var e=new shaka.net.Backoff(b.retryParameters,!1);return this.send_(a,b,c,e,0,null,d)};
shaka.net.NetworkingEngine.prototype.send_=function(a,b,c,d,e,f,g){var h=this;goog.asserts.assert(this.config_,"Config must not be null!");this.config_.forceHTTP&&(b.uris[e]=b.uris[e].replace("https://","http://"));this.config_.forceHTTPS&&(b.uris[e]=b.uris[e].replace("http://","https://"));if(e>0&&this.onRetry_)this.onRetry_(a,c,b.uris[e],b.uris[e-1]);var k=new goog.Uri(b.uris[e]),l=k.getScheme(),m=!1;l||(l=shaka.net.NetworkingEngine.getLocationProtocol_(),goog.asserts.assert(l[l.length-1]==":",
"location.protocol expected to end with a colon!"),l=l.slice(0,-1),k.setScheme(l),b.uris[e]=k.toString());l=l.toLowerCase();var n=(l=shaka.net.NetworkingEngine.schemes_.get(l))?l.plugin:null;if(!n)return shaka.util.AbortableOperation.failed(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.NETWORK,shaka.util.Error.Code.UNSUPPORTED_SCHEME,k));var p=l.progressSupport;(k=this.hostCommonAccessTokenMap_.get(k.getDomain()))&&(b.headers[shaka.net.NetworkingEngine.CommonAccessTokenHeaderName_]=
k);var q=null,r=null,t=!1,u=!1,v;return shaka.util.AbortableOperation.notAbortable(d.attempt()).chain(function(){if(h.destroyed_)return shaka.util.AbortableOperation.aborted();v=Date.now();var w=shaka.net.NetworkingEngine.RequestType.SEGMENT,x=0;b.requestStartTime=Date.now();var y=n(b.uris[e],b,a,function(A,z,B){q&&q.stop();r&&r.tickAfter(D/1E3);if(h.onProgressUpdated_&&a==w){x++;b.packetNumber=x;var E=h.allowSwitch_(c);h.onProgressUpdated_(A,z,E,b,c);m=!0;g.setBytes(B)}},function(A){u=!0;b.timeToFirstByte=
Date.now()-b.requestStartTime;if(h.onHeadersReceived_)h.onHeadersReceived_(A,b,a)},{minBytesForProgressEvents:h.config_.minBytesForProgressEvents});if(!p)return y;var C=b.retryParameters.connectionTimeout;C&&(q=new shaka.util.Timer(function(){t=!0;y.abort()}),q.tickAfter(C/1E3));var D=b.retryParameters.stallTimeout;D&&(r=new shaka.util.Timer(function(){t=!0;y.abort()}));return y}).chain(function(w){q&&q.stop();r&&r.stop();w.timeMs==void 0&&(w.timeMs=Date.now()-v);var x=w.headers[shaka.net.NetworkingEngine.CommonAccessTokenHeaderName_];
if(x){var y=new goog.Uri(w.uri);h.hostCommonAccessTokenMap_.set(y.getDomain(),x)}x={response:w,gotProgress:m};if(!u&&h.onHeadersReceived_)h.onHeadersReceived_(w.headers,b,a);if(h.onDownloadCompleted_)h.onDownloadCompleted_(b,w);return x},function(w){q&&q.stop();r&&r.stop();if(h.onDownloadFailed_){var x=null,y=0;w instanceof shaka.util.Error&&(x=w,w.code==shaka.util.Error.Code.BAD_HTTP_STATUS&&(y=w.data[1]));h.onDownloadFailed_(b,x,y,t)}if(h.destroyed_)return shaka.util.AbortableOperation.aborted();
t&&(w=new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.NETWORK,shaka.util.Error.Code.TIMEOUT,b.uris[e],a));if(w instanceof shaka.util.Error){if(w.code==shaka.util.Error.Code.OPERATION_ABORTED)throw w;if(w.code==shaka.util.Error.Code.ATTEMPTS_EXHAUSTED)throw goog.asserts.assert(f,"Should have last error"),f;if(w.severity==shaka.util.Error.Severity.RECOVERABLE){x=(new Map).set("error",w);x=new shaka.util.FakeEvent("retry",x);x.cancelable=!0;h.dispatchEvent(x);if(x.defaultPrevented)throw w;
e=(e+1)%b.uris.length;return h.send_(a,b,c,d,e,w,g)}}throw w;})};
shaka.net.NetworkingEngine.prototype.filterResponse_=function(a,b,c){for(var d=shaka.util.AbortableOperation.completed(void 0),e=(0,$jscomp.makeIterator)(this.responseFilters_),f=e.next(),g={};!f.done;g={responseFilter:void 0},f=e.next())g.responseFilter=f.value,d=d.chain(function(h){return function(){var k=b.response;k.data&&(k.data=shaka.util.BufferUtils.toArrayBuffer(k.data));return(0,h.responseFilter)(a,k,c)}}(g));return d.chain(function(){return b},function(h){var k=shaka.util.Error.Severity.CRITICAL;
if(h instanceof shaka.util.Error){if(h.code==shaka.util.Error.Code.OPERATION_ABORTED)throw h;k=h.severity}throw new shaka.util.Error(k,shaka.util.Error.Category.NETWORK,shaka.util.Error.Code.RESPONSE_FILTER_ERROR,h);})};shaka.net.NetworkingEngine.prototype.allowSwitch_=function(a){if(a){var b=a.segment;a=a.stream;if(b&&a&&a.fastSwitching&&b.isPartial())return!1}return!0};shaka.net.NetworkingEngine.getLocationProtocol_=function(){return location.protocol};
goog.exportSymbol("shaka.net.NetworkingEngine",shaka.net.NetworkingEngine);goog.exportProperty(shaka.net.NetworkingEngine.prototype,"request",shaka.net.NetworkingEngine.prototype.request);goog.exportProperty(shaka.net.NetworkingEngine.prototype,"destroy",shaka.net.NetworkingEngine.prototype.destroy);goog.exportProperty(shaka.net.NetworkingEngine,"makeRequest",shaka.net.NetworkingEngine.makeRequest);goog.exportProperty(shaka.net.NetworkingEngine,"defaultRetryParameters",shaka.net.NetworkingEngine.defaultRetryParameters);
goog.exportProperty(shaka.net.NetworkingEngine.prototype,"clearCommonAccessTokenMap",shaka.net.NetworkingEngine.prototype.clearCommonAccessTokenMap);goog.exportProperty(shaka.net.NetworkingEngine.prototype,"clearAllResponseFilters",shaka.net.NetworkingEngine.prototype.clearAllResponseFilters);goog.exportProperty(shaka.net.NetworkingEngine.prototype,"unregisterResponseFilter",shaka.net.NetworkingEngine.prototype.unregisterResponseFilter);
goog.exportProperty(shaka.net.NetworkingEngine.prototype,"registerResponseFilter",shaka.net.NetworkingEngine.prototype.registerResponseFilter);goog.exportProperty(shaka.net.NetworkingEngine.prototype,"clearAllRequestFilters",shaka.net.NetworkingEngine.prototype.clearAllRequestFilters);goog.exportProperty(shaka.net.NetworkingEngine.prototype,"unregisterRequestFilter",shaka.net.NetworkingEngine.prototype.unregisterRequestFilter);
goog.exportProperty(shaka.net.NetworkingEngine.prototype,"registerRequestFilter",shaka.net.NetworkingEngine.prototype.registerRequestFilter);goog.exportProperty(shaka.net.NetworkingEngine,"unregisterScheme",shaka.net.NetworkingEngine.unregisterScheme);goog.exportProperty(shaka.net.NetworkingEngine,"registerScheme",shaka.net.NetworkingEngine.registerScheme);goog.exportProperty(shaka.net.NetworkingEngine.prototype,"configure",shaka.net.NetworkingEngine.prototype.configure);
shaka.net.NetworkingEngine.NumBytesRemainingClass=function(){this.bytesToLoad_=0};shaka.net.NetworkingEngine.NumBytesRemainingClass.prototype.setBytes=function(a){this.bytesToLoad_=a};shaka.net.NetworkingEngine.NumBytesRemainingClass.prototype.getBytes=function(){return this.bytesToLoad_};goog.exportProperty(shaka.net.NetworkingEngine,"NumBytesRemainingClass",shaka.net.NetworkingEngine.NumBytesRemainingClass);
shaka.net.NetworkingEngine.PendingRequest=function(a,b,c){shaka.util.AbortableOperation.call(this,a,b);this.bytesRemaining_=c};$jscomp.inherits(shaka.net.NetworkingEngine.PendingRequest,shaka.util.AbortableOperation);shaka.net.NetworkingEngine.PendingRequest.prototype.getBytesRemaining=function(){return this.bytesRemaining_.getBytes()};goog.exportProperty(shaka.net.NetworkingEngine,"PendingRequest",shaka.net.NetworkingEngine.PendingRequest);
shaka.net.NetworkingEngine.CommonAccessTokenHeaderName_="common-access-token";shaka.net.NetworkingEngine.RequestType={MANIFEST:0,SEGMENT:1,LICENSE:2,APP:3,TIMING:4,SERVER_CERTIFICATE:5,KEY:6,ADS:7,CONTENT_STEERING:8,CMCD:9};goog.exportProperty(shaka.net.NetworkingEngine,"RequestType",shaka.net.NetworkingEngine.RequestType);
shaka.net.NetworkingEngine.AdvancedRequestType={INIT_SEGMENT:0,MEDIA_SEGMENT:1,MEDIA_PLAYLIST:2,MASTER_PLAYLIST:3,MPD:4,MSS:5,MPD_PATCH:6,MEDIATAILOR_SESSION_INFO:7,MEDIATAILOR_TRACKING_INFO:8,MEDIATAILOR_STATIC_RESOURCE:9,MEDIATAILOR_TRACKING_EVENT:10,INTERSTITIAL_ASSET_LIST:11,INTERSTITIAL_AD_URL:12};goog.exportProperty(shaka.net.NetworkingEngine,"AdvancedRequestType",shaka.net.NetworkingEngine.AdvancedRequestType);shaka.net.NetworkingEngine.PluginPriority={FALLBACK:1,PREFERRED:2,APPLICATION:3};
goog.exportProperty(shaka.net.NetworkingEngine,"PluginPriority",shaka.net.NetworkingEngine.PluginPriority);shaka.net.NetworkingEngine.schemes_=new Map;shaka.dash.MpdUtils=function(){};
shaka.dash.MpdUtils.fillUriTemplate=function(a,b,c,d,e,f){var g=(new Map).set("RepresentationID",b).set("Number",c).set("SubNumber",d).set("Bandwidth",e).set("Time",f);return a.replace(/\$(RepresentationID|Number|SubNumber|Bandwidth|Time)?(?:%0([0-9]+)([diouxX]))?\$/g,function(h,k,l,m){if(h=="$$")return"$";var n=g.get(k);goog.asserts.assert(n!==void 0,"Unrecognized identifier");if(n==null)return shaka.log.warning("URL template does not have an available substitution for ",'identifier "'+k+'":',a),
h;k=="RepresentationID"&&l&&(shaka.log.warning("URL template should not contain a width specifier for identifier",'"RepresentationID":',a),l=void 0);k=="Time"&&typeof n!="bigint"&&(goog.asserts.assert(typeof n=="number","Time value should be a number or bigint!"),Math.abs(n-Math.round(n))>=.2&&shaka.log.alwaysWarn("Calculated $Time$ values must be close to integers"),n=Math.round(n));switch(m){case void 0:case "d":case "i":case "u":h=n.toString();break;case "o":h=n.toString(8);break;case "x":h=n.toString(16);
break;case "X":h=n.toString(16).toUpperCase();break;default:goog.asserts.assert(!1,"Unhandled format specifier"),h=n.toString()}l=window.parseInt(l,10)||1;return Array(Math.max(0,l-h.length)+1).join("0")+h})};
shaka.dash.MpdUtils.createTimeline=function(a,b,c,d,e){goog.asserts.assert(b>0&&b<Infinity,"timescale must be a positive, finite integer");goog.asserts.assert(d>0,"period duration must be a positive integer");for(var f=shaka.util.TXml,g=[],h=-c,k=0;k<a.length;++k){var l=a[k],m=a[k+1],n=f.parseAttr(l,"t",f.parseNonNegativeInt),p=f.parseAttr(l,"d",f.parseNonNegativeInt),q=f.parseAttr(l,"r",f.parseInt),r=f.parseAttr(l,"k",f.parseInt)||0;n!=null&&(n-=c);if(p){n=n!=null?n:h;q=q||0;if(q<0)if(m){m=f.parseAttr(m,
"t",f.parseNonNegativeInt);if(m==null){shaka.log.warning('An "S" element cannot have a negative repeat','if the next "S" element does not have a valid start time:','ignoring the remaining "S" elements.',l);break}else if(n>=m){shaka.log.warning('An "S" element cannot have a negative repeat if its start ','time exceeds the next "S" element\'s start time:','ignoring the remaining "S" elements.',l);break}q=Math.ceil((m-n)/p)-1}else{if(d==Infinity){shaka.log.warning('The last "S" element cannot have a negative repeat',
"if the Period has an infinite duration:",'ignoring the last "S" element.',l);break}else if(n/b>=d){shaka.log.warning('The last "S" element cannot have a negative repeat',"if its start time exceeds the Period's duration:",'ignoring the last "S" element.',l);break}q=Math.ceil((d*b-n)/p)-1}g.length>0&&n!=h&&(Math.abs((n-h)/b)>=shaka.util.ManifestParserUtils.GAP_OVERLAP_TOLERANCE_SECONDS&&shaka.log.warning("SegmentTimeline contains a large gap/overlap:","the content may have errors in it.",l),g[g.length-
1].end=n/b);for(l=0;l<=q;++l)h=n+p,g.push({start:n/b,unscaledStart:n,end:h/b,unscaledEnd:h,partialSegments:r,segmentPosition:g.length+e}),n=h}else shaka.log.warning('"S" element must have a duration: ignoring this element.',l)}return g};
shaka.dash.MpdUtils.parseSegmentInfo=function(a,b){goog.asserts.assert(b(a.representation),"There must be at least one element of the given type.");var c=shaka.dash.MpdUtils,d=shaka.util.TXml,e=c.inheritAttribute(a,b,"timescale"),f=1;e&&(f=d.parsePositiveInt(e)||1);e=c.inheritAttribute(a,b,"duration");var g=(e=d.parsePositiveInt(e||""))?e/f:null,h=c.inheritAttribute(a,b,"startNumber"),k=Number(c.inheritAttribute(a,b,"presentationTimeOffset"))||0,l=d.parseNonNegativeInt(h||"");if(h==null||l==null)l=
1;h=null;if(b=c.inheritChild(a,b,"SegmentTimeline"))d=d.findChildren(b,"S"),h=c.createTimeline(d,f,k,a.periodInfo.duration||Infinity,l);return{timescale:f,unscaledSegmentDuration:e,segmentDuration:g,startNumber:l,scaledPresentationTimeOffset:k/f||0,unscaledPresentationTimeOffset:k,timeline:h}};
shaka.dash.MpdUtils.getNodes=function(a,b){var c=shaka.util.Functional;goog.asserts.assert(b(a.representation),"There must be at least one element of the given type.");return[b(a.representation),b(a.adaptationSet),b(a.period)].filter(c.isNotNull)};shaka.dash.MpdUtils.inheritAttribute=function(a,b,c){b=shaka.dash.MpdUtils.getNodes(a,b);a=null;b=(0,$jscomp.makeIterator)(b);for(var d=b.next();!d.done&&!(a=d.value.attributes[c]);d=b.next());return a};
shaka.dash.MpdUtils.inheritChild=function(a,b,c){var d=shaka.dash.MpdUtils.getNodes(a,b);a=shaka.util.TXml;b=null;d=(0,$jscomp.makeIterator)(d);for(var e=d.next();!e.done&&!(b=a.findChild(e.value,c));e=d.next());return b};
shaka.dash.MpdUtils.handleXlinkInElement_=function(a,b,c,d,e,f){for(var g=shaka.util.TXml,h=shaka.util.Error,k=shaka.util.ManifestParserUtils,l=shaka.dash.MpdUtils.XlinkNamespaceUri_,m=g.getAttributeNS(a,l,"href"),n=g.getAttributeNS(a,l,"actuate")||"onRequest",p=(0,$jscomp.makeIterator)(Object.keys(a.attributes)),q=p.next();!q.done;q=p.next()){q=q.value;var r=q.split(":"),t=shaka.util.TXml.getKnownNameSpace(l);r[0]==t&&delete a.attributes[q]}if(f>=5)return shaka.util.AbortableOperation.failed(new h(h.Severity.CRITICAL,
h.Category.MANIFEST,h.Code.DASH_XLINK_DEPTH_LIMIT));if(n!="onLoad")return shaka.util.AbortableOperation.failed(new h(h.Severity.CRITICAL,h.Category.MANIFEST,h.Code.DASH_UNSUPPORTED_XLINK_ACTUATE));var u=k.resolveUris([d],[m]);d=shaka.net.NetworkingEngine.RequestType.MANIFEST;k=shaka.net.NetworkingEngine.makeRequest(u,b);d=e.request(d,k);goog.asserts.assert(d instanceof shaka.util.AbortableOperation,"Unexpected implementation of IAbortableOperation!");return d.chain(function(v){v=g.parseXml(v.data,
a.tagName);if(!v)return shaka.util.AbortableOperation.failed(new h(h.Severity.CRITICAL,h.Category.MANIFEST,h.Code.DASH_INVALID_XML,m));for(a.children=[];v.children.length;){var w=v.children.shift();a.children.push(w)}w=(0,$jscomp.makeIterator)(Object.keys(v.attributes));for(var x=w.next();!x.done;x=w.next())x=x.value,a.attributes[x]=v.attributes[x];return shaka.dash.MpdUtils.processXlinks(a,b,c,u[0],e,f+1)})};
shaka.dash.MpdUtils.processXlinks=function(a,b,c,d,e,f){f=f===void 0?0:f;var g=shaka.dash.MpdUtils,h=shaka.util.TXml,k=g.XlinkNamespaceUri_;if(h.getAttributeNS(a,k,"href"))return h=g.handleXlinkInElement_(a,b,c,d,e,f),c&&(h=h.chain(void 0,function(q){return g.processXlinks(a,b,c,d,e,f)})),h;for(var l=[],m=(0,$jscomp.makeIterator)(shaka.util.TXml.getChildNodes(a)),n=m.next(),p={};!n.done;p={child$jscomp$10:void 0},n=m.next())p.child$jscomp$10=n.value,h.getAttributeNS(p.child$jscomp$10,k,"href")=="urn:mpeg:dash:resolve-to-zero:2013"?
a.children=a.children.filter(function(q){return function(r){return r!==q.child$jscomp$10}}(p)):p.child$jscomp$10.tagName!="SegmentTimeline"&&l.push(shaka.dash.MpdUtils.processXlinks(p.child$jscomp$10,b,c,d,e,f));return shaka.util.AbortableOperation.all(l).chain(function(){return a})};shaka.dash.MpdUtils.XlinkNamespaceUri_="http://www.w3.org/1999/xlink";shaka.media.InitSegmentReference=function(a,b,c,d,e,f,g,h){this.getUris=a;this.startByte=b;this.endByte=c;this.mediaQuality=d===void 0?null:d;this.timescale=e===void 0?null:e;this.segmentData=f===void 0?null:f;this.aesKey=g===void 0?null:g;this.boundaryEnd=this.mimeType=this.codecs=null;this.encrypted=h===void 0?!1:h};shaka.media.InitSegmentReference.prototype.getStartByte=function(){return this.startByte};shaka.media.InitSegmentReference.prototype.getEndByte=function(){return this.endByte};
shaka.media.InitSegmentReference.prototype.getSize=function(){return this.endByte?this.endByte+1-this.startByte:null};shaka.media.InitSegmentReference.prototype.getMediaQuality=function(){return this.mediaQuality};shaka.media.InitSegmentReference.prototype.setSegmentData=function(a){this.segmentData=a};shaka.media.InitSegmentReference.prototype.getSegmentData=function(){return this.segmentData};
shaka.media.InitSegmentReference.equal=function(a,b){var c=shaka.util.ArrayUtils,d=shaka.util.BufferUtils;return a===b?!0:a&&b?a.getStartByte()==b.getStartByte()&&a.getEndByte()==b.getEndByte()&&c.equal(a.getUris().sort(),b.getUris().sort())&&d.equal(a.getSegmentData(),b.getSegmentData()):a==b};goog.exportSymbol("shaka.media.InitSegmentReference",shaka.media.InitSegmentReference);goog.exportProperty(shaka.media.InitSegmentReference.prototype,"getEndByte",shaka.media.InitSegmentReference.prototype.getEndByte);
goog.exportProperty(shaka.media.InitSegmentReference.prototype,"getStartByte",shaka.media.InitSegmentReference.prototype.getStartByte);
shaka.media.SegmentReference=function(a,b,c,d,e,f,g,h,k,l,m,n,p,q,r,t){l=l===void 0?[]:l;m=m===void 0?"":m;n=n===void 0?null:n;p=p===void 0?null:p;q=q===void 0?shaka.media.SegmentReference.Status.AVAILABLE:q;r=r===void 0?null:r;t=t===void 0?!1:t;goog.asserts.assert(a<=b,"startTime must be less than or equal to endTime");goog.asserts.assert(e==null||d<e,"startByte must be < endByte");this.startTime=a;this.trueEndTime=this.endTime=b;this.getUrisInner=c;this.startByte=d;this.endByte=e;this.initSegmentReference=
f;this.timestampOffset=g;this.appendWindowStart=h;this.appendWindowEnd=k;this.partialReferences=l;this.tilesLayout=m;this.tileDuration=n;this.syncTime=p;this.status=q;this.preload=!1;this.independent=!0;this.byterangeOptimization=!1;this.aesKey=r;this.thumbnailSprite=null;this.discontinuitySequence=-1;this.allPartialSegments=t;this.lastPartial=this.partial=!1;a=(0,$jscomp.makeIterator)(this.partialReferences);for(b=a.next();!b.done;b=a.next())b.value.markAsPartial();this.allPartialSegments&&this.partialReferences.length&&
this.partialReferences[this.partialReferences.length-1].markAsLastPartial();this.segmentData=this.bandwidth=this.mimeType=this.codecs=null;this.removeSegmentDataOnGet=!1};shaka.media.SegmentReference.prototype.getUris=function(){return this.getUrisInner()};shaka.media.SegmentReference.prototype.getStartTime=function(){return this.startTime};shaka.media.SegmentReference.prototype.getEndTime=function(){return this.endTime};shaka.media.SegmentReference.prototype.getStartByte=function(){return this.startByte};
shaka.media.SegmentReference.prototype.getEndByte=function(){return this.endByte};shaka.media.SegmentReference.prototype.getSize=function(){if(this.endByte)return this.endByte+1-this.startByte;if(this.bandwidth){var a=this.bandwidth*(this.endTime-this.startTime);if(!isNaN(a)&&a>0)return a}if(this.hasPartialSegments()&&this.hasAllPartialSegments())for(a=(0,$jscomp.makeIterator)(this.partialReferences),a=a.next();!a.done;a=a.next()){a.value.getSize();break}return null};
shaka.media.SegmentReference.prototype.hasPartialSegments=function(){return this.partialReferences.length>0};shaka.media.SegmentReference.prototype.hasAllPartialSegments=function(){return this.allPartialSegments};shaka.media.SegmentReference.prototype.getTilesLayout=function(){return this.tilesLayout};shaka.media.SegmentReference.prototype.getTileDuration=function(){return this.tileDuration};shaka.media.SegmentReference.prototype.getStatus=function(){return this.status};
shaka.media.SegmentReference.prototype.markAsUnavailable=function(){this.status=shaka.media.SegmentReference.Status.UNAVAILABLE};shaka.media.SegmentReference.prototype.markAsPreload=function(){this.preload=!0};shaka.media.SegmentReference.prototype.isPreload=function(){return this.preload};shaka.media.SegmentReference.prototype.markAsNonIndependent=function(){this.independent=!1};shaka.media.SegmentReference.prototype.isIndependent=function(){return this.independent};
shaka.media.SegmentReference.prototype.markAsPartial=function(){this.partial=!0};shaka.media.SegmentReference.prototype.isPartial=function(){return this.partial};shaka.media.SegmentReference.prototype.markAsLastPartial=function(){this.lastPartial=!0};shaka.media.SegmentReference.prototype.isLastPartial=function(){return this.lastPartial};shaka.media.SegmentReference.prototype.markAsByterangeOptimization=function(){this.byterangeOptimization=!0};
shaka.media.SegmentReference.prototype.hasByterangeOptimization=function(){return this.byterangeOptimization};shaka.media.SegmentReference.prototype.setThumbnailSprite=function(a){this.thumbnailSprite=a};shaka.media.SegmentReference.prototype.getThumbnailSprite=function(){return this.thumbnailSprite};
shaka.media.SegmentReference.prototype.offset=function(a){this.startTime+=a;this.endTime+=a;this.trueEndTime+=a;for(var b=(0,$jscomp.makeIterator)(this.partialReferences),c=b.next();!c.done;c=b.next())c=c.value,c.startTime+=a,c.endTime+=a,c.trueEndTime+=a};shaka.media.SegmentReference.prototype.syncAgainst=function(a){this.syncTime==null?shaka.log.alwaysError("Sync attempted without sync time!"):(a=this.syncTime-a-this.startTime,Math.abs(a)>=.001&&this.offset(a))};
shaka.media.SegmentReference.prototype.setSegmentData=function(a,b){this.segmentData=a;this.removeSegmentDataOnGet=b===void 0?!1:b};shaka.media.SegmentReference.prototype.getSegmentData=function(a){var b=this.segmentData;(a===void 0||a)&&this.removeSegmentDataOnGet&&(this.segmentData=null);return b};shaka.media.SegmentReference.prototype.updateInitSegmentReference=function(a){this.initSegmentReference=a;for(var b=(0,$jscomp.makeIterator)(this.partialReferences),c=b.next();!c.done;c=b.next())c.value.updateInitSegmentReference(a)};
goog.exportSymbol("shaka.media.SegmentReference",shaka.media.SegmentReference);goog.exportProperty(shaka.media.SegmentReference.prototype,"getSegmentData",shaka.media.SegmentReference.prototype.getSegmentData);goog.exportProperty(shaka.media.SegmentReference.prototype,"setSegmentData",shaka.media.SegmentReference.prototype.setSegmentData);goog.exportProperty(shaka.media.SegmentReference.prototype,"syncAgainst",shaka.media.SegmentReference.prototype.syncAgainst);
goog.exportProperty(shaka.media.SegmentReference.prototype,"offset",shaka.media.SegmentReference.prototype.offset);goog.exportProperty(shaka.media.SegmentReference.prototype,"getThumbnailSprite",shaka.media.SegmentReference.prototype.getThumbnailSprite);goog.exportProperty(shaka.media.SegmentReference.prototype,"setThumbnailSprite",shaka.media.SegmentReference.prototype.setThumbnailSprite);goog.exportProperty(shaka.media.SegmentReference.prototype,"hasByterangeOptimization",shaka.media.SegmentReference.prototype.hasByterangeOptimization);
goog.exportProperty(shaka.media.SegmentReference.prototype,"markAsByterangeOptimization",shaka.media.SegmentReference.prototype.markAsByterangeOptimization);goog.exportProperty(shaka.media.SegmentReference.prototype,"isLastPartial",shaka.media.SegmentReference.prototype.isLastPartial);goog.exportProperty(shaka.media.SegmentReference.prototype,"markAsLastPartial",shaka.media.SegmentReference.prototype.markAsLastPartial);goog.exportProperty(shaka.media.SegmentReference.prototype,"isPartial",shaka.media.SegmentReference.prototype.isPartial);
goog.exportProperty(shaka.media.SegmentReference.prototype,"markAsPartial",shaka.media.SegmentReference.prototype.markAsPartial);goog.exportProperty(shaka.media.SegmentReference.prototype,"isIndependent",shaka.media.SegmentReference.prototype.isIndependent);goog.exportProperty(shaka.media.SegmentReference.prototype,"markAsNonIndependent",shaka.media.SegmentReference.prototype.markAsNonIndependent);goog.exportProperty(shaka.media.SegmentReference.prototype,"isPreload",shaka.media.SegmentReference.prototype.isPreload);
goog.exportProperty(shaka.media.SegmentReference.prototype,"markAsPreload",shaka.media.SegmentReference.prototype.markAsPreload);goog.exportProperty(shaka.media.SegmentReference.prototype,"markAsUnavailable",shaka.media.SegmentReference.prototype.markAsUnavailable);goog.exportProperty(shaka.media.SegmentReference.prototype,"getStatus",shaka.media.SegmentReference.prototype.getStatus);goog.exportProperty(shaka.media.SegmentReference.prototype,"getTileDuration",shaka.media.SegmentReference.prototype.getTileDuration);
goog.exportProperty(shaka.media.SegmentReference.prototype,"getTilesLayout",shaka.media.SegmentReference.prototype.getTilesLayout);goog.exportProperty(shaka.media.SegmentReference.prototype,"getEndByte",shaka.media.SegmentReference.prototype.getEndByte);goog.exportProperty(shaka.media.SegmentReference.prototype,"getStartByte",shaka.media.SegmentReference.prototype.getStartByte);goog.exportProperty(shaka.media.SegmentReference.prototype,"getEndTime",shaka.media.SegmentReference.prototype.getEndTime);
goog.exportProperty(shaka.media.SegmentReference.prototype,"getStartTime",shaka.media.SegmentReference.prototype.getStartTime);goog.exportProperty(shaka.media.SegmentReference.prototype,"getUris",shaka.media.SegmentReference.prototype.getUris);shaka.media.SegmentReference.Status={AVAILABLE:0,UNAVAILABLE:1,MISSING:2};goog.exportProperty(shaka.media.SegmentReference,"Status",shaka.media.SegmentReference.Status);shaka.dash.Mp4SegmentIndexParser=function(){};shaka.dash.Mp4SegmentIndexParser.parse=function(a,b,c,d,e,f,g,h){var k=shaka.dash.Mp4SegmentIndexParser,l,m=(new shaka.util.Mp4Parser).fullBox("sidx",function(n){l=k.parseSIDX_(b,d,e,f,g,c,n,h)});a&&m.parse(a);if(l)return l;shaka.log.error('Invalid box type, expected "sidx".');throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.MP4_SIDX_WRONG_BOX_TYPE);};
shaka.dash.Mp4SegmentIndexParser.parseSIDX_=function(a,b,c,d,e,f,g,h){h=h===void 0?!1:h;goog.asserts.assert(g.version!=null,"SIDX is a full box and should have a valid version.");var k=[];g.reader.skip(4);var l=g.reader.readUint32();if(l==0)throw shaka.log.error("Invalid timescale."),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.MP4_SIDX_INVALID_TIMESCALE);if(g.version==0){var m=g.reader.readUint32();var n=g.reader.readUint32()}else m=
g.reader.readUint64(),n=g.reader.readUint64();g.reader.skip(2);var p=g.reader.readUint16();a=(h?-g.size:a)+g.size+n;for(h=0;h<p;h++){var q=g.reader.readUint32();n=(q&2147483648)>>>31;q&=2147483647;var r=g.reader.readUint32();g.reader.skip(4);if(n==1)throw shaka.log.error("Hierarchical SIDXs are not supported."),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.MP4_SIDX_TYPE_NOT_SUPPORTED);k.push(new shaka.media.SegmentReference(m/l+c,(m+
r)/l+c,function(){return f},a,a+q-1,b,c,d,e));m+=r;a+=q}g.parser.stop();return k};shaka.dash.EbmlParser=function(a){this.dataView_=shaka.util.BufferUtils.toDataView(a);this.reader_=new shaka.util.DataViewReader(this.dataView_,shaka.util.DataViewReader.Endianness.BIG_ENDIAN)};shaka.dash.EbmlParser.prototype.hasMoreData=function(){return this.reader_.hasMoreData()};
shaka.dash.EbmlParser.prototype.parseElement=function(){var a=this.parseId_(),b=this.parseVint_();b=shaka.dash.EbmlParser.isDynamicSizeValue_(b)?this.dataView_.byteLength-this.reader_.getPosition():shaka.dash.EbmlParser.getVintValue_(b);b=this.reader_.getPosition()+b<=this.dataView_.byteLength?b:this.dataView_.byteLength-this.reader_.getPosition();var c=shaka.util.BufferUtils.toDataView(this.dataView_,this.reader_.getPosition(),b);this.reader_.skip(b);return new shaka.util.EbmlElement(a,c)};
shaka.dash.EbmlParser.prototype.parseId_=function(){var a=this.parseVint_();if(a.length>7)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.EBML_OVERFLOW);var b=0;a=(0,$jscomp.makeIterator)(a);for(var c=a.next();!c.done;c=a.next())b=256*b+c.value;return b};
shaka.dash.EbmlParser.prototype.parseVint_=function(){var a=this.reader_.getPosition(),b=this.reader_.readUint8();if(b==0)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.EBML_OVERFLOW);b=8-Math.floor(Math.log2(b));goog.asserts.assert(b<=8&&b>=1,"Incorrect log2 value");this.reader_.skip(b-1);return shaka.util.BufferUtils.toUint8(this.dataView_,a,b)};
shaka.dash.EbmlParser.getVintValue_=function(a){if(a.length==8&&a[1]&224)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.JS_INTEGER_OVERFLOW);for(var b=0,c=0;c<a.length;c++){var d=a[c];b=c==0?d&(1<<8-a.length)-1:256*b+d}return b};
shaka.dash.EbmlParser.isDynamicSizeValue_=function(a){for(var b=shaka.util.BufferUtils,c=(0,$jscomp.makeIterator)(shaka.dash.EbmlParser.DYNAMIC_SIZES),d=c.next();!d.done;d=c.next())if(b.equal(a,new Uint8Array(d.value)))return!0;return!1};shaka.dash.EbmlParser.DYNAMIC_SIZES=[[255],[127,255],[63,255,255],[31,255,255,255],[15,255,255,255,255],[7,255,255,255,255,255],[3,255,255,255,255,255,255],[1,255,255,255,255,255,255,255]];shaka.util.EbmlElement=function(a,b){this.id=a;this.dataView_=b};
shaka.util.EbmlElement.prototype.getOffset=function(){return this.dataView_.byteOffset};shaka.util.EbmlElement.prototype.createParser=function(){return new shaka.dash.EbmlParser(this.dataView_)};
shaka.util.EbmlElement.prototype.getUint=function(){if(this.dataView_.byteLength>8)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.EBML_OVERFLOW);if(this.dataView_.byteLength==8&&this.dataView_.getUint8(0)&224)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.JS_INTEGER_OVERFLOW);for(var a=0,b=0;b<this.dataView_.byteLength;b++){var c=this.dataView_.getUint8(b);a=256*
a+c}return a};shaka.util.EbmlElement.prototype.getFloat=function(){if(this.dataView_.byteLength==4)return this.dataView_.getFloat32(0);if(this.dataView_.byteLength==8)return this.dataView_.getFloat64(0);throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.EBML_BAD_FLOATING_POINT_SIZE);};shaka.dash.WebmSegmentIndexParser=function(){};
shaka.dash.WebmSegmentIndexParser.parse=function(a,b,c,d,e,f,g){b=shaka.dash.WebmSegmentIndexParser.parseWebmContainer_(b);a=(new shaka.dash.EbmlParser(a)).parseElement();if(a.id!=shaka.dash.WebmSegmentIndexParser.CUES_ID)throw shaka.log.error("Not a Cues element."),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.WEBM_CUES_ELEMENT_MISSING);return shaka.dash.WebmSegmentIndexParser.parseCues_(a,b.segmentOffset,b.timecodeScale,b.duration,
c,d,e,f,g)};
shaka.dash.WebmSegmentIndexParser.parseWebmContainer_=function(a){a=new shaka.dash.EbmlParser(a);if(a.parseElement().id!=shaka.dash.WebmSegmentIndexParser.EBML_ID)throw shaka.log.error("Not an EBML element."),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.WEBM_EBML_HEADER_ELEMENT_MISSING);var b=a.parseElement();if(b.id!=shaka.dash.WebmSegmentIndexParser.SEGMENT_ID)throw shaka.log.error("Not a Segment element."),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,
shaka.util.Error.Code.WEBM_SEGMENT_ELEMENT_MISSING);a=b.getOffset();b=shaka.dash.WebmSegmentIndexParser.parseSegment_(b);return{segmentOffset:a,timecodeScale:b.timecodeScale,duration:b.duration}};
shaka.dash.WebmSegmentIndexParser.parseSegment_=function(a){a=a.createParser();for(var b=null;a.hasMoreData();){var c=a.parseElement();if(c.id==shaka.dash.WebmSegmentIndexParser.INFO_ID){b=c;break}}if(!b)throw shaka.log.error("Not an Info element."),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.WEBM_INFO_ELEMENT_MISSING);return shaka.dash.WebmSegmentIndexParser.parseInfo_(b)};
shaka.dash.WebmSegmentIndexParser.parseInfo_=function(a){var b=a.createParser(),c=1E6;for(a=null;b.hasMoreData();){var d=b.parseElement();d.id==shaka.dash.WebmSegmentIndexParser.TIMECODE_SCALE_ID?c=d.getUint():d.id==shaka.dash.WebmSegmentIndexParser.DURATION_ID&&(a=d.getFloat())}if(a==null)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.WEBM_DURATION_ELEMENT_MISSING);b=c/1E9;return{timecodeScale:b,duration:a*b}};
shaka.dash.WebmSegmentIndexParser.parseCues_=function(a,b,c,d,e,f,g,h,k){var l=[],m=function(){return e};a=a.createParser();for(var n=null,p=null;a.hasMoreData();){var q=a.parseElement();if(q.id==shaka.dash.WebmSegmentIndexParser.CUE_POINT_ID){var r=shaka.dash.WebmSegmentIndexParser.parseCuePoint_(q);r&&(q=c*r.unscaledTime,r=b+r.relativeOffset,n!=null&&(goog.asserts.assert(p!=null,"last offset cannot be null"),l.push(new shaka.media.SegmentReference(n+g,q+g,m,p,r-1,f,g,h,k))),n=q,p=r)}}n!=null&&(goog.asserts.assert(p!=
null,"last offset cannot be null"),l.push(new shaka.media.SegmentReference(n+g,d+g,m,p,null,f,g,h,k)));return l};
shaka.dash.WebmSegmentIndexParser.parseCuePoint_=function(a){var b=a.createParser();a=b.parseElement();if(a.id!=shaka.dash.WebmSegmentIndexParser.CUE_TIME_ID)throw shaka.log.warning("Not a CueTime element."),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.WEBM_CUE_TIME_ELEMENT_MISSING);a=a.getUint();b=b.parseElement();if(b.id!=shaka.dash.WebmSegmentIndexParser.CUE_TRACK_POSITIONS_ID)throw shaka.log.warning("Not a CueTrackPositions element."),
new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.WEBM_CUE_TRACK_POSITIONS_ELEMENT_MISSING);b=b.createParser();for(var c=0;b.hasMoreData();){var d=b.parseElement();if(d.id==shaka.dash.WebmSegmentIndexParser.CUE_CLUSTER_POSITION){c=d.getUint();break}}return{unscaledTime:a,relativeOffset:c}};shaka.dash.WebmSegmentIndexParser.EBML_ID=440786851;shaka.dash.WebmSegmentIndexParser.SEGMENT_ID=408125543;shaka.dash.WebmSegmentIndexParser.INFO_ID=357149030;
shaka.dash.WebmSegmentIndexParser.TIMECODE_SCALE_ID=2807729;shaka.dash.WebmSegmentIndexParser.DURATION_ID=17545;shaka.dash.WebmSegmentIndexParser.CUES_ID=475249515;shaka.dash.WebmSegmentIndexParser.CUE_POINT_ID=187;shaka.dash.WebmSegmentIndexParser.CUE_TIME_ID=179;shaka.dash.WebmSegmentIndexParser.CUE_TRACK_POSITIONS_ID=183;shaka.dash.WebmSegmentIndexParser.CUE_CLUSTER_POSITION=241;shaka.media.SegmentIndex=function(a){goog.DEBUG&&shaka.media.SegmentIndex.assertCorrectReferences_(a);this.references=a;this.timer_=null;this.numEvicted_=0;this.immutable_=!1};shaka.media.SegmentIndex.prototype.getIsImmutable=function(){return this.immutable_};shaka.media.SegmentIndex.prototype.getNumReferences=function(){return this.references.length};shaka.media.SegmentIndex.prototype.getNumEvicted=function(){return this.numEvicted_};
shaka.media.SegmentIndex.prototype.release=function(){this.immutable_||(this.references=[],this.timer_&&this.timer_.stop(),this.timer_=null)};shaka.media.SegmentIndex.prototype.markImmutable=function(){this.immutable_=!0};shaka.media.SegmentIndex.prototype.forEachTopLevelReference=function(a){for(var b=(0,$jscomp.makeIterator)(this.references),c=b.next();!c.done;c=b.next())a(c.value)};shaka.media.SegmentIndex.prototype.earliestReference=function(){return this.references[0]||null};
shaka.media.SegmentIndex.prototype.dropFirstReferences=function(a){this.references.splice(0,a)};shaka.media.SegmentIndex.prototype.find=function(a){var b=this.references.length-1;if(b<0)return null;if(a<this.references[0].startTime)return this.numEvicted_;var c=shaka.util.ArrayUtils.binarySearch(this.references,function(e){return e.startTime<=a})-1;if(c<0)return null;var d=this.references[c];b=c<b?this.references[c+1].startTime:d.endTime;return a>=d.startTime&&a<b?c+this.numEvicted_:null};
shaka.media.SegmentIndex.prototype.get=function(a){if(this.references.length==0)return null;a-=this.numEvicted_;return a<0||a>=this.references.length?null:this.references[a]};shaka.media.SegmentIndex.prototype.offset=function(a){if(!this.immutable_)for(var b=(0,$jscomp.makeIterator)(this.references),c=b.next();!c.done;c=b.next())c.value.offset(a)};
shaka.media.SegmentIndex.prototype.merge=function(a){goog.DEBUG&&shaka.media.SegmentIndex.assertCorrectReferences_(a);if(!this.immutable_&&a.length){var b=Math.round(a[0].startTime*1E3)/1E3,c=shaka.util.ArrayUtils.binarySearch(this.references,function(d){return Math.round(d.startTime*1E3)/1E3<b});this.references.length=c;this.references.push.apply(this.references,(0,$jscomp.arrayFromIterable)(a));goog.DEBUG&&shaka.media.SegmentIndex.assertCorrectReferences_(this.references)}};
shaka.media.SegmentIndex.prototype.mergeAndEvict=function(a,b){for(var c=Math.max(b,this.references.length>0?this.references[0].startTime:-Infinity),d=0;d<a.length&&a[d].endTime<=c;)d++;d>0&&(a=a.slice(d));c=this.references[0];this.merge(a);a=this.references[0];c&&goog.asserts.assert(c.startTime==a.startTime,"SegmentIndex.merge should not change the first reference time!");this.evict(b)};
shaka.media.SegmentIndex.prototype.evict=function(a){if(!this.immutable_){var b=shaka.util.ArrayUtils.binarySearch(this.references,function(c){return c.endTime<=a});b>0&&(this.numEvicted_+=b,this.references=this.references.slice(b))}};
shaka.media.SegmentIndex.prototype.fit=function(a,b,c){c=c===void 0?!1:c;goog.asserts.assert(b!=null,"Content duration must be known for static content!");goog.asserts.assert(b!=Infinity,"Content duration must be finite for static content!");if(!this.immutable_){for(;this.references.length;)if(this.references[this.references.length-1].startTime>=b)this.references.pop();else break;var d=shaka.util.ArrayUtils.binarySearch(this.references,function(e){return e.endTime<=a});d>0&&(c||(this.numEvicted_+=
d),this.references=this.references.slice(d));this.references.length!=0&&(c=this.references[this.references.length-1],b=new shaka.media.SegmentReference(c.startTime,b,c.getUrisInner,c.startByte,c.endByte,c.initSegmentReference,c.timestampOffset,c.appendWindowStart,c.appendWindowEnd,c.partialReferences,c.tilesLayout,c.tileDuration,c.syncTime,c.status,c.aesKey),b.mimeType=c.mimeType,b.codecs=c.codecs,b.discontinuitySequence=c.discontinuitySequence,this.references[this.references.length-1]=b)}};
shaka.media.SegmentIndex.prototype.updateEvery=function(a,b){var c=this;goog.asserts.assert(!this.timer_,"SegmentIndex timer already started!");this.immutable_||(this.timer_&&this.timer_.stop(),this.timer_=new shaka.util.Timer(function(){var d=b();d?c.references.push.apply(c.references,(0,$jscomp.arrayFromIterable)(d)):(c.timer_.stop(),c.timer_=null)}),this.timer_.tickEvery(a))};
shaka.media.SegmentIndex.prototype[Symbol.iterator]=function(){var a=this.getIteratorForTime(0);goog.asserts.assert(a!=null,"Iterator for 0 should never be null!");return a};
shaka.media.SegmentIndex.prototype.getIteratorForTime=function(a,b,c){b=b===void 0?!1:b;c=c===void 0?!1:c;var d=this.find(a);if(d==null)return null;var e=this.get(d);c?d++:d--;var f=-1;if(e&&e.hasPartialSegments())for(var g=e.partialReferences.length-1;g>=0;--g){var h=e.partialReferences[g];if(a>=h.startTime&&a<h.endTime){if(!b){for(;g&&!h.isIndependent();)g--,h=e.partialReferences[g];if(!h.isIndependent())return shaka.log.alwaysError("No independent partial segment found!"),null}c?d--:d++;f=g-1;
break}}return new shaka.media.SegmentIterator(this,d,f,c)};shaka.media.SegmentIndex.prototype.isEmpty=function(){return this.getNumReferences()==0};shaka.media.SegmentIndex.prototype.continuityTimeline=function(){return-1};shaka.media.SegmentIndex.forSingleSegment=function(a,b,c){a=new shaka.media.SegmentReference(a,a+b,function(){return c},0,null,null,a,a,a+b);return new shaka.media.SegmentIndex([a])};goog.exportSymbol("shaka.media.SegmentIndex",shaka.media.SegmentIndex);
goog.exportProperty(shaka.media.SegmentIndex,"forSingleSegment",shaka.media.SegmentIndex.forSingleSegment);goog.exportProperty(shaka.media.SegmentIndex.prototype,"getIteratorForTime",shaka.media.SegmentIndex.prototype.getIteratorForTime);goog.exportProperty(shaka.media.SegmentIndex.prototype,"updateEvery",shaka.media.SegmentIndex.prototype.updateEvery);goog.exportProperty(shaka.media.SegmentIndex.prototype,"fit",shaka.media.SegmentIndex.prototype.fit);
goog.exportProperty(shaka.media.SegmentIndex.prototype,"evict",shaka.media.SegmentIndex.prototype.evict);goog.exportProperty(shaka.media.SegmentIndex.prototype,"mergeAndEvict",shaka.media.SegmentIndex.prototype.mergeAndEvict);goog.exportProperty(shaka.media.SegmentIndex.prototype,"offset",shaka.media.SegmentIndex.prototype.offset);goog.exportProperty(shaka.media.SegmentIndex.prototype,"get",shaka.media.SegmentIndex.prototype.get);goog.exportProperty(shaka.media.SegmentIndex.prototype,"find",shaka.media.SegmentIndex.prototype.find);
goog.exportProperty(shaka.media.SegmentIndex.prototype,"markImmutable",shaka.media.SegmentIndex.prototype.markImmutable);goog.exportProperty(shaka.media.SegmentIndex.prototype,"release",shaka.media.SegmentIndex.prototype.release);goog.exportProperty(shaka.media.SegmentIndex.prototype,"getNumEvicted",shaka.media.SegmentIndex.prototype.getNumEvicted);goog.exportProperty(shaka.media.SegmentIndex.prototype,"getNumReferences",shaka.media.SegmentIndex.prototype.getNumReferences);
goog.DEBUG&&(shaka.media.SegmentIndex.assertCorrectReferences_=function(a){goog.asserts.assert(a.every(function(b,c){if(c==0)return!0;c=a[c-1];return c.startTime<b.startTime?!0:c.startTime>b.startTime?!1:c.endTime<=b.endTime?!0:!1}),"SegmentReferences are incorrect")});shaka.media.SegmentIterator=function(a,b,c,d){this.segmentIndex_=a;this.currentPosition_=b;this.currentPartialPosition_=c;this.reverse=d};shaka.media.SegmentIterator.prototype.setReverse=function(a){this.reverse=a};
shaka.media.SegmentIterator.prototype.currentPosition=function(){return this.currentPosition_};
shaka.media.SegmentIterator.prototype.current=function(){var a=this.segmentIndex_.get(this.currentPosition_);a&&a.hasPartialSegments()&&a.hasAllPartialSegments()&&this.currentPartialPosition_>=a.partialReferences.length&&(this.currentPosition_++,this.currentPartialPosition_=0,a=this.segmentIndex_.get(this.currentPosition_));return a&&a.hasPartialSegments()?a.partialReferences[this.currentPartialPosition_]:a};
shaka.media.SegmentIterator.prototype.next=function(){var a=this.segmentIndex_.get(this.currentPosition_);this.reverse?a&&a.hasPartialSegments()?(this.currentPartialPosition_--,this.currentPartialPosition_<0&&(this.currentPosition_--,(a=this.segmentIndex_.get(this.currentPosition_))&&a.hasPartialSegments()?this.currentPartialPosition_=a.partialReferences.length-1:this.currentPartialPosition_=0)):(this.currentPosition_--,this.currentPartialPosition_=0):a&&a.hasPartialSegments()?(this.currentPartialPosition_++,
a.hasAllPartialSegments()&&this.currentPartialPosition_==a.partialReferences.length&&(this.currentPosition_++,this.currentPartialPosition_=0)):(this.currentPosition_++,this.currentPartialPosition_=0);a=this.current();return{value:a,done:!a}};
shaka.media.SegmentIterator.prototype.resetToLastIndependent=function(){var a=this.current();if(a&&a.isPartial()&&!a.isIndependent()&&(a=this.segmentIndex_.get(this.currentPosition_))&&a.hasPartialSegments())for(var b=a.partialReferences[this.currentPartialPosition_];b.isIndependent()&&!(this.currentPartialPosition_<=0);)this.currentPartialPosition_--,b=a.partialReferences[this.currentPartialPosition_]};goog.exportSymbol("shaka.media.SegmentIterator",shaka.media.SegmentIterator);
goog.exportProperty(shaka.media.SegmentIterator.prototype,"resetToLastIndependent",shaka.media.SegmentIterator.prototype.resetToLastIndependent);goog.exportProperty(shaka.media.SegmentIterator.prototype,"next",shaka.media.SegmentIterator.prototype.next);goog.exportProperty(shaka.media.SegmentIterator.prototype,"current",shaka.media.SegmentIterator.prototype.current);goog.exportProperty(shaka.media.SegmentIterator.prototype,"currentPosition",shaka.media.SegmentIterator.prototype.currentPosition);
goog.exportProperty(shaka.media.SegmentIterator.prototype,"setReverse",shaka.media.SegmentIterator.prototype.setReverse);shaka.media.MetaSegmentIndex=function(){shaka.media.SegmentIndex.call(this,[]);this.indexes_=[]};$jscomp.inherits(shaka.media.MetaSegmentIndex,shaka.media.SegmentIndex);shaka.media.MetaSegmentIndex.prototype.appendSegmentIndex=function(a){goog.asserts.assert(this.indexes_.length==0||a.getNumEvicted()==0,"Should not append a new segment index with already-evicted segments");this.indexes_.push(a)};
shaka.media.MetaSegmentIndex.prototype.clone=function(){var a=new shaka.media.MetaSegmentIndex;a.indexes_=this.indexes_.slice();a.numEvicted_=this.numEvicted_;return a};shaka.media.MetaSegmentIndex.prototype.release=function(){this.indexes_=[]};shaka.media.MetaSegmentIndex.prototype.forEachTopLevelReference=function(a){for(var b=(0,$jscomp.makeIterator)(this.indexes_),c=b.next();!c.done;c=b.next())c.value.forEachTopLevelReference(a)};
shaka.media.MetaSegmentIndex.prototype.forEachIndex=function(a){for(var b=(0,$jscomp.makeIterator)(this.indexes_),c=b.next();!c.done;c=b.next())a(c.value)};shaka.media.MetaSegmentIndex.prototype.find=function(a){for(var b=this.numEvicted_,c=(0,$jscomp.makeIterator)(this.indexes_),d=c.next();!d.done;d=c.next()){d=d.value;var e=d.find(a);if(e!=null)return e+b;b+=d.getNumEvicted()+d.getNumReferences()}return null};
shaka.media.MetaSegmentIndex.prototype.getTimelineForTime=function(a){for(var b=(0,$jscomp.makeIterator)(this.indexes_),c=b.next();!c.done;c=b.next())if(c=c.value,c.find(a)!=null)return c.continuityTimeline();return-1};
shaka.media.MetaSegmentIndex.prototype.get=function(a){for(var b=this.numEvicted_,c=!1,d=(0,$jscomp.makeIterator)(this.indexes_),e=d.next();!e.done;e=d.next()){e=e.value;goog.asserts.assert(!c||e.getNumEvicted()==0,"Should not see evicted segments after available segments");var f=e.get(a-b);if(f)return f;f=e.getNumReferences();b+=e.getNumEvicted()+f;c=c||f!=0}return null};shaka.media.MetaSegmentIndex.prototype.offset=function(a){goog.asserts.assert(!1,"offset() should not be used in MetaSegmentIndex!")};
shaka.media.MetaSegmentIndex.prototype.merge=function(a){goog.asserts.assert(!1,"merge() should not be used in MetaSegmentIndex!")};shaka.media.MetaSegmentIndex.prototype.evict=function(a){if(this.indexes_.length){var b=this.indexes_[0];b.evict(a);b.isEmpty()&&(this.indexes_.shift(),this.numEvicted_+=b.getNumEvicted(),b.release(),this.evict(a))}};shaka.media.MetaSegmentIndex.prototype.mergeAndEvict=function(a,b){goog.asserts.assert(!1,"mergeAndEvict() should not be used in MetaSegmentIndex!")};
shaka.media.MetaSegmentIndex.prototype.fit=function(a,b){goog.asserts.assert(!1,"fit() should not be used in MetaSegmentIndex!")};shaka.media.MetaSegmentIndex.prototype.updateEvery=function(a,b){goog.asserts.assert(!1,"updateEvery() should not be used in MetaSegmentIndex!")};goog.exportSymbol("shaka.media.MetaSegmentIndex",shaka.media.MetaSegmentIndex);goog.exportProperty(shaka.media.MetaSegmentIndex.prototype,"updateEvery",shaka.media.MetaSegmentIndex.prototype.updateEvery);
goog.exportProperty(shaka.media.MetaSegmentIndex.prototype,"fit",shaka.media.MetaSegmentIndex.prototype.fit);goog.exportProperty(shaka.media.MetaSegmentIndex.prototype,"mergeAndEvict",shaka.media.MetaSegmentIndex.prototype.mergeAndEvict);goog.exportProperty(shaka.media.MetaSegmentIndex.prototype,"evict",shaka.media.MetaSegmentIndex.prototype.evict);goog.exportProperty(shaka.media.MetaSegmentIndex.prototype,"merge",shaka.media.MetaSegmentIndex.prototype.merge);
goog.exportProperty(shaka.media.MetaSegmentIndex.prototype,"offset",shaka.media.MetaSegmentIndex.prototype.offset);goog.exportProperty(shaka.media.MetaSegmentIndex.prototype,"get",shaka.media.MetaSegmentIndex.prototype.get);goog.exportProperty(shaka.media.MetaSegmentIndex.prototype,"find",shaka.media.MetaSegmentIndex.prototype.find);goog.exportProperty(shaka.media.MetaSegmentIndex.prototype,"forEachTopLevelReference",shaka.media.MetaSegmentIndex.prototype.forEachTopLevelReference);
goog.exportProperty(shaka.media.MetaSegmentIndex.prototype,"release",shaka.media.MetaSegmentIndex.prototype.release);shaka.dash.SegmentBase=function(){};
shaka.dash.SegmentBase.createInitSegment=function(a,b,c){var d=shaka.util.TXml,e=shaka.util.ManifestParserUtils,f=shaka.util.StringUtils;b=shaka.dash.MpdUtils.inheritChild(a,b,"Initialization");if(!b)return null;var g=a.representation.getBaseUris(),h=b.attributes.sourceURL;h&&(g=e.resolveUris(g,[f.htmlUnescape(h)],a.urlParams()));e=0;f=null;if(d=d.parseAttr(b,"range",d.parseRange))e=d.start,f=d.end;d=shaka.dash.SegmentBase.createQualityInfo(a);c=new shaka.media.InitSegmentReference(function(){return g},e,
f,d,null,null,c,a.adaptationSet.encrypted);c.codecs=a.representation.codecs;c.mimeType=a.representation.mimeType;a.periodInfo&&!a.periodInfo.isLastPeriod&&(c.boundaryEnd=a.periodInfo.start+a.periodInfo.duration);return c};
shaka.dash.SegmentBase.createStreamInfo=function(a,b,c){goog.asserts.assert(a.representation.segmentBase,"Should only be called with SegmentBase");var d=shaka.dash.MpdUtils,e=shaka.dash.SegmentBase,f=shaka.util.TXml,g=Number(d.inheritAttribute(a,e.fromInheritance_,"presentationTimeOffset"))||0;d=d.inheritAttribute(a,e.fromInheritance_,"timescale");var h=1;d&&(h=f.parsePositiveInt(d)||1);var k=g/h||0,l=e.createInitSegment(a,e.fromInheritance_,c);e.checkSegmentIndexRangeSupport_(a,l);var m=shaka.util.ObjectUtils.shallowCloneObject(a);
return{endTime:-1,timeline:-1,generateSegmentIndex:function(){return e.generateSegmentIndex_(m,b,l,k)},timescale:h}};
shaka.dash.SegmentBase.generateSegmentIndexFromUris=function(a,b,c,d,e,f,g){var h,k,l,m,n,p,q,r,t,u,v,w,x,y,C,D,A,z,B,E;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(H){if(H.getNextAddressJsc()==1)return h=a.presentationTimeline,k=!a.dynamic||!a.periodInfo.isLastPeriod,l=a.periodInfo.start,m=a.periodInfo.duration,n=a.representation.mimeType.split("/")[1],p=b,q=null,r=[p(d,e,f,!1),n=="webm"?p(c.getUris(),c.startByte,c.endByte,!0):null],p=null,H.yield(Promise.all(r),2);t=H.getYieldResultJsc();
u=t[0];v=t[1]||null;w=null;x=l-g;y=l;C=m?l+m:Infinity;D=a.representation.getBaseUris();A=D.length!=d.length||D.some(function(N,F){return N!=d[F]});n=="mp4"?w=shaka.dash.Mp4SegmentIndexParser.parse(u,e,D,c,x,y,C,A):(goog.asserts.assert(v,"WebM requires init data"),w=shaka.dash.WebmSegmentIndexParser.parse(u,v,D,c,x,y,C));z=(0,$jscomp.makeIterator)(w);for(B=z.next();!B.done;B=z.next())E=B.value,E.codecs=a.representation.codecs,E.mimeType=a.representation.mimeType,E.bandwidth=a.bandwidth;h.notifySegments(w);
goog.asserts.assert(!q,"Should not call generateSegmentIndex twice");q=new shaka.media.SegmentIndex(w);k&&q.fit(y,C,!0);return H.return(q)})};shaka.dash.SegmentBase.fromInheritance_=function(a){return a.segmentBase};
shaka.dash.SegmentBase.computeIndexRange_=function(a){var b=shaka.dash.MpdUtils,c=shaka.dash.SegmentBase,d=shaka.util.TXml,e=b.inheritChild(a,c.fromInheritance_,"RepresentationIndex");a=b.inheritAttribute(a,c.fromInheritance_,"indexRange");a=d.parseRange(a||"");e&&(a=d.parseAttr(e,"range",d.parseRange,a));return a};
shaka.dash.SegmentBase.computeIndexUris_=function(a){var b=shaka.util.ManifestParserUtils,c=shaka.util.StringUtils,d=shaka.dash.MpdUtils.inheritChild(a,shaka.dash.SegmentBase.fromInheritance_,"RepresentationIndex"),e=a.representation.getBaseUris();d&&(c=c.htmlUnescape(d.attributes.sourceURL))&&(e=b.resolveUris(e,[c],a.urlParams()));return e};
shaka.dash.SegmentBase.checkSegmentIndexRangeSupport_=function(a,b){var c=shaka.dash.SegmentBase;c.checkSegmentIndexSupport(a,b);if(!c.computeIndexRange_(a))throw shaka.log.error("SegmentBase does not contain sufficient segment information:","the SegmentBase does not contain @indexRange","or a RepresentationIndex element.",a.representation),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_NO_SEGMENT_INFO);};
shaka.dash.SegmentBase.checkSegmentIndexSupport=function(a,b){var c=shaka.util.ManifestParserUtils.ContentType,d=a.representation.contentType,e=a.representation.mimeType.split("/")[1];if(d!=c.TEXT&&e!="mp4"&&e!="webm")throw shaka.log.error("SegmentBase specifies an unsupported container type.",a.representation),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_UNSUPPORTED_CONTAINER);if(e=="webm"&&!b)throw shaka.log.error("SegmentBase does not contain sufficient segment information:",
"the SegmentBase uses a WebM container,","but does not contain an Initialization element.",a.representation),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_WEBM_MISSING_INIT);};
shaka.dash.SegmentBase.generateSegmentIndex_=function(a,b,c,d){var e=shaka.dash.SegmentBase,f=e.computeIndexUris_(a);e=e.computeIndexRange_(a);goog.asserts.assert(e,"Index range should not be null!");return shaka.dash.SegmentBase.generateSegmentIndexFromUris(a,b,c,f,e.start,e.end,d)};
shaka.dash.SegmentBase.createQualityInfo=function(a){var b=a.representation;return{bandwidth:a.bandwidth,audioSamplingRate:b.audioSamplingRate,codecs:b.codecs,contentType:b.contentType,frameRate:b.frameRate||null,height:b.height||null,mimeType:b.mimeType,channelsCount:b.numChannels,pixelAspectRatio:b.pixelAspectRatio||null,width:b.width||null,label:a.adaptationSet.label||null,roles:a.roles||null,language:a.adaptationSet.language||null}};shaka.dash.SegmentList=function(){};
shaka.dash.SegmentList.createStreamInfo=function(a,b,c){goog.asserts.assert(a.representation.segmentList,"Should only be called with SegmentList");var d=shaka.dash.SegmentList,e=shaka.dash.SegmentBase.createInitSegment(a,d.fromInheritance_,c),f=d.parseSegmentListInfo_(a);d.checkSegmentListInfo_(a,f);var g=null,h=null;a.period.id&&a.representation.id&&(h=b.get(a.period.id+","+a.representation.id))&&(g=h.segmentIndex);var k=d.createSegmentReferences_(a.periodInfo.start,a.periodInfo.duration,f.startNumber,
a.representation.getBaseUris,f,e,c,a.representation.mimeType,a.representation.codecs,a.bandwidth,a.urlParams);b=!g;g?(c=a.presentationTimeline.getSegmentAvailabilityStart(),g.mergeAndEvict(k,c)):g=new shaka.media.SegmentIndex(k);a.presentationTimeline.notifySegments(k);a.dynamic&&a.periodInfo.isLastPeriod||g.fit(a.periodInfo.start,a.periodInfo.duration?a.periodInfo.start+a.periodInfo.duration:Infinity,b);h&&(h.segmentIndex=g);return{endTime:-1,timeline:-1,generateSegmentIndex:function(){g&&!g.isEmpty()||
g.merge(k);return Promise.resolve(g)},timescale:f.timescale}};shaka.dash.SegmentList.fromInheritance_=function(a){return a.segmentList};
shaka.dash.SegmentList.parseSegmentListInfo_=function(a){var b=shaka.dash.SegmentList,c=shaka.dash.MpdUtils,d=b.parseMediaSegments_(a);a=c.parseSegmentInfo(a,b.fromInheritance_);b=a.startNumber;b==0&&(shaka.log.warning("SegmentList@startNumber must be > 0"),b=1);c=0;a.segmentDuration?c=a.segmentDuration*(b-1):a.timeline&&a.timeline.length>0&&(c=a.timeline[0].start);return{segmentDuration:a.segmentDuration,startTime:c,startNumber:b,scaledPresentationTimeOffset:a.scaledPresentationTimeOffset,timescale:a.timescale,
timeline:a.timeline,mediaSegments:d}};
shaka.dash.SegmentList.checkSegmentListInfo_=function(a,b){if(!b.segmentDuration&&!b.timeline&&b.mediaSegments.length>1)throw shaka.log.warning("SegmentList does not contain sufficient segment information:","the SegmentList specifies multiple segments,","but does not specify a segment duration or timeline.",a.representation),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_NO_SEGMENT_INFO);if(!b.segmentDuration&&!a.periodInfo.duration&&
!b.timeline&&b.mediaSegments.length==1)throw shaka.log.warning("SegmentList does not contain sufficient segment information:","the SegmentList specifies one segment,","but does not specify a segment duration, period duration,","or timeline.",a.representation),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_NO_SEGMENT_INFO);if(b.timeline&&b.timeline.length==0)throw shaka.log.warning("SegmentList does not contain sufficient segment information:",
"the SegmentList has an empty timeline.",a.representation),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_NO_SEGMENT_INFO);};
shaka.dash.SegmentList.createSegmentReferences_=function(a,b,c,d,e,f,g,h,k,l,m){var n=shaka.util.ManifestParserUtils;c=e.mediaSegments.length;e.timeline&&e.timeline.length!=e.mediaSegments.length&&(c=Math.min(e.timeline.length,e.mediaSegments.length),shaka.log.warning("The number of items in the segment timeline and the number of ","segment URLs do not match, truncating",e.mediaSegments.length,"to",c));for(var p=a-e.scaledPresentationTimeOffset,q=b?a+b:Infinity,r=[],t=e.startTime,u={},v=0;v<c;u={uris$jscomp$10:void 0,
segment$jscomp$3:void 0},v++){u.segment$jscomp$3=e.mediaSegments[v];var w=t;t=void 0;e.segmentDuration!=null?t=w+e.segmentDuration:e.timeline?t=e.timeline[v].end:(goog.asserts.assert(e.mediaSegments.length==1&&b,"There should be exactly one segment with a Period duration."),t=w+b);u.uris$jscomp$10=null;var x=function(y){return function(){y.uris$jscomp$10==null&&(y.uris$jscomp$10=n.resolveUris(d(),[y.segment$jscomp$3.mediaUri],m()));return y.uris$jscomp$10}}(u);u=new shaka.media.SegmentReference(a+
w,a+t,x,u.segment$jscomp$3.start,u.segment$jscomp$3.end,f,p,a,q,[],"",null,null,shaka.media.SegmentReference.Status.AVAILABLE,g);u.codecs=k;u.mimeType=h;u.bandwidth=l;r.push(u)}return r};
shaka.dash.SegmentList.parseMediaSegments_=function(a){var b=[a.representation.segmentList,a.adaptationSet.segmentList,a.period.segmentList].filter(shaka.util.Functional.isNotNull),c=shaka.util.TXml,d=shaka.util.StringUtils;return b.map(function(e){return c.findChildren(e,"SegmentURL")}).reduce(function(e,f){return e.length>0?e:f}).map(function(e){e.attributes.indexRange&&!a.indexRangeWarningGiven&&(a.indexRangeWarningGiven=!0,shaka.log.warning("We do not support the SegmentURL@indexRange attribute on SegmentList.  We only use the SegmentList@duration attribute or SegmentTimeline, which must be accurate."));
var f=d.htmlUnescape(e.attributes.media);e=c.parseAttr(e,"mediaRange",c.parseRange,{start:0,end:null});return{mediaUri:f,start:e.start,end:e.end}})};shaka.dash.SegmentTemplate=function(){};
shaka.dash.SegmentTemplate.createStreamInfo=function(a,b,c,d,e,f,g,h,k,l){goog.asserts.assert(a.representation.segmentTemplate,"Should only be called with SegmentTemplate or segment info defined");var m=shaka.dash.MpdUtils,n=shaka.dash.SegmentTemplate,p=shaka.dash.TimelineSegmentIndex;k||a.representation.initialization||(a.representation.initialization=m.inheritAttribute(a,n.fromInheritance_,"initialization"));var q=a.representation.initialization?n.createInitSegment_(a,g):null,r=n.parseSegmentTemplateInfo_(a);
n.checkSegmentTemplateInfo_(a,r);var t=shaka.util.ObjectUtils.shallowCloneObject(a);if(r.indexTemplate)return shaka.dash.SegmentBase.checkSegmentIndexSupport(a,q),{endTime:-1,timeline:-1,generateSegmentIndex:function(){return n.generateSegmentIndexFromIndexTemplate_(t,b,q,r)},timescale:r.timescale};if(r.segmentDuration)return d||a.adaptationSet.contentType==="image"||a.adaptationSet.contentType==="text"||(p=a.periodInfo.start,d=a.period.id,l=a.periodInfo.duration,d=(d=d!=null&&f.get(d)||l)?p+d:Infinity,
a.presentationTimeline.notifyMaxSegmentDuration(r.segmentDuration),a.presentationTimeline.notifyPeriodDuration(p,d)),{endTime:-1,timeline:-1,generateSegmentIndex:function(){return n.generateSegmentIndexFromDuration_(t,r,e,q,f,g,h,a.representation.segmentSequenceCadence)},timescale:r.timescale};var u=null;d=d=null;a.period.id&&a.representation.id&&(d=a.period.id+","+a.representation.id,d=c.get(d))&&(u=d.segmentIndex);var v=a.periodInfo.start,w=a.periodInfo.duration?v+a.periodInfo.duration:Infinity;
shaka.log.debug("New manifest "+v+" - "+w);if(u)p=u,p.appendTemplateInfo(r,v,w,q,a.dynamic),l=a.presentationTimeline.getSegmentAvailabilityStart(),p.evict(l);else{c=0;k=-1;if(a.period.id!=null&&a.representation.id!=null)if(m=l.get(a.period.id))k=m.timeline;else for(l=(0,$jscomp.makeIterator)(l.values()),m=l.next();!m.done;m=l.next())if(m=m.value,Math.abs(r.scaledPresentationTimeOffset-m.endTime)<=shaka.util.ManifestParserUtils.GAP_OVERLAP_TOLERANCE_SECONDS&&m.reps.includes(a.representation.id)){k=
m.timeline;break}else m.timeline>=c&&(c=m.timeline+1);k==-1&&(k=c);shaka.log.debug("Creating TSI with end "+w);u=new p(a.dynamic,r,a.representation.originalId,a.bandwidth,a.representation.getBaseUris,a.urlParams,v,w,q,g,a.representation.segmentSequenceCadence,k)}r.timeline&&a.adaptationSet.contentType!=="image"&&a.adaptationSet.contentType!=="text"&&(p=u.getTimeline(),a.presentationTimeline.notifyTimeRange(p,v));d&&a.dynamic&&(d.segmentIndex=u);p=(p=(p=r.timeline)&&p[p.length-1])?p.end+r.scaledPresentationTimeOffset:
-1;d=-1;u instanceof shaka.dash.TimelineSegmentIndex&&(d=u.continuityTimeline());return{endTime:p,timeline:d,generateSegmentIndex:function(){u instanceof shaka.dash.TimelineSegmentIndex&&u.isEmpty()&&u.appendTemplateInfo(r,v,w,q,a.dynamic);return Promise.resolve(u)},timescale:r.timescale}};
shaka.dash.SegmentTemplate.modifyTimepoints=function(a,b){var c=shaka.util.TXml;a=shaka.dash.MpdUtils.inheritChild(a,shaka.dash.SegmentTemplate.fromInheritance_,"SegmentTimeline");goog.asserts.assert(a,"timeline node not found");var d=c.findChildren(a,"S");goog.asserts.assert(d,"timepoints should exist");c.modifyNodes(d,b);a.children=d};
shaka.dash.SegmentTemplate.removeTimepoints=function(a){a=shaka.dash.MpdUtils.inheritChild(a,shaka.dash.SegmentTemplate.fromInheritance_,"SegmentTimeline");goog.asserts.assert(a,"timeline node not found");a.children=[]};shaka.dash.SegmentTemplate.fromInheritance_=function(a){return a.segmentTemplate};
shaka.dash.SegmentTemplate.parseSegmentTemplateInfo_=function(a){var b=shaka.dash.SegmentTemplate,c=shaka.dash.MpdUtils,d=shaka.util.StringUtils,e=c.parseSegmentInfo(a,b.fromInheritance_),f=c.inheritAttribute(a,b.fromInheritance_,"media"),g=c.inheritAttribute(a,b.fromInheritance_,"index");b=c.inheritAttribute(a,b.fromInheritance_,"k");c=0;b&&(c=parseInt(b,10));return{unscaledSegmentDuration:e.unscaledSegmentDuration,segmentDuration:e.segmentDuration,timescale:e.timescale,startNumber:e.startNumber,
scaledPresentationTimeOffset:e.scaledPresentationTimeOffset,unscaledPresentationTimeOffset:e.unscaledPresentationTimeOffset,timeline:e.timeline,mediaTemplate:f&&d.htmlUnescape(f),indexTemplate:g,mimeType:a.representation.mimeType,codecs:a.representation.codecs,bandwidth:a.bandwidth,numChunks:c}};
shaka.dash.SegmentTemplate.checkSegmentTemplateInfo_=function(a,b){var c=b.indexTemplate?1:0;c+=b.timeline?1:0;c+=b.segmentDuration?1:0;if(c==0)throw shaka.log.error("SegmentTemplate does not contain any segment information:","the SegmentTemplate must contain either an index URL template","a SegmentTimeline, or a segment duration.",a.representation),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_NO_SEGMENT_INFO);c!=1&&(shaka.log.warning("SegmentTemplate contains multiple segment information sources:",
"the SegmentTemplate should only contain an index URL template,","a SegmentTimeline or a segment duration.",a.representation),b.indexTemplate?(shaka.log.info("Using the index URL template by default."),b.timeline=null):(goog.asserts.assert(b.timeline,"There should be a timeline"),shaka.log.info("Using the SegmentTimeline by default.")),b.unscaledSegmentDuration=null,b.segmentDuration=null);if(!b.indexTemplate&&!b.mediaTemplate)throw shaka.log.error("SegmentTemplate does not contain sufficient segment information:",
"the SegmentTemplate's media URL template is missing.",a.representation),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_NO_SEGMENT_INFO);};
shaka.dash.SegmentTemplate.generateSegmentIndexFromIndexTemplate_=function(a,b,c,d){var e=shaka.dash.MpdUtils,f=shaka.util.ManifestParserUtils;goog.asserts.assert(d.indexTemplate,"must be using index template");e=e.fillUriTemplate(d.indexTemplate,a.representation.originalId,null,null,a.bandwidth||null,null);f=f.resolveUris(a.representation.getBaseUris(),[e]);return shaka.dash.SegmentBase.generateSegmentIndexFromUris(a,b,c,f,0,null,d.scaledPresentationTimeOffset)};
shaka.dash.SegmentTemplate.generateSegmentIndexFromDuration_=function(a,b,c,d,e,f,g,h){goog.asserts.assert(b.mediaTemplate,"There should be a media template with duration");var k=shaka.dash.MpdUtils,l=shaka.util.ManifestParserUtils,m=a.presentationTimeline,n=a.periodInfo.start,p=a.period.id,q=a.periodInfo.duration,r=function(){var F=p!=null&&e.get(p)||q;return F?n+F:Infinity},t=b.segmentDuration;goog.asserts.assert(t!=null,"Segment duration must not be null!");var u=b.startNumber,v=b.mediaTemplate,
w=a.bandwidth||null,x=a.representation.originalId,y=a.representation.getBaseUris,C=a.urlParams,D=n-b.scaledPresentationTimeOffset,A=function(){var F=[Math.max(m.getSegmentAvailabilityStart(),n),Math.min(m.getSegmentAvailabilityEnd(),r())];goog.asserts.assert(F.every(isFinite),"Available presentation times must be finite!");goog.asserts.assert(F.every(function(I){return I>=0}),"Available presentation times must be positive!");goog.asserts.assert(t!=null,"Segment duration must not be null!");F=F.map(function(I){return I-
n});F=[Math.ceil(F[0]/t),Math.ceil(F[1]/t)-1];a.representation.availabilityTimeOffset&&F[1]++;return F.map(function(I){return I+u})},z=A();c=a.dynamic?Math.max(z[0],z[1]-c+1):z[0];g=g||z[1];var B=function(F){goog.asserts.assert(t!=null,"Segment duration must not be null!");var I=F-u,L=I*t,G=b.unscaledSegmentDuration;goog.asserts.assert(G!=null,"Segment duration must not be null!");var M=I*G;"BigInt"in window&&M>Number.MAX_SAFE_INTEGER&&(M=BigInt(I)*BigInt(G));L+=n;I=L+t;G=Math.min(I,r());goog.asserts.assert(L<
G,"Generated a segment outside of the period!");var J=[],O=b.numChunks;if(O)for(var P=(G-L)/O,Q={},K=0;K<O;Q={subNumber$jscomp$1:void 0},K++){var T=L+P*K,U=T+P;Q.subNumber$jscomp$1=K;Q=function(W){return function(){var X=k.fillUriTemplate(v,x,F,W.subNumber$jscomp$1,w,M);return l.resolveUris(y(),[X],C())}}(Q);T=new shaka.media.SegmentReference(T,U,Q,0,null,d,D,n,r(),[],"",null,null,shaka.media.SegmentReference.Status.AVAILABLE,f);T.codecs=a.representation.codecs;T.mimeType=a.representation.mimeType;
h==0?K>0&&T.markAsNonIndependent():K%h!=0&&T.markAsNonIndependent();J.push(T)}L=new shaka.media.SegmentReference(L,G,function(){if(O)return[];var W=k.fillUriTemplate(v,x,F,null,w,M);return l.resolveUris(y(),[W],C())},0,null,d,D,n,r(),J,"",null,null,shaka.media.SegmentReference.Status.AVAILABLE,f,J.length>0);L.codecs=a.representation.codecs;L.mimeType=a.representation.mimeType;L.bandwidth=a.bandwidth;L.trueEndTime=I;return L},E=new shaka.dash.SegmentTemplate.FixedDurationSegmentIndex_(c,g,u,n,t,B);
z=m.getSegmentAvailabilityEnd()<r();var H=m.isLive();if(z||H){var N=Math.max(c,g+1);c=t;a.representation.availabilityTimeOffset&&(c=.1);E.updateEvery(c,function(){var F=m.getSegmentAvailabilityStart();E.evict(F);var I=(0,$jscomp.makeIterator)(A());I.next();I=I.next().value;for(var L=[];N<=I;){var G=B(N);L.push(G);N++}return F>r()&&!L.length?null:L})}return Promise.resolve(E)};
shaka.dash.SegmentTemplate.createInitSegment_=function(a,b){var c=shaka.dash.MpdUtils,d=shaka.util.ManifestParserUtils,e=shaka.dash.SegmentTemplate,f=a.representation.initialization;f||(f=c.inheritAttribute(a,e.fromInheritance_,"initialization"));if(!f)return null;f=shaka.util.StringUtils.htmlUnescape(f);var g=a.representation.originalId,h=a.bandwidth||null,k=a.representation.getBaseUris,l=a.urlParams;e=shaka.dash.SegmentBase.createQualityInfo(a);b=new shaka.media.InitSegmentReference(function(){goog.asserts.assert(f,
"Should have returned earlier");var m=c.fillUriTemplate(f,g,null,null,h,null);return d.resolveUris(k(),[m],l())},0,null,e,null,null,b,a.adaptationSet.encrypted);b.codecs=a.representation.codecs;b.mimeType=a.representation.mimeType;a.periodInfo&&!a.periodInfo.isLastPeriod&&(b.boundaryEnd=a.periodInfo.start+a.periodInfo.duration);return b};
shaka.dash.SegmentTemplate.FixedDurationSegmentIndex_=function(a,b,c,d,e,f){shaka.media.SegmentIndex.call(this,Array(Math.max(0,b-a+1)));this.minPosition_=a;this.startNumber_=c;this.periodStart_=d;this.segmentDuration_=e;this.createReference_=f};$jscomp.inherits(shaka.dash.SegmentTemplate.FixedDurationSegmentIndex_,shaka.media.SegmentIndex);
shaka.dash.SegmentTemplate.FixedDurationSegmentIndex_.prototype.find=function(a){var b=this.references.length-1;if(b<0)return null;var c=this.get(this.numEvicted_);if(!c)return null;if(a<c.startTime)return this.numEvicted_;c=Math.floor((a-this.periodStart_)/this.segmentDuration_)+this.startNumber_-this.minPosition_;if(c<this.numEvicted_)return null;var d=this.get(c);if(!d)return null;b=(b=c-this.numEvicted_<b?this.get(c+1):null)?b.startTime:d.endTime;return a>=d.startTime&&a<b?c:null};
shaka.dash.SegmentTemplate.FixedDurationSegmentIndex_.prototype.get=function(a){var b=a-this.numEvicted_;if(b<0||b>=this.references.length)return null;var c=this.references[b];c||(c=this.createReference_(this.minPosition_+a),this.references[b]=c);return c};shaka.dash.SegmentTemplate.FixedDurationSegmentIndex_.prototype.earliestReference=function(){return this.get(this.numEvicted_)};
shaka.dash.SegmentTemplate.FixedDurationSegmentIndex_.prototype.forEachTopLevelReference=function(a){for(var b=0;b<this.references.length;b++){var c=this.get(b+this.numEvicted_);c&&a(c)}};
shaka.dash.SegmentTemplate.FixedDurationSegmentIndex_.prototype.evict=function(a){if(!this.getIsImmutable()){var b=this.references.length-1;if(!(b<0)){var c=this.get(this.numEvicted_);!c||c.endTime>a||(a=(b=this.get(this.numEvicted_+b))&&b.endTime<=a?this.references.length:Math.max(0,Math.min(this.references.length,Math.floor((a-this.periodStart_)/this.segmentDuration_+this.startNumber_-1)-(this.minPosition_+this.numEvicted_)+1)),a>0&&(this.numEvicted_+=a,this.references=this.references.slice(a)))}}};
shaka.dash.TimelineSegmentIndex=function(a,b,c,d,e,f,g,h,k,l,m,n){shaka.media.SegmentIndex.call(this,[]);this.dynamic_=a;this.templateInfo_=b;this.representationId_=c;this.bandwidth_=d;this.getBaseUris_=e;this.urlParams_=f;this.periodStart_=g;this.periodEnd_=h;this.initSegmentReference_=k;this.aesKey_=l;this.segmentSequenceCadence_=m;this.timeline_=n;this.fitTimeline()};$jscomp.inherits(shaka.dash.TimelineSegmentIndex,shaka.media.SegmentIndex);
shaka.dash.TimelineSegmentIndex.prototype.getNumReferences=function(){return this.templateInfo_?this.templateInfo_.timeline.length:0};shaka.dash.TimelineSegmentIndex.prototype.release=function(){shaka.media.SegmentIndex.prototype.release.call(this);this.templateInfo_=null};
shaka.dash.TimelineSegmentIndex.prototype.evict=function(a){if(this.templateInfo_){shaka.log.debug(this.representationId_+" Evicting at "+a);var b=this.templateInfo_.timeline;if(b){for(var c=0;c<b.length&&b[c].end+this.periodStart_<=a;)c++;c>0&&(this.templateInfo_.timeline=b.slice(c),this.references.length>=c&&(this.references=this.references.slice(c)),this.numEvicted_+=c,this.getNumReferences()===0&&this.release())}}};
shaka.dash.TimelineSegmentIndex.prototype.appendTemplateInfo=function(a,b,c,d,e){this.updateInitSegmentReference(d);this.dynamic_=e;if(this.templateInfo_){if(this.templateInfo_.unscaledPresentationTimeOffset!==a.unscaledPresentationTimeOffset)for(b=a.unscaledPresentationTimeOffset-this.templateInfo_.unscaledPresentationTimeOffset,shaka.log.error("Possibly suboptimal manifest detected!","presentationTimeOffset is "+a.unscaledPresentationTimeOffset,"which differs "+b+" from the cache template."),d=
0;d<a.timeline.length;d++)e=a.timeline[d],e.unscaledStart+=b,e.unscaledEnd+=b,e.start=(e.unscaledStart+b)/a.timescale,e.end=(e.unscaledEnd+b)/a.timescale;this.templateInfo_.mediaTemplate!==a.mediaTemplate&&(this.templateInfo_.mediaTemplate=a.mediaTemplate);b=this.templateInfo_.timeline;if(b.length){var f=b[b.length-1];a=a.timeline.filter(function(g){return g.end>f.end})}else a=a.timeline.slice();a.length>0&&(shaka.log.debug("Appending "+a.length+" entries"),this.templateInfo_.timeline.push.apply(this.templateInfo_.timeline,
(0,$jscomp.arrayFromIterable)(a)));this.periodEnd_!==c&&(this.periodEnd_=c)}else this.templateInfo_=a,this.periodStart_=b,this.periodEnd_=c;this.fitTimeline()};shaka.dash.TimelineSegmentIndex.prototype.updateInitSegmentReference=function(a){if(this.initSegmentReference_!==a){this.initSegmentReference_=a;for(var b=(0,$jscomp.makeIterator)(this.references),c=b.next();!c.done;c=b.next())(c=c.value)&&c.updateInitSegmentReference(a)}};
shaka.dash.TimelineSegmentIndex.prototype.isBeforeFirstEntry=function(a){return this.templateInfo_&&this.templateInfo_.timeline&&this.templateInfo_.timeline.length?a<this.templateInfo_.timeline[0].start+this.periodStart_:!1};
shaka.dash.TimelineSegmentIndex.prototype.fitTimeline=function(){if(this.templateInfo_&&!this.getIsImmutable()){var a=this.templateInfo_.timeline;goog.asserts.assert(a,"Timeline should be non-null!");var b=[];a=(0,$jscomp.makeIterator)(a);for(var c=a.next();!c.done;c=a.next())c=c.value,c.start>=this.periodEnd_||c.end<=0||b.push(c);this.templateInfo_.timeline=b;this.evict(this.periodStart_)}};
shaka.dash.TimelineSegmentIndex.prototype.getTimeline=function(){if(!this.templateInfo_)return[];var a=this.templateInfo_.timeline;goog.asserts.assert(a,"Timeline should be non-null!");return a};
shaka.dash.TimelineSegmentIndex.prototype.find=function(a){var b=this;shaka.log.debug("Find "+a);if(this.isBeforeFirstEntry(a))return this.numEvicted_;if(!this.templateInfo_)return null;var c=this.templateInfo_.timeline;if(a<this.periodStart_||a>=this.periodEnd_)return null;var d=c.length-1,e=shaka.util.ArrayUtils.binarySearch(c,function(h){return h.start+b.periodStart_<=a})-1;if(e<0)return null;var f=c[e],g=f.start+this.periodStart_;c=e<d?c[e+1].start+this.periodStart_:this.periodEnd_===Infinity?
f.end+this.periodStart_:this.periodEnd_;return a>=g&&a<c?e+this.numEvicted_:null};
shaka.dash.TimelineSegmentIndex.prototype.get=function(a){var b=this;a-=this.numEvicted_;if(a<0||a>=this.getNumReferences()||!this.templateInfo_)return null;var c=this.references[a];if(!c){c=this.templateInfo_.timeline[a];var d=c.segmentPosition,e=c.unscaledStart+this.templateInfo_.unscaledPresentationTimeOffset,f=this.periodStart_-this.templateInfo_.scaledPresentationTimeOffset,g=this.periodStart_+c.end,h=g;a===this.getNumReferences()-1&&this.periodEnd_!==Infinity&&(h=this.dynamic_&&Math.abs(h-this.periodEnd_)>
.1?Math.min(h,this.periodEnd_):this.periodEnd_);var k=this.templateInfo_.codecs,l=this.templateInfo_.mimeType,m=this.templateInfo_.bandwidth,n=[],p=!1;c.partialSegments&&this.templateInfo_&&this.templateInfo_.mediaTemplate&&(p=this.templateInfo_.mediaTemplate.includes("$SubNumber$"));if(p){p=(c.end-c.start)/c.partialSegments;for(var q={},r=0;r<c.partialSegments;q={uris$jscomp$11:void 0,subNumber$jscomp$2:void 0},r++){var t=c.start+p*r,u=t+p;q.subNumber$jscomp$2=r;q.uris$jscomp$11=null;q=function(v){return function(){if(!b.templateInfo_)return[];
v.uris$jscomp$11==null&&(v.uris$jscomp$11=shaka.dash.TimelineSegmentIndex.createUris_(b.templateInfo_.mediaTemplate,b.representationId_,d,b.bandwidth_,e,v.subNumber$jscomp$2,b.getBaseUris_,b.urlParams_));return v.uris$jscomp$11}}(q);t=new shaka.media.SegmentReference(this.periodStart_+t,this.periodStart_+u,q,0,null,this.initSegmentReference_,f,this.periodStart_,this.periodEnd_,[],"",null,null,shaka.media.SegmentReference.Status.AVAILABLE,this.aesKey_);t.codecs=k;t.mimeType=l;t.bandwidth=m;this.segmentSequenceCadence_==
0?r>0&&t.markAsNonIndependent():r%this.segmentSequenceCadence_!=0&&t.markAsNonIndependent();n.push(t)}}c=new shaka.media.SegmentReference(this.periodStart_+c.start,h,function(){return n.length>0||!b.templateInfo_?[]:shaka.dash.TimelineSegmentIndex.createUris_(b.templateInfo_.mediaTemplate,b.representationId_,d,b.bandwidth_,e,null,b.getBaseUris_,b.urlParams_)},0,null,this.initSegmentReference_,f,this.periodStart_,this.periodEnd_,n,"",null,null,shaka.media.SegmentReference.Status.AVAILABLE,this.aesKey_,
n.length>0);c.codecs=k;c.mimeType=l;c.trueEndTime=g;c.bandwidth=m;this.references[a]=c}return c};shaka.dash.TimelineSegmentIndex.prototype.forEachTopLevelReference=function(a){this.fitTimeline();for(var b=0;b<this.getNumReferences();b++){var c=this.get(b+this.numEvicted_);c&&a(c)}};shaka.dash.TimelineSegmentIndex.createUris_=function(a,b,c,d,e,f,g,h){a=shaka.dash.MpdUtils.fillUriTemplate(a,b,c,f,d||null,e);return shaka.util.ManifestParserUtils.resolveUris(g(),[a],h()).map(function(k){return k.toString()})};
shaka.dash.TimelineSegmentIndex.prototype.continuityTimeline=function(){return this.timeline_};shaka.media.PresentationTimeline=function(a,b,c){this.presentationStartTime_=a;this.presentationDelay_=b;this.segmentAvailabilityDuration_=this.duration_=Infinity;this.maxSegmentDuration_=1;this.maxSegmentEndTime_=this.minSegmentStartTime_=null;this.clockOffset_=0;this.static_=!0;this.isLive2VodTransition_=!1;this.userSeekStart_=0;this.autoCorrectDrift_=c===void 0?!0:c;this.availabilityTimeOffset_=0;this.startTimeLocked_=!1;this.initialProgramDateTime_=a};
shaka.media.PresentationTimeline.prototype.getDuration=function(){return this.duration_};shaka.media.PresentationTimeline.prototype.getMaxSegmentDuration=function(){return this.maxSegmentDuration_};shaka.media.PresentationTimeline.prototype.setPresentationStartTime=function(a){goog.asserts.assert(a>=0,"presentationStartTime must be >= 0");this.presentationStartTime_=a};
shaka.media.PresentationTimeline.prototype.setDuration=function(a){goog.asserts.assert(a>0,"duration must be > 0");this.duration_=a};shaka.media.PresentationTimeline.prototype.getPresentationStartTime=function(){return this.presentationStartTime_};shaka.media.PresentationTimeline.prototype.setClockOffset=function(a){this.clockOffset_=a};shaka.media.PresentationTimeline.prototype.setStatic=function(a){a&&!this.static_&&(this.isLive2VodTransition_=!0);this.static_=a};
shaka.media.PresentationTimeline.prototype.setSegmentAvailabilityDuration=function(a){goog.asserts.assert(a>=0,"segmentAvailabilityDuration must be >= 0");this.segmentAvailabilityDuration_=a};shaka.media.PresentationTimeline.prototype.getSegmentAvailabilityDuration=function(){return this.segmentAvailabilityDuration_};shaka.media.PresentationTimeline.prototype.setDelay=function(a){goog.asserts.assert(a>=0,"delay must be >= 0");this.presentationDelay_=a};
shaka.media.PresentationTimeline.prototype.getDelay=function(){return this.presentationDelay_};
shaka.media.PresentationTimeline.prototype.notifyTimeRange=function(a,b){if(a.length!=0){var c=(Date.now()+this.clockOffset_)/1E3;a=a.filter(function(e){return e.start+b<c});if(a.length!=0){var d=a[a.length-1].end+b;this.notifyMinSegmentStartTime(a[0].start+b);this.maxSegmentDuration_=a.reduce(function(e,f){return Math.max(e,f.end-f.start)},this.maxSegmentDuration_);this.maxSegmentEndTime_=Math.max(this.maxSegmentEndTime_,d);this.presentationStartTime_!=null&&this.autoCorrectDrift_&&!this.startTimeLocked_&&
(this.presentationStartTime_=c-this.maxSegmentEndTime_-this.maxSegmentDuration_);shaka.log.v1("notifySegments:","maxSegmentDuration="+this.maxSegmentDuration_)}}};
shaka.media.PresentationTimeline.prototype.notifySegments=function(a){if(a.length!=0){var b=a[0].startTime,c=a[0].endTime,d=(Date.now()+this.clockOffset_)/1E3;a=(0,$jscomp.makeIterator)(a);for(var e=a.next();!e.done;e=a.next())e=e.value,d<e.startTime||(b=Math.min(b,e.startTime),c=Math.max(c,e.endTime),this.maxSegmentDuration_=Math.max(this.maxSegmentDuration_,e.endTime-e.startTime));this.notifyMinSegmentStartTime(b);this.maxSegmentEndTime_=Math.max(this.maxSegmentEndTime_,c);this.presentationStartTime_!=
null&&this.autoCorrectDrift_&&!this.startTimeLocked_&&(this.presentationStartTime_=d-this.maxSegmentEndTime_-this.maxSegmentDuration_);shaka.log.v1("notifySegments:","maxSegmentDuration="+this.maxSegmentDuration_)}};shaka.media.PresentationTimeline.prototype.notifyPeriodDuration=function(a,b){this.notifyMinSegmentStartTime(a);b==Infinity||this.isLive()||(this.maxSegmentEndTime_=Math.max(this.maxSegmentEndTime_,b))};shaka.media.PresentationTimeline.prototype.getMaxSegmentEndTime=function(){return this.maxSegmentEndTime_};
shaka.media.PresentationTimeline.prototype.lockStartTime=function(){this.startTimeLocked_=!0};shaka.media.PresentationTimeline.prototype.isStartTimeLocked=function(){return this.startTimeLocked_};shaka.media.PresentationTimeline.prototype.setInitialProgramDateTime=function(a){this.initialProgramDateTime_=a};shaka.media.PresentationTimeline.prototype.getInitialProgramDateTime=function(){return this.initialProgramDateTime_};
shaka.media.PresentationTimeline.prototype.notifyMinSegmentStartTime=function(a){this.minSegmentStartTime_==null?this.minSegmentStartTime_=a:this.isLive2VodTransition_||(this.minSegmentStartTime_=Math.min(this.minSegmentStartTime_,a))};shaka.media.PresentationTimeline.prototype.notifyMaxSegmentDuration=function(a){this.maxSegmentDuration_=Math.max(this.maxSegmentDuration_,a);shaka.log.v1("notifyNewSegmentDuration:","maxSegmentDuration="+this.maxSegmentDuration_)};
shaka.media.PresentationTimeline.prototype.offset=function(a){this.minSegmentStartTime_!=null&&(this.minSegmentStartTime_+=a);this.maxSegmentEndTime_!=null&&(this.maxSegmentEndTime_+=a)};shaka.media.PresentationTimeline.prototype.isLive=function(){return this.duration_==Infinity&&!this.static_};shaka.media.PresentationTimeline.prototype.isInProgress=function(){return this.duration_!=Infinity&&!this.static_};
shaka.media.PresentationTimeline.prototype.getSegmentAvailabilityStart=function(){goog.asserts.assert(this.segmentAvailabilityDuration_>=0,"The availability duration should be positive");var a=this.getSegmentAvailabilityEnd()-this.segmentAvailabilityDuration_;return Math.max(this.userSeekStart_,a)};shaka.media.PresentationTimeline.prototype.setUserSeekStart=function(a){this.userSeekStart_=a};
shaka.media.PresentationTimeline.prototype.getSegmentAvailabilityEnd=function(){return this.isLive()||this.isInProgress()?Math.min(this.getLiveEdge_()+this.availabilityTimeOffset_,this.duration_):this.maxSegmentEndTime_?Math.min(this.maxSegmentEndTime_,this.duration_):this.duration_};
shaka.media.PresentationTimeline.prototype.getSafeSeekRangeStart=function(a){var b=Math.max(this.minSegmentStartTime_,this.userSeekStart_);if(this.segmentAvailabilityDuration_==Infinity)return Math.ceil(b*1E3)/1E3;var c=this.getSegmentAvailabilityEnd()-this.segmentAvailabilityDuration_;a=Math.min(c+a,this.getSeekRangeEnd());return Math.max(b,a)};shaka.media.PresentationTimeline.prototype.getSeekRangeStart=function(){return this.getSafeSeekRangeStart(0)};
shaka.media.PresentationTimeline.prototype.getSeekRangeEnd=function(){var a=this.isLive()||this.isInProgress()?this.presentationDelay_:0;return Math.max(0,this.getSegmentAvailabilityEnd()-a)};shaka.media.PresentationTimeline.prototype.usingPresentationStartTime=function(){return this.presentationStartTime_==null||this.maxSegmentEndTime_!=null&&this.autoCorrectDrift_?!1:!0};
shaka.media.PresentationTimeline.prototype.getLiveEdge_=function(){goog.asserts.assert(this.presentationStartTime_!=null,"Cannot compute timeline live edge without start time");var a=(Date.now()+this.clockOffset_)/1E3;return Math.max(0,a-this.maxSegmentDuration_-this.presentationStartTime_)};shaka.media.PresentationTimeline.prototype.setAvailabilityTimeOffset=function(a){this.availabilityTimeOffset_=a};shaka.media.PresentationTimeline.prototype.getAvailabilityTimeOffset=function(){return this.availabilityTimeOffset_};
shaka.media.PresentationTimeline.prototype.assertIsValid=function(){goog.DEBUG&&(this.isLive()?goog.asserts.assert(this.presentationStartTime_!=null,"Detected as live stream, but does not match our model of live!"):this.isInProgress()?goog.asserts.assert(this.presentationStartTime_!=null&&this.segmentAvailabilityDuration_==Infinity,"Detected as IPR stream, but does not match our model of IPR!"):goog.asserts.assert(this.segmentAvailabilityDuration_==Infinity&&this.duration_!=Infinity&&this.static_,
"Detected as VOD stream, but does not match our model of VOD!"))};goog.exportSymbol("shaka.media.PresentationTimeline",shaka.media.PresentationTimeline);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"getAvailabilityTimeOffset",shaka.media.PresentationTimeline.prototype.getAvailabilityTimeOffset);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"setAvailabilityTimeOffset",shaka.media.PresentationTimeline.prototype.setAvailabilityTimeOffset);
goog.exportProperty(shaka.media.PresentationTimeline.prototype,"usingPresentationStartTime",shaka.media.PresentationTimeline.prototype.usingPresentationStartTime);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"getSeekRangeEnd",shaka.media.PresentationTimeline.prototype.getSeekRangeEnd);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"getSeekRangeStart",shaka.media.PresentationTimeline.prototype.getSeekRangeStart);
goog.exportProperty(shaka.media.PresentationTimeline.prototype,"getSafeSeekRangeStart",shaka.media.PresentationTimeline.prototype.getSafeSeekRangeStart);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"getSegmentAvailabilityEnd",shaka.media.PresentationTimeline.prototype.getSegmentAvailabilityEnd);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"setUserSeekStart",shaka.media.PresentationTimeline.prototype.setUserSeekStart);
goog.exportProperty(shaka.media.PresentationTimeline.prototype,"getSegmentAvailabilityStart",shaka.media.PresentationTimeline.prototype.getSegmentAvailabilityStart);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"isInProgress",shaka.media.PresentationTimeline.prototype.isInProgress);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"isLive",shaka.media.PresentationTimeline.prototype.isLive);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"offset",shaka.media.PresentationTimeline.prototype.offset);
goog.exportProperty(shaka.media.PresentationTimeline.prototype,"notifyMaxSegmentDuration",shaka.media.PresentationTimeline.prototype.notifyMaxSegmentDuration);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"notifyMinSegmentStartTime",shaka.media.PresentationTimeline.prototype.notifyMinSegmentStartTime);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"getInitialProgramDateTime",shaka.media.PresentationTimeline.prototype.getInitialProgramDateTime);
goog.exportProperty(shaka.media.PresentationTimeline.prototype,"setInitialProgramDateTime",shaka.media.PresentationTimeline.prototype.setInitialProgramDateTime);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"isStartTimeLocked",shaka.media.PresentationTimeline.prototype.isStartTimeLocked);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"lockStartTime",shaka.media.PresentationTimeline.prototype.lockStartTime);
goog.exportProperty(shaka.media.PresentationTimeline.prototype,"getMaxSegmentEndTime",shaka.media.PresentationTimeline.prototype.getMaxSegmentEndTime);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"notifyPeriodDuration",shaka.media.PresentationTimeline.prototype.notifyPeriodDuration);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"notifySegments",shaka.media.PresentationTimeline.prototype.notifySegments);
goog.exportProperty(shaka.media.PresentationTimeline.prototype,"notifyTimeRange",shaka.media.PresentationTimeline.prototype.notifyTimeRange);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"getDelay",shaka.media.PresentationTimeline.prototype.getDelay);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"setDelay",shaka.media.PresentationTimeline.prototype.setDelay);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"getSegmentAvailabilityDuration",shaka.media.PresentationTimeline.prototype.getSegmentAvailabilityDuration);
goog.exportProperty(shaka.media.PresentationTimeline.prototype,"setSegmentAvailabilityDuration",shaka.media.PresentationTimeline.prototype.setSegmentAvailabilityDuration);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"setStatic",shaka.media.PresentationTimeline.prototype.setStatic);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"setClockOffset",shaka.media.PresentationTimeline.prototype.setClockOffset);
goog.exportProperty(shaka.media.PresentationTimeline.prototype,"getPresentationStartTime",shaka.media.PresentationTimeline.prototype.getPresentationStartTime);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"setDuration",shaka.media.PresentationTimeline.prototype.setDuration);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"setPresentationStartTime",shaka.media.PresentationTimeline.prototype.setPresentationStartTime);
goog.exportProperty(shaka.media.PresentationTimeline.prototype,"getMaxSegmentDuration",shaka.media.PresentationTimeline.prototype.getMaxSegmentDuration);goog.exportProperty(shaka.media.PresentationTimeline.prototype,"getDuration",shaka.media.PresentationTimeline.prototype.getDuration);shaka.media.Capabilities=function(){};shaka.media.Capabilities.isTypeSupported=function(a){var b=shaka.media.Capabilities.MediaSourceTypeSupportMap;if(b.has(a))return b.get(a);var c=window.ManagedMediaSource||window.MediaSource;return c?(c=c.isTypeSupported(a),b.set(a,c),c):!1};shaka.media.Capabilities.isInfiniteLiveStreamDurationSupported=function(){var a=window.ManagedMediaSource||window.MediaSource;return a&&a.prototype?!!a.prototype.setLiveSeekableRange&&!!a.prototype.clearLiveSeekableRange:!1};
shaka.media.Capabilities.MediaSourceTypeSupportMap=new Map;shaka.media.SegmentUtils=function(){};shaka.media.SegmentUtils.getBasicInfoFromMimeType=function(a){var b=shaka.util.MimeUtils.getBasicType(a),c=b.split("/")[0];a=shaka.util.MimeUtils.getCodecs(a);return{type:c,mimeType:b,codecs:a,language:null,height:null,width:null,channelCount:null,sampleRate:null,closedCaptions:new Map,videoRange:null,colorGamut:null,frameRate:null,timescale:null}};
shaka.media.SegmentUtils.getBasicInfoFromTs=function(a,b,c,d){var e=shaka.util.BufferUtils.toUint8(a),f=(new shaka.util.TsParser).parse(e),g=f.getCodecs();e=f.getVideoInfo();var h=[],k=!1,l=!1;if(!b)switch(g.audio){case "aac":case "aac-loas":f.getAudioData().length&&(h.push("mp4a.40.2"),k=!0);break;case "mp3":f.getAudioData().length&&(h.push("mp4a.40.34"),k=!0);break;case "ac3":f.getAudioData().length&&(h.push("ac-3"),k=!0);break;case "ec3":f.getAudioData().length&&(h.push("ec-3"),k=!0);break;case "opus":f.getAudioData().length&&
(h.push("opus"),k=!0)}if(!c)switch(g.video){case "avc":e.codec?h.push(e.codec):h.push("avc1.42E01E");l=!0;break;case "hvc":e.codec?h.push(e.codec):h.push("hvc1.1.6.L93.90");l=!0;break;case "av1":h.push("av01.0.01M.08"),l=!0}if(!h.length)return null;b=k&&!l;c=new Map;if(l&&!d){d=new shaka.media.ClosedCaptionParser("video/mp2t");d.parseFrom(a);a=(0,$jscomp.makeIterator)(d.getStreams());for(l=a.next();!l.done;l=a.next())l=l.value,c.set(l,l);d.reset()}return{type:b?"audio":"video",mimeType:"video/mp2t",
codecs:h.join(", "),language:null,height:e.height,width:e.width,channelCount:null,sampleRate:null,closedCaptions:c,videoRange:null,colorGamut:null,frameRate:e.frameRate,timescale:null}};
shaka.media.SegmentUtils.getBasicInfoFromMp4=function(a,b,c){var d=shaka.util.Mp4Parser,e=shaka.media.SegmentUtils,f=[],g=[],h=!1,k=!1,l=function(z){z=z.toLowerCase();switch(z){case "avc1":case "avc3":g.push(z+".42E01E");k=!0;break;case "hev1":case "hvc1":g.push(z+".1.6.L93.90");k=!0;break;case "dvh1":case "dvhe":g.push(z+".05.04");k=!0;break;case "vp09":g.push(z+".00.10.08");k=!0;break;case "av01":g.push(z+".0.01M.08");k=!0;break;case "mp4a":f.push("mp4a.40.2");h=!0;break;case "ac-3":case "ec-3":case "ac-4":case "opus":case "flac":f.push(z);
h=!0;break;case "apac":f.push("apac.31.00"),h=!0}},m=null,n=null,p=null,q=null,r=null,t=null,u=null,v=null,w,x=function(z){var B=shaka.util.Mp4BoxParsers.audioSampleEntry(z.reader);q=B.channelCount;r=B.sampleRate;l(z.name)},y=function(z){w=z.name;var B=shaka.util.Mp4BoxParsers.visualSampleEntry(z.reader);p=String(B.width);n=String(B.height);z.reader.hasMoreData()&&d.children(z)};(new d).box("moov",d.children).box("trak",d.children).box("mdia",d.children).fullBox("mdhd",function(z){goog.asserts.assert(z.version!=
null,"MDHD is a full box and should have a valid version.");z=shaka.util.Mp4BoxParsers.parseMDHD(z.reader,z.version);m=z.language;v=z.timescale}).box("minf",d.children).box("stbl",d.children).fullBox("stsd",d.sampleDescription).box("mp4a",function(z){var B=shaka.util.Mp4BoxParsers.audioSampleEntry(z.reader);q=B.channelCount;r=B.sampleRate;z.reader.hasMoreData()?d.children(z):l(z.name)}).box("esds",function(z){z=shaka.util.Mp4BoxParsers.parseESDS(z.reader);f.push(z.codec);h=!0}).box("ac-3",x).box("ec-3",
x).box("ac-4",x).box("Opus",x).box("fLaC",x).box("apac",x).box("avc1",y).box("avc3",y).box("hev1",y).box("hvc1",y).box("dva1",y).box("dvav",y).box("dvh1",y).box("dvhe",y).box("vp09",y).box("av01",y).box("avcC",function(z){var B=w||"";switch(w){case "dvav":B="avc3";break;case "dva1":B="avc1"}z=shaka.util.Mp4BoxParsers.parseAVCC(B,z.reader);g.push(z.codec);k=!0}).box("hvcC",function(z){var B=w||"";switch(w){case "dvh1":B="hvc1";break;case "dvhe":B="hev1"}z=shaka.util.Mp4BoxParsers.parseHVCC(B,z.reader);
g.push(z.codec);k=!0}).box("dvcC",function(z){var B=w||"";switch(w){case "hvc1":B="dvh1";break;case "hev1":B="dvhe";break;case "avc1":B="dva1";break;case "avc3":B="dvav";break;case "av01":B="dav1"}z=shaka.util.Mp4BoxParsers.parseDVCC(B,z.reader);g.push(z.codec);k=!0}).box("dvvC",function(z){var B=w||"";switch(w){case "hvc1":B="dvh1";break;case "hev1":B="dvhe";break;case "avc1":B="dva1";break;case "avc3":B="dvav";break;case "av01":B="dav1"}z=shaka.util.Mp4BoxParsers.parseDVVC(B,z.reader);g.push(z.codec);
k=!0}).fullBox("vpcC",function(z){z=shaka.util.Mp4BoxParsers.parseVPCC(w||"",z.reader);g.push(z.codec);k=!0}).box("av1C",function(z){var B=w||"";switch(w){case "dav1":B="av01"}z=shaka.util.Mp4BoxParsers.parseAV1C(B,z.reader);g.push(z.codec);k=!0}).box("enca",d.audioSampleEntry).box("encv",d.visualSampleEntry).box("sinf",d.children).box("frma",function(z){z=shaka.util.Mp4BoxParsers.parseFRMA(z.reader).codec;l(z)}).box("colr",function(z){g=g.map(function(H){return H.startsWith("av01.")?shaka.util.Mp4BoxParsers.updateAV1CodecWithCOLRBox(H,
z.reader):H});var B=shaka.util.Mp4BoxParsers.parseCOLR(z.reader),E=B.colorGamut;t=B.videoRange;u=E}).parse(a||b,!0,!0);if(!f.length&&!g.length)return null;x=h&&!k;y=new Map;if(k&&!c){c=new shaka.media.ClosedCaptionParser("video/mp4");a&&c.init(a);try{c.parseFrom(b);for(var C=(0,$jscomp.makeIterator)(c.getStreams()),D=C.next();!D.done;D=C.next()){var A=D.value;y.set(A,A)}}catch(z){shaka.log.debug("Error detecting CC streams",z)}c.reset()}a=f.concat(g);return{type:x?"audio":"video",mimeType:x?"audio/mp4":
"video/mp4",codecs:e.codecsFiltering(a).join(", "),language:m,height:n,width:p,channelCount:q,sampleRate:r,closedCaptions:y,videoRange:t,colorGamut:u,frameRate:null,timescale:v}};
shaka.media.SegmentUtils.codecsFiltering=function(a){var b=shaka.util.ManifestParserUtils.ContentType,c=shaka.util.ManifestParserUtils,d=shaka.media.SegmentUtils;a=d.filterDuplicateCodecs_(a);var e=c.guessAllCodecsSafe(b.AUDIO,a),f=c.guessAllCodecsSafe(b.VIDEO,a);b=c.guessAllCodecsSafe(b.TEXT,a);d=d.chooseBetterCodecs_(f);d=e.concat(d).concat(b);return a.length&&!d.length?a:d};
shaka.media.SegmentUtils.filterDuplicateCodecs_=function(a){var b=new Set,c=[];a=(0,$jscomp.makeIterator)(a);for(var d=a.next();!d.done;d=a.next()){d=d.value;var e=shaka.util.MimeUtils.getCodecBase(d);b.has(e)?shaka.log.debug("Ignoring duplicate codec"):(c.push(d),b.add(e))}return c};
shaka.media.SegmentUtils.chooseBetterCodecs_=function(a){if(a.length<=1)return a;var b=a.find(function(c){return c.startsWith("dvav.")||c.startsWith("dva1.")||c.startsWith("dvh1.")||c.startsWith("dvhe.")||c.startsWith("dav1.")||c.startsWith("dvc1.")||c.startsWith("dvi1.")});return b?shaka.media.Capabilities.isTypeSupported('video/mp4; codecs="'+b+'"')?[b]:a.filter(function(c){return c!=b}):a};
shaka.media.SegmentUtils.getDefaultKID=function(a){var b=shaka.util.Mp4Parser,c=null;(new b).box("moov",b.children).box("trak",b.children).box("mdia",b.children).box("minf",b.children).box("stbl",b.children).fullBox("stsd",b.sampleDescription).box("encv",b.visualSampleEntry).box("enca",b.audioSampleEntry).box("sinf",b.children).box("schi",b.children).fullBox("tenc",function(d){c=shaka.util.Mp4BoxParsers.parseTENC(d.reader).defaultKID}).parse(a,!0);return c};
shaka.media.SegmentUtils.aesDecrypt=function(a,b,c){var d,e,f,g,h;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(k){if(k.getNextAddressJsc()==1){d=b;if(d.cryptoKey)return k.jumpTo(2);goog.asserts.assert(d.fetchKey,"If AES cryptoKey was not preloaded, fetchKey function should be provided");return k.yield(d.fetchKey(),3)}k.getNextAddressJsc()!=2&&goog.asserts.assert(d.cryptoKey,"AES cryptoKey should now be set");e=d.iv;if(!e)for(e=shaka.util.BufferUtils.toUint8(new ArrayBuffer(16)),
f=d.firstMediaSequenceNumber+c,g=e.byteLength-1;g>=0;g--)e[g]=f&255,f>>=8;h=b.blockCipherMode=="CBC"?{name:"AES-CBC",iv:e}:{name:"AES-CTR",counter:e,length:64};return k.return(window.crypto.subtle.decrypt(h,d.cryptoKey,a))})};shaka.net.NetworkingUtils=function(){};
shaka.net.NetworkingUtils.getMimeType=function(a,b,c){var d,e,f,g,h,k,l;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(m){switch(m.getNextAddressJsc()){case 1:d=shaka.net.NetworkingUtils.getExtension(a);if(e=shaka.net.NetworkingUtils.EXTENSIONS_TO_MIME_TYPES_.get(d))return m.return(e);f=shaka.net.NetworkingEngine.RequestType.MANIFEST;g=shaka.net.NetworkingEngine.makeRequest([a],c);m.setCatchFinallyBlocks(2);g.method="HEAD";return m.yield(b.request(f,g).promise,4);case 4:h=m.getYieldResultJsc();
e=h.headers["content-type"];m.leaveTryBlock(3);break;case 2:k=m.enterCatchBlock();if(!k||k.code!=shaka.util.Error.Code.HTTP_ERROR&&k.code!=shaka.util.Error.Code.BAD_HTTP_STATUS){m.jumpTo(3);break}g.method="GET";return m.yield(b.request(f,g).promise,6);case 6:l=m.getYieldResultJsc(),e=l.headers["content-type"];case 3:return m.return(e?e.toLowerCase().split(";").shift():"")}})};
shaka.net.NetworkingUtils.getExtension=function(a){for(var b=a.length,c=0;c<a.length;c++){var d=a.charCodeAt(c);if(d===63||d===35){b=c;break}}for(c=b-1;c>=0;c--){d=a.charCodeAt(c);if(d===46){if(c+1<b)return a.slice(c+1,b).toLowerCase();break}if(d===47)break}return""};shaka.net.NetworkingUtils.createSegmentRequest=function(a,b,c,d,e){a=shaka.net.NetworkingEngine.makeRequest(a,d,e);if(b!=0||c!=null)a.headers.Range=c?"bytes="+b+"-"+c:"bytes="+b+"-";return a};
shaka.net.NetworkingUtils.EXTENSIONS_TO_MIME_TYPES_=(new Map).set("mp4","video/mp4").set("m4v","video/mp4").set("m4a","audio/mp4").set("webm","video/webm").set("weba","audio/webm").set("mkv","video/webm").set("ts","video/mp2t").set("ogv","video/ogg").set("ogg","audio/ogg").set("mpg","video/mpeg").set("mpeg","video/mpeg").set("mov","video/quicktime").set("m3u8","application/x-mpegurl").set("mpd","application/dash+xml").set("ism","application/vnd.ms-sstr+xml").set("mp3","audio/mpeg").set("aac","audio/aac").set("flac",
"audio/flac").set("wav","audio/wav").set("sbv","text/x-subviewer").set("srt","text/srt").set("vtt","text/vtt").set("webvtt","text/vtt").set("ttml","application/ttml+xml").set("lrc","application/x-subtitle-lrc").set("ssa","text/x-ssa").set("ass","text/x-ssa").set("jpeg","image/jpeg").set("jpg","image/jpeg").set("png","image/png").set("svg","image/svg+xml").set("webp","image/webp").set("avif","image/avif").set("html","text/html").set("htm","text/html");shaka.util.ContentSteeringManager=function(a){this.config_=null;this.playerInterface_=a;this.operationManager_=new shaka.util.OperationManager;this.baseUris_=[];this.defaultPathwayId_=null;this.pathwayPriority_=[];this.lastPathwayUsed_=null;this.pathwayClones_=[];this.lastTTL_=300;this.locations_=new Map;this.bannedLocations_=new Map;this.updateTimer_=null;this.manifestType_=shaka.media.ManifestParser.UNKNOWN};shaka.util.ContentSteeringManager.prototype.configure=function(a){this.config_=a};
shaka.util.ContentSteeringManager.prototype.destroy=function(){this.playerInterface_=this.config_=null;this.baseUris_=[];this.defaultPathwayId_=null;this.pathwayPriority_=[];this.pathwayClones_=[];this.locations_.clear();this.updateTimer_!=null&&(this.updateTimer_.stop(),this.updateTimer_=null);return this.operationManager_.destroy()};shaka.util.ContentSteeringManager.prototype.setManifestType=function(a){this.manifestType_=a};
shaka.util.ContentSteeringManager.prototype.setBaseUris=function(a){this.baseUris_=a};shaka.util.ContentSteeringManager.prototype.setDefaultPathwayId=function(a){this.defaultPathwayId_=a};
shaka.util.ContentSteeringManager.prototype.requestInfo=function(a){var b=this,c,d,e,f,g,h,k,l;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(m){if(m.getNextAddressJsc()==1)return c=shaka.util.ManifestParserUtils.resolveUris(b.baseUris_,[b.addQueryParams_(a)]),d=shaka.net.NetworkingEngine.RequestType.CONTENT_STEERING,e=shaka.net.NetworkingEngine.makeRequest(c,b.config_.retryParameters),f=b.playerInterface_.networkingEngine.request(d,e),b.operationManager_.manage(f),m.setCatchFinallyBlocks(2),
m.yield(f.promise,4);if(m.getNextAddressJsc()!=2)return g=m.getYieldResultJsc(),h=shaka.util.StringUtils.fromUTF8(g.data),k=JSON.parse(h),k.VERSION==1&&b.processManifest_(k,g.uri),m.leaveTryBlock(0);if((l=m.enterCatchBlock())&&l.code==shaka.util.Error.Code.OPERATION_ABORTED)return m.return();b.updateTimer_!=null&&(b.updateTimer_.stop(),b.updateTimer_=null);b.updateTimer_=new shaka.util.Timer(function(){b.requestInfo(a)});b.updateTimer_.tickAfter(b.lastTTL_);m.jumpToEnd()})};
shaka.util.ContentSteeringManager.prototype.addQueryParams_=function(a){if(!this.pathwayPriority_.length)return a;a=new goog.Uri(a);var b=this.lastPathwayUsed_||this.pathwayPriority_[0],c=Math.round(this.playerInterface_.getBandwidthEstimate()),d=a.getQueryData();this.manifestType_==shaka.media.ManifestParser.DASH?(d.add("_DASH_pathway",b),d.add("_DASH_throughput",String(c))):this.manifestType_==shaka.media.ManifestParser.HLS&&(d.add("_HLS_pathway",b),d.add("_HLS_throughput",String(c)));d.getCount()&&
a.setQueryData(d);return a.toString()};shaka.util.ContentSteeringManager.prototype.processManifest_=function(a,b){var c=this;this.updateTimer_!=null&&(this.updateTimer_.stop(),this.updateTimer_=null);var d=a["RELOAD-URI"]||b;this.updateTimer_=new shaka.util.Timer(function(){c.requestInfo(d)});if(b=a.TTL)this.lastTTL_=b;this.updateTimer_.tickAfter(this.lastTTL_);this.pathwayPriority_=a["PATHWAY-PRIORITY"]||[];this.pathwayClones_=a["PATHWAY-CLONES"]||[]};
shaka.util.ContentSteeringManager.prototype.clearPreviousLocations=function(){this.locations_.clear()};shaka.util.ContentSteeringManager.prototype.addLocation=function(a,b,c){var d=this.locations_.get(a);d||(d=new Map);d.set(b,c);this.locations_.set(a,d)};shaka.util.ContentSteeringManager.prototype.banLocation=function(a){var b=Date.now()+6E4;this.bannedLocations_.set(a,b)};
shaka.util.ContentSteeringManager.prototype.getLocations=function(a,b){var c=this;b=b===void 0?!1:b;a=this.locations_.get(a)||new Map;for(var d=[],e=(0,$jscomp.makeIterator)(this.pathwayPriority_),f=e.next(),g={};!f.done;g={pathwayId$jscomp$1:void 0},f=e.next())if(g.pathwayId$jscomp$1=f.value,f=a.get(g.pathwayId$jscomp$1))d.push({pathwayId:g.pathwayId$jscomp$1,location:f});else if(f=this.pathwayClones_.find(function(k){return function(l){return l.ID==k.pathwayId$jscomp$1}}(g))){var h=a.get(f["BASE-ID"]);
h&&(f["URI-REPLACEMENT"].HOST?(h=new goog.Uri(h),h.setDomain(f["URI-REPLACEMENT"].HOST),d.push({pathwayId:g.pathwayId$jscomp$1,location:h.toString()})):d.push({pathwayId:g.pathwayId$jscomp$1,location:h}))}e=Date.now();g=(0,$jscomp.makeIterator)(this.bannedLocations_.keys());for(f=g.next();!f.done;f=g.next())f=f.value,h=this.bannedLocations_.get(f),e>h&&this.bannedLocations_.delete(f);d=d.filter(function(k){for(var l=(0,$jscomp.makeIterator)(c.bannedLocations_.keys()),m=l.next();!m.done;m=l.next())if(m.value.includes((new goog.Uri(k.location)).getDomain()))return!1;
return!0});d.length&&(this.lastPathwayUsed_=d[0].pathwayId);d=d.map(function(k){return k.location});if(!d.length&&this.defaultPathwayId_)for(e=(0,$jscomp.makeIterator)(this.defaultPathwayId_.split(",")),g=e.next();!g.done;g=e.next())if(g=a.get(g.value))this.lastPathwayUsed_=this.defaultPathwayId_,d.push(g);if(!d.length)for(a=(0,$jscomp.makeIterator)(a.values()),e=a.next();!e.done;e=a.next())d.push(e.value);return b?d:shaka.util.ManifestParserUtils.resolveUris(this.baseUris_,d)};shaka.util.PeriodCombiner=function(){this.variants_=[];this.audioStreams_=[];this.videoStreams_=[];this.textStreams_=[];this.imageStreams_=[];this.useStreamOnce_=!1;this.usedPeriodIds_=new Set};
shaka.util.PeriodCombiner.prototype.release=function(){var a=this.audioStreams_.concat(this.videoStreams_,this.textStreams_,this.imageStreams_);a=(0,$jscomp.makeIterator)(a);for(var b=a.next();!b.done;b=a.next())b=b.value,b.segmentIndex&&b.segmentIndex.release();this.audioStreams_=[];this.videoStreams_=[];this.textStreams_=[];this.imageStreams_=[];this.variants_=[];this.useStreamOnce_=!1;this.usedPeriodIds_.clear()};shaka.util.PeriodCombiner.prototype.getVariants=function(){return this.variants_};
shaka.util.PeriodCombiner.prototype.getTextStreams=function(){return this.textStreams_.slice()};shaka.util.PeriodCombiner.prototype.getImageStreams=function(){return this.imageStreams_};
shaka.util.PeriodCombiner.prototype.deleteStream=function(a,b){if(a){var c=shaka.util.ManifestParserUtils.ContentType;if(a.type==c.AUDIO){c=(0,$jscomp.makeIterator)(this.audioStreams_);for(var d=c.next();!d.done;d=c.next())d=d.value,d.matchedStreams=d.matchedStreams.filter(function(e){return e!==a})}else if(a.type==c.VIDEO)for(c=(0,$jscomp.makeIterator)(this.videoStreams_),d=c.next();!d.done;d=c.next())d=d.value,d.matchedStreams=d.matchedStreams.filter(function(e){return e!==a}),d.trickModeVideo&&
(d.trickModeVideo.matchedStreams=d.trickModeVideo.matchedStreams.filter(function(e){return e!==a})),d.dependencyStream&&(d.dependencyStream.matchedStreams=d.dependencyStream.matchedStreams.filter(function(e){return e!==a}));else if(a.type==c.TEXT)for(c=(0,$jscomp.makeIterator)(this.textStreams_),d=c.next();!d.done;d=c.next())d=d.value,d.matchedStreams=d.matchedStreams.filter(function(e){return e!==a});else if(a.type==c.IMAGE)for(c=(0,$jscomp.makeIterator)(this.imageStreams_),d=c.next();!d.done;d=
c.next())d=d.value,d.matchedStreams=d.matchedStreams.filter(function(e){return e!==a});a.segmentIndex&&a.closeSegmentIndex();this.usedPeriodIds_.delete(b)}};
shaka.util.PeriodCombiner.prototype.getStreamsPerPeriod_=function(a,b){var c=shaka.util.ManifestParserUtils.ContentType,d=shaka.util.PeriodCombiner,e=[],f=[],g=[],h=[];a=(0,$jscomp.makeIterator)(a);for(var k=a.next();!k.done;k=a.next()){var l=k.value;k=new Map(l.audioStreams.map(function(q){return[d.generateAudioKey_(q),q]}));var m=new Map(l.videoStreams.map(function(q){return[d.generateVideoKey_(q),q]})),n=new Map(l.textStreams.map(function(q){return[d.generateTextKey_(q),q]}));l=new Map(l.imageStreams.map(function(q){return[d.generateImageKey_(q),
q]}));if(b){var p=d.dummyStream_(c.TEXT);n.set(d.generateTextKey_(p),p);p=d.dummyStream_(c.IMAGE);l.set(d.generateImageKey_(p),p)}e.push(k);f.push(m);g.push(n);h.push(l)}return{audioStreamsPerPeriod:e,videoStreamsPerPeriod:f,textStreamsPerPeriod:g,imageStreamsPerPeriod:h}};
shaka.util.PeriodCombiner.prototype.combinePeriods=function(a,b,c){c=c===void 0?!1:c;var d=this,e,f,g,h,k,l,m,n,p,q,r,t,u,v,w,x,y,C,D,A,z,B,E,H,N,F,I,L,G,M,J,O;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(P){if(P.getNextAddressJsc()==1){e=shaka.util.ManifestParserUtils.ContentType;if(!b&&a.length==1)return f=d.getStreamsPerPeriod_(a,!1),g=f.audioStreamsPerPeriod,h=f.videoStreamsPerPeriod,k=f.textStreamsPerPeriod,l=f.imageStreamsPerPeriod,d.audioStreams_=Array.from(g[0].values()),
d.videoStreams_=Array.from(h[0].values()),d.textStreams_=Array.from(k[0].values()),d.imageStreams_=Array.from(l[0].values()),P.jumpTo(2);m=c?d.usedPeriodIds_.size:0;n=-1;for(p=0;p<a.length;p++)q=a[p],d.usedPeriodIds_.has(q.id)||(d.usedPeriodIds_.add(q.id),n==-1&&(n=p));if(n==-1)return P.return();r=d.getStreamsPerPeriod_(a,!0);t=r.audioStreamsPerPeriod;u=r.videoStreamsPerPeriod;v=r.textStreamsPerPeriod;w=r.imageStreamsPerPeriod;return P.yield(Promise.all([d.combine_(d.audioStreams_,t,n,shaka.util.PeriodCombiner.cloneStream_,
shaka.util.PeriodCombiner.concatenateStreams_,m),d.combine_(d.videoStreams_,u,n,shaka.util.PeriodCombiner.cloneStream_,shaka.util.PeriodCombiner.concatenateStreams_,m),d.combine_(d.textStreams_,v,n,shaka.util.PeriodCombiner.cloneStream_,shaka.util.PeriodCombiner.concatenateStreams_,m),d.combine_(d.imageStreams_,w,n,shaka.util.PeriodCombiner.cloneStream_,shaka.util.PeriodCombiner.concatenateStreams_,m)]),2)}x=0;y=[];if(d.videoStreams_.length&&d.audioStreams_.length)for(H=(0,$jscomp.makeIterator)(d.audioStreams_),
N=H.next();!N.done;N=H.next())for(F=N.value,I=(0,$jscomp.makeIterator)(d.videoStreams_),L=I.next();!L.done;L=I.next())G=L.value,M=shaka.drm.DrmUtils.getCommonDrmInfos(F.drmInfos,G.drmInfos),F.drmInfos.length&&G.drmInfos.length&&!M.length?shaka.log.warning("Incompatible DRM in audio & video, skipping variant creation.",F,G):(J=(F.bandwidth||0)+(G.bandwidth||0),F.dependencyStream&&(J+=F.dependencyStream.bandwidth||0),G.dependencyStream&&(J+=G.dependencyStream.bandwidth||0),O=x++,y.push({id:O,language:F.language,
disabledUntilTime:0,primary:F.primary,audio:F,video:G,bandwidth:J,drmInfos:M,allowedByApplication:!0,allowedByKeySystem:!0,decodingInfos:[]}));else for(C=d.videoStreams_.length?d.videoStreams_:d.audioStreams_,D=(0,$jscomp.makeIterator)(C),A=D.next();!A.done;A=D.next())z=A.value,B=x++,E=z.bandwidth||0,z.dependencyStream&&(E+=z.dependencyStream.bandwidth||0),y.push({id:B,language:z.language,disabledUntilTime:0,primary:z.primary,audio:z.type==e.AUDIO?z:null,video:z.type==e.VIDEO?z:null,bandwidth:E,drmInfos:z.drmInfos,
allowedByApplication:!0,allowedByKeySystem:!0,decodingInfos:[]});d.variants_=y;P.jumpToEnd()})};
shaka.util.PeriodCombiner.combineDbStreams=function(a){var b,c,d,e,f,g,h,k,l,m,n,p,q,r,t,u,v,w,x,y,C,D,A,z,B,E,H,N,F,I,L;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(G){switch(G.getNextAddressJsc()){case 1:b=shaka.util.ManifestParserUtils.ContentType;c=shaka.util.PeriodCombiner;if(a.length==1)return G.return(a[0]);d=a.map(function(M){return new Map(M.filter(function(J){return J.type===b.AUDIO}).map(function(J){return[c.generateAudioKey_(J),J]}))});e=a.map(function(M){return new Map(M.filter(function(J){return J.type===
b.VIDEO}).map(function(J){return[c.generateVideoKey_(J),J]}))});f=a.map(function(M){return new Map(M.filter(function(J){return J.type===b.TEXT}).map(function(J){return[c.generateTextKey_(J),J]}))});g=a.map(function(M){return new Map(M.filter(function(J){return J.type===b.IMAGE}).map(function(J){return[c.generateImageKey_(J),J]}))});h=(0,$jscomp.makeIterator)(f);for(k=h.next();!k.done;k=h.next())l=k.value,m=c.dummyStreamDB_(b.TEXT),l.set(c.generateTextKey_(m),m);n=(0,$jscomp.makeIterator)(g);for(p=
n.next();!p.done;p=n.next())q=p.value,r=c.dummyStreamDB_(b.IMAGE),q.set(c.generateImageKey_(r),r);t=new shaka.util.PeriodCombiner;return G.yield(t.combine_([],d,0,shaka.util.PeriodCombiner.cloneStreamDB_,shaka.util.PeriodCombiner.concatenateStreamDBs_,0),2);case 2:return u=G.getYieldResultJsc(),G.yield(t.combine_([],e,0,shaka.util.PeriodCombiner.cloneStreamDB_,shaka.util.PeriodCombiner.concatenateStreamDBs_,0),3);case 3:return v=G.getYieldResultJsc(),G.yield(t.combine_([],f,0,shaka.util.PeriodCombiner.cloneStreamDB_,
shaka.util.PeriodCombiner.concatenateStreamDBs_,0),4);case 4:return w=G.getYieldResultJsc(),G.yield(t.combine_([],g,0,shaka.util.PeriodCombiner.cloneStreamDB_,shaka.util.PeriodCombiner.concatenateStreamDBs_,0),5);case 5:x=G.getYieldResultJsc();y=0;if(v.length&&u.length)for(B=(0,$jscomp.makeIterator)(u),E=B.next();!E.done;E=B.next())for(H=E.value,N=(0,$jscomp.makeIterator)(v),F=N.next();!F.done;F=N.next())I=F.value,L=y++,I.variantIds.push(L),H.variantIds.push(L);else for(C=v.concat(u),D=(0,$jscomp.makeIterator)(C),
A=D.next();!A.done;A=D.next())z=A.value,z.variantIds=[y++];return G.return(v.concat(u).concat(w).concat(x))}})};
shaka.util.PeriodCombiner.prototype.combine_=function(a,b,c,d,e,f){var g=this,h,k,l,m,n,p,q,r,t,u,v,w,x,y,C,D,A,z,B,E;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(H){switch(H.getNextAddressJsc()){case 1:h=[];for(k=0;k<b.length;k++)k>=c?h.push(new Set(b[k].values())):h.push(new Set);l=(0,$jscomp.makeIterator)(a);m=l.next();case 2:if(m.done){H.jumpTo(4);break}n=m.value;return H.yield(g.extendExistingOutputStream_(n,b,c,e,h,f),5);case 5:p=H.getYieldResultJsc();if(!p)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.PERIOD_FLATTENING_FAILED);m=l.next();H.jumpTo(2);break;case 4:q=(0,$jscomp.makeIterator)(h);for(r=q.next();!r.done;r=q.next())for(t=r.value,u=(0,$jscomp.makeIterator)(t),v=u.next();!v.done;v=u.next())w=v.value,(x=g.createNewOutputStream_(a,w,b,d,e,h))&&a.push(x);y=(0,$jscomp.makeIterator)(h);for(C=y.next();!C.done;C=y.next())for(D=C.value,A=(0,$jscomp.makeIterator)(D),z=A.next(),B={};!z.done;B={stream$jscomp$44:void 0},z=A.next())if(B.stream$jscomp$44=
z.value,!shaka.util.PeriodCombiner.isDummy_(B.stream$jscomp$44)&&(E=a.some(function(N){return function(F){return g.areAVStreamsCompatible_(N.stream$jscomp$44,F)}}(B))))throw shaka.log.error("Unused stream in period-flattening!",B.stream$jscomp$44,a),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.PERIOD_FLATTENING_FAILED);return H.return(a)}})};
shaka.util.PeriodCombiner.prototype.extendExistingOutputStream_=function(a,b,c,d,e,f){var g=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(h){if(h.getNextAddressJsc()==1)return g.findMatchesInAllPeriods_(b,a,f>0),goog.asserts.assert(a.createSegmentIndex,"outputStream should be a Stream type!"),a.matchedStreams?a.segmentIndex?h.yield(shaka.util.PeriodCombiner.extendOutputSegmentIndex_(a,c+f),2):h.jumpTo(2):(shaka.log.error("No matches extending output stream!",a,b),h.return(!1));
shaka.util.PeriodCombiner.extendOutputStream_(a,c,d,e,f);return h.return(!0)})};
shaka.util.PeriodCombiner.extendOutputSegmentIndex_=function(a,b){var c,d,e,f,g,h;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(k){if(k.getNextAddressJsc()==1){c=[];d=a.matchedStreams;goog.asserts.assert(d,"matched streams should be valid");for(e=b;e<d.length;e++)f=d[e],c.push(f.createSegmentIndex()),f.trickModeVideo&&!f.trickModeVideo.segmentIndex&&c.push(f.trickModeVideo.createSegmentIndex()),f.dependencyStream&&!f.dependencyStream.segmentIndex&&c.push(f.dependencyStream.createSegmentIndex());
return k.yield(Promise.all(c),2)}if(a.segmentIndex instanceof shaka.media.MetaSegmentIndex)for(g=b;g<d.length;g++)h=d[g],goog.asserts.assert(h.segmentIndex,"stream should have a segmentIndex."),h.segmentIndex&&a.segmentIndex.appendSegmentIndex(h.segmentIndex);k.jumpToEnd()})};
shaka.util.PeriodCombiner.prototype.createNewOutputStream_=function(a,b,c,d,e,f){if(shaka.util.PeriodCombiner.isDummy_(b))return null;var g=d(b);this.findMatchesInAllPeriods_(c,g);g.createSegmentIndex&&(g.createSegmentIndex=function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(h){if(g.segmentIndex)return h.jumpTo(0);g.segmentIndex=new shaka.media.MetaSegmentIndex;return h.yield(shaka.util.PeriodCombiner.extendOutputSegmentIndex_(g,0),0)})},g.closeSegmentIndex=function(){g.segmentIndex&&
(g.segmentIndex.release(),g.segmentIndex=null);if(g.matchedStreams)for(var h=(0,$jscomp.makeIterator)(g.matchedStreams),k=h.next();!k.done;k=h.next())k=k.value,k.segmentIndex&&!shaka.util.PeriodCombiner.isStreamActivelyUsed_(k,g,a)&&(k.segmentIndex.release(),k.segmentIndex=null)});if(!g.matchedStreams||!g.matchedStreams.length)return null;shaka.util.PeriodCombiner.extendOutputStream_(g,0,e,f,0);return g};
shaka.util.PeriodCombiner.extendOutputStream_=function(a,b,c,d,e){var f=shaka.util.ManifestParserUtils.ContentType,g=shaka.util.LanguageUtils,h=a.matchedStreams;goog.asserts.assert(a.matchedStreams,"matchedStreams should be non-null");for(b+=e;b<h.length;b++){var k=h[b];c(a,k);var l=!0;a.type==f.AUDIO&&g.relatedness(a.language,k.language)==0&&(l=!1);if(l&&((l=d[b-e])&&l.delete(k),k.fullMimeTypes))for(k=(0,$jscomp.makeIterator)(k.fullMimeTypes.values()),l=k.next();!l.done;l=k.next())a.fullMimeTypes.add(l.value)}};
shaka.util.PeriodCombiner.cloneStream_=function(a){var b=Object.assign({},a);b.originalId=null;b.createSegmentIndex=function(){return Promise.resolve()};b.closeSegmentIndex=function(){};b.roles=b.roles.slice();b.segmentIndex=null;b.emsgSchemeIdUris=[];b.keyIds=new Set(a.keyIds);b.closedCaptions=a.closedCaptions?new Map(a.closedCaptions):null;b.trickModeVideo=null;b.dependencyStream=null;return b};
shaka.util.PeriodCombiner.cloneStreamDB_=function(a){var b=Object.assign({},a);b.roles=b.roles.slice();b.keyIds=new Set(a.keyIds);b.segments=[];b.variantIds=[];b.closedCaptions=a.closedCaptions?new Map(a.closedCaptions):null;return b};
shaka.util.PeriodCombiner.concatenateStreams_=function(a,b){var c=function(f,g){f||(f=[]);g=(0,$jscomp.makeIterator)(g);for(var h=g.next();!h.done;h=g.next())h=h.value,f.includes(h)||f.push(h);return f};a.roles=c(a.roles,b.roles);b.emsgSchemeIdUris&&(a.emsgSchemeIdUris=c(a.emsgSchemeIdUris,b.emsgSchemeIdUris));c=(0,$jscomp.makeIterator)(b.keyIds);for(var d=c.next();!d.done;d=c.next())a.keyIds.add(d.value);a.originalId==null?a.originalId=b.originalId:(c=b.originalId||"")&&!a.originalId.endsWith(c)&&
(a.originalId+=","+c);c=shaka.drm.DrmUtils.getCommonDrmInfos(a.drmInfos,b.drmInfos);if(b.drmInfos.length&&a.drmInfos.length&&!c.length)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.INCONSISTENT_DRM_ACROSS_PERIODS);a.drmInfos=c;a.encrypted=a.encrypted||b.encrypted;if(b.closedCaptions)for(a.closedCaptions||(a.closedCaptions=new Map),c=(0,$jscomp.makeIterator)(b.closedCaptions),d=c.next();!d.done;d=c.next()){var e=(0,$jscomp.makeIterator)(d.value);
d=e.next().value;e=e.next().value;a.closedCaptions.set(d,e)}a.bandwidth&&b.bandwidth&&(a.bandwidth=Math.max(a.bandwidth,b.bandwidth));b.trickModeVideo?(a.trickModeVideo||(a.trickModeVideo=shaka.util.PeriodCombiner.cloneStream_(b.trickModeVideo),a.trickModeVideo.matchedStreams=[],a.trickModeVideo.createSegmentIndex=function(){if(a.trickModeVideo.segmentIndex)return Promise.resolve();var f=new shaka.media.MetaSegmentIndex;goog.asserts.assert(a.trickModeVideo.matchedStreams,"trickmode matched streams should exist");
for(var g=(0,$jscomp.makeIterator)(a.trickModeVideo.matchedStreams),h=g.next();!h.done;h=g.next())h=h.value,goog.asserts.assert(h.segmentIndex,"trickmode segment index should exist"),f.appendSegmentIndex(h.segmentIndex);a.trickModeVideo.segmentIndex=f;return Promise.resolve()}),a.trickModeVideo.matchedStreams.push(b.trickModeVideo),shaka.util.PeriodCombiner.concatenateStreams_(a.trickModeVideo,b.trickModeVideo)):a.trickModeVideo&&(a.trickModeVideo.matchedStreams.push(b),shaka.util.PeriodCombiner.concatenateStreams_(a.trickModeVideo,
b));b.dependencyStream?(a.dependencyStream||(a.dependencyStream=shaka.util.PeriodCombiner.cloneStream_(b.dependencyStream),a.dependencyStream.matchedStreams=[],a.dependencyStream.createSegmentIndex=function(){if(a.dependencyStream.segmentIndex)return Promise.resolve();var f=new shaka.media.MetaSegmentIndex;goog.asserts.assert(a.dependencyStream.matchedStreams,"dependency video matched streams should exist");for(var g=(0,$jscomp.makeIterator)(a.dependencyStream.matchedStreams),h=g.next();!h.done;h=
g.next())h=h.value,goog.asserts.assert(h.segmentIndex,"dependency video segment index should exist"),f.appendSegmentIndex(h.segmentIndex);a.dependencyStream.segmentIndex=f;return Promise.resolve()}),a.dependencyStream.matchedStreams.push(b.dependencyStream),shaka.util.PeriodCombiner.concatenateStreams_(a.dependencyStream,b.dependencyStream)):a.dependencyStream&&(a.dependencyStream.matchedStreams.push(b),shaka.util.PeriodCombiner.concatenateStreams_(a.dependencyStream,b))};
shaka.util.PeriodCombiner.concatenateStreamDBs_=function(a,b){var c=a.roles;c||(c=[]);for(var d=(0,$jscomp.makeIterator)(b.roles),e=d.next();!e.done;e=d.next())e=e.value,c.includes(e)||c.push(e);a.roles=c;c=(0,$jscomp.makeIterator)(b.keyIds);for(d=c.next();!d.done;d=c.next())a.keyIds.add(d.value);a.encrypted=a.encrypted&&b.encrypted;a.segments.push.apply(a.segments,(0,$jscomp.arrayFromIterable)(b.segments));if(b.closedCaptions)for(a.closedCaptions||(a.closedCaptions=new Map),b=(0,$jscomp.makeIterator)(b.closedCaptions),
c=b.next();!c.done;c=b.next())d=(0,$jscomp.makeIterator)(c.value),c=d.next().value,d=d.next().value,a.closedCaptions.set(c,d)};shaka.util.PeriodCombiner.prototype.findMatchesInAllPeriods_=function(a,b,c){c=(c===void 0?0:c)?b.matchedStreams:[];a=(0,$jscomp.makeIterator)(a);for(var d=a.next();!d.done;d=a.next()){d=this.findBestMatchInPeriod_(d.value,b);if(!d)return;c.push(d)}b.matchedStreams=c};
shaka.util.PeriodCombiner.prototype.findBestMatchInPeriod_=function(a,b){var c=this,d={audio:shaka.util.PeriodCombiner.generateAudioKey_,video:shaka.util.PeriodCombiner.generateVideoKey_,text:shaka.util.PeriodCombiner.generateTextKey_,image:shaka.util.PeriodCombiner.generateImageKey_}[b.type],e=null,f=d(b);if(a.has(f))e=a.get(f);else{f={audio:function(l,m){return c.areAVStreamsCompatible_(l,m)},video:function(l,m){return c.areAVStreamsCompatible_(l,m)},text:shaka.util.PeriodCombiner.areTextStreamsCompatible_,
image:shaka.util.PeriodCombiner.areImageStreamsCompatible_}[b.type];for(var g={audio:shaka.util.PeriodCombiner.isAudioStreamBetterMatch_,video:shaka.util.PeriodCombiner.isVideoStreamBetterMatch_,text:shaka.util.PeriodCombiner.isTextStreamBetterMatch_,image:shaka.util.PeriodCombiner.isImageStreamBetterMatch_}[b.type],h=(0,$jscomp.makeIterator)(a.values()),k=h.next();!k.done;k=h.next())k=k.value,!f(b,k)||b.fastSwitching!=k.fastSwitching||e&&!g(b,e,k)||(e=k)}this.useStreamOnce_&&!shaka.util.PeriodCombiner.isDummy_(e)&&
a.delete(d(e));return e};shaka.util.PeriodCombiner.areAVStreamsExactMatch_=function(a,b){return a.mimeType===b.mimeType&&a.codecs===b.codecs};shaka.util.PeriodCombiner.areAVStreamsCodecsCompatible_=function(a,b){return a.mimeType!=b.mimeType?!1:shaka.util.PeriodCombiner.getCodec_(a.codecs)===shaka.util.PeriodCombiner.getCodec_(b.codecs)};shaka.util.PeriodCombiner.prototype.setUseStreamOnce=function(a){this.useStreamOnce_=a};
shaka.util.PeriodCombiner.prototype.areAVStreamsCompatible_=function(a,b){return a.drmInfos&&!shaka.drm.DrmUtils.areDrmCompatible(a.drmInfos,b.drmInfos)?!1:!0};shaka.util.PeriodCombiner.areTextStreamsCompatible_=function(a,b){return b.language?a.forced!==b.forced||shaka.util.LanguageUtils.relatedness(a.language,b.language)==0||b.kind!=a.kind?!1:!0:!0};shaka.util.PeriodCombiner.areImageStreamsCompatible_=function(a,b){return!0};
shaka.util.PeriodCombiner.isAudioStreamBetterMatch_=function(a,b,c){var d=shaka.util.LanguageUtils,e=shaka.util.PeriodCombiner.BetterOrWorse,f=e.BETTER;e=e.WORSE;var g=shaka.util.PeriodCombiner.compareCodecs_(a,b,c);if(g===f)return!0;if(g===e)return!1;g=d.relatedness(a.language,b.language);d=d.relatedness(a.language,c.language);if(d>g)return!0;if(d<g)return!1;if(b.label!==c.label){if(a.label===b.label)return!1;if(a.label===c.label)return!0}if(a.roles.length){d=b.roles.filter(function(h){return a.roles.includes(h)});
g=c.roles.filter(function(h){return a.roles.includes(h)});if(g.length>d.length)return!0;if(g.length<d.length)return!1;if(c.roles.length!==b.roles.length)return c.roles.length<b.roles.length}else{if(!c.roles.length&&b.roles.length)return!0;if(c.roles.length&&!b.roles.length)return!1}if(!b.primary&&c.primary)return!0;if(b.primary&&!c.primary)return!1;d=shaka.util.PeriodCombiner.compareClosestPreferLower(a.channelsCount,b.channelsCount,c.channelsCount);if(d==f)return!0;if(d==e)return!1;d=shaka.util.PeriodCombiner.compareClosestPreferLower(a.audioSamplingRate,
b.audioSamplingRate,c.audioSamplingRate);return d==f?!0:d==e?!1:a.bandwidth&&shaka.util.PeriodCombiner.compareClosestPreferMinimalAbsDiff_(a.bandwidth,b.bandwidth,c.bandwidth)==f?!0:!1};
shaka.util.PeriodCombiner.isVideoStreamBetterMatch_=function(a,b,c){var d=shaka.util.PeriodCombiner.BetterOrWorse,e=d.BETTER;d=d.WORSE;var f=shaka.util.PeriodCombiner.compareCodecs_(a,b,c);if(f===e)return!0;if(f===d)return!1;f=shaka.util.PeriodCombiner.compareClosestPreferLower(a.width*a.height,b.width*b.height,c.width*c.height);if(f==e)return!0;if(f==d)return!1;if(a.frameRate){f=shaka.util.PeriodCombiner.compareClosestPreferLower(a.frameRate,b.frameRate,c.frameRate);if(f==e)return!0;if(f==d)return!1}return a.bandwidth&&
shaka.util.PeriodCombiner.compareClosestPreferMinimalAbsDiff_(a.bandwidth,b.bandwidth,c.bandwidth)==e?!0:!1};
shaka.util.PeriodCombiner.isTextStreamBetterMatch_=function(a,b,c){var d=shaka.util.LanguageUtils,e=d.relatedness(a.language,b.language);d=d.relatedness(a.language,c.language);if(d>e)return!0;if(d<e)return!1;if(!b.primary&&c.primary)return!0;if(b.primary&&!c.primary)return!1;if(b.label!==c.label){if(a.label===b.label)return!1;if(a.label===c.label)return!0}if(a.roles.length){e=b.roles.filter(function(f){return a.roles.includes(f)});d=c.roles.filter(function(f){return a.roles.includes(f)});if(d.length>
e.length)return!0;if(d.length<e.length)return!1}else{if(!c.roles.length&&b.roles.length)return!0;if(c.roles.length&&!b.roles.length)return!1}return c.mimeType!=a.mimeType||c.codecs!=a.codecs||b.mimeType==a.mimeType&&b.codecs==a.codecs?!1:!0};shaka.util.PeriodCombiner.isImageStreamBetterMatch_=function(a,b,c){var d=shaka.util.PeriodCombiner.BetterOrWorse.BETTER;return shaka.util.PeriodCombiner.compareClosestPreferLower(a.width*a.height,b.width*b.height,c.width*c.height)==d?!0:!1};
shaka.util.PeriodCombiner.dummyStreamDB_=function(a){return{id:0,originalId:"",groupId:null,primary:!1,type:a,mimeType:"",codecs:"",language:"",originalLanguage:null,label:null,width:null,height:null,encrypted:!1,keyIds:new Set,segments:[],variantIds:[],roles:[],forced:!1,channelsCount:null,audioSamplingRate:null,spatialAudio:!1,closedCaptions:null,external:!1,fastSwitching:!1,isAudioMuxedInVideo:!1,baseOriginalId:null}};
shaka.util.PeriodCombiner.dummyStream_=function(a){return{id:0,originalId:"",groupId:null,createSegmentIndex:function(){return Promise.resolve()},segmentIndex:new shaka.media.SegmentIndex([]),mimeType:"",codecs:"",encrypted:!1,drmInfos:[],keyIds:new Set,language:"",originalLanguage:null,label:null,type:a,primary:!1,trickModeVideo:null,dependencyStream:null,emsgSchemeIdUris:null,roles:[],forced:!1,channelsCount:null,audioSamplingRate:null,spatialAudio:!1,closedCaptions:null,accessibilityPurpose:null,
external:!1,fastSwitching:!1,fullMimeTypes:new Set,isAudioMuxedInVideo:!1,baseOriginalId:null}};shaka.util.PeriodCombiner.compareClosestPreferLower=function(a,b,c){var d=shaka.util.PeriodCombiner.BetterOrWorse,e=d.BETTER,f=d.WORSE;if(b==a&&a!=c)return f;if(c==a&&a!=b)return e;if(b>a){if(c<=a||c-a<b-a)return e;if(c-a>b-a)return f}else{if(c>a)return f;if(a-c<a-b)return e;if(a-c>a-b)return f}return d.EQUAL};
shaka.util.PeriodCombiner.compareCodecs_=function(a,b,c){var d=shaka.util.PeriodCombiner.BetterOrWorse,e=d.BETTER,f=d.EQUAL;d=d.WORSE;var g=shaka.util.PeriodCombiner.areAVStreamsExactMatch_(a,b),h=shaka.util.PeriodCombiner.areAVStreamsExactMatch_(a,c);if(g&&!h)return d;if(!g&&h)return e;b=shaka.util.PeriodCombiner.areAVStreamsCodecsCompatible_(a,b);a=shaka.util.PeriodCombiner.areAVStreamsCodecsCompatible_(a,c);return b&&!a?d:!b&&a?e:f};
shaka.util.PeriodCombiner.compareClosestPreferMinimalAbsDiff_=function(a,b,c){var d=shaka.util.PeriodCombiner.BetterOrWorse,e=d.BETTER,f=d.WORSE;b=Math.abs(a-b);a=Math.abs(a-c);return a<b?e:b<a?f:d.EQUAL};shaka.util.PeriodCombiner.isDummy_=function(a){var b=shaka.util.ManifestParserUtils.ContentType;switch(a.type){case b.TEXT:return!a.language;case b.IMAGE:return!a.tilesLayout;default:return!1}};
shaka.util.PeriodCombiner.generateVideoKey_=function(a){return shaka.util.PeriodCombiner.generateKey_([a.fastSwitching,a.width,a.frameRate,a.codecs,a.mimeType,a.label,a.roles,a.closedCaptions?Array.from(a.closedCaptions.entries()):null,a.bandwidth,a.dependencyStream?a.dependencyStream.baseOriginalId:null,Array.from(a.keyIds)])};
shaka.util.PeriodCombiner.generateAudioKey_=function(a){return shaka.util.PeriodCombiner.generateKey_([a.fastSwitching,a.channelsCount,a.language,a.bandwidth,a.label,a.codecs,a.mimeType,a.roles,a.audioSamplingRate,a.primary,a.dependencyStream?a.dependencyStream.baseOriginalId:null,Array.from(a.keyIds)])};shaka.util.PeriodCombiner.generateTextKey_=function(a){return shaka.util.PeriodCombiner.generateKey_([a.language,a.label,a.codecs,a.mimeType,a.bandwidth,a.roles])};
shaka.util.PeriodCombiner.generateImageKey_=function(a){return shaka.util.PeriodCombiner.generateKey_([a.width,a.codecs,a.mimeType])};shaka.util.PeriodCombiner.generateKey_=function(a){return JSON.stringify(a)};shaka.util.PeriodCombiner.getCodec_=function(a){if(!shaka.util.PeriodCombiner.memoizedCodecs.has(a)){var b=shaka.util.MimeUtils.getNormalizedCodec(a);shaka.util.PeriodCombiner.memoizedCodecs.set(a,b)}return shaka.util.PeriodCombiner.memoizedCodecs.get(a)};
shaka.util.PeriodCombiner.isStreamActivelyUsed_=function(a,b,c){c=(0,$jscomp.makeIterator)(c);for(var d=c.next();!d.done;d=c.next())if(d=d.value,d!==b&&d.segmentIndex&&d.matchedStreams&&d.matchedStreams.includes(a))return shaka.log.v2("Stream "+a.id+" is already used in output stream "+(d.id+", cannot close it now.")),!0;shaka.log.v2("Stream "+a.id+" not used anywhere else besides "+(b.id+", good to close."));return!1};goog.exportSymbol("shaka.util.PeriodCombiner",shaka.util.PeriodCombiner);
goog.exportProperty(shaka.util.PeriodCombiner.prototype,"setUseStreamOnce",shaka.util.PeriodCombiner.prototype.setUseStreamOnce);goog.exportProperty(shaka.util.PeriodCombiner.prototype,"combinePeriods",shaka.util.PeriodCombiner.prototype.combinePeriods);goog.exportProperty(shaka.util.PeriodCombiner.prototype,"deleteStream",shaka.util.PeriodCombiner.prototype.deleteStream);goog.exportProperty(shaka.util.PeriodCombiner.prototype,"getImageStreams",shaka.util.PeriodCombiner.prototype.getImageStreams);
goog.exportProperty(shaka.util.PeriodCombiner.prototype,"getTextStreams",shaka.util.PeriodCombiner.prototype.getTextStreams);goog.exportProperty(shaka.util.PeriodCombiner.prototype,"getVariants",shaka.util.PeriodCombiner.prototype.getVariants);shaka.util.PeriodCombiner.BetterOrWorse={BETTER:1,EQUAL:0,WORSE:-1};shaka.util.PeriodCombiner.memoizedCodecs=new Map;shaka.drm.FairPlay=function(){};shaka.drm.FairPlay.isFairPlaySupported=function(){var a;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(b){if(b.getNextAddressJsc()==1)return a={initDataTypes:["cenc","sinf","skd"],videoCapabilities:[{contentType:'video/mp4; codecs="avc1.42E01E"'}]},b.setCatchFinallyBlocks(2),b.yield(navigator.requestMediaKeySystemAccess("com.apple.fps",[a]),4);if(b.getNextAddressJsc()!=2)return b.return(!0);b.enterCatchBlock();return b.return(!1)})};
shaka.drm.FairPlay.defaultGetContentId=function(a){a=shaka.util.StringUtils.fromBytesAutoDetect(a);return(new goog.Uri(a)).getDomain()};shaka.drm.FairPlay.defaultGetKeyId=function(a){a=(new goog.Uri(a)).getDomain().replace(/-/g,"").toLowerCase();return a.length===32&&/^[0-9a-f]+$/.test(a)?a:null};
shaka.drm.FairPlay.initDataTransform=function(a,b,c){if(!c||!c.byteLength)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.SERVER_CERTIFICATE_REQUIRED);b=typeof b=="string"?shaka.util.StringUtils.toUTF16(b,!0):b;a=shaka.util.StringUtils.fromBytesAutoDetect(a);a=shaka.util.StringUtils.toUTF16(a,!0);var d=new Uint8Array(12+a.byteLength+b.byteLength+c.byteLength),e=0,f=function(g){shaka.util.BufferUtils.toDataView(d).setUint32(e,g.byteLength,
!0);e+=4;d.set(shaka.util.BufferUtils.toUint8(g),e);e+=g.byteLength};f(a);f(b);f(c);goog.asserts.assert(e==d.length,"Inconsistent init data length");return d};shaka.drm.FairPlay.basicInitDataTransform_=function(a,b,c){if(b!=="skd")return a;b=c.serverCertificate;c=shaka.util.StringUtils.fromBytesAutoDetect(a).split("skd://").pop();return shaka.drm.FairPlay.initDataTransform(a,c,b)};
shaka.drm.FairPlay.verimatrixInitDataTransform=function(a,b,c){return shaka.drm.FairPlay.basicInitDataTransform_(a,b,c)};shaka.drm.FairPlay.ezdrmInitDataTransform=function(a,b,c){if(b!=="skd")return a;b=c.serverCertificate;c=shaka.util.StringUtils.fromBytesAutoDetect(a).split(";").pop();return shaka.drm.FairPlay.initDataTransform(a,c,b)};
shaka.drm.FairPlay.conaxInitDataTransform=function(a,b,c){if(b!=="skd")return a;b=c.serverCertificate;c=shaka.util.StringUtils.fromBytesAutoDetect(a).split("skd://").pop().split("?").shift();c=window.atob(c);var d=new ArrayBuffer(c.length*2);d=shaka.util.BufferUtils.toUint16(d);for(var e=0,f=c.length;e<f;e++)d[e]=c.charCodeAt(e);return shaka.drm.FairPlay.initDataTransform(a,d,b)};
shaka.drm.FairPlay.expressplayInitDataTransform=function(a,b,c){return shaka.drm.FairPlay.basicInitDataTransform_(a,b,c)};shaka.drm.FairPlay.muxInitDataTransform=function(a,b,c){return shaka.drm.FairPlay.basicInitDataTransform_(a,b,c)};
shaka.drm.FairPlay.verimatrixFairPlayRequest=function(a,b,c){a===shaka.net.NetworkingEngine.RequestType.LICENSE&&(a=b.drmInfo)&&shaka.drm.DrmUtils.isFairPlayKeySystem(a.keySystem)&&(a=shaka.util.BufferUtils.toUint8(b.body),a=shaka.util.Uint8ArrayUtils.toBase64(a),b.headers["Content-Type"]="application/x-www-form-urlencoded",b.body=shaka.util.StringUtils.toUTF8("spc="+a))};
shaka.drm.FairPlay.octetStreamFairPlayRequest_=function(a,b,c){a===shaka.net.NetworkingEngine.RequestType.LICENSE&&(a=b.drmInfo)&&shaka.drm.DrmUtils.isFairPlayKeySystem(a.keySystem)&&(b.headers["Content-Type"]="application/octet-stream")};shaka.drm.FairPlay.ezdrmFairPlayRequest=function(a,b,c){shaka.drm.FairPlay.octetStreamFairPlayRequest_(a,b)};shaka.drm.FairPlay.conaxFairPlayRequest=function(a,b,c){shaka.drm.FairPlay.octetStreamFairPlayRequest_(a,b)};
shaka.drm.FairPlay.expressplayFairPlayRequest=function(a,b,c){a===shaka.net.NetworkingEngine.RequestType.LICENSE&&(c=b.drmInfo)&&shaka.drm.DrmUtils.isFairPlayKeySystem(c.keySystem)&&shaka.drm.FairPlay.octetStreamFairPlayRequest_(a,b)};shaka.drm.FairPlay.muxFairPlayRequest=function(a,b,c){shaka.drm.FairPlay.octetStreamFairPlayRequest_(a,b)};
shaka.drm.FairPlay.commonFairPlayResponse=function(a,b,c){if(a===shaka.net.NetworkingEngine.RequestType.LICENSE&&(a=b.originalRequest.drmInfo)&&shaka.drm.DrmUtils.isFairPlayKeySystem(a.keySystem)){try{var d=shaka.util.StringUtils.fromUTF8(b.data)}catch(f){return}a=!1;d=d.trim();d.substr(0,5)==="<ckc>"&&d.substr(-6)==="</ckc>"&&(d=d.slice(5,-6),a=!0);if(!a)try{var e=JSON.parse(d);e.ckc&&(d=e.ckc,a=!0);e.CkcMessage&&(d=e.CkcMessage,a=!0);e.License&&(d=e.License,a=!0)}catch(f){}a&&(b.data=shaka.util.BufferUtils.toArrayBuffer(shaka.util.Uint8ArrayUtils.fromBase64(d)))}};
goog.exportSymbol("shaka.drm.FairPlay",shaka.drm.FairPlay);goog.exportProperty(shaka.drm.FairPlay,"commonFairPlayResponse",shaka.drm.FairPlay.commonFairPlayResponse);goog.exportProperty(shaka.drm.FairPlay,"muxFairPlayRequest",shaka.drm.FairPlay.muxFairPlayRequest);goog.exportProperty(shaka.drm.FairPlay,"expressplayFairPlayRequest",shaka.drm.FairPlay.expressplayFairPlayRequest);goog.exportProperty(shaka.drm.FairPlay,"conaxFairPlayRequest",shaka.drm.FairPlay.conaxFairPlayRequest);
goog.exportProperty(shaka.drm.FairPlay,"ezdrmFairPlayRequest",shaka.drm.FairPlay.ezdrmFairPlayRequest);goog.exportProperty(shaka.drm.FairPlay,"verimatrixFairPlayRequest",shaka.drm.FairPlay.verimatrixFairPlayRequest);goog.exportProperty(shaka.drm.FairPlay,"muxInitDataTransform",shaka.drm.FairPlay.muxInitDataTransform);goog.exportProperty(shaka.drm.FairPlay,"expressplayInitDataTransform",shaka.drm.FairPlay.expressplayInitDataTransform);
goog.exportProperty(shaka.drm.FairPlay,"conaxInitDataTransform",shaka.drm.FairPlay.conaxInitDataTransform);goog.exportProperty(shaka.drm.FairPlay,"ezdrmInitDataTransform",shaka.drm.FairPlay.ezdrmInitDataTransform);goog.exportProperty(shaka.drm.FairPlay,"verimatrixInitDataTransform",shaka.drm.FairPlay.verimatrixInitDataTransform);goog.exportProperty(shaka.drm.FairPlay,"initDataTransform",shaka.drm.FairPlay.initDataTransform);goog.exportProperty(shaka.drm.FairPlay,"defaultGetContentId",shaka.drm.FairPlay.defaultGetContentId);
goog.exportProperty(shaka.drm.FairPlay,"isFairPlaySupported",shaka.drm.FairPlay.isFairPlaySupported);shaka.media.AdaptationSet=function(a,b,c){c=c===void 0?!0:c;this.root_=a;this.variants_=new Set([a]);b=b||[];a=(0,$jscomp.makeIterator)(b);for(b=a.next();!b.done;b=a.next())this.add(b.value,c)};shaka.media.AdaptationSet.prototype.add=function(a,b){if(this.canInclude(a,b))return this.variants_.add(a),!0;shaka.log.warning("Rejecting variant - not compatible with root.");return!1};
shaka.media.AdaptationSet.prototype.canInclude=function(a,b){return shaka.media.AdaptationSet.areAdaptable(this.root_,a,b===void 0?!0:b)};
shaka.media.AdaptationSet.areAdaptable=function(a,b,c){var d=shaka.media.AdaptationSet;if(!!a.audio!=!!b.audio||!!a.video!=!!b.video||a.language!=b.language)return!1;goog.asserts.assert(!!a.audio==!!b.audio,"Both should either have audio or not have audio.");if(a.audio&&b.audio&&!d.areAudiosCompatible_(a.audio,b.audio,c))return!1;goog.asserts.assert(!!a.video==!!b.video,"Both should either have video or not have video.");return a.video&&b.video&&!d.areVideosCompatible_(a.video,b.video,c)?!1:!0};
shaka.media.AdaptationSet.prototype.values=function(){return this.variants_.values()};shaka.media.AdaptationSet.areAudiosCompatible_=function(a,b,c){var d=shaka.media.AdaptationSet;return(!a.channelsCount||!b.channelsCount||a.channelsCount>2||b.channelsCount>2)&&a.channelsCount!=b.channelsCount||a.spatialAudio!==b.spatialAudio||c&&!d.canTransitionBetween_(a,b)||!d.areRolesEqual_(a.roles,b.roles)||a.groupId!==b.groupId?!1:!0};
shaka.media.AdaptationSet.areVideosCompatible_=function(a,b,c){var d=shaka.media.AdaptationSet;return c&&!d.canTransitionBetween_(a,b)||!d.areRolesEqual_(a.roles,b.roles)?!1:!0};
shaka.media.AdaptationSet.canTransitionBetween_=function(a,b){if(a.mimeType!=b.mimeType)return!1;a=shaka.util.MimeUtils.splitCodecs(a.codecs).map(function(c){return shaka.util.MimeUtils.getCodecBase(c)});b=shaka.util.MimeUtils.splitCodecs(b.codecs).map(function(c){return shaka.util.MimeUtils.getCodecBase(c)});return shaka.util.ArrayUtils.hasSameElements(a,b)};shaka.media.AdaptationSet.areRolesEqual_=function(a,b){return shaka.util.ArrayUtils.hasSameElements(a,b)};
goog.exportSymbol("shaka.media.AdaptationSet",shaka.media.AdaptationSet);shaka.media.PreferenceBasedCriteria=function(){this.lastAdaptationSet_=this.config_=null};shaka.media.PreferenceBasedCriteria.prototype.configure=function(a){this.config_=a};shaka.media.PreferenceBasedCriteria.prototype.getConfiguration=function(){return this.config_};
shaka.media.PreferenceBasedCriteria.prototype.create=function(a){var b=shaka.media.PreferenceBasedCriteria,c;if(this.config_.language){var d=b.filterByLanguage_(a,this.config_.language);d.length&&(c=d)}c||(c=a.filter(function(g){return g.primary}),c=c.length?c:a);a=b.filterVariantsByAudioRole_(c,this.config_.role);a.length?c=a:shaka.log.warning("No exact match for variant audio role could be found.");a=b.filterVariantsByVideoRole_(c,this.config_.videoRole);a.length?c=a:shaka.log.warning("No exact match for variant video role could be found.");
this.config_.videoLayout&&(a=b.filterVariantsByVideoLayout_(c,this.config_.videoLayout),a.length?c=a:shaka.log.warning("No exact match for the video layout could be found."));this.config_.hdrLevel&&(a=b.filterVariantsByHDRLevel_(c,this.config_.hdrLevel),a.length?c=a:shaka.log.warning("No exact match for the hdr level could be found."));var e=[this.config_.channelCount,this.config_.preferredAudioChannelCount];a=e.filter(function(g,h){return g&&e.indexOf(g)===h});if(a.length)for(a=(0,$jscomp.makeIterator)(a),
d=a.next();!d.done;d=a.next())if(d=b.filterVariantsByAudioChannelCount_(c,d.value),d.length){c=d;break}else shaka.log.warning("No exact match for the channel count could be found.");this.config_.audioLabel&&(a=b.filterVariantsByAudioLabel_(c,this.config_.audioLabel),a.length?c=a:shaka.log.warning("No exact match for audio label could be found."));this.config_.videoLabel&&(a=b.filterVariantsByVideoLabel_(c,this.config_.videoLabel),a.length?c=a:shaka.log.warning("No exact match for video label could be found."));
a=b.filterVariantsBySpatialAudio_(c,this.config_.spatialAudio);a.length?c=a:shaka.log.warning("No exact match for spatial audio could be found.");var f=[this.config_.audioCodec,this.config_.activeAudioCodec].concat((0,$jscomp.arrayFromIterable)(this.config_.preferredAudioCodecs));a=f.filter(function(g,h){return g&&f.indexOf(g)===h});if(a.length)for(a=(0,$jscomp.makeIterator)(a),d=a.next();!d.done;d=a.next())if(d=b.filterVariantsByAudioCodec_(c,d.value),d.length){c=d;break}else shaka.log.warning("No exact match for audio codec could be found.");
b=shaka.device.DeviceFactory.getDevice();b=this.config_.codecSwitchingStrategy==shaka.config.CodecSwitchingStrategy.SMOOTH&&b.supportsSmoothCodecSwitching();return this.lastAdaptationSet_=new shaka.media.AdaptationSet(c[0],c,!b)};shaka.media.PreferenceBasedCriteria.prototype.getLastAdaptationSet=function(){return this.lastAdaptationSet_};
shaka.media.PreferenceBasedCriteria.filterByLanguage_=function(a,b){var c=shaka.util.LanguageUtils;b=c.normalize(b);var d=c.findClosestLocale(b,a.map(function(e){return c.getLocaleForVariant(e)}));return d?a.filter(function(e){return d==c.getLocaleForVariant(e)}):[]};shaka.media.PreferenceBasedCriteria.filterVariantsByAudioRole_=function(a,b){return a.filter(function(c){return c.audio?b?c.audio.roles.includes(b):c.audio.roles.length==0:!1})};
shaka.media.PreferenceBasedCriteria.filterVariantsByVideoRole_=function(a,b){return a.filter(function(c){return c.video?b?c.video.roles.includes(b):c.video.roles.length==0:!1})};shaka.media.PreferenceBasedCriteria.filterVariantsByAudioLabel_=function(a,b){return a.filter(function(c){if(!c.audio||!c.audio.label)return!1;c=c.audio.label.toLowerCase();var d=b.toLowerCase();return c==d})};
shaka.media.PreferenceBasedCriteria.filterVariantsByVideoLabel_=function(a,b){return a.filter(function(c){if(!c.video||!c.video.label)return!1;c=c.video.label.toLowerCase();var d=b.toLowerCase();return c==d})};
shaka.media.PreferenceBasedCriteria.filterVariantsByAudioChannelCount_=function(a,b){return a.filter(function(c){return c.audio&&c.audio.channelsCount&&c.audio.channelsCount>b?!1:!0}).sort(function(c,d){return c.audio||d.audio?c.audio?d.audio?(d.audio.channelsCount||0)-(c.audio.channelsCount||0):1:-1:0})};
shaka.media.PreferenceBasedCriteria.filterVariantsByHDRLevel_=function(a,b){if(b=="AUTO"){var c=a.some(function(d){return d.video&&d.video.hdr&&d.video.hdr=="HLG"?!0:!1});b=shaka.device.DeviceFactory.getDevice().getHdrLevel(c)}return a.filter(function(d){return d.video&&d.video.hdr&&d.video.hdr!=b?!1:!0})};shaka.media.PreferenceBasedCriteria.filterVariantsByVideoLayout_=function(a,b){return a.filter(function(c){return c.video&&c.video.videoLayout&&c.video.videoLayout!=b?!1:!0})};
shaka.media.PreferenceBasedCriteria.filterVariantsBySpatialAudio_=function(a,b){return a.filter(function(c){return c.audio&&c.audio.spatialAudio!=b?!1:!0})};shaka.media.PreferenceBasedCriteria.filterVariantsByAudioCodec_=function(a,b){return a.filter(function(c){return c.audio&&c.audio.codecs!=b?!1:!0})};shaka.util.ConfigUtils=function(){};
shaka.util.ConfigUtils.mergeConfigObjects=function(a,b,c,d,e){goog.asserts.assert(a,"Destination config must not be null!");var f=e in d,g=new Set(["__proto__","constructor","prototype"]);var h=f?c.constructor==Object&&Object.keys(d).length==0:c.constructor==Object&&Object.keys(c).length==0;for(var k=f||h,l=!0,m=(0,$jscomp.makeIterator)(Object.keys(b)),n=m.next();!n.done;n=m.next()){n=n.value;var p=e+"."+n,q=f?d[e]:c[n];g.has(n)?(shaka.log.alwaysError("Invalid config, dangerous key "+p),l=!1):k||
n in c?b[n]===void 0?q===void 0||k?delete a[n]:a[n]=shaka.util.ObjectUtils.cloneObject(q):h?a[n]=b[n]:q.constructor==Object&&b[n]&&b[n].constructor==Object?(a[n]||(a[n]=shaka.util.ObjectUtils.cloneObject(q)),n=shaka.util.ConfigUtils.mergeConfigObjects(a[n],b[n],q,d,p),l=l&&n):typeof b[n]!=typeof q||b[n]==null||typeof b[n]!="function"&&b[n].constructor!=q.constructor?(shaka.log.alwaysError("Invalid config, wrong type for "+p),l=!1):typeof c[n]=="function"&&c[n].length!=b[n].length?(shaka.log.alwaysWarn("Unexpected number of arguments for "+
p),a[n]=b[n]):Array.isArray(a[n])?a[n]=b[n].slice():a[n]=b[n]:(shaka.log.alwaysError("Invalid config, unrecognized key "+p),l=!1)}return l};shaka.util.ConfigUtils.convertToConfigObject=function(a,b){for(var c={},d=c,e=0,f=0;;){e=a.indexOf(".",e);if(e<0)break;if(e==0||a[e-1]!="\\")f=a.substring(f,e).replace(/\\\./g,"."),d[f]={},d=d[f],f=e+1;e+=1}d[a.substring(f).replace(/\\\./g,".")]=b;return c};shaka.util.ConfigUtils.referenceParametersAndReturn=function(a,b){return a&&b};
shaka.util.ConfigUtils.getDifferenceFromConfigObjects=function(a,b){var c=function(f){return f&&typeof f==="object"&&!Array.isArray(f)},d=function(f,g){return Object.keys(f).reduce(function(h,k){var l=f[k];if(g.hasOwnProperty(k))if(l instanceof HTMLElement&&g[k]instanceof HTMLElement)l.isEqualNode(g[k])||(h[k]=l);else if(c(l)&&c(g[k])){if(l=d(l,g[k]),Object.keys(l).length>0||!c(l))h[k]=l}else Array.isArray(l)&&Array.isArray(g[k])?shaka.util.ArrayUtils.hasSameElements(l,g[k])||(h[k]=l):Number.isNaN(l)&&
Number.isNaN(g[k])||l!==g[k]&&(h[k]=l);else h[k]=l;return h},{})};a=d(a,b);var e=function(f){for(var g=(0,$jscomp.makeIterator)(Object.keys(f)),h=g.next();!h.done;h=g.next())if(h=h.value,!(f[h]instanceof HTMLElement))if(c(f[h])&&Object.keys(f[h]).length===0)delete f[h];else{var k=f[h];Array.isArray(k)&&k.length===0?delete f[h]:typeof f[h]=="function"?delete f[h]:c(f[h])&&(e(f[h]),Object.keys(f[h]).length===0&&delete f[h])}};e(a);return a};goog.exportSymbol("shaka.util.ConfigUtils",shaka.util.ConfigUtils);
goog.exportProperty(shaka.util.ConfigUtils,"getDifferenceFromConfigObjects",shaka.util.ConfigUtils.getDifferenceFromConfigObjects);goog.exportProperty(shaka.util.ConfigUtils,"convertToConfigObject",shaka.util.ConfigUtils.convertToConfigObject);goog.exportProperty(shaka.util.ConfigUtils,"mergeConfigObjects",shaka.util.ConfigUtils.mergeConfigObjects);shaka.util.PlayerConfiguration=function(){};
shaka.util.PlayerConfiguration.createDefault=function(){var a=Infinity,b=shaka.device.DeviceFactory.getDevice();navigator.connection&&navigator.connection.saveData&&(a=360);var c={retryParameters:shaka.net.NetworkingEngine.defaultRetryParameters(),servers:{},clearKeys:{},advanced:{},delayLicenseRequestUntilPlayed:!1,persistentSessionOnlinePlayback:!1,persistentSessionsMetadata:[],initDataTransform:function(k,l,m){shaka.drm.DrmUtils.isMediaKeysPolyfilled("apple")&&l=="skd"&&(l=m.serverCertificate,
m=shaka.drm.FairPlay.defaultGetContentId(k),k=shaka.drm.FairPlay.initDataTransform(k,m,l));return k},logLicenseExchange:!1,updateExpirationTime:1,preferredKeySystems:[],keySystemsMapping:{},parseInbandPsshEnabled:!1,minHdcpVersion:"",ignoreDuplicateInitData:!0,defaultAudioRobustnessForWidevine:"SW_SECURE_CRYPTO",defaultVideoRobustnessForWidevine:"SW_SECURE_DECODE"},d=shaka.config.CodecSwitchingStrategy.RELOAD;b.supportsSmoothCodecSwitching()&&(d=shaka.config.CodecSwitchingStrategy.SMOOTH);var e={retryParameters:shaka.net.NetworkingEngine.defaultRetryParameters(),
availabilityWindowOverride:NaN,disableAudio:!1,disableVideo:!1,disableText:!1,disableThumbnails:!1,disableIFrames:!1,defaultPresentationDelay:0,segmentRelativeVttTiming:!1,raiseFatalErrorOnManifestUpdateRequestFailure:!1,continueLoadingWhenPaused:!0,ignoreSupplementalCodecs:!1,updatePeriod:-1,ignoreDrmInfo:!1,enableAudioGroups:!0,dash:{clockSyncUri:"",disableXlinkProcessing:!0,xlinkFailGracefully:!1,ignoreMinBufferTime:!1,autoCorrectDrift:!0,initialSegmentLimit:1E3,ignoreSuggestedPresentationDelay:!1,
ignoreEmptyAdaptationSet:!1,ignoreMaxSegmentDuration:!1,keySystemsByURI:{"urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b":"org.w3.clearkey","urn:uuid:e2719d58-a985-b3c9-781a-b030af78d30e":"org.w3.clearkey","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":"com.widevine.alpha","urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":"com.microsoft.playready","urn:uuid:79f0049a-4098-8642-ab92-e65be0885f95":"com.microsoft.playready","urn:uuid:94ce86fb-07ff-4f43-adb8-93d2fa968ca2":"com.apple.fps","urn:uuid:3d5e6d35-9b9a-41e8-b843-dd3c6e72c42c":"com.huawei.wiseplay"},
manifestPreprocessor:shaka.util.PlayerConfiguration.defaultManifestPreprocessor,manifestPreprocessorTXml:shaka.util.PlayerConfiguration.defaultManifestPreprocessorTXml,sequenceMode:!1,useStreamOnceInPeriodFlattening:!1,enableFastSwitching:!0},hls:{ignoreTextStreamFailures:!1,ignoreImageStreamFailures:!1,defaultAudioCodec:"mp4a.40.2",defaultVideoCodec:"avc1.42E01E",ignoreManifestProgramDateTime:!1,ignoreManifestProgramDateTimeForTypes:[],mediaPlaylistFullMimeType:'video/mp2t; codecs="avc1.42E01E, mp4a.40.2"',
liveSegmentsDelay:3,sequenceMode:b.supportsSequenceMode(),ignoreManifestTimestampsInSegmentsMode:!1,disableCodecGuessing:!1,disableClosedCaptionsDetection:!1,allowLowLatencyByteRangeOptimization:!0,allowRangeRequestsToGuessMimeType:!1},mss:{manifestPreprocessor:shaka.util.PlayerConfiguration.defaultManifestPreprocessor,manifestPreprocessorTXml:shaka.util.PlayerConfiguration.defaultManifestPreprocessorTXml,sequenceMode:!1,keySystemsBySystemId:{"9a04f079-9840-4286-ab92-e65be0885f95":"com.microsoft.playready",
"79f0049a-4098-8642-ab92-e65be0885f95":"com.microsoft.playready"}}},f={retryParameters:shaka.net.NetworkingEngine.defaultRetryParameters(),failureCallback:function(k){shaka.log.error("Unhandled streaming error",k);return shaka.util.ConfigUtils.referenceParametersAndReturn([k],void 0)},rebufferingGoal:0,bufferingGoal:10,bufferBehind:30,evictionGoal:1,ignoreTextStreamFailures:!1,alwaysStreamText:!1,startAtSegmentBoundary:!1,gapDetectionThreshold:.5,gapPadding:0,gapJumpTimerTime:.25,durationBackoff:1,
safeSeekOffset:5,safeSeekEndOffset:0,stallEnabled:!0,stallThreshold:1,stallSkip:.1,useNativeHlsForFairPlay:!0,inaccurateManifestTolerance:2,lowLatencyMode:!0,preferNativeDash:!1,preferNativeHls:!1,updateIntervalSeconds:1,observeQualityChanges:!1,maxDisabledTime:30,segmentPrefetchLimit:1,prefetchAudioLanguages:[],disableAudioPrefetch:!1,disableTextPrefetch:!1,disableVideoPrefetch:!1,liveSync:{enabled:!1,targetLatency:.5,targetLatencyTolerance:.5,maxPlaybackRate:1.1,minPlaybackRate:.95,panicMode:!1,
panicThreshold:60,dynamicTargetLatency:{enabled:!1,stabilityThreshold:60,rebufferIncrement:.5,maxAttempts:10,maxLatency:4,minLatency:1}},allowMediaSourceRecoveries:!0,minTimeBetweenRecoveries:5,vodDynamicPlaybackRate:!1,vodDynamicPlaybackRateLowBufferRate:.95,vodDynamicPlaybackRateBufferRatio:.5,preloadNextUrlWindow:30,loadTimeout:30,clearDecodingCache:!1,dontChooseCodecs:!1,shouldFixTimestampOffset:!1,avoidEvictionOnQuotaExceededError:!1,crossBoundaryStrategy:shaka.config.CrossBoundaryStrategy.KEEP,
returnToEndOfLiveWindowWhenOutside:!1},g={trackSelectionCallback:function(k){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(l){return l.return(k)})},downloadSizeCallback:function(k){var l;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(m){if(m.getNextAddressJsc()==1)return navigator.storage&&navigator.storage.estimate?m.yield(navigator.storage.estimate(),3):m.return(!0);l=m.getYieldResultJsc();return m.return(l.usage+k<l.quota*.95)})},progressCallback:function(k,l){return shaka.util.ConfigUtils.referenceParametersAndReturn([k,
l],void 0)},usePersistentLicense:!0,numberOfParallelDownloads:5},h={drm:c,manifest:e,streaming:f,networking:{forceHTTP:!1,forceHTTPS:!1,minBytesForProgressEvents:16E3},mediaSource:{codecSwitchingStrategy:d,addExtraFeaturesToSourceBuffer:function(k){return shaka.util.ConfigUtils.referenceParametersAndReturn([k],"")},forceTransmux:!1,insertFakeEncryptionInInit:!0,correctEc3Enca:!1,modifyCueCallback:function(k,l,m){return shaka.util.ConfigUtils.referenceParametersAndReturn([k,l,m],void 0)},dispatchAllEmsgBoxes:!1,
useSourceElements:!0,durationReductionEmitsUpdateEnd:!0},offline:g,abrFactory:function(){return new shaka.abr.SimpleAbrManager},adaptationSetCriteriaFactory:function(){var k=$jscomp.getRestArguments.apply(0,arguments);return new (Function.prototype.bind.apply(shaka.media.PreferenceBasedCriteria,[null].concat((0,$jscomp.arrayFromIterable)(k))))},abr:{enabled:!0,useNetworkInformation:!0,defaultBandwidthEstimate:1E6,switchInterval:8,bandwidthUpgradeTarget:.85,bandwidthDowngradeTarget:.95,restrictions:{minWidth:0,
maxWidth:Infinity,minHeight:0,maxHeight:a,minPixels:0,maxPixels:Infinity,minFrameRate:0,maxFrameRate:Infinity,minBandwidth:0,maxBandwidth:Infinity,minChannelsCount:0,maxChannelsCount:Infinity},advanced:{minTotalBytes:128E3,minBytes:16E3,fastHalfLife:2,slowHalfLife:5},restrictToElementSize:!1,restrictToScreenSize:!1,ignoreDevicePixelRatio:!1,clearBufferSwitch:!1,safeMarginSwitch:0,cacheLoadThreshold:5,minTimeToSwitch:0,preferNetworkInformationBandwidth:!1,removeLatencyFromFirstPacketTime:!1},autoShowText:shaka.config.AutoShowText.IF_SUBTITLES_MAY_BE_NEEDED,
preferredAudioLanguage:"",preferredAudioLabel:"",preferredTextLanguage:"",preferredAudioRole:"",preferredVideoRole:"",preferredTextRole:"",preferredAudioChannelCount:2,preferredVideoHdrLevel:"AUTO",preferredVideoLayout:"",preferredVideoLabel:"",preferredVideoCodecs:[],preferredAudioCodecs:[],preferredTextFormats:[],preferForcedSubs:!1,preferSpatialAudio:!1,preferredDecodingAttributes:[],restrictions:{minWidth:0,maxWidth:Infinity,minHeight:0,maxHeight:Infinity,minPixels:0,maxPixels:Infinity,minFrameRate:0,
maxFrameRate:Infinity,minBandwidth:0,maxBandwidth:Infinity,minChannelsCount:0,maxChannelsCount:Infinity},playRangeStart:0,playRangeEnd:Infinity,textDisplayer:{captionsUpdatePeriod:.25,fontScaleFactor:1},textDisplayFactory:function(){return null},cmcd:{enabled:!1,sessionId:"",contentId:"",rtpSafetyFactor:5,useHeaders:!1,includeKeys:[],version:1,targets:[]},cmsd:{enabled:!0,applyMaximumSuggestedBitrate:!0,estimatedThroughputWeightRatio:.5},lcevc:{enabled:!1,dynamicPerformanceScaling:!0,logLevel:0,drawLogo:!1,
poster:!0},ads:{customPlayheadTracker:!1,skipPlayDetection:!1,supportsMultipleMediaElements:!0,disableHLSInterstitial:!1,disableDASHInterstitial:!1,allowPreloadOnDomElements:!0,allowStartInMiddleOfInterstitial:!0},ignoreHardwareResolution:!1,queue:{preloadNextUrlWindow:Infinity,preloadPrevItem:!0,repeatMode:shaka.config.RepeatMode.OFF}};g.trackSelectionCallback=function(k){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(l){return l.return(shaka.util.PlayerConfiguration.defaultTrackSelect(k,
h.preferredAudioLanguage,h.preferredVideoHdrLevel))})};return b.adjustConfig(h)};shaka.util.PlayerConfiguration.createDefaultForLL=function(){return{streaming:{inaccurateManifestTolerance:0,segmentPrefetchLimit:2,updateIntervalSeconds:.1,maxDisabledTime:1,retryParameters:{baseDelay:100}},manifest:{dash:{autoCorrectDrift:!1},retryParameters:{baseDelay:100}},drm:{retryParameters:{baseDelay:100}}}};
shaka.util.PlayerConfiguration.mergeConfigObjects=function(a,b,c){var d={".drm.keySystemsMapping":"",".drm.servers":"",".drm.clearKeys":"",".drm.advanced":{distinctiveIdentifierRequired:!1,persistentStateRequired:!1,videoRobustness:[],audioRobustness:[],sessionType:"",serverCertificate:new Uint8Array(0),serverCertificateUri:"",individualizationServer:"",headers:{}}};return shaka.util.ConfigUtils.mergeConfigObjects(a,b,c||shaka.util.PlayerConfiguration.createDefault(),d,"")};
shaka.util.PlayerConfiguration.defaultTrackSelect=function(a,b,c){var d=shaka.util.ManifestParserUtils.ContentType,e=shaka.util.LanguageUtils,f=c;f=="AUTO"&&(c=a.some(function(l){return l.hdr&&l.hdr=="HLG"?!0:!1}),f=shaka.device.DeviceFactory.getDevice().getHdrLevel(c));var g=a.filter(function(l){return l.type!="variant"||l.hdr&&l.hdr!=f?!1:!0});c=[];var h=e.findClosestLocale(b,g.map(function(l){return l.language}));h&&(c=g.filter(function(l){return e.normalize(l.language)==h}));c.length==0&&(c=g.filter(function(l){return l.primary}));
c.length==0&&((new Set(g.map(function(l){return l.language}))).size>1&&shaka.log.warning("Could not choose a good audio track based on language preferences or primary tracks.  An arbitrary language will be stored!"),c=g);var k=c.filter(function(l){return l.height&&l.height<=480});k.length&&(k.sort(function(l,m){goog.asserts.assert(l.height!=null,"Null height");goog.asserts.assert(m.height!=null,"Null height");return m.height-l.height}),c=k.filter(function(l){return l.height==k[0].height}));b=[];c.length&&
(g=Math.floor(c.length/2),c.sort(function(l,m){return l.bandwidth-m.bandwidth}),b.push(c[g]));a=(0,$jscomp.makeIterator)(a);for(c=a.next();!c.done;c=a.next())c=c.value,c.type!=d.TEXT&&c.type!=d.IMAGE||b.push(c);return b};shaka.util.PlayerConfiguration.defaultManifestPreprocessor=function(a){return shaka.util.ConfigUtils.referenceParametersAndReturn([a],a)};shaka.util.PlayerConfiguration.defaultManifestPreprocessorTXml=function(a){return shaka.util.ConfigUtils.referenceParametersAndReturn([a],a)};
goog.exportSymbol("shaka.util.PlayerConfiguration",shaka.util.PlayerConfiguration);goog.exportProperty(shaka.util.PlayerConfiguration,"mergeConfigObjects",shaka.util.PlayerConfiguration.mergeConfigObjects);goog.exportProperty(shaka.util.PlayerConfiguration,"createDefaultForLL",shaka.util.PlayerConfiguration.createDefaultForLL);goog.exportProperty(shaka.util.PlayerConfiguration,"createDefault",shaka.util.PlayerConfiguration.createDefault);shaka.util.TimeUtils=function(){};shaka.util.TimeUtils.convertNtp=function(a){var b=Date.UTC(1900,0,1,0,0,0,0);return(new Date(b+a)).getTime()};shaka.util.XmlUtils=function(){};
shaka.util.XmlUtils.parseXmlString=function(a,b){var c=new DOMParser,d=shaka.util.XmlUtils.trustedHTMLFromString_.value()(a);a=null;try{a=c.parseFromString(d,"text/xml")}catch(e){return shaka.log.error("XML parsing exception:",e),null}goog.asserts.assert(a,"Parsed XML document cannot be null!");c=a.documentElement;if(!c)return shaka.log.error("XML document was empty!"),null;d=c.getElementsByTagName("parsererror");if(d.length)return shaka.log.error("XML parser error found:",d[0]),null;if(c.tagName!=
b)return shaka.log.error('XML tag name does not match expected "'+b+'":',c.tagName),null;if(!("createNodeIterator"in document))return c;for(b=document.createNodeIterator(a,NodeFilter.SHOW_ALL);a=b.nextNode();)if(a instanceof HTMLElement||a instanceof SVGElement)return shaka.log.error("XML document embeds unsafe content!"),null;return c};
shaka.util.XmlUtils.parseXml=function(a,b){try{var c=shaka.util.StringUtils.fromBytesAutoDetect(a);return shaka.util.XmlUtils.parseXmlString(c,b)}catch(d){return shaka.log.error("parseXmlString threw!",d),null}};shaka.util.XmlUtils.toArrayBuffer=function(a){return shaka.util.StringUtils.toUTF8(a.outerHTML)};
shaka.util.XmlUtils.trustedHTMLFromString_=new shaka.util.Lazy(function(){if(typeof trustedTypes!=="undefined"){var a=trustedTypes.createPolicy("shaka-player#xml",{createHTML:function(b){return b}});return function(b){return a.createHTML(b)}}return function(b){return b}});shaka.dash.DashParser=function(){var a=this;this.playerInterface_=this.config_=null;this.manifestUris_=[];this.manifest_=null;this.globalId_=1;this.patchLocationNodes_=[];this.manifestPatchContext_={mpdId:"",type:"",profiles:[],mediaPresentationDuration:null,availabilityTimeOffset:0,getBaseUris:null,publishTime:0};this.contextCache_=new Map;this.continuityCache_=new Map;this.parsedPeriodCache_=new Map;this.streamMap_=new Map;this.indexStreamMap_=new Map;this.periodDurations_=new Map;this.periodCombiner_=
new shaka.util.PeriodCombiner;this.updatePeriod_=0;this.averageUpdateDuration_=new shaka.abr.Ewma(5);this.updateTimer_=new shaka.util.Timer(function(){if(a.mediaElement_&&!a.config_.continueLoadingWhenPaused&&(a.eventManager_.unlisten(a.mediaElement_,"timeupdate"),a.mediaElement_.paused)){a.eventManager_.listenOnce(a.mediaElement_,"timeupdate",function(){return a.onUpdate_()});return}a.onUpdate_()});this.operationManager_=new shaka.util.OperationManager;this.largestPeriodStartTime_=null;this.lastManifestUpdatePeriodIds_=
[];this.minTotalAvailabilityTimeOffset_=Infinity;this.lowLatencyMode_=!1;this.contentSteeringManager_=null;this.gapCount_=0;this.isLowLatency_=!1;this.eventManager_=new shaka.util.EventManager;this.mediaElement_=null;this.isTransitionFromDynamicToStatic_=!1;this.lastManifestQueryParams_="";this.isPreloadFn_=function(){return!1};this.lastCalculatedBaseUris_=[];this.parsedPrftNodes_=new Set;this.contentProtection_=new shaka.dash.ContentProtection};
shaka.dash.DashParser.prototype.configure=function(a,b){goog.asserts.assert(a.dash!=null,"DashManifestConfiguration should not be null!");var c=this.playerInterface_&&a.updatePeriod!=this.config_.updatePeriod&&a.updatePeriod>=0;this.config_=a;b&&(this.isPreloadFn_=b);c&&this.manifest_&&this.manifest_.presentationTimeline.isLive()&&this.updateNow_();this.contentSteeringManager_&&this.contentSteeringManager_.configure(this.config_);this.periodCombiner_&&this.periodCombiner_.setUseStreamOnce(this.config_.dash.useStreamOnceInPeriodFlattening)};
shaka.dash.DashParser.prototype.start=function(a,b){var c=this,d;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(e){if(e.getNextAddressJsc()==1)return goog.asserts.assert(c.config_,"Must call configure() before start()!"),c.lowLatencyMode_=b.isLowLatencyMode(),c.manifestUris_=[a],c.playerInterface_=b,e.yield(c.requestManifest_(),2);d=e.getYieldResultJsc();c.playerInterface_&&c.setUpdateTimer_(d);if(!c.playerInterface_)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.PLAYER,
shaka.util.Error.Code.OPERATION_ABORTED);goog.asserts.assert(c.manifest_,"Manifest should be non-null!");return e.return(c.manifest_)})};
shaka.dash.DashParser.prototype.stop=function(){for(var a=(0,$jscomp.makeIterator)(this.streamMap_.values()),b=a.next();!b.done;b=a.next())b=b.value,b.segmentIndex&&b.segmentIndex.release();this.periodCombiner_&&this.periodCombiner_.release();this.config_=this.playerInterface_=null;this.manifestUris_=[];this.manifest_=null;this.streamMap_.clear();this.indexStreamMap_.clear();this.contextCache_.clear();this.continuityCache_.clear();this.parsedPeriodCache_.clear();this.manifestPatchContext_={mpdId:"",
type:"",profiles:[],mediaPresentationDuration:null,availabilityTimeOffset:0,getBaseUris:null,publishTime:0};this.periodCombiner_=null;this.updateTimer_!=null&&(this.updateTimer_.stop(),this.updateTimer_=null);this.contentSteeringManager_&&this.contentSteeringManager_.destroy();this.eventManager_&&(this.eventManager_.release(),this.eventManager_=null);this.parsedPrftNodes_.clear();this.contentProtection_.release();return this.operationManager_.destroy()};
shaka.dash.DashParser.prototype.update=function(){var a=this,b;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){if(c.getNextAddressJsc()==1)return c.setCatchFinallyBlocks(2),c.yield(a.requestManifest_(),4);if(c.getNextAddressJsc()!=2)return c.leaveTryBlock(0);b=c.enterCatchBlock();if(!a.playerInterface_||!b)return c.return();goog.asserts.assert(b instanceof shaka.util.Error,"Bad error type");a.playerInterface_.onError(b);c.jumpToEnd()})};
shaka.dash.DashParser.prototype.onExpirationUpdated=function(a,b){};shaka.dash.DashParser.prototype.onInitialVariantChosen=function(a){if(this.manifest_&&this.manifest_.presentationTimeline.isLive()){var b=a.video||a.audio;if(b&&b.segmentIndex){a=this.manifest_.presentationTimeline.getSegmentAvailabilityEnd();var c=b.segmentIndex.find(a);c!=null&&(b=b.segmentIndex.get(c))&&(this.updatePeriod_=b.endTime-a,this.setUpdateTimer_(0))}}};
shaka.dash.DashParser.prototype.banLocation=function(a){this.contentSteeringManager_&&this.contentSteeringManager_.banLocation(a)};shaka.dash.DashParser.prototype.setMediaElement=function(a){this.mediaElement_=a};
shaka.dash.DashParser.prototype.requestManifest_=function(){var a=this,b,c,d,e,f,g,h,k,l,m,n,p;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(q){if(q.getNextAddressJsc()==1)return b=shaka.net.NetworkingEngine.RequestType.MANIFEST,c=shaka.net.NetworkingEngine.AdvancedRequestType.MPD,d="MPD",e=a.getPatchLocationUris_(),f=a.manifestUris_,e.length?(f=e,d="Patch",c=shaka.net.NetworkingEngine.AdvancedRequestType.MPD_PATCH):a.manifestUris_.length>1&&a.contentSteeringManager_&&(g=a.contentSteeringManager_.getLocations("Location",
!0),g.length&&(f=g)),h=shaka.net.NetworkingEngine.makeRequest(f,a.config_.retryParameters),k=Date.now(),q.yield(a.makeNetworkRequest_(h,b,{type:c}),2);if(q.getNextAddressJsc()!=3){l=q.getYieldResultJsc();if(!a.playerInterface_)return q.return(0);l.uri&&l.uri!=l.originalUri&&!a.manifestUris_.includes(l.uri)&&a.manifestUris_.unshift(l.uri);m=new goog.Uri(l.uri);a.lastManifestQueryParams_=m.getQueryData().toString();return q.yield(a.parseManifest_(l.data,l.uri,d),3)}n=Date.now();p=(n-k)/1E3;a.averageUpdateDuration_.sample(1,
p);a.parsedPrftNodes_.clear();return q.return(p)})};
shaka.dash.DashParser.prototype.parseManifest_=function(a,b,c){var d=this,e,f,g,h,k,l,m,n,p,q,r;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(t){if(t.getNextAddressJsc()==1){e=a;f=d.config_.dash.manifestPreprocessor;g=shaka.util.PlayerConfiguration.defaultManifestPreprocessor;if(f!=g){shaka.Deprecate.deprecateFeature(5,"manifest.dash.manifestPreprocessor configuration","Please Use manifest.dash.manifestPreprocessorTXml instead.");h=shaka.util.XmlUtils.parseXml(e,c);if(!h)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_INVALID_XML,b);f(h);e=shaka.util.XmlUtils.toArrayBuffer(h)}k=shaka.util.TXml.parseXml(e,c);if(!k)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_INVALID_XML,b);l=d.config_.dash.manifestPreprocessorTXml;m=shaka.util.PlayerConfiguration.defaultManifestPreprocessorTXml;l!=m&&l(k);if(c==="Patch")return t.return(d.processPatchManifest_(k));if(n=d.config_.dash.disableXlinkProcessing)return t.return(d.processManifest_(k,
b));p=d.config_.dash.xlinkFailGracefully;q=shaka.dash.MpdUtils.processXlinks(k,d.config_.retryParameters,p,b,d.playerInterface_.networkingEngine);d.operationManager_.manage(q);return t.yield(q.promise,2)}r=t.getYieldResultJsc();return t.return(d.processManifest_(r,b))})};
shaka.dash.DashParser.prototype.processManifest_=function(a,b){var c=this,d,e,f,g,h,k,l,m,n,p,q,r,t,u,v,w,x,y,C,D,A,z,B,E,H,N,F,I,L,G,M,J,O,P,Q,K,T,U,W,X,V,S,Z,R,ba,da,ja,ea,fa,pa,ha,ia,ca,ka,aa,la,ma,na,oa;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(Y){switch(Y.getNextAddressJsc()){case 1:d=shaka.util.TXml;goog.asserts.assert(c.config_,"Must call configure() before processManifest_()!");c.contentSteeringManager_&&c.contentSteeringManager_.clearPreviousLocations();e=[b];f=[];g=
new Map;h=d.findChildren(a,"Location");k=(0,$jscomp.makeIterator)(h);for(l=k.next();!l.done;l=k.next())if(m=l.value,n=m.attributes.serviceLocation,p=d.getContents(m))q=shaka.util.ManifestParserUtils.resolveUris(e,[p])[0],n&&(c.contentSteeringManager_?c.contentSteeringManager_.addLocation("Location",n,q):g.set(n,q)),f.push(q);c.contentSteeringManager_?(r=c.contentSteeringManager_.getLocations("Location",!0),r.length>0&&(e=c.manifestUris_=r)):f.length&&(e=c.manifestUris_=f);c.manifestPatchContext_.mpdId=
a.attributes.id||"";c.manifestPatchContext_.publishTime=d.parseAttr(a,"publishTime",d.parseDate)||0;c.patchLocationNodes_=d.findChildren(a,"PatchLocation");t=Promise.resolve();if((u=d.findChild(a,"ContentSteering"))&&c.playerInterface_){v=u.attributes.defaultServiceLocation;if(c.contentSteeringManager_)c.contentSteeringManager_.setBaseUris(e),c.contentSteeringManager_.setDefaultPathwayId(v);else if(c.contentSteeringManager_=new shaka.util.ContentSteeringManager(c.playerInterface_),c.contentSteeringManager_.configure(c.config_),
c.contentSteeringManager_.setManifestType(shaka.media.ManifestParser.DASH),c.contentSteeringManager_.setBaseUris(e),c.contentSteeringManager_.setDefaultPathwayId(v),w=d.getContents(u))(x=d.parseAttr(u,"queryBeforeStart",d.parseBoolean,!1))?t=c.contentSteeringManager_.requestInfo(w):c.contentSteeringManager_.requestInfo(w);y=(0,$jscomp.makeIterator)(g.keys());for(C=y.next();!C.done;C=y.next())D=C.value,A=g.get(D),c.contentSteeringManager_.addLocation("Location",D,A)}z=d.findChildren(a,"BaseURL");B=
!1;if(c.contentSteeringManager_)for(E=(0,$jscomp.makeIterator)(z),H=E.next();!H.done;H=E.next())N=H.value,F=N.attributes.serviceLocation,I=d.getContents(N),F&&I&&(c.contentSteeringManager_.addLocation("BaseURL",F,I),B=!0);c.lastCalculatedBaseUris_.splice(0);B&&c.contentSteeringManager_||(L=z.map(d.getContents),c.lastCalculatedBaseUris_.push.apply(c.lastCalculatedBaseUris_,(0,$jscomp.arrayFromIterable)(shaka.util.ManifestParserUtils.resolveUris(e,L))));G=c.contentSteeringManager_;M=c.lastCalculatedBaseUris_;
J=shaka.dash.DashParser.makeBaseUriGetter_;O=J.call(shaka.dash.DashParser,G,B,M);c.manifestPatchContext_.getBaseUris=O;P=0;z&&z.length&&(P=d.parseAttr(z[0],"availabilityTimeOffset",d.parseFloat)||0);c.manifestPatchContext_.availabilityTimeOffset=P;c.updatePeriod_=d.parseAttr(a,"minimumUpdatePeriod",d.parseDuration,-1);Q=d.parseAttr(a,"availabilityStartTime",d.parseDate);K=d.parseAttr(a,"timeShiftBufferDepth",d.parseDuration);T=c.config_.dash.ignoreSuggestedPresentationDelay;U=null;T||(U=d.parseAttr(a,
"suggestedPresentationDelay",d.parseDuration));W=c.config_.dash.ignoreMaxSegmentDuration;X=null;W||(X=d.parseAttr(a,"maxSegmentDuration",d.parseDuration));V=a.attributes.type||"static";c.manifest_&&c.manifest_.presentationTimeline&&(c.isTransitionFromDynamicToStatic_=c.manifest_.presentationTimeline.isLive()&&V=="static");c.manifestPatchContext_.type=V;if(c.manifest_)for(S=c.manifest_.presentationTimeline,Z=S.getSegmentAvailabilityStart(),R=(0,$jscomp.makeIterator)(c.streamMap_.values()),ba=R.next();!ba.done;ba=
R.next())da=ba.value,da.segmentIndex&&da.segmentIndex.evict(Z);else ja=c.config_.dash.ignoreMinBufferTime,ea=0,ja||(ea=d.parseAttr(a,"minBufferTime",d.parseDuration)||0),fa=0,fa=U!=null?Math.min(U,K||Infinity):c.config_.defaultPresentationDelay>0?c.config_.defaultPresentationDelay:Math.min(ea*1.5,K||Infinity),S=new shaka.media.PresentationTimeline(Q,fa,c.config_.dash.autoCorrectDrift);S.setStatic(V=="static");(pa=S.isLive())&&!isNaN(c.config_.availabilityWindowOverride)&&(K=c.config_.availabilityWindowOverride);
K==null&&(K=Infinity);S.setSegmentAvailabilityDuration(K);ha=a.attributes.profiles||"";c.manifestPatchContext_.profiles=ha.split(",");ia={dynamic:V!="static",presentationTimeline:S,period:null,periodInfo:null,adaptationSet:null,representation:null,bandwidth:0,indexRangeWarningGiven:!1,availabilityTimeOffset:P,mediaPresentationDuration:null,profiles:ha.split(","),roles:null,urlParams:shaka.dash.DashParser.defaultUrlParams_};return Y.yield(t,2);case 2:c.gapCount_=0;ca=c.parsePeriods_(ia,O,a,!1);ka=
ca.duration;aa=ca.periods;(V!="static"||c.isTransitionFromDynamicToStatic_)&&ca.durationDerivedFromPeriods||S.setDuration(ka||Infinity);c.isLowLatency_&&c.lowLatencyMode_&&S.setAvailabilityTimeOffset(c.minTotalAvailabilityTimeOffset_);S.notifyMaxSegmentDuration(X||1);goog.DEBUG&&!c.isTransitionFromDynamicToStatic_&&S.assertIsValid();c.isLowLatency_&&c.lowLatencyMode_&&(la=U!=null?U:c.config_.defaultPresentationDelay,S.setDelay(la));if(!c.manifest_)return Y.yield(c.periodCombiner_.combinePeriods(aa,
ia.dynamic),6);c.manifest_.periodCount=aa.length;c.manifest_.gapCount=c.gapCount_;return Y.yield(c.postPeriodProcessing_(aa,!1),4);case 6:c.manifest_={presentationTimeline:S,variants:c.periodCombiner_.getVariants(),textStreams:c.periodCombiner_.getTextStreams(),imageStreams:c.periodCombiner_.getImageStreams(),offlineSessionIds:[],sequenceMode:c.config_.dash.sequenceMode,ignoreManifestTimestampsInSegmentsMode:!1,type:shaka.media.ManifestParser.DASH,serviceDescription:c.parseServiceDescription_(a),
nextUrl:c.parseMpdChaining_(a),periodCount:aa.length,gapCount:c.gapCount_,isLowLatency:c.isLowLatency_,startTime:null};if(!S.usingPresentationStartTime()){Y.jumpTo(7);break}ma=shaka.util.TXml;na=ma.findChildren(a,"UTCTiming");return Y.yield(c.parseUtcTiming_(O,na),8);case 8:oa=Y.getYieldResultJsc();if(!c.playerInterface_)return Y.return();S.setClockOffset(oa);case 7:S.lockStartTime(),c.periodCombiner_&&!c.manifest_.presentationTimeline.isLive()&&c.periodCombiner_.release();case 4:c.playerInterface_.makeTextStreamsForClosedCaptions(c.manifest_),
c.cleanStreamMap_(),c.cleanContinuityCache_(aa),Y.jumpToEnd()}})};
shaka.dash.DashParser.prototype.postPeriodProcessing_=function(a,b){var c=this,d;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(e){if(e.getNextAddressJsc()==1)return e.yield(c.periodCombiner_.combinePeriods(a,!0,b),2);c.manifest_.variants=c.periodCombiner_.getVariants();d=c.periodCombiner_.getTextStreams();d.length>0&&(c.manifest_.textStreams=d);c.manifest_.imageStreams=c.periodCombiner_.getImageStreams();c.playerInterface_.filter(c.manifest_);e.jumpToEnd()})};
shaka.dash.DashParser.prototype.processPatchManifest_=function(a){var b=this,c,d,e,f,g,h,k,l,m,n,p,q,r,t,u,v,w,x,y,C,D,A,z,B,E,H,N,F,I;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(L){if(L.getNextAddressJsc()==1){c=shaka.util.TXml;d=a.attributes.mpdId;e=c.parseAttr(a,"originalPublishTime",c.parseDate);if(!d||d!==b.manifestPatchContext_.mpdId||e!==b.manifestPatchContext_.publishTime)throw b.patchLocationNodes_=[],new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.MANIFEST,
shaka.util.Error.Code.DASH_INVALID_PATCH);f=[];g=[];h=new Set;k=(0,$jscomp.makeIterator)(c.getChildNodes(a));for(l=k.next();!l.done;l=k.next()){m=l.value;n=!0;p=c.parseXpath(m.attributes.sel||"");q=p[p.length-1];r=c.getContents(m)||"";if(q.name==="MPD")q.attribute==="mediaPresentationDuration"?(t=c.getContents(m)||"",b.parsePatchMediaPresentationDurationChange_(t)):q.attribute==="type"?b.parsePatchMpdTypeChange_(r):q.attribute==="publishTime"?b.manifestPatchContext_.publishTime=c.parseDate(r)||0:
q.attribute===null&&m.tagName==="add"?g.push(m):n=!1;else if(q.name==="PatchLocation")b.updatePatchLocationNodes_(m);else if(q.name==="Period")m.tagName==="add"?g.push(m):m.tagName==="remove"&&q.id&&b.removePatchPeriod_(q.id);else if(q.name==="SegmentTemplate")for(u=b.modifySegmentTemplate_(m),v=(0,$jscomp.makeIterator)(u),w=v.next();!w.done;w=v.next())x=w.value,h.add(x);else if(q.name==="SegmentTimeline"||q.name==="S")for(y=b.modifyTimepoints_(m),C=(0,$jscomp.makeIterator)(y),D=C.next();!D.done;D=
C.next())A=D.value,h.add(A);else n=!1;n||shaka.log.warning("Unhandled "+m.tagName+" operation",m.attributes.sel)}z=(0,$jscomp.makeIterator)(h);for(B=z.next();!B.done;B=z.next())E=B.value,b.parsePatchSegment_(E);H=(0,$jscomp.makeIterator)(g);for(N=H.next();!N.done;N=H.next())F=N.value,f.push.apply(f,(0,$jscomp.arrayFromIterable)(b.parsePatchPeriod_(F)));if(!f.length)return L.jumpTo(2);b.manifest_.periodCount+=f.length;b.manifest_.gapCount=b.gapCount_;return L.yield(b.postPeriodProcessing_(f,!0),2)}b.manifestPatchContext_.type==
"static"&&(I=b.manifestPatchContext_.mediaPresentationDuration,b.manifest_.presentationTimeline.setDuration(I||Infinity));L.jumpToEnd()})};shaka.dash.DashParser.prototype.parsePatchMpdTypeChange_=function(a){this.manifest_.presentationTimeline.setStatic(a=="static");this.manifestPatchContext_.type=a;for(var b=(0,$jscomp.makeIterator)(this.contextCache_.values()),c=b.next();!c.done;c=b.next())c.value.dynamic=a=="dynamic";a=="static"&&(this.updatePeriod_=-1)};
shaka.dash.DashParser.prototype.parsePatchMediaPresentationDurationChange_=function(a){a=shaka.util.TXml.parseDuration(a);if(a!=null){this.manifestPatchContext_.mediaPresentationDuration=a;for(var b=(0,$jscomp.makeIterator)(this.contextCache_.values()),c=b.next();!c.done;c=b.next())c.value.mediaPresentationDuration=a}};
shaka.dash.DashParser.prototype.parsePatchPeriod_=function(a){goog.asserts.assert(this.manifestPatchContext_.getBaseUris,"Must provide getBaseUris on manifestPatchContext_");return this.parsePeriods_({dynamic:this.manifestPatchContext_.type=="dynamic",presentationTimeline:this.manifest_.presentationTimeline,period:null,periodInfo:null,adaptationSet:null,representation:null,bandwidth:0,indexRangeWarningGiven:!1,availabilityTimeOffset:this.manifestPatchContext_.availabilityTimeOffset,profiles:this.manifestPatchContext_.profiles,
mediaPresentationDuration:this.manifestPatchContext_.mediaPresentationDuration,roles:null,urlParams:shaka.dash.DashParser.defaultUrlParams_},this.manifestPatchContext_.getBaseUris,a,!0).periods};
shaka.dash.DashParser.prototype.removePatchPeriod_=function(a){var b=shaka.dash.SegmentTemplate;this.manifest_.periodCount--;for(var c=(0,$jscomp.makeIterator)(this.contextCache_.keys()),d=c.next();!d.done;d=c.next())if(d=d.value,d.startsWith(a)){var e=this.contextCache_.get(d);b.removeTimepoints(e);this.parsePatchSegment_(d);this.contextCache_.delete(d)}this.lastManifestUpdatePeriodIds_=this.lastManifestUpdatePeriodIds_.filter(function(f){return f!==a});this.parsedPeriodCache_.delete(a)};
shaka.dash.DashParser.prototype.getContextIdsFromPath_=function(a){var b="",c="",d=-1,e="";a=(0,$jscomp.makeIterator)(a);for(var f=a.next();!f.done;f=a.next())f=f.value,f.name==="Period"?b=f.id:f.name==="AdaptationSet"?(c=f.id,f.position!==null&&(d=f.position)):f.name==="Representation"&&(e=f.id);a=[];if(e)a.push(b+","+e);else if(c)for(d=(0,$jscomp.makeIterator)(this.contextCache_.values()),e=d.next();!e.done;e=d.next())e=e.value,e.period.id===b&&e.adaptationSet.id===c&&e.representation.id&&a.push(b+
","+e.representation.id);else if(d>-1)for(c=(0,$jscomp.makeIterator)(this.contextCache_.values()),e=c.next();!e.done;e=c.next())e=e.value,e.period.id===b&&e.adaptationSet.position===d&&e.representation.id&&a.push(b+","+e.representation.id);return a};
shaka.dash.DashParser.prototype.modifySegmentTemplate_=function(a){var b=shaka.util.TXml,c=b.parseXpath(a.attributes.sel||""),d=c[c.length-1];if(!d.attribute)return[];c=this.getContextIdsFromPath_(c);for(var e=b.getContents(a)||"",f=(0,$jscomp.makeIterator)(c),g=f.next();!g.done;g=f.next())g=this.contextCache_.get(g.value),goog.asserts.assert(g&&g.representation.segmentTemplate,"cannot modify segment template"),b.modifyNodeAttribute(g.representation.segmentTemplate,a.tagName,d.attribute,e);return c};
shaka.dash.DashParser.prototype.modifyTimepoints_=function(a){var b=shaka.dash.SegmentTemplate,c=shaka.util.TXml.parseXpath(a.attributes.sel||"");c=this.getContextIdsFromPath_(c);for(var d=(0,$jscomp.makeIterator)(c),e=d.next();!e.done;e=d.next())e=this.contextCache_.get(e.value),b.modifyTimepoints(e,a);return c};
shaka.dash.DashParser.prototype.parsePatchSegment_=function(a){var b=this,c=this.contextCache_.get(a),d=this.streamMap_.get(a);goog.asserts.assert(d,"stream should exist");d.segmentIndex&&d.segmentIndex.evict(this.manifest_.presentationTimeline.getSegmentAvailabilityStart());try{var e=shaka.dash.SegmentTemplate.createStreamInfo(c,function(g,h,k,l){return b.requestSegment_(g,h,k,l)},this.streamMap_,!0,this.config_.dash.initialSegmentLimit,this.periodDurations_,c.representation.aesKey,null,!0,this.continuityCache_);
d.createSegmentIndex=function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(g){if(g.getNextAddressJsc()==1)return d.segmentIndex?g.jumpTo(0):g.yield(e.generateSegmentIndex(),3);d.segmentIndex=g.getYieldResultJsc();g.jumpToEnd()})}}catch(g){a=shaka.util.ManifestParserUtils.ContentType;c=c.representation.contentType;var f=c==a.IMAGE;if(c!=a.TEXT&&c!=a.APPLICATION&&!f||g.code!=shaka.util.Error.Code.DASH_NO_SEGMENT_INFO)throw g;}};
shaka.dash.DashParser.prototype.parseServiceDescription_=function(a){var b=shaka.util.TXml,c=b.findChild(a,"ServiceDescription");if(!c)return null;a=b.findChild(c,"Latency");b=b.findChild(c,"PlaybackRate");if(!a&&!b)return null;c={};a&&("target"in a.attributes&&(c.targetLatency=parseInt(a.attributes.target,10)/1E3),"max"in a.attributes&&(c.maxLatency=parseInt(a.attributes.max,10)/1E3),"min"in a.attributes&&(c.minLatency=parseInt(a.attributes.min,10)/1E3));b&&("max"in b.attributes&&(c.maxPlaybackRate=
parseFloat(b.attributes.max)),"min"in b.attributes&&(c.minPlaybackRate=parseFloat(b.attributes.min)));return c};shaka.dash.DashParser.prototype.parseMpdChaining_=function(a){a=shaka.util.TXml.findChildren(a,"SupplementalProperty");if(!a.length)return null;a=(0,$jscomp.makeIterator)(a);for(var b=a.next();!b.done;b=a.next())if(b=b.value,b.attributes.schemeIdUri=="urn:mpeg:dash:chaining:2016")return b.attributes.value;return null};
shaka.dash.DashParser.prototype.parsePeriods_=function(a,b,c,d){var e=shaka.util.TXml,f=a.mediaPresentationDuration;f||(f=e.parseAttr(c,"mediaPresentationDuration",e.parseDuration),this.manifestPatchContext_.mediaPresentationDuration=f);var g=0;this.manifest_&&this.manifest_.presentationTimeline&&this.isTransitionFromDynamicToStatic_&&(g=this.manifest_.presentationTimeline.getSeekRangeStart());var h=[],k=g;c=e.findChildren(c,"Period");var l=a.dynamic;l||this.parsedPeriodCache_.clear();for(var m=l&&
!d?new Set(this.lastManifestUpdatePeriodIds_.slice(1,-1)):null,n=0;n<c.length;n++){var p=c[n],q=c[n+1],r=e.parseAttr(p,"start",e.parseDuration,k),t=p.attributes.id,u=e.parseAttr(p,"duration",e.parseDuration);r=n==0&&r==0&&this.isTransitionFromDynamicToStatic_?g:r;var v=null;if(q){var w=e.parseAttr(q,"start",e.parseDuration);w!=null&&(v=w-r+g)}else f!=null&&(v=f-r+g);w=shaka.util.ManifestParserUtils.GAP_OVERLAP_TOLERANCE_SECONDS;v&&u&&Math.abs(v-u)>w&&(shaka.log.warning("There is a gap/overlap between Periods",
p),v>u&&this.gapCount_++);v==null&&(v=u);if(this.largestPeriodStartTime_!==null&&t!=null&&r!==null&&r<this.largestPeriodStartTime_&&!this.lastManifestUpdatePeriodIds_.includes(t)&&n+1!=c.length)shaka.log.debug("Skipping Period with ID "+t+" as its start time is smaller than the largest period start time that has been seen, and ID is unseen before");else{r!==null&&(this.largestPeriodStartTime_===null||r>this.largestPeriodStartTime_)&&(this.largestPeriodStartTime_=r);k={start:r,duration:v,node:p,isLastPeriod:v==
null||!q};p=null;u=n>0&&n<c.length-1;l&&m&&u&&!d&&(t!=null||(t=this.periodIdFallback_(r)),m.has(t)&&(t=this.parsedPeriodCache_.get(t))&&(p=t));p||(p=this.parsePeriod_(a,b,k),l&&p.id&&this.parsedPeriodCache_.set(p.id,p));h.push(p);p.id&&v&&this.periodDurations_.set(p.id,v);if(v==null){q&&shaka.log.warning("Skipping Period",n+1,"and any subsequent Periods:","Period",n+1,"does not have a valid start time.",q);k=null;break}k=r+v}}l&&!d&&this.prunePeriodCache_(h);if(d)for(a=(0,$jscomp.makeIterator)(h),
b=a.next();!b.done;b=a.next())b=b.value.id,this.lastManifestUpdatePeriodIds_.includes(b)||this.lastManifestUpdatePeriodIds_.push(b);else this.lastManifestUpdatePeriodIds_=h.map(function(x){return x.id});return f!=null?(k!=null&&Math.abs(k-g-f)>shaka.util.ManifestParserUtils.GAP_OVERLAP_TOLERANCE_SECONDS&&shaka.log.warning("@mediaPresentationDuration does not match the total duration ","of all Periods."),{periods:h,duration:f+g,durationDerivedFromPeriods:!1}):{periods:h,duration:k,durationDerivedFromPeriods:!0}};
shaka.dash.DashParser.prototype.prunePeriodCache_=function(a){a=new Set(a.map(function(d){return d.id}));for(var b=(0,$jscomp.makeIterator)(Array.from(this.parsedPeriodCache_.keys())),c=b.next();!c.done;c=b.next())c=c.value,a.has(c)||this.parsedPeriodCache_.delete(c)};shaka.dash.DashParser.prototype.periodIdFallback_=function(a){return"__shaka_period_"+a};
shaka.dash.DashParser.prototype.cleanStreamMap_=function(){var a=this,b=Array.from(this.indexStreamMap_.keys()).filter(function(h){return!a.lastManifestUpdatePeriodIds_.includes(h)});b=(0,$jscomp.makeIterator)(b);for(var c=b.next();!c.done;c=b.next()){c=c.value;for(var d=!0,e=(0,$jscomp.makeIterator)(this.indexStreamMap_.get(c)),f=e.next();!f.done;f=e.next()){f=f.value;var g=this.streamMap_.get(f);g&&(g.segmentIndex&&!g.segmentIndex.isEmpty()?d=!1:(this.periodCombiner_&&this.periodCombiner_.deleteStream(g,
c),this.streamMap_.delete(f)))}d&&this.indexStreamMap_.delete(c)}};shaka.dash.DashParser.prototype.cleanContinuityCache_=function(a){a=new Set(a.map(function(d){return d.id}));for(var b=(0,$jscomp.makeIterator)(this.continuityCache_.keys()),c=b.next();!c.done;c=b.next())c=c.value,a.has(c)||this.continuityCache_.delete(c)};
shaka.dash.DashParser.prototype.parsePeriod_=function(a,b,c){var d=this,e=shaka.util.Functional,f=shaka.util.TXml,g=shaka.util.ManifestParserUtils.ContentType;goog.asserts.assert(c.node,"periodInfo.node should exist");a.period=this.createFrame_(c.node,null,b);a.periodInfo=c;a.period.availabilityTimeOffset=a.availabilityTimeOffset;a.period.id||(shaka.log.info("No Period ID given for Period with start time "+c.start+",  Assigning a default"),a.period.id=this.periodIdFallback_(c.start));var h=f.findChildren(c.node,
"EventStream");b=a.presentationTimeline.getSegmentAvailabilityStart();h=(0,$jscomp.makeIterator)(h);for(var k=h.next();!k.done;k=h.next())this.parseEventStream_(c.start,c.duration,k.value,b);b=f.findChildren(c.node,"SupplementalProperty");b=(0,$jscomp.makeIterator)(b);for(h=b.next();!h.done;h=b.next())if(h=h.value,h.attributes.schemeIdUri=="urn:mpeg:dash:urlparam:2014"&&(h=this.getURLParametersFunction_(h)))a.urlParams=h;b=f.findChildren(c.node,"AdaptationSet").map(function(u,v){return d.parseAdaptationSet_(a,
v,u)}).filter(e.isNotNull);if(a.dynamic){h=[];k=(0,$jscomp.makeIterator)(b);for(var l=k.next();!l.done;l=k.next()){l=(0,$jscomp.makeIterator)(l.value.representationIds);for(var m=l.next();!m.done;m=l.next())h.push(m.value)}k=new Set(h);if(h.length!=k.size)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_DUPLICATE_REPRESENTATION_ID);}h=new Map;k=(0,$jscomp.makeIterator)(b);for(l=k.next();!l.done;l=k.next())for(l=(0,$jscomp.makeIterator)(l.value.dependencyStreamMap),
m=l.next();!m.done;m=l.next()){var n=(0,$jscomp.makeIterator)(m.value);m=n.next().value;n=n.next().value;h.set(m,n)}if(h.size)for(k=null,l=(0,$jscomp.makeIterator)(b),m=l.next();!m.done;m=l.next()){m=m.value;n=[];for(var p=(0,$jscomp.makeIterator)(m.streams),q=p.next(),r={};!q.done;r={stream$jscomp$58:void 0},q=p.next())if(r.stream$jscomp$58=q.value,h.has(r.stream$jscomp$58.originalId)){k||(k=f.findChildren(c.node,"AdaptationSet").map(function(u,v){return d.parseAdaptationSet_(a,v,u)}).filter(e.isNotNull));
q=(0,$jscomp.makeIterator)(k);for(var t=q.next();!t.done;t=q.next())if(t=t.value.streams.find(function(u){return function(v){return v.originalId==u.stream$jscomp$58.originalId}}(r)))t.dependencyStream=h.get(t.originalId),t.originalId+=t.dependencyStream.originalId,n.push(t)}n.length&&m.streams.push.apply(m.streams,(0,$jscomp.arrayFromIterable)(n))}c=(0,$jscomp.makeIterator)(shaka.util.ArrayUtils.partition(b,function(u){return!!u.trickModeFor}));e=c.next().value;c=c.next().value;if(!this.config_.disableIFrames)for(e=
(0,$jscomp.makeIterator)(e),f=e.next();!f.done;f=e.next())for(f=f.value,b=f.trickModeFor.split(" "),h=(0,$jscomp.makeIterator)(c),k=h.next();!k.done;k=h.next())if(k=k.value,b.includes(k.id))for(k=(0,$jscomp.makeIterator)(k.streams),l=k.next();!l.done;l=k.next())shaka.util.StreamUtils.setBetterIFrameStream(l.value,f.streams);e=this.getStreamsFromSets_(this.config_.disableAudio,c,g.AUDIO);f=this.getStreamsFromSets_(this.config_.disableVideo,c,g.VIDEO);b=this.getStreamsFromSets_(this.config_.disableText,
c,g.TEXT);g=this.getStreamsFromSets_(this.config_.disableThumbnails,c,g.IMAGE);if(f.length===0&&e.length===0)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_EMPTY_PERIOD);return{id:a.period.id,audioStreams:e,videoStreams:f,textStreams:b,imageStreams:g}};
shaka.dash.DashParser.prototype.getStreamsFromSets_=function(a,b,c){return a||!b.length?[]:b.reduce(function(d,e){if(e.contentType!=c)return d;d.push.apply(d,(0,$jscomp.arrayFromIterable)(e.streams));return d},[])};
shaka.dash.DashParser.prototype.parseAdaptationSet_=function(a,b,c){var d=this,e=shaka.util.TXml,f=shaka.util.Functional,g=shaka.util.ManifestParserUtils,h=g.ContentType;a.adaptationSet=this.createFrame_(c,a.period,null);a.adaptationSet.position=b;var k=!1,l=e.findChildren(c,"Role"),m=l.map(function(F){return F.attributes.value}).filter(f.isNotNull),n=void 0;if(b=a.adaptationSet.contentType==h.TEXT)n=g.TextStreamKind.SUBTITLE;f=(0,$jscomp.makeIterator)(l);for(l=f.next();!l.done;l=f.next()){l=l.value;
var p=l.attributes.schemeIdUri;if(p==null||p=="urn:mpeg:dash:role:2011")switch(l=l.attributes.value,l){case "main":k=!0;break;case "caption":case "subtitle":n=l}}l=function(F){switch(F){case 1:case 6:case 13:case 14:case 15:return"SDR";case 16:return"PQ";case 18:return"HLG"}};p=function(F){switch(F){case 1:case 5:case 6:case 7:return"srgb";case 9:return"rec2020";case 11:case 12:return"p3"}};var q=function(F){var I=F.attributes["dvb:fontFamily"];F=F.attributes["dvb:url"];I&&F&&(F=shaka.util.ManifestParserUtils.resolveUris(a.adaptationSet.getBaseUris(),
[F],a.urlParams()),d.playerInterface_.addFont(I,F[0]))},r=e.findChildren(c,"EssentialProperty");f=null;var t=!1,u=null,v=!1;r=(0,$jscomp.makeIterator)(r);for(var w=r.next();!w.done;w=r.next()){w=w.value;var x=w.attributes.schemeIdUri;if(x=="http://dashif.org/guidelines/trickmode")f=w.attributes.value;else if(x=="urn:mpeg:mpegB:cicp:TransferCharacteristics")var y=l(parseInt(w.attributes.value,10));else if(x=="urn:mpeg:mpegB:cicp:ColourPrimaries")var C=p(parseInt(w.attributes.value,10));else x!="urn:mpeg:mpegB:cicp:MatrixCoefficients"&&
(x=="urn:mpeg:dash:ssr:2023"&&this.config_.dash.enableFastSwitching?t=!0:x=="urn:dvb:dash:fontdownload:2014"?q(w):x=="urn:mpeg:dash:urlparam:2014"?(u=this.getURLParametersFunction_(w))||(v=!0):v=!0)}if(v)return null;var D=null;v=e.findChildren(c,"SupplementalProperty");v=(0,$jscomp.makeIterator)(v);for(r=v.next();!r.done;r=v.next())r=r.value,w=r.attributes.schemeIdUri,w=="http://dashif.org/guidelines/last-segment-number"?D=parseInt(r.attributes.value,10)-1:w=="urn:mpeg:mpegB:cicp:TransferCharacteristics"?
y=l(parseInt(r.attributes.value,10)):w=="urn:mpeg:mpegB:cicp:ColourPrimaries"?C=p(parseInt(r.attributes.value,10)):w=="urn:dvb:dash:fontdownload:2014"?q(r):w=="urn:mpeg:dash:urlparam:2014"&&(u=this.getURLParametersFunction_(r));u&&(a.urlParams=u);p=e.findChildren(c,"Accessibility");l=shaka.util.LanguageUtils;var A=new Map;p=(0,$jscomp.makeIterator)(p);for(q=p.next();!q.done;q=p.next())if(u=q.value,q=u.attributes.schemeIdUri,u=u.attributes.value,q=="urn:scte:dash:cc:cea-608:2015"&&!this.config_.disableText)if(q=
1,u!=null)for(u=u.split(";"),v=(0,$jscomp.makeIterator)(u),r=v.next();!r.done;r=v.next())w=r.value,x=r=void 0,w.includes("=")?(w=w.split("="),r=w[0].startsWith("CC")?w[0]:"CC"+w[0],x=w[1]||"und"):(r="CC"+q,u.length==2?q+=2:q++,x=w),A.set(r,l.normalize(x));else A.set("CC1","und");else if(q=="urn:scte:dash:cc:cea-708:2015"&&!this.config_.disableText)if(q=1,u!=null)for(u=(0,$jscomp.makeIterator)(u.split(";")),v=u.next();!v.done;v=u.next())r=v.value,w=v=void 0,r.includes("=")?(r=r.split("="),v="svc"+
r[0],w=r[1].split(",")[0].split(":").pop()):(v="svc"+q,q++,w=r),A.set(v,l.normalize(w));else A.set("svc1","und");else if(q=="urn:mpeg:dash:role:2011")u!=null&&(m.push(u),u=="captions"&&(n=g.TextStreamKind.CLOSED_CAPTION));else if(q=="urn:tva:metadata:cs:AudioPurposeCS:2007")if(u=="1")var z=shaka.media.ManifestParser.AccessibilityPurpose.VISUALLY_IMPAIRED;else u=="2"?z=shaka.media.ManifestParser.AccessibilityPurpose.HARD_OF_HEARING:u=="9"&&(z=shaka.media.ManifestParser.AccessibilityPurpose.SPOKEN_SUBTITLES);
g=e.findChildren(c,"ContentProtection");var B=this.contentProtection_.parseFromAdaptationSet(g,this.config_.ignoreDrmInfo,this.config_.dash.keySystemsByURI);a.adaptationSet.encrypted=g.length>0;var E=shaka.util.LanguageUtils.normalize(a.adaptationSet.language||"und"),H=a.adaptationSet.label,N=new Map;c=e.findChildren(c,"Representation");if(!this.config_.ignoreSupplementalCodecs){g=[];l=(0,$jscomp.makeIterator)(c);for(p=l.next();!p.done;p=l.next())if(q=p.value,p=e.getAttributeNS(q,shaka.dash.DashParser.SCTE214_,
"supplementalCodecs"))q=shaka.util.ObjectUtils.cloneObject(q),q.attributes.codecs=p.split(" ").join(","),q.attributes.id&&(q.attributes.supplementalId=q.attributes.id+"_supplementalCodecs"),g.push(q);c.push.apply(c,(0,$jscomp.arrayFromIterable)(g))}e=c.map(function(F){var I=d.parseRepresentation_(a,B,n,E,H,k,m,A,F,z,D);return I&&(I.hdr=I.hdr||y,I.colorGamut=I.colorGamut||C,I.fastSwitching=t,F=F.attributes.dependencyId)?(I.baseOriginalId=F,N.set(F,I),null):I}).filter(function(F){return!!F});if(e.length==
0&&N.size==0){f=a.adaptationSet.contentType==h.IMAGE;if(this.config_.dash.ignoreEmptyAdaptationSet||b||f)return null;throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.DASH_EMPTY_ADAPTATION_SET);}if(!a.adaptationSet.contentType||a.adaptationSet.contentType==h.APPLICATION)for(a.adaptationSet.contentType=shaka.dash.DashParser.guessContentType_(e[0].mimeType,e[0].codecs),h=(0,$jscomp.makeIterator)(e),b=h.next();!b.done;b=h.next())b.value.type=
a.adaptationSet.contentType;h=a.adaptationSet.id||"__fake__"+this.globalId_++;b=(0,$jscomp.makeIterator)(e);for(g=b.next();!g.done;g=b.next()){g=g.value;l=(0,$jscomp.makeIterator)(B.drmInfos);for(p=l.next();!p.done;p=l.next())p=p.value,p.keyIds=p.keyIds&&g.keyIds?new Set([].concat((0,$jscomp.arrayFromIterable)(p.keyIds),(0,$jscomp.arrayFromIterable)(g.keyIds))):p.keyIds||g.keyIds;this.config_.enableAudioGroups&&(g.groupId=h)}b=c.map(function(F){return F.attributes.supplementalId||F.attributes.id}).filter(shaka.util.Functional.isNotNull);
return{id:h,contentType:a.adaptationSet.contentType,language:E,main:k,streams:e,drmInfos:B.drmInfos,trickModeFor:f,representationIds:b,dependencyStreamMap:N}};
shaka.dash.DashParser.prototype.getURLParametersFunction_=function(a){var b=this,c=shaka.util.TXml;if((a=c.findChildNS(a,shaka.dash.DashParser.UP_NAMESPACE_,"UrlQueryInfo"))&&c.parseAttr(a,"useMPDUrlQuery",c.parseBoolean,!1)){var d=a.attributes.queryTemplate;if(d)return function(){return d=="$querypart$"?b.lastManifestQueryParams_:d.split("&").map(function(e){if(e=="$querypart$")return b.lastManifestQueryParams_;var f=/\$query:(.*?)\$/g.exec(e);if(f&&f.length==2){f=f[1];var g=(new goog.Uri.QueryData(b.lastManifestQueryParams_)).get(f);
if(g.length)return f+"="+g[0]}return e}).join("&")}}return null};
shaka.dash.DashParser.prototype.parseRepresentation_=function(a,b,c,d,e,f,g,h,k,l,m){var n=this,p=shaka.util.TXml,q=shaka.util.ManifestParserUtils.ContentType;a.representation=this.createFrame_(k,a.adaptationSet,null);var r=a.representation.id;this.minTotalAvailabilityTimeOffset_=Math.min(this.minTotalAvailabilityTimeOffset_,a.representation.availabilityTimeOffset);this.isLowLatency_=this.minTotalAvailabilityTimeOffset_>0;if(!this.verifyRepresentation_(a.representation))return shaka.log.warning("Skipping Representation",a.representation),
null;var t=a.periodInfo.start;a.bandwidth=p.parseAttr(k,"bandwidth",p.parsePositiveInt)||0;a.roles=g;var u=p.findChildren(k,"SupplementalProperty"),v=p.findChildren(k,"EssentialProperty");p=p.findChildren(k,"ContentProtection");k=null;var w=v.find(function(M){return M.attributes.schemeIdUri=="urn:mpeg:dash:urlparam:2014"});w?k=this.getURLParametersFunction_(w):(w=u.find(function(M){return M.attributes.schemeIdUri=="urn:mpeg:dash:urlparam:2014"}))&&(k=this.getURLParametersFunction_(w));k&&(a.urlParams=
k);w=a.representation.contentType;k=w==q.TEXT||w==q.APPLICATION;q=w==q.IMAGE;p.length&&(a.adaptationSet.encrypted=!0);try{var x=void 0;if(b.aes128Info){var y=a.representation.getBaseUris,C=a.urlParams,D=shaka.util.ManifestParserUtils.resolveUris(y(),[b.aes128Info.keyUri],C()),A=shaka.net.NetworkingEngine.RequestType.KEY,z=shaka.net.NetworkingEngine.makeRequest(D,this.config_.retryParameters);x={bitsKey:128,blockCipherMode:"CBC",iv:b.aes128Info.iv,firstMediaSequenceNumber:0,fetchKey:function(){var M,
J,O;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(P){if(P.getNextAddressJsc()==1)return P.yield(n.makeNetworkRequest_(z,A),2);if(P.getNextAddressJsc()!=3){M=P.getYieldResultJsc();if(!M.data||M.data.byteLength!=16)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.AES_128_INVALID_KEY_LENGTH);J={name:"AES-CBC"};O=x;return P.yield(window.crypto.subtle.importKey("raw",M.data,J,!0,["decrypt"]),3)}O.cryptoKey=P.getYieldResultJsc();
x.fetchKey=void 0;P.jumpToEnd()})}}}a.representation.aesKey=x;y=function(M,J,O,P){return n.requestSegment_(M,J,O,P)};if(a.representation.segmentBase)var B=shaka.dash.SegmentBase.createStreamInfo(a,y,x);else if(a.representation.segmentList)B=shaka.dash.SegmentList.createStreamInfo(a,this.streamMap_,x);else if(a.representation.segmentTemplate)B=shaka.dash.SegmentTemplate.createStreamInfo(a,y,this.streamMap_,!!this.manifest_,this.config_.dash.initialSegmentLimit,this.periodDurations_,x,m,!1,this.continuityCache_);
else{goog.asserts.assert(k,"Must have Segment* with non-text streams.");var E=a.periodInfo.duration||0,H=a.representation.getBaseUris,N=a.representation.mimeType,F=a.representation.codecs;B={endTime:-1,timeline:-1,generateSegmentIndex:function(){var M=shaka.media.SegmentIndex.forSingleSegment(t,E,H());M.forEachTopLevelReference(function(J){J.mimeType=N;J.codecs=F});return Promise.resolve(M)},timescale:1}}}catch(M){if((k||q)&&M.code==shaka.util.Error.Code.DASH_NO_SEGMENT_INFO)return null;throw M;}m=
this.contentProtection_.parseFromRepresentation(p,b,this.config_.ignoreDrmInfo,this.config_.dash.keySystemsByURI);m=new Set(m?[m]:[]);y=u.some(function(M){return M.attributes.schemeIdUri=="tag:dolby.com,2018:dash:EC3_ExtensionType:2018"&&M.attributes.value=="JOC"});u=u.some(function(M){return M.attributes.schemeIdUri=="tag:dolby.com,2016:dash:virtualized_content:2016"&&M.attributes.value=="1"});u=y||u;y=!1;k&&(y=g.includes("forced_subtitle")||g.includes("forced-subtitle"));var I;if(q&&((v=v.find(function(M){return["http://dashif.org/thumbnail_tile",
"http://dashif.org/guidelines/thumbnail_tile"].includes(M.attributes.schemeIdUri)}))&&(I=v.attributes.value),!I))return null;var L;k=a.representation.codecs;a.profiles.includes("http://dashif.org/guidelines/dash-if-uhd#hevc-hdr-pq10")&&(k.includes("hvc1.2.4.L153.B0")||k.includes("hev1.2.4.L153.B0"))&&(L="PQ");v=a.representation.id?a.period.id+","+a.representation.id:"";this.patchLocationNodes_.length&&r&&this.contextCache_.set(a.period.id+","+r,this.cloneContext_(a));a.representation.producerReferenceTime&&
this.parseProducerReferenceTime_(a.representation.producerReferenceTime,B,a.presentationTimeline);B.endTime!=-1&&a.period.id!=null&&a.representation.id!=null&&((r=this.continuityCache_.get(a.period.id))?(r.endTime=B.endTime,r.reps.includes(a.representation.id)||r.reps.push(a.representation.id),this.continuityCache_.set(a.period.id,r)):this.continuityCache_.set(a.period.id,{endTime:B.endTime,timeline:B.timeline,reps:[a.representation.id]}));var G=v&&this.streamMap_.has(v)?this.streamMap_.get(v):{id:this.globalId_++,
originalId:a.representation.id,groupId:null,createSegmentIndex:function(){return Promise.resolve()},closeSegmentIndex:function(){G.segmentIndex&&(G.segmentIndex.release(),G.segmentIndex=null)},segmentIndex:null,mimeType:a.representation.mimeType,codecs:k,frameRate:a.representation.frameRate,pixelAspectRatio:a.representation.pixelAspectRatio,bandwidth:a.bandwidth,width:a.representation.width,height:a.representation.height,kind:c,encrypted:b.drmInfos.length>0,drmInfos:b.drmInfos,keyIds:m,language:d,
originalLanguage:a.adaptationSet.language,label:e,type:a.adaptationSet.contentType,primary:f,trickModeVideo:null,dependencyStream:null,emsgSchemeIdUris:a.representation.emsgSchemeIdUris,roles:g,forced:y,channelsCount:a.representation.numChannels,audioSamplingRate:a.representation.audioSamplingRate,spatialAudio:u,closedCaptions:h,hdr:L,colorGamut:void 0,videoLayout:void 0,tilesLayout:I,accessibilityPurpose:l,external:!1,fastSwitching:!1,fullMimeTypes:new Set([shaka.util.MimeUtils.getFullType(a.representation.mimeType,
a.representation.codecs)]),isAudioMuxedInVideo:!1,baseOriginalId:null};G.createSegmentIndex=function(){var M;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(J){if(J.getNextAddressJsc()==1){if(G.segmentIndex)return J.jumpTo(0);M=G;return J.yield(B.generateSegmentIndex(),3)}M.segmentIndex=J.getYieldResultJsc();J.jumpToEnd()})};v&&a.dynamic&&!this.streamMap_.has(v)&&(a=a.period.id||"",this.indexStreamMap_.has(a)||this.indexStreamMap_.set(a,[]),this.streamMap_.set(v,G),this.indexStreamMap_.get(a).push(v));
return G};
shaka.dash.DashParser.prototype.parseProducerReferenceTime_=function(a,b,c){var d=shaka.util.TXml;if(!this.parsedPrftNodes_.has(a)){this.parsedPrftNodes_.add(a);var e=d.parseAttr(a,"presentationTime",d.parseNonNegativeInt)||0,f=d.findChild(a,"UTCTiming");f&&f.attributes.schemeIdUri&&!shaka.dash.DashParser.isNtpScheme_(f.attributes.schemeIdUri)?a=(d.parseAttr(a,"wallClockTime",d.parseDate)||0)*1E3:(a=d.parseAttr(a,"wallClockTime",d.parseNonNegativeInt)||0,a=shaka.util.TimeUtils.convertNtp(a));b=new Date(a-
e/b.timescale*1E3);e=b.getTime()/1E3;isNaN(e)||(c.isStartTimeLocked()||c.setInitialProgramDateTime(e),b={wallClockTime:a,programStartDate:b},c=shaka.util.FakeEvent.EventName.Prft,b=(new Map).set("detail",b),c=new shaka.util.FakeEvent(c,b),this.playerInterface_.onEvent(c))}};
shaka.dash.DashParser.prototype.cloneContext_=function(a){var b=function(c){if(!c)return null;c=shaka.util.ObjectUtils.shallowCloneObject(c);c.segmentBase=null;c.segmentList=null;c.segmentTemplate=shaka.util.TXml.cloneNode(c.segmentTemplate);c.producerReferenceTime=null;return c};a=shaka.util.ObjectUtils.shallowCloneObject(a);a.period=b(a.period);a.adaptationSet=b(a.adaptationSet);a.representation=b(a.representation);a.periodInfo&&(a.periodInfo=shaka.util.ObjectUtils.shallowCloneObject(a.periodInfo),
a.periodInfo.node=null);return a};
shaka.dash.DashParser.prototype.onUpdate_=function(){var a=this,b,c;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(d){switch(d.getNextAddressJsc()){case 1:return goog.asserts.assert(a.updatePeriod_>=0,"There should be an update period"),shaka.log.info("Updating manifest..."),b=0,d.setCatchFinallyBlocks(2),d.yield(a.requestManifest_(),4);case 4:b=d.getYieldResultJsc();d.leaveTryBlock(3);break;case 2:if(c=d.enterCatchBlock(),goog.asserts.assert(c instanceof shaka.util.Error,"Should only receive a Shaka error"),
a.playerInterface_){if(a.config_.raiseFatalErrorOnManifestUpdateRequestFailure)return a.playerInterface_.onError(c),d.return();c.severity=shaka.util.Error.Severity.RECOVERABLE;a.playerInterface_.onError(c)}case 3:if(!a.playerInterface_)return d.return();a.playerInterface_.onManifestUpdated();a.setUpdateTimer_(b);d.jumpToEnd()}})};shaka.dash.DashParser.prototype.updateNow_=function(){this.updateTimer_.tickNow()};
shaka.dash.DashParser.prototype.setUpdateTimer_=function(a){if(!(this.updatePeriod_<0)){var b=this.updatePeriod_;this.config_.updatePeriod>=0&&(b=this.config_.updatePeriod);a=Math.max(b-a,this.averageUpdateDuration_.getEstimate());this.updateTimer_.tickAfter(a)}};
shaka.dash.DashParser.prototype.createFrame_=function(a,b,c){goog.asserts.assert(b||c,"Must provide either parent or getBaseUris");var d=shaka.media.SegmentUtils,e=shaka.util.ManifestParserUtils,f=shaka.util.TXml;b=b||{contentType:"",mimeType:"",codecs:"",emsgSchemeIdUris:[],frameRate:void 0,pixelAspectRatio:void 0,numChannels:null,audioSamplingRate:null,availabilityTimeOffset:0,segmentSequenceCadence:1,encrypted:!1};c=c||b.getBaseUris;var g=f.parseNonNegativeInt,h=f.evalDivision,k=a.attributes.id,
l=a.attributes.supplementalId,m=f.findChildren(a,"BaseURL"),n,p=!1;if(this.contentSteeringManager_)for(var q=(0,$jscomp.makeIterator)(m),r=q.next();!r.done;r=q.next()){var t=r.value;r=t.attributes.serviceLocation;t=f.getContents(t);r&&t&&(this.contentSteeringManager_.addLocation(k,r,t),p=!0)}p&&this.contentSteeringManager_||(n=m.map(f.getContents));var u=this.contentSteeringManager_;q=a.attributes.contentType||b.contentType;r=a.attributes.mimeType||b.mimeType;d=d.codecsFiltering([a.attributes.codecs||
b.codecs]).join(",");h=f.parseAttr(a,"frameRate",h)||b.frameRate;t=a.attributes.sar||b.pixelAspectRatio;var v=this.emsgSchemeIdUris_(f.findChildren(a,"InbandEventStream"),b.emsgSchemeIdUris),w=f.findChildren(a,"AudioChannelConfiguration");w=this.parseAudioChannels_(w)||b.numChannels;var x=f.parseAttr(a,"audioSamplingRate",g)||b.audioSamplingRate;q||(q=shaka.dash.DashParser.guessContentType_(r,d));var y=f.findChild(a,"SegmentBase"),C=f.findChild(a,"SegmentTemplate"),D=y?f.parseAttr(y,"availabilityTimeOffset",
f.parseFloat)||0:0,A=C?f.parseAttr(C,"availabilityTimeOffset",f.parseFloat)||0:0,z=m&&m.length?f.parseAttr(m[0],"availabilityTimeOffset",f.parseFloat)||0:0;D=b.availabilityTimeOffset+z+D+A;A=null;(z=f.findChild(a,"SegmentSequenceProperties"))&&(z=f.parseAttr(z,"cadence",f.parsePositiveInt))&&(A=z);z=a.attributes.label;var B=f.findChildren(a,"Label");B&&B.length&&(B=B[0],f.getTextContents(B)&&(z=f.getTextContents(B)));return{getBaseUris:function(){return e.resolveUris(c(),m.length?u&&p?u.getLocations(k):
n?n:[]:[])},segmentBase:y||b.segmentBase,segmentList:f.findChild(a,"SegmentList")||b.segmentList,segmentTemplate:C||b.segmentTemplate,producerReferenceTime:f.findChild(a,"ProducerReferenceTime")||b.producerReferenceTime,width:f.parseAttr(a,"width",g)||b.width,height:f.parseAttr(a,"height",g)||b.height,contentType:q,mimeType:r,codecs:d,frameRate:h,pixelAspectRatio:t,emsgSchemeIdUris:v,id:l||k,originalId:k,language:a.attributes.lang,numChannels:w,audioSamplingRate:x,availabilityTimeOffset:D,initialization:null,
segmentSequenceCadence:A||b.segmentSequenceCadence,label:z||null,encrypted:!1}};shaka.dash.DashParser.prototype.emsgSchemeIdUris_=function(a,b){b=b.slice();a=(0,$jscomp.makeIterator)(a);for(var c=a.next();!c.done;c=a.next())c=c.value.attributes.schemeIdUri,b.includes(c)||b.push(c);return b};
shaka.dash.DashParser.prototype.parseAudioChannels_=function(a){a=(0,$jscomp.makeIterator)(a);for(var b=a.next();!b.done;b=a.next()){var c=b.value;if(b=c.attributes.schemeIdUri)if(c=c.attributes.value)switch(b){case "urn:mpeg:dash:outputChannelPositionList:2012":return c.trim().split(/ +/).length;case "urn:mpeg:dash:23003:3:audio_channel_configuration:2011":case "urn:dts:dash:audio_channel_configuration:2012":var d=parseInt(c,10);if(!d){shaka.log.warning("Channel parsing failure! Ignoring scheme and value",
b,c);continue}return d;case "tag:dolby.com,2015:dash:audio_channel_configuration:2015":d=[2,1,2,2,2,2,1,2,2,1,1,1,1,2,1,1,2,2];var e=parseInt(c,16);if(!e){shaka.log.warning("Channel parsing failure! Ignoring scheme and value",b,c);continue}for(c=b=0;c<d.length;c++)e&1<<c&&(b+=d[c]);if(b)return b;continue;case "tag:dolby.com,2014:dash:audio_channel_configuration:2011":case "urn:dolby:dash:audio_channel_configuration:2011":d=[1,1,1,1,1,2,2,1,1,2,2,2,1,2,1,1].reverse();e=parseInt(c,16);if(!e){shaka.log.warning("Channel parsing failure! Ignoring scheme and value",
b,c);continue}for(c=b=0;c<d.length;c++)e&1<<c&&(b+=d[c]);if(b)return b;continue;case "urn:mpeg:mpegB:cicp:ChannelConfiguration":d=[0,1,2,3,4,5,6,8,2,3,4,7,8,24,8,12,10,12,14,12,14];e=parseInt(c,10);if(!e){shaka.log.warning("Channel parsing failure! Ignoring scheme and value",b,c);continue}if(e>0&&e<d.length)return d[e];continue;default:shaka.log.warning("Unrecognized audio channel scheme:",b,c)}}return null};
shaka.dash.DashParser.prototype.verifyRepresentation_=function(a){var b=shaka.util.ManifestParserUtils.ContentType;var c=a.segmentBase?1:0;c+=a.segmentList?1:0;c+=a.segmentTemplate?1:0;if(c==0){if(a.contentType==b.TEXT||a.contentType==b.APPLICATION)return!0;shaka.log.warning("Representation does not contain a segment information source:","the Representation must contain one of SegmentBase, SegmentList,",'SegmentTemplate, or explicitly indicate that it is "text".',a);return!1}c!=1&&(shaka.log.warning("Representation contains multiple segment information sources:",
"the Representation should only contain one of SegmentBase,","SegmentList, or SegmentTemplate.",a),a.segmentBase?(shaka.log.info("Using SegmentBase by default."),a.segmentList=null):(goog.asserts.assert(a.segmentList,"There should be a SegmentList"),shaka.log.info("Using SegmentList by default.")),a.segmentTemplate=null);return!0};
shaka.dash.DashParser.prototype.requestForTiming_=function(a,b,c){var d=this,e,f,g,h,k,l,m,n;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(p){if(p.getNextAddressJsc()==1)return e=[shaka.util.StringUtils.htmlUnescape(b)],f=shaka.util.ManifestParserUtils.resolveUris(a(),e),g=shaka.net.NetworkingEngine.makeRequest(f,d.config_.retryParameters),g.method=c,h=shaka.net.NetworkingEngine.RequestType.TIMING,k=d.playerInterface_.networkingEngine.request(h,g,{isPreload:d.isPreloadFn_()}),d.operationManager_.manage(k),
p.yield(k.promise,2);l=p.getYieldResultJsc();if(c=="HEAD"){if(!l.headers||!l.headers.date)return shaka.log.warning("UTC timing response is missing","expected date header"),p.return(0);m=l.headers.date}else m=shaka.util.StringUtils.fromUTF8(l.data);n=Date.parse(m);return isNaN(n)?(shaka.log.warning("Unable to parse date from UTC timing response"),p.return(0)):p.return(n-Date.now())})};
shaka.dash.DashParser.prototype.parseUtcTiming_=function(a,b){var c=this,d,e,f,g,h,k,l,m,n;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(p){switch(p.getNextAddressJsc()){case 1:d=b.map(function(q){return{scheme:q.attributes.schemeIdUri,value:q.attributes.value}}),e=c.config_.dash.clockSyncUri,!d.length&&e&&d.push({scheme:"urn:mpeg:dash:utc:http-head:2014",value:e}),f=(0,$jscomp.makeIterator)(d),g=f.next();case 2:if(g.done){p.jumpTo(4);break}h=g.value;p.setCatchFinallyBlocks(5);k=
h.scheme;l=h.value;switch(k){case "urn:mpeg:dash:utc:http-head:2014":case "urn:mpeg:dash:utc:http-head:2012":return p.jumpTo(7);case "urn:mpeg:dash:utc:http-xsdate:2014":case "urn:mpeg:dash:utc:http-iso:2014":case "urn:mpeg:dash:utc:http-xsdate:2012":case "urn:mpeg:dash:utc:http-iso:2012":return p.jumpTo(8);case "urn:mpeg:dash:utc:direct:2014":case "urn:mpeg:dash:utc:direct:2012":return m=Date.parse(l),p.return(isNaN(m)?0:m-Date.now());case "urn:mpeg:dash:utc:http-ntp:2014":case "urn:mpeg:dash:utc:ntp:2014":case "urn:mpeg:dash:utc:sntp:2014":shaka.log.alwaysWarn("NTP UTCTiming scheme is not supported");
break;default:shaka.log.alwaysWarn("Unrecognized scheme in UTCTiming element",k)}p.jumpTo(9);break;case 7:return p.yield(c.requestForTiming_(a,l,"HEAD"),10);case 10:return p.return(p.getYieldResultJsc());case 8:return p.yield(c.requestForTiming_(a,l,"GET"),11);case 11:return p.return(p.getYieldResultJsc());case 9:p.leaveTryBlock(3);break;case 5:n=p.enterCatchBlock(),shaka.log.warning("Error fetching time from UTCTiming elem",n.message);case 3:g=f.next();p.jumpTo(2);break;case 4:return shaka.log.alwaysWarn("A UTCTiming element should always be given in live manifests! This content may not play on clients with bad clocks!"),
p.return(0)}})};
shaka.dash.DashParser.prototype.parseEventStream_=function(a,b,c,d){var e=shaka.util.TXml,f=shaka.util.TXml.parseNonNegativeInt,g=c.attributes.schemeIdUri||"",h=c.attributes.value||"",k=e.parseAttr(c,"timescale",f)||1,l=e.parseAttr(c,"presentationTimeOffset",f)||0;c=(0,$jscomp.makeIterator)(e.findChildren(c,"Event"));for(var m=c.next();!m.done;m=c.next()){m=m.value;var n=e.parseAttr(m,"presentationTime",f)||0,p=e.parseAttr(m,"duration",f)||0;n=Math.max((n-l)/k+a,a);p=n+p/k;b!=null&&(n=Math.min(n,
a+b),p=Math.min(p,a+b));p<d||(m={schemeIdUri:g,value:h,startTime:n,endTime:p,id:m.attributes.id||"",timescale:k,eventElement:e.txmlNodeToDomElement(m),eventNode:e.cloneNode(m)},this.playerInterface_.onTimelineRegionAdded(m))}};
shaka.dash.DashParser.prototype.requestSegment_=function(a,b,c,d){var e=this,f,g,h,k;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(l){if(l.getNextAddressJsc()==1)return f=shaka.net.NetworkingEngine.RequestType.SEGMENT,g=d?shaka.net.NetworkingEngine.AdvancedRequestType.INIT_SEGMENT:shaka.net.NetworkingEngine.AdvancedRequestType.MEDIA_SEGMENT,h=shaka.net.NetworkingUtils.createSegmentRequest(a,b,c,e.config_.retryParameters),l.yield(e.makeNetworkRequest_(h,f,{type:g}),2);k=l.getYieldResultJsc();
return l.return(k.data)})};shaka.dash.DashParser.guessContentType_=function(a,b){b=shaka.util.MimeUtils.getFullType(a,b);return shaka.text.TextEngine.isTypeSupported(b)?shaka.util.ManifestParserUtils.ContentType.TEXT:a.split("/")[0]};shaka.dash.DashParser.prototype.makeNetworkRequest_=function(a,b,c){c||(c={});c.isPreload=this.isPreloadFn_();a=this.playerInterface_.networkingEngine.request(b,a,c);this.operationManager_.manage(a);return a.promise};
shaka.dash.DashParser.prototype.updatePatchLocationNodes_=function(a){shaka.util.TXml.modifyNodes(this.patchLocationNodes_,a)};
shaka.dash.DashParser.prototype.getPatchLocationUris_=function(){var a=shaka.util.TXml,b=this.manifestPatchContext_.publishTime;if(!this.manifestPatchContext_.mpdId||!b||!this.patchLocationNodes_.length)return[];var c=Date.now()/1E3,d=this.patchLocationNodes_.filter(function(e){e=a.parseNonNegativeInt(e.attributes.ttl);return!e||b+e>c}).map(a.getContents).filter(shaka.util.Functional.isNotNull);return d.length?shaka.util.ManifestParserUtils.resolveUris(this.manifestUris_,d):[]};
shaka.dash.DashParser.isNtpScheme_=function(a){return a==="urn:mpeg:dash:utc:http-ntp:2014"||a==="urn:mpeg:dash:utc:ntp:2014"||a==="urn:mpeg:dash:utc:sntp:2014"};shaka.dash.DashParser.defaultUrlParams_=function(){return""};shaka.dash.DashParser.makeBaseUriGetter_=function(a,b,c){return function(){return a&&b?a.getLocations("BaseURL"):c.slice()}};goog.exportSymbol("shaka.dash.DashParser",shaka.dash.DashParser);shaka.dash.DashParser.SCTE214_="urn:scte:dash:scte214-extensions";
shaka.dash.DashParser.UP_NAMESPACE_="urn:mpeg:dash:schema:urlparam:2014";shaka.media.ManifestParser.registerParserByMime("application/dash+xml",function(){return new shaka.dash.DashParser});shaka.media.ManifestParser.registerParserByMime("video/vnd.mpeg.dash.mpd",function(){return new shaka.dash.DashParser});shaka.debug={};shaka.debug.RunningInLab=!1;shaka.dependencies=function(){};shaka.dependencies.add=function(a,b){if(!shaka.dependencies.Allowed[a])throw Error(a+" is not supported");a==shaka.dependencies.Allowed.muxjs?shaka.Deprecate.deprecateFeature(5,"mux.js","mux.js is no longer used in Shaka Player."):shaka.dependencies.dependencies_.set(a,function(){return b})};shaka.dependencies.has=function(a){return shaka.dependencies.dependencies_.has(a)};shaka.dependencies.isoBoxer=function(){return shaka.dependencies.dependencies_.get(shaka.dependencies.Allowed.ISOBoxer)()};
goog.exportSymbol("shaka.dependencies",shaka.dependencies);goog.exportProperty(shaka.dependencies,"has",shaka.dependencies.has);goog.exportProperty(shaka.dependencies,"add",shaka.dependencies.add);shaka.dependencies.Allowed={muxjs:"muxjs",ISOBoxer:"ISOBoxer"};goog.exportProperty(shaka.dependencies,"Allowed",shaka.dependencies.Allowed);shaka.dependencies.dependencies_=new Map([[shaka.dependencies.Allowed.ISOBoxer,function(){return window.ISOBoxer}]]);shaka.util.Dom=function(){};shaka.util.Dom.createHTMLElement=function(a){return document.createElement(a)};shaka.util.Dom.createSVGElement=function(a){return document.createElementNS("http://www.w3.org/2000/svg",a)};shaka.util.Dom.createButton=function(){var a=document.createElement("button");a.setAttribute("type","button");return a};shaka.util.Dom.createSourceElement=function(a,b){b=b===void 0?"":b;var c=document.createElement("source");c.src=a;c.type=b;return c};
shaka.util.Dom.clearSourceFromVideo=function(a){for(var b=!1,c=a.getElementsByTagName("source"),d=c.length-1;d>=0;--d)a.removeChild(c[d]),b=!0;a.src&&(a.removeAttribute("src"),b=!0);return b};shaka.util.Dom.asHTMLElement=function(a){return a};shaka.util.Dom.asHTMLCanvasElement=function(a){return a};shaka.util.Dom.asHTMLMediaElement=function(a){return a};
shaka.util.Dom.getElementByClassName=function(a,b){b=b.getElementsByClassName(a);goog.asserts.assert(b.length==1,"Should only be one element with class name "+a);return shaka.util.Dom.asHTMLElement(b[0])};shaka.util.Dom.getElementByClassNameIfItExists=function(a,b){b=b.getElementsByClassName(a);if(!b.length)return null;goog.asserts.assert(b.length==1,"Should only be one element with class name "+a);return shaka.util.Dom.asHTMLElement(b[0])};shaka.util.Dom.removeAllChildren=function(a){for(;a.firstChild;)a.removeChild(a.firstChild)};
shaka.util.Dom.anyMediaElement=function(){if(shaka.util.Dom.cachedMediaElement_)return shaka.util.Dom.cachedMediaElement_;shaka.util.Dom.cacheExpirationTimer_||(shaka.util.Dom.cacheExpirationTimer_=new shaka.util.Timer(function(){shaka.util.Dom.cachedMediaElement_=null}));shaka.util.Dom.cachedMediaElement_=document.getElementsByTagName("video")[0]||document.getElementsByTagName("audio")[0];shaka.util.Dom.cachedMediaElement_||(shaka.util.Dom.cachedMediaElement_=document.createElement("video"));shaka.util.Dom.cacheExpirationTimer_.tickAfter(1);
return shaka.util.Dom.cachedMediaElement_};
shaka.util.Dom.addFont=function(a,b){var c,d,e,f,g;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(h){if(h.getNextAddressJsc()==1)return"fonts"in document&&"FontFace"in window?h.yield(document.fonts.ready,2):h.return();if(!("entries"in document.fonts))return h.return();c=function(k){k=k.entries();for(var l=[],m=k.next();m.done===!1;)l.push(m.value),m=k.next();return l};d=(0,$jscomp.makeIterator)(c(document.fonts));for(e=d.next();!e.done;e=d.next())if(f=e.value,f.family===a&&f.display===
"swap")return h.return();g=new FontFace(a,"url("+b+")",{display:"swap"});document.fonts.add(g);h.jumpToEnd()})};goog.exportSymbol("shaka.util.Dom",shaka.util.Dom);goog.exportProperty(shaka.util.Dom,"removeAllChildren",shaka.util.Dom.removeAllChildren);goog.exportProperty(shaka.util.Dom,"clearSourceFromVideo",shaka.util.Dom.clearSourceFromVideo);shaka.util.Dom.cacheExpirationTimer_=null;shaka.util.Dom.cachedMediaElement_=null;shaka.device.AbstractDevice=function(){this.abstractDeviceType_=new shaka.util.Lazy(function(){for(var a=navigator.userAgent.toLowerCase(),b=(0,$jscomp.makeIterator)([{type:shaka.device.IDevice.DeviceType.VR,regex:/oculus|quest/},{type:shaka.device.IDevice.DeviceType.TV,regex:/smart[ _]?tv|android ?tv/},{type:shaka.device.IDevice.DeviceType.MOBILE,regex:/iphone|ipad|ipod|android/}]),c=b.next();!c.done;c=b.next())if(c=c.value,c.regex.test(a))return c.type;a=navigator.userAgentData;var d;b=(a==null?
void 0:(d=a.platform)==null?void 0:d.toLowerCase())||"";if(a){if(a.mobile)return shaka.device.IDevice.DeviceType.MOBILE;if(b.includes("android"))return shaka.device.IDevice.DeviceType.TV}return shaka.device.IDevice.DeviceType.DESKTOP});this.browserEngine_=new shaka.util.Lazy(function(){var a=navigator.userAgent;return navigator.vendor.includes("Apple")&&(a.includes("Version/")||a.includes("OS/"))?shaka.device.IDevice.BrowserEngine.WEBKIT:a.includes("Edge/")?shaka.device.IDevice.BrowserEngine.EDGE:
a.includes("Chrome/")?shaka.device.IDevice.BrowserEngine.CHROMIUM:a.includes("Firefox/")?shaka.device.IDevice.BrowserEngine.GECKO:shaka.device.IDevice.BrowserEngine.UNKNOWN})};shaka.device.AbstractDevice.prototype.supportsMediaSource=function(){var a=window.ManagedMediaSource||window.MediaSource;return a&&a.isTypeSupported?!0:!1};shaka.device.AbstractDevice.prototype.supportsMediaType=function(a){return shaka.util.Dom.anyMediaElement().canPlayType(a)!=""};
shaka.device.AbstractDevice.prototype.supportsMediaCapabilities=function(){return!!navigator.mediaCapabilities};shaka.device.AbstractDevice.prototype.getDeviceType=function(){return this.abstractDeviceType_.value()};shaka.device.AbstractDevice.prototype.getBrowserEngine=function(){return this.browserEngine_.value()};shaka.device.AbstractDevice.prototype.requiresEncryptionInfoInAllInitSegments=function(a,b){return!1};shaka.device.AbstractDevice.prototype.requiresClearAndEncryptedInitSegments=function(){return!1};
shaka.device.AbstractDevice.prototype.insertEncryptionDataBeforeClear=function(){return!1};shaka.device.AbstractDevice.prototype.requiresTfhdFix=function(a){return!1};shaka.device.AbstractDevice.prototype.requiresEC3InitSegments=function(){return!1};shaka.device.AbstractDevice.prototype.supportsSequenceMode=function(){return!0};shaka.device.AbstractDevice.prototype.supportsSmoothCodecSwitching=function(){var a=window.ManagedSourceBuffer||window.SourceBuffer;return!!a&&!!a.prototype&&!!a.prototype.changeType};
shaka.device.AbstractDevice.prototype.supportsServerCertificate=function(){return!0};shaka.device.AbstractDevice.prototype.seekDelay=function(){return 0};shaka.device.AbstractDevice.prototype.detectMaxHardwareResolution=function(){return Promise.resolve({width:Infinity,height:Infinity})};shaka.device.AbstractDevice.prototype.shouldOverrideDolbyVisionCodecs=function(){return!1};shaka.device.AbstractDevice.prototype.shouldAvoidUseTextDecoderEncoder=function(){return!1};
shaka.device.AbstractDevice.prototype.adjustConfig=function(a){var b=this.getDeviceType();if(b===shaka.device.IDevice.DeviceType.TV||b===shaka.device.IDevice.DeviceType.CONSOLE||b===shaka.device.IDevice.DeviceType.CAST)a.ads.customPlayheadTracker=!0,a.ads.skipPlayDetection=!0,a.ads.supportsMultipleMediaElements=!1;return a};shaka.device.AbstractDevice.prototype.supportsOfflineStorage=function(){return!!window.indexedDB};shaka.device.AbstractDevice.prototype.rejectCodecs=function(){return[]};
shaka.device.AbstractDevice.prototype.getHdrLevel=function(a){return window.matchMedia!==void 0&&(window.matchMedia("(color-gamut: p3)").matches||window.matchMedia("(dynamic-range: high)").matches)?a?"HLG":"PQ":"SDR"};shaka.device.AbstractDevice.prototype.supportsAirPlay=function(){return!1};shaka.device.AbstractDevice.prototype.misreportAC3UsingDrm=function(){return!1};shaka.device.AbstractDevice.prototype.returnLittleEndianUsingPlayReady=function(){return!1};
shaka.device.AbstractDevice.prototype.supportsEncryptionSchemePolyfill=function(){return!0};shaka.device.AbstractDevice.prototype.misreportsSupportForPersistentLicenses=function(){return!1};shaka.device.AbstractDevice.prototype.supportStandardVP9Checking=function(){return!0};shaka.device.AbstractDevice.prototype.createMediaKeysWhenCheckingSupport=function(){return!0};shaka.device.AbstractDevice.prototype.disableHEVCSupport=function(){return!1};
shaka.device.AbstractDevice.prototype.supportsCbcsWithoutEncryptionSchemeSupport=function(){return!1};shaka.device.AbstractDevice.prototype.needWaitForEncryptedEvent=function(a){return a==="com.apple.fps"};shaka.device.AbstractDevice.prototype.supportsContainerChangeType=function(){return!0};shaka.device.AbstractDevice.prototype.toString=function(){return"Device: "+this.getDeviceName()+" v"+this.getVersion()+"; Type: "+this.getDeviceType()};shaka.device.AppleBrowser=function(){shaka.device.AbstractDevice.call(this);this.version_=new shaka.util.Lazy(function(){var a=navigator.userAgent.match(/Version\/(\d+)(?:\.(\d+))?/);a||(a=navigator.userAgent.match(/OS (\d+)(?:_(\d+))?/));return a?[parseInt(a[1],10),parseInt(a[2]||"0",10)]:[0,0]});this.deviceType_=new shaka.util.Lazy(function(){return/(?:iPhone|iPad|iPod)/.test(navigator.userAgent)||navigator.maxTouchPoints>1?"xr"in navigator?shaka.device.IDevice.DeviceType.APPLE_VR:shaka.device.IDevice.DeviceType.MOBILE:
"xr"in navigator?shaka.device.IDevice.DeviceType.APPLE_VR:shaka.device.IDevice.DeviceType.DESKTOP})};$jscomp.inherits(shaka.device.AppleBrowser,shaka.device.AbstractDevice);shaka.device.AppleBrowser.prototype.getVersion=function(){return this.version_.value()[0]};shaka.device.AppleBrowser.prototype.getDeviceName=function(){return"Apple Browser"};shaka.device.AppleBrowser.prototype.getDeviceType=function(){return this.deviceType_.value()};shaka.device.AppleBrowser.prototype.getBrowserEngine=function(){return shaka.device.IDevice.BrowserEngine.WEBKIT};
shaka.device.AppleBrowser.prototype.supportsMediaCapabilities=function(){return!1};shaka.device.AppleBrowser.prototype.requiresEncryptionInfoInAllInitSegments=function(a,b){return!this.supportsMixedClearEncryptedContent_()&&b==="audio"};shaka.device.AppleBrowser.prototype.insertEncryptionDataBeforeClear=function(){return!this.supportsMixedClearEncryptedContent_()};shaka.device.AppleBrowser.prototype.requiresTfhdFix=function(a){return!this.supportsMixedClearEncryptedContent_()&&a==="audio"};
shaka.device.AppleBrowser.prototype.adjustConfig=function(a){shaka.device.AbstractDevice.prototype.adjustConfig.call(this,a);a.abr.minTimeToSwitch=.5;return a};shaka.device.AppleBrowser.prototype.supportsAirPlay=function(){return!0};shaka.device.AppleBrowser.prototype.supportsContainerChangeType=function(){return!1};shaka.device.AppleBrowser.prototype.supportsMixedClearEncryptedContent_=function(){var a=this.version_.value();return a[0]>=27?!0:a[0]===26&&a[1]>=4};
shaka.device.AppleBrowser.isAppleBrowser_=function(){return(navigator.vendor||"").includes("Apple")?/(?:iPhone|iPad|iPod)/.test(navigator.userAgent)||navigator.maxTouchPoints>1||navigator.userAgentData&&navigator.userAgentData.platform&&navigator.userAgentData.platform.toLowerCase()=="macos"||navigator.platform&&navigator.platform.toLowerCase().includes("mac")?!0:!1:!1};shaka.device.AppleBrowser.isAppleBrowser_()&&shaka.device.DeviceFactory.registerDeviceFactory(function(){return new shaka.device.AppleBrowser});shaka.device.Chromecast=function(){if(!shaka.device.Chromecast.isChromecast_())throw Error("Not a Chromecast device!");shaka.device.AbstractDevice.call(this);this.version_=new shaka.util.Lazy(function(){var a=navigator.userAgent.match(/Chrome\/(\d+)/);return a?parseInt(a[1],10):null});this.osType_=new shaka.util.Lazy(function(){var a=navigator.userAgentData&&navigator.userAgentData.platform||navigator.userAgent;a=a.toLowerCase();return a.includes("android")?shaka.device.Chromecast.OsType_.ANDROID:
a.includes("fuchsia")?shaka.device.Chromecast.OsType_.FUCHSIA:shaka.device.Chromecast.OsType_.LINUX})};$jscomp.inherits(shaka.device.Chromecast,shaka.device.AbstractDevice);shaka.device.Chromecast.prototype.getVersion=function(){return this.version_.value()};shaka.device.Chromecast.prototype.getDeviceName=function(){return"Chromecast with "+this.osType_.value()};shaka.device.Chromecast.prototype.getDeviceType=function(){return shaka.device.IDevice.DeviceType.CAST};
shaka.device.Chromecast.prototype.getBrowserEngine=function(){return shaka.device.IDevice.BrowserEngine.CHROMIUM};shaka.device.Chromecast.prototype.supportsMediaCapabilities=function(){return shaka.device.AbstractDevice.prototype.supportsMediaCapabilities.call(this)&&this.osType_.value()!==shaka.device.Chromecast.OsType_.LINUX};
shaka.device.Chromecast.prototype.supportsSmoothCodecSwitching=function(){return shaka.device.AbstractDevice.prototype.supportsSmoothCodecSwitching.call(this)&&this.osType_.value()!==shaka.device.Chromecast.OsType_.LINUX};shaka.device.Chromecast.prototype.seekDelay=function(){switch(this.osType_.value()){case shaka.device.Chromecast.OsType_.ANDROID:return 0;case shaka.device.Chromecast.OsType_.FUCHSIA:return 3;default:return 1}};
shaka.device.Chromecast.prototype.detectMaxHardwareResolution=function(){var a,b,c,d,e;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){switch(f.getNextAddressJsc()){case 1:a=window.cast&&cast.__platform__&&cast.__platform__.canDisplayType;b={width:1280,height:720};f.setCatchFinallyBlocks(2);if(!(c=a)){f.jumpTo(4);break}return f.yield(cast.__platform__.canDisplayType('video/mp4; codecs="avc1.640028"; width=3840; height=2160'),5);case 5:c=f.getYieldResultJsc();case 4:if(c){b.width=
3840;b.height=2160;f.jumpTo(6);break}if(!(d=a)){f.jumpTo(7);break}return f.yield(cast.__platform__.canDisplayType('video/mp4; codecs="avc1.640028"; width=1920; height=1080'),8);case 8:d=f.getYieldResultJsc();case 7:d&&(b.width=1920,b.height=1080);case 6:f.leaveTryBlock(3);break;case 2:e=f.enterCatchBlock(),shaka.log.alwaysError("Failed to check canDisplayType:",e);case 3:return f.return(b)}})};
shaka.device.Chromecast.prototype.adjustConfig=function(a){shaka.device.AbstractDevice.prototype.adjustConfig.call(this,a);a.streaming.stallSkip=0;return a};shaka.device.Chromecast.prototype.supportsOfflineStorage=function(){return!1};shaka.device.Chromecast.prototype.supportsCbcsWithoutEncryptionSchemeSupport=function(){return!0};shaka.device.Chromecast.isChromecast_=function(){return navigator.userAgent.includes("CrKey")&&!navigator.userAgent.includes("VIZIO SmartCast")};
shaka.device.Chromecast.OsType_={ANDROID:"Android",FUCHSIA:"Fuchsia",LINUX:"Linux"};shaka.device.Chromecast.isChromecast_()&&shaka.device.DeviceFactory.registerDeviceFactory(function(){return new shaka.device.Chromecast});shaka.device.DefaultBrowser=function(){shaka.device.AbstractDevice.call(this);var a=this;this.version_=new shaka.util.Lazy(function(){var b=navigator.userAgent.match(/(Chrome|Firefox)\/(\d+)/);return b?parseInt(b[2],10):null});this.deviceName_=new shaka.util.Lazy(function(){return navigator.userAgent.match(/Edge?\//)?"Edge":navigator.userAgent.includes("Chrome")?"Chrome":navigator.userAgent.includes("Firefox")?"Firefox":"Unknown"});this.isWindows_=new shaka.util.Lazy(function(){return navigator.userAgentData&&
navigator.userAgentData.platform?navigator.userAgentData.platform.toLowerCase()=="windows":navigator.platform?navigator.platform.toLowerCase().includes("win32"):!1});this.supportsSmoothCodecSwitching_=new shaka.util.Lazy(function(){return shaka.device.AbstractDevice.prototype.supportsSmoothCodecSwitching.call(a)?navigator.userAgent.match(/Edge?\//)?!a.isWindows_.value():!0:!1});this.isSonyTV_=new shaka.util.Lazy(function(){return navigator.userAgent.includes("sony.hbbtv.tv")});this.isAndroid_=new shaka.util.Lazy(function(){return navigator.userAgentData&&
navigator.userAgentData.platform?navigator.userAgentData.platform.toLowerCase()=="android":navigator.userAgent.includes("Android")?!0:!1})};$jscomp.inherits(shaka.device.DefaultBrowser,shaka.device.AbstractDevice);shaka.device.DefaultBrowser.prototype.getVersion=function(){return this.version_.value()};shaka.device.DefaultBrowser.prototype.getDeviceName=function(){return this.deviceName_.value()};
shaka.device.DefaultBrowser.prototype.requiresEncryptionInfoInAllInitSegments=function(a){return shaka.drm.DrmUtils.isPlayReadyKeySystem(a)?this.deviceName_.value()==="Edge"&&this.isWindows_.value():!1};shaka.device.DefaultBrowser.prototype.requiresClearAndEncryptedInitSegments=function(){return this.deviceName_.value()==="Edge"&&this.isWindows_.value()};shaka.device.DefaultBrowser.prototype.insertEncryptionDataBeforeClear=function(){return this.deviceName_.value()==="Edge"&&this.isWindows_.value()};
shaka.device.DefaultBrowser.prototype.supportsSmoothCodecSwitching=function(){return this.supportsSmoothCodecSwitching_.value()};
shaka.device.DefaultBrowser.prototype.adjustConfig=function(a){shaka.device.AbstractDevice.prototype.adjustConfig.call(this,a);if(this.isWindows_.value())switch(this.deviceName_.value()){case "Firefox":a.drm.keySystemsMapping={"com.microsoft.playready":"com.microsoft.playready.recommendation"};break;case "Chrome":a.drm.keySystemsMapping={"com.microsoft.playready":"com.microsoft.playready.recommendation.3000","com.microsoft.playready.recommendation":"com.microsoft.playready.recommendation.3000"}}this.isAndroid_.value()&&
(a.drm.defaultAudioRobustnessForWidevine="",a.drm.defaultVideoRobustnessForWidevine="");return a};shaka.device.DefaultBrowser.prototype.returnLittleEndianUsingPlayReady=function(){return this.deviceName_.value()==="Edge"||this.isSonyTV_.value()};shaka.device.DefaultBrowser.prototype.createMediaKeysWhenCheckingSupport=function(){return goog.DEBUG&&shaka.debug.RunningInLab&&this.isWindows_.value()&&this.getBrowserEngine()===shaka.device.IDevice.BrowserEngine.GECKO?!1:!0};
shaka.device.DefaultBrowser.prototype.disableHEVCSupport=function(){return this.isWindows_.value()&&this.getBrowserEngine()===shaka.device.IDevice.BrowserEngine.GECKO};shaka.device.DefaultBrowser.prototype.supportsCbcsWithoutEncryptionSchemeSupport=function(){if(this.getBrowserEngine()===shaka.device.IDevice.BrowserEngine.GECKO){var a=this.getVersion();return a!==null?a>=100:shaka.device.AbstractDevice.prototype.supportsCbcsWithoutEncryptionSchemeSupport.call(this)}return shaka.device.AbstractDevice.prototype.supportsCbcsWithoutEncryptionSchemeSupport.call(this)};
shaka.device.DefaultBrowser.prototype.needWaitForEncryptedEvent=function(a){return this.getBrowserEngine()===shaka.device.IDevice.BrowserEngine.GECKO?a.startsWith("com.microsoft.playready.recommendation"):shaka.device.AbstractDevice.prototype.needWaitForEncryptedEvent.call(this,a)};shaka.device.DeviceFactory.registerDefaultDeviceFactory(function(){return new shaka.device.DefaultBrowser});shaka.device.Hisense=function(){shaka.device.AbstractDevice.apply(this,arguments)};$jscomp.inherits(shaka.device.Hisense,shaka.device.AbstractDevice);shaka.device.Hisense.prototype.getVersion=function(){return null};shaka.device.Hisense.prototype.getDeviceName=function(){return"Hisense"};shaka.device.Hisense.prototype.getDeviceType=function(){return shaka.device.IDevice.DeviceType.TV};shaka.device.Hisense.prototype.supportsMediaCapabilities=function(){return!1};
shaka.device.Hisense.prototype.supportsSmoothCodecSwitching=function(){return!1};shaka.device.Hisense.prototype.detectMaxHardwareResolution=function(){var a={width:1920,height:1080},b=null;if(window.Hisense_Get4KSupportState)try{b=window.Hisense_Get4KSupportState()}catch(c){shaka.log.debug("Hisense: Failed to get 4K support state",c)}b==null&&(b=navigator.userAgent.includes("UHD"));b&&(a.width=3840,a.height=2160);return Promise.resolve(a)};
shaka.device.Hisense.prototype.adjustConfig=function(a){shaka.device.AbstractDevice.prototype.adjustConfig.call(this,a);a.streaming.stallSkip=0;return a};shaka.device.Hisense.isHisense_=function(){return navigator.userAgent.includes("Hisense")||navigator.userAgent.includes("VIDAA")};shaka.device.Hisense.isHisense_()&&shaka.device.DeviceFactory.registerDeviceFactory(function(){return new shaka.device.Hisense});shaka.device.PlayStation=function(){shaka.device.AbstractDevice.call(this);this.version_=new shaka.util.Lazy(function(){var a=navigator.userAgent.match(/PlayStation (\d+)/);return a?parseInt(a[1],10):null})};$jscomp.inherits(shaka.device.PlayStation,shaka.device.AbstractDevice);shaka.device.PlayStation.prototype.getDeviceName=function(){return"PlayStation"};shaka.device.PlayStation.prototype.getDeviceType=function(){return shaka.device.IDevice.DeviceType.CONSOLE};
shaka.device.PlayStation.prototype.getBrowserEngine=function(){return shaka.device.IDevice.BrowserEngine.WEBKIT};shaka.device.PlayStation.prototype.getVersion=function(){return this.version_.value()};shaka.device.PlayStation.prototype.supportsMediaCapabilities=function(){return!1};shaka.device.PlayStation.prototype.supportsSequenceMode=function(){return!1};shaka.device.PlayStation.prototype.supportsSmoothCodecSwitching=function(){return!1};
shaka.device.PlayStation.prototype.shouldAvoidUseTextDecoderEncoder=function(){return this.getVersion()===4};
shaka.device.PlayStation.prototype.detectMaxHardwareResolution=function(){var a,b,c,d,e;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){switch(f.getNextAddressJsc()){case 1:return a={width:1920,height:1080},b=!1,f.setCatchFinallyBlocks(2),f.yield(window.msdk.device.getDisplayInfo(),4);case 4:c=f.getYieldResultJsc();b=c.resolution==="4K";f.leaveTryBlock(3);break;case 2:return f.enterCatchBlock(),f.setCatchFinallyBlocks(5),f.yield(window.msdk.device.getDisplayInfoImmediate(),7);case 7:d=
f.getYieldResultJsc();b=d.resolution==="4K";f.leaveTryBlock(3);break;case 5:e=f.enterCatchBlock(),shaka.log.alwaysWarn("PlayStation: Failed to get the display info:",e);case 3:return b&&(a.width=3840,a.height=2160),f.return(a)}})};shaka.device.PlayStation.prototype.adjustConfig=function(a){shaka.device.AbstractDevice.prototype.adjustConfig.call(this,a);this.getVersion()===4&&a.drm.preferredKeySystems.push("com.microsoft.playready");a.streaming.clearDecodingCache=!0;return a};
shaka.device.PlayStation.prototype.returnLittleEndianUsingPlayReady=function(){return this.getVersion()===4};shaka.device.PlayStation.prototype.supportsEncryptionSchemePolyfill=function(){return this.getVersion()!==4};shaka.device.PlayStation.isPlayStation_=function(){return navigator.userAgent.includes("PlayStation")};shaka.device.PlayStation.isPlayStation_()&&shaka.device.DeviceFactory.registerDeviceFactory(function(){return new shaka.device.PlayStation});shaka.device.Tizen=function(){shaka.device.AbstractDevice.call(this);var a=navigator.userAgent.match(/Tizen (\d+).(\d+)/);this.osMajorVersion_=a?parseInt(a[1],10):null;this.osMinorVersion_=a?parseInt(a[2],10):null};$jscomp.inherits(shaka.device.Tizen,shaka.device.AbstractDevice);shaka.device.Tizen.prototype.getVersion=function(){return this.osMajorVersion_};shaka.device.Tizen.prototype.getDeviceName=function(){return"Tizen"};shaka.device.Tizen.prototype.getBrowserEngine=function(){return shaka.device.IDevice.BrowserEngine.CHROMIUM};
shaka.device.Tizen.prototype.getDeviceType=function(){return shaka.device.IDevice.DeviceType.TV};shaka.device.Tizen.prototype.requiresEncryptionInfoInAllInitSegments=function(a){return!0};shaka.device.Tizen.prototype.requiresEC3InitSegments=function(){return this.getVersion()===3};shaka.device.Tizen.prototype.supportsMediaCapabilities=function(){return!1};shaka.device.Tizen.prototype.supportsSequenceMode=function(){var a=this.getVersion();return a!==null?a>=4:shaka.device.AbstractDevice.prototype.supportsSequenceMode.call(this)};
shaka.device.Tizen.prototype.supportsSmoothCodecSwitching=function(){return!1};shaka.device.Tizen.prototype.supportsServerCertificate=function(){return this.osMajorVersion_&&this.osMinorVersion_?this.osMajorVersion_===5?this.osMinorVersion_>=5:this.osMajorVersion_>5:shaka.device.AbstractDevice.prototype.supportsServerCertificate.call(this)};
shaka.device.Tizen.prototype.detectMaxHardwareResolution=function(){var a=window.devicePixelRatio;a={width:window.screen.width*a>1920?3840:1920,height:window.screen.height*a>1080?2160:1080};try{if(webapis.systeminfo&&webapis.systeminfo.getMaxVideoResolution){var b=webapis.systeminfo.getMaxVideoResolution();a.width=b.width;a.height=b.height}else webapis.productinfo.is8KPanelSupported&&webapis.productinfo.is8KPanelSupported()?(a.width=7680,a.height=4320):webapis.productinfo.isUdPanelSupported&&webapis.productinfo.isUdPanelSupported()&&
(a.width=3840,a.height=2160)}catch(c){shaka.log.alwaysWarn("Tizen: Error detecting screen size, default screen size 1920x1080.")}return Promise.resolve(a)};
shaka.device.Tizen.prototype.adjustConfig=function(a){shaka.device.AbstractDevice.prototype.adjustConfig.call(this,a);a.drm.ignoreDuplicateInitData=this.getVersion()!==2;this.getVersion()===3&&(a.streaming.crossBoundaryStrategy=shaka.config.CrossBoundaryStrategy.RESET_TO_ENCRYPTED);a.streaming.shouldFixTimestampOffset=!0;a.streaming.stallSkip=0;a.streaming.gapPadding=2;return a};
shaka.device.Tizen.prototype.rejectCodecs=function(){var a=[];this.osMajorVersion_!==null&&this.osMajorVersion_<5&&a.push("opus");return a};shaka.device.Tizen.prototype.getHdrLevel=function(a){try{if(webapis.avinfo.isHdrTvSupport())return a?"HLG":"PQ"}catch(b){return shaka.device.AbstractDevice.prototype.getHdrLevel.call(this,a)}return"SDR"};shaka.device.Tizen.prototype.misreportAC3UsingDrm=function(){return!0};
shaka.device.Tizen.prototype.misreportsSupportForPersistentLicenses=function(){return this.getVersion()===3};shaka.device.Tizen.isTizen_=function(){return navigator.userAgent.includes("Tizen")};shaka.device.Tizen.isTizen_()&&shaka.device.DeviceFactory.registerDeviceFactory(function(){return new shaka.device.Tizen});shaka.device.Vizio=function(){shaka.device.AbstractDevice.apply(this,arguments)};$jscomp.inherits(shaka.device.Vizio,shaka.device.AbstractDevice);shaka.device.Vizio.prototype.getVersion=function(){return null};shaka.device.Vizio.prototype.getDeviceName=function(){return"Vizio"};shaka.device.Vizio.prototype.getDeviceType=function(){return shaka.device.IDevice.DeviceType.TV};shaka.device.Vizio.prototype.supportsMediaCapabilities=function(){return!1};shaka.device.Vizio.isVizio_=function(){return navigator.userAgent.includes("VIZIO SmartCast")};
shaka.device.Vizio.isVizio_()&&shaka.device.DeviceFactory.registerDeviceFactory(function(){return new shaka.device.Vizio});shaka.device.WebKitSTB=function(){shaka.device.AbstractDevice.call(this);this.isSkyQ_=new shaka.util.Lazy(function(){return navigator.userAgent.includes("DT_STB_BCM")||navigator.userAgent.includes("Sky_STB")});this.isOrange_=new shaka.util.Lazy(function(){return navigator.userAgent.includes("SOPOpenBrowser")});this.version_=new shaka.util.Lazy(function(){if(navigator.userAgent.includes("DT_STB_BCM"))return 11;var a=navigator.userAgent.match(/Version\/(\d+)/);return a?parseInt(a[1],10):(a=navigator.userAgent.match(/OS (\d+)(?:_\d+)?/))?
parseInt(a[1],10):null})};$jscomp.inherits(shaka.device.WebKitSTB,shaka.device.AbstractDevice);shaka.device.WebKitSTB.prototype.getVersion=function(){return this.version_.value()};shaka.device.WebKitSTB.prototype.getDeviceName=function(){return"WebKit STB"};shaka.device.WebKitSTB.prototype.getDeviceType=function(){return shaka.device.IDevice.DeviceType.TV};shaka.device.WebKitSTB.prototype.getBrowserEngine=function(){return shaka.device.IDevice.BrowserEngine.WEBKIT};
shaka.device.WebKitSTB.prototype.supportsMediaCapabilities=function(){return!1};shaka.device.WebKitSTB.prototype.supportsSequenceMode=function(){var a=this.version_.value();return a!==null?a>=15:!0};shaka.device.WebKitSTB.prototype.requiresEncryptionInfoInAllInitSegments=function(a){return this.isOrange_.value()};shaka.device.WebKitSTB.prototype.detectMaxHardwareResolution=function(){return Promise.resolve({width:window.screen.width*window.devicePixelRatio,height:window.screen.height*window.devicePixelRatio})};
shaka.device.WebKitSTB.prototype.supportsEncryptionSchemePolyfill=function(){return!this.isSkyQ_.value()};shaka.device.WebKitSTB.prototype.supportsContainerChangeType=function(){return!1};
shaka.device.WebKitSTB.isWebkitSTB_=function(){return navigator.userAgent.includes("SOPOpenBrowser")||navigator.userAgent.includes("DT_STB_BCM")||navigator.userAgent.includes("Sky_STB")?!0:!(navigator.vendor||"").includes("Apple")||/(?:iPhone|iPad|iPod)/.test(navigator.userAgent)||navigator.maxTouchPoints>1||navigator.userAgentData&&navigator.userAgentData.platform&&navigator.userAgentData.platform.toLowerCase()=="macos"||navigator.platform&&navigator.platform.toLowerCase().includes("mac")?!1:!0};
shaka.device.WebKitSTB.isWebkitSTB_()&&shaka.device.DeviceFactory.registerDeviceFactory(function(){return new shaka.device.WebKitSTB});shaka.device.WebOS=function(){shaka.device.AbstractDevice.call(this);var a=this;this.osVersion_=this.guessWebOSVersion_();this.supportHdr_=null;try{var b=new PalmServiceBridge;b.onservicecallback=function(c){shaka.log.info("WebOS: config support",c);c=JSON.parse(c);var d,e,f,g;a.supportHdr_=(g=(f=(d=c.configs)==null?void 0:d["tv.model.supportHDR"])!=null?f:(e=c.configs)==null?void 0:e["tv.config.supportDolbyHDRContents"])!=null?g:!1};b.call("luna://com.webos.service.config/getConfigs",JSON.stringify({configNames:["tv.model.supportHDR",
"tv.config.supportDolbyHDRContents"]}))}catch(c){shaka.log.alwaysWarn("WebOS: getConfigs call failed",c)}};$jscomp.inherits(shaka.device.WebOS,shaka.device.AbstractDevice);shaka.device.WebOS.prototype.getVersion=function(){return this.osVersion_};shaka.device.WebOS.prototype.getDeviceName=function(){return"WebOS"};shaka.device.WebOS.prototype.getDeviceType=function(){return shaka.device.IDevice.DeviceType.TV};shaka.device.WebOS.prototype.getBrowserEngine=function(){return shaka.device.IDevice.BrowserEngine.CHROMIUM};
shaka.device.WebOS.prototype.supportsMediaCapabilities=function(){return!1};shaka.device.WebOS.prototype.supportsSequenceMode=function(){var a=this.getVersion();return a!==null?a>3:shaka.device.AbstractDevice.prototype.supportsSequenceMode.call(this)};shaka.device.WebOS.prototype.supportsSmoothCodecSwitching=function(){return!1};shaka.device.WebOS.prototype.supportsServerCertificate=function(){var a=this.getVersion();return a!==null?a>3:shaka.device.AbstractDevice.prototype.supportsServerCertificate.call(this)};
shaka.device.WebOS.prototype.detectMaxHardwareResolution=function(){var a={width:1920,height:1080};try{var b=JSON.parse(window.PalmSystem.deviceInfo);a.width=Math.max(1920,b.screenWidth);a.height=Math.max(1080,b.screenHeight)}catch(c){shaka.log.alwaysWarn("WebOS: Error detecting screen size, default screen size 1920x1080.")}return Promise.resolve(a)};
shaka.device.WebOS.prototype.adjustConfig=function(a){shaka.device.AbstractDevice.prototype.adjustConfig.call(this,a);this.getVersion()===3&&(a.streaming.crossBoundaryStrategy=shaka.config.CrossBoundaryStrategy.RESET);a.streaming.shouldFixTimestampOffset=!0;a.streaming.stallSkip=0;return a};
shaka.device.WebOS.prototype.getHdrLevel=function(a){return this.supportHdr_==null?(shaka.log.alwaysWarn("WebOS: getConfigs call haven't finished"),shaka.device.AbstractDevice.prototype.getHdrLevel.call(this,a)):this.supportHdr_?a?"HLG":"PQ":"SDR"};
shaka.device.WebOS.prototype.guessWebOSVersion_=function(){var a=null,b=navigator.userAgent.match(/Chrome\/(\d+)/);b&&(a=parseInt(b[1],10));switch(a){case 38:return 3;case 53:return 4;case 68:return 5;case 79:return 6;case 87:return 22;case 94:return 23;case 108:return 24;case 120:return 25;default:return null}};shaka.device.WebOS.prototype.supportStandardVP9Checking=function(){return!1};
shaka.device.WebOS.prototype.supportsCbcsWithoutEncryptionSchemeSupport=function(){var a=this.getVersion();return a!==null?a>=6:shaka.device.AbstractDevice.prototype.supportsCbcsWithoutEncryptionSchemeSupport.call(this)};shaka.device.WebOS.isWebOS_=function(){return navigator.userAgent.includes("Web0S")};if(shaka.device.WebOS.isWebOS_()){var webOSDevice=new shaka.device.WebOS;shaka.device.DeviceFactory.registerDeviceFactory(function(){return webOSDevice})};shaka.device.Xbox=function(){shaka.device.AbstractDevice.call(this);this.isLegacyEdge_=navigator.userAgent.includes("Edge/");var a=navigator.userAgent.match(/Edge?\/(\d+)/);this.version_=a?parseInt(a[1],10):null};$jscomp.inherits(shaka.device.Xbox,shaka.device.AbstractDevice);shaka.device.Xbox.prototype.getVersion=function(){return this.version_};shaka.device.Xbox.prototype.getDeviceName=function(){return"Xbox"};shaka.device.Xbox.prototype.getDeviceType=function(){return shaka.device.IDevice.DeviceType.CONSOLE};
shaka.device.Xbox.prototype.getBrowserEngine=function(){return this.isLegacyEdge_?shaka.device.IDevice.BrowserEngine.EDGE:shaka.device.IDevice.BrowserEngine.CHROMIUM};shaka.device.Xbox.prototype.requiresEncryptionInfoInAllInitSegments=function(a){return!0};shaka.device.Xbox.prototype.requiresClearAndEncryptedInitSegments=function(){return!0};shaka.device.Xbox.prototype.insertEncryptionDataBeforeClear=function(){return!0};shaka.device.Xbox.prototype.shouldOverrideDolbyVisionCodecs=function(){return this.isLegacyEdge_};
shaka.device.Xbox.prototype.detectMaxHardwareResolution=function(){var a={width:1920,height:1080},b=shaka.device.Xbox.getWinRT_();if(b)try{var c=new b.Media.Protection.ProtectionCapabilities,d=b.Media.Protection.ProtectionCapabilityResult;b=null;do b=c.isTypeSupported('video/mp4;codecs="hvc1,mp4a";features="decode-res-x=3840,decode-res-y=2160,decode-bitrate=20000,decode-fps=30,decode-bpc=10,display-res-x=3840,display-res-y=2160,display-bpc=8"',"com.microsoft.playready.recommendation");while(b===d.maybe);
b===d.probably&&(a.width=3840,a.height=2160)}catch(e){shaka.log.alwaysWarn("Xbox: Error detecting screen size, default screen size 1920x1080.")}return Promise.resolve(a)};shaka.device.Xbox.prototype.adjustConfig=function(a){shaka.device.AbstractDevice.prototype.adjustConfig.call(this,a);a.drm.parseInbandPsshEnabled=this.isLegacyEdge_;a.drm.preferredKeySystems.push("com.microsoft.playready");this.isLegacyEdge_&&(a.streaming.gapPadding=.01);return a};
shaka.device.Xbox.prototype.returnLittleEndianUsingPlayReady=function(){return!0};shaka.device.Xbox.prototype.supportsOfflineStorage=function(){return!1};shaka.device.Xbox.getWinRT_=function(){var a=null;try{a=typeof Windows!=="undefined"?Windows:chrome.webview.hostObjects.sync.Windows}catch(b){}return a};shaka.device.Xbox.isXbox_=function(){return navigator.userAgent.includes("Xbox One")||shaka.device.Xbox.getWinRT_()!==null};shaka.device.Xbox.isXbox_()&&shaka.device.DeviceFactory.registerDeviceFactory(function(){return new shaka.device.Xbox});shaka.util.Destroyer=function(a){this.destroyed_=!1;this.waitOnDestroy_=new shaka.util.PublicPromise;this.onDestroy_=a};shaka.util.Destroyer.prototype.destroyed=function(){return this.destroyed_};shaka.util.Destroyer.prototype.destroy=function(){var a=this;if(this.destroyed_)return this.waitOnDestroy_;this.destroyed_=!0;return this.onDestroy_().then(function(){a.waitOnDestroy_.resolve()},function(){a.waitOnDestroy_.resolve()})};
shaka.util.Destroyer.prototype.ensureNotDestroyed=function(a){if(this.destroyed_){if(a instanceof shaka.util.Error&&a.code==shaka.util.Error.Code.OBJECT_DESTROYED)throw a;throw shaka.util.Destroyer.destroyedError(a);}};shaka.util.Destroyer.destroyedError=function(a){return new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.PLAYER,shaka.util.Error.Code.OBJECT_DESTROYED,a)};shaka.util.Iterables=function(){};shaka.util.Iterables.map=function(a,b){var c=[];a=(0,$jscomp.makeIterator)(a);for(var d=a.next();!d.done;d=a.next())c.push(b(d.value));return c};shaka.util.Iterables.every=function(a,b){a=(0,$jscomp.makeIterator)(a);for(var c=a.next();!c.done;c=a.next())if(!b(c.value))return!1;return!0};shaka.util.Iterables.some=function(a,b){a=(0,$jscomp.makeIterator)(a);for(var c=a.next();!c.done;c=a.next())if(b(c.value))return!0;return!1};
shaka.util.Iterables.filter=function(a,b){var c=[];a=(0,$jscomp.makeIterator)(a);for(var d=a.next();!d.done;d=a.next())d=d.value,b(d)&&c.push(d);return c};shaka.util.MapUtils=function(){};shaka.util.MapUtils.asMap=function(a){for(var b=new Map,c=(0,$jscomp.makeIterator)(Object.keys(a)),d=c.next();!d.done;d=c.next())d=d.value,b.set(d,a[d]);return b};shaka.util.MapUtils.asObject=function(a){var b={};a.forEach(function(c,d){b[d]=c});return b};
shaka.util.MapUtils.hasSameElements=function(a,b){if(a||b){if(a&&!b||b&&!a)return!1}else return!0;if(a.size!=b.size)return!1;a=(0,$jscomp.makeIterator)(a);for(var c=a.next();!c.done;c=a.next()){var d=(0,$jscomp.makeIterator)(c.value);c=d.next().value;d=d.next().value;if(!b.has(c))return!1;c=b.get(c);if(c!=d||c==void 0)return!1}return!0};shaka.drm.DrmEngine=function(a){var b=this;this.playerInterface_=a;this.video_=this.mediaKeys_=null;this.initializedForStorage_=this.initialized_=!1;this.licenseTimeSeconds_=0;this.currentDrmInfo_=null;this.eventManager_=new shaka.util.EventManager;this.activeSessions_=new Map;this.activeRequests_=[];this.storedPersistentSessions_=new Map;this.hasInitData_=!1;this.allSessionsLoaded_=new shaka.util.PublicPromise;this.config_=null;this.onError_=function(c){c.severity==shaka.util.Error.Severity.CRITICAL&&
b.allSessionsLoaded_.reject(c);a.onError(c)};this.keyStatusByKeyId_=new Map;this.announcedKeyStatusByKeyId_=new Map;this.keyStatusTimer_=new shaka.util.Timer(function(){return b.processKeyStatusChanges_()});this.usePersistentLicenses_=!1;this.mediaKeyMessageEvents_=[];this.initialRequestsSent_=!1;this.expirationTimer_=new shaka.util.Timer(function(){b.pollExpiration_()});this.allSessionsLoaded_.catch(function(){});this.destroyer_=new shaka.util.Destroyer(function(){return b.destroyNow_()});this.srcEquals_=
!1;this.manifestInitData_=this.mediaKeysAttached_=null;this.isPreload_=function(){return!1}};shaka.drm.DrmEngine.prototype.destroy=function(){return this.destroyer_.destroy()};
shaka.drm.DrmEngine.prototype.destroyNow_=function(){var a=this,b;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){switch(c.getNextAddressJsc()){case 1:return a.eventManager_.release(),a.eventManager_=null,a.allSessionsLoaded_.reject(),a.expirationTimer_.stop(),a.expirationTimer_=null,a.keyStatusTimer_.stop(),a.keyStatusTimer_=null,c.yield(a.closeOpenSessions_(),2);case 2:if(!a.video_){c.jumpTo(3);break}shaka.drm.DrmUtils.isMediaKeysPolyfilled("webkit")||goog.asserts.assert(!a.video_.src&&
!a.video_.getElementsByTagName("source").length,"video src must be removed first!");c.setCatchFinallyBlocks(4);return c.yield(a.video_.setMediaKeys(null),6);case 6:c.leaveTryBlock(5);break;case 4:b=c.enterCatchBlock(),shaka.log.alwaysWarn("DrmEngine.destroyNow_ exception",b);case 5:a.video_=null;case 3:a.currentDrmInfo_=null,a.mediaKeys_=null,a.storedPersistentSessions_=new Map,a.config_=null,a.onError_=function(){},a.playerInterface_=null,a.srcEquals_=!1,a.mediaKeysAttached_=null,c.jumpToEnd()}})};
shaka.drm.DrmEngine.prototype.configure=function(a,b){this.config_=a;b&&(this.isPreload_=b);this.expirationTimer_&&this.initialized_&&this.currentDrmInfo_&&this.expirationTimer_.tickEvery(this.config_.updateExpirationTime)};shaka.drm.DrmEngine.prototype.setSrcEquals=function(a){this.srcEquals_=a};shaka.drm.DrmEngine.prototype.initForStorage=function(a,b){this.initializedForStorage_=!0;this.storedPersistentSessions_=new Map;this.usePersistentLicenses_=b;return this.init_(a,!1)};
shaka.drm.DrmEngine.prototype.initForPlayback=function(a,b,c){c=c===void 0?!0:c;this.storedPersistentSessions_=new Map;b=(0,$jscomp.makeIterator)(b);for(var d=b.next();!d.done;d=b.next())this.storedPersistentSessions_.set(d.value,{initData:null,initDataType:null});b=(0,$jscomp.makeIterator)(this.config_.persistentSessionsMetadata);for(d=b.next();!d.done;d=b.next())d=d.value,this.storedPersistentSessions_.set(d.sessionId,{initData:d.initData,initDataType:d.initDataType});this.usePersistentLicenses_=
this.storedPersistentSessions_.size>0;return this.init_(a,c)};
shaka.drm.DrmEngine.prototype.initForRemoval=function(a,b,c,d,e){var f=this,g,h,k,l,m;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(n){if(n.getNextAddressJsc()==1)return g=[],e.length&&g.push(e[0].contentType),d.length&&g.push(d[0].contentType),h=function(p){p=shaka.util.ManifestParserUtils.createDrmInfo(a,p,null);p.licenseServerUri=b;p.serverCertificate=c;p.persistentStateRequired=!0;p.sessionType="persistent-license";return p},k=shaka.util.StreamUtils.createEmptyVariant(g),k.video&&
(l=h(e[0].encryptionScheme||""),k.video.drmInfos.push(l)),k.audio&&(m=h(d[0].encryptionScheme||""),k.audio.drmInfos.push(m)),n.yield(shaka.util.StreamUtils.getDecodingInfosForVariants([k],!0,f.srcEquals_,[]),2);f.destroyer_.ensureNotDestroyed();return n.return(f.queryMediaKeys_([k]))})};
shaka.drm.DrmEngine.prototype.init_=function(a,b){var c=this,d,e,f,g,h,k,l,m,n,p,q,r,t,u,v,w,x,y;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(C){if(C.getNextAddressJsc()==1){goog.asserts.assert(c.config_,"DrmEngine configure() must be called before init()!");shaka.drm.DrmEngine.configureClearKey(c.config_.clearKeys,a);d=a.some(function(D){return D.video&&D.video.drmInfos.length||D.audio&&D.audio.drmInfos.length?!0:!1});e=shaka.util.MapUtils.asMap(c.config_.servers);f=shaka.util.MapUtils.asMap(c.config_.advanced||
{});!d&&b&&shaka.drm.DrmEngine.replaceDrmInfo_(a,e);g=new WeakSet;h=(0,$jscomp.makeIterator)(a);for(k=h.next();!k.done;k=h.next())for(l=k.value,m=c.getVariantDrmInfos_(l),n=(0,$jscomp.makeIterator)(m),p=n.next();!p.done;p=n.next())q=p.value,g.has(q)||(g.add(q),shaka.drm.DrmEngine.fillInDrmInfoDefaults_(q,e,f,c.config_.keySystemsMapping));r=function(D,A){var z=[];D=(0,$jscomp.makeIterator)(D);for(var B=D.next();!B.done;B=D.next()){B=B.value;var E=B[A]||f.has(B.keySystem)&&f.get(B.keySystem)[A]||"";
E==""&&shaka.drm.DrmUtils.isWidevineKeySystem(B.keySystem)&&(A=="audioRobustness"?E=[c.config_.defaultAudioRobustnessForWidevine]:A=="videoRobustness"&&(E=[c.config_.defaultVideoRobustnessForWidevine]));if(typeof E==="string")z.push(B);else if(Array.isArray(E)){E.length===0&&(E=[""]);E=(0,$jscomp.makeIterator)(E);for(var H=E.next();!H.done;H=E.next()){var N={};z.push(Object.assign({},B,(N[A]=H.value,N)))}}}return z};t=new WeakSet;u=(0,$jscomp.makeIterator)(a);for(v=u.next();!v.done;v=u.next())w=v.value,
w.video&&!t.has(w.video)&&(w.video.drmInfos=r(w.video.drmInfos,"videoRobustness"),w.video.drmInfos=r(w.video.drmInfos,"audioRobustness"),t.add(w.video)),w.audio&&!t.has(w.audio)&&(w.audio.drmInfos=r(w.audio.drmInfos,"videoRobustness"),w.audio.drmInfos=r(w.audio.drmInfos,"audioRobustness"),t.add(w.audio));return C.yield(shaka.util.StreamUtils.getDecodingInfosForVariants(a,c.usePersistentLicenses_,c.srcEquals_,c.config_.preferredKeySystems),2)}c.destroyer_.ensureNotDestroyed();x=d||e.size>0;if(!x)return c.initialized_=
!0,C.return(Promise.resolve());y=c.queryMediaKeys_(a);return C.return(d?y:y.catch(function(){}))})};
shaka.drm.DrmEngine.prototype.attachMediaKeys_=function(){var a=this,b;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){switch(c.getNextAddressJsc()){case 1:if(a.video_.mediaKeys)return c.return();if(!a.mediaKeysAttached_){c.jumpTo(2);break}return c.yield(a.mediaKeysAttached_,3);case 3:return a.destroyer_.ensureNotDestroyed(),c.return();case 2:return c.setCatchFinallyBlocks(4),a.mediaKeysAttached_=a.video_.setMediaKeys(a.mediaKeys_),c.yield(a.mediaKeysAttached_,6);case 6:c.leaveTryBlock(5);
break;case 4:b=c.enterCatchBlock(),goog.asserts.assert(b instanceof Error,"Wrong error type!"),a.onError_(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.FAILED_TO_ATTACH_TO_VIDEO,b.message));case 5:a.destroyer_.ensureNotDestroyed(),c.jumpToEnd()}})};
shaka.drm.DrmEngine.prototype.onEncryptedEvent_=function(a){var b=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){if(c.getNextAddressJsc()==1)return c.yield(b.attachMediaKeys_(),2);b.newInitData(a.initDataType,shaka.util.BufferUtils.toUint8(a.initData));c.jumpToEnd()})};
shaka.drm.DrmEngine.prototype.attach=function(a){var b=this,c,d;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(e){if(e.getNextAddressJsc()==1){if(b.video_===a)return e.return();if(!b.mediaKeys_)return b.eventManager_.listenOnce(a,"encrypted",function(f){b.onError_(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.ENCRYPTED_CONTENT_WITHOUT_DRM_INFO))}),e.return();b.video_=a;b.config_.delayLicenseRequestUntilPlayed&&b.eventManager_.listenOnce(b.video_,
"play",function(){return b.onPlay_()});b.video_.remote?(b.eventManager_.listen(b.video_.remote,"connect",function(){return b.closeOpenSessions_()}),b.eventManager_.listen(b.video_.remote,"connecting",function(){return b.closeOpenSessions_()}),b.eventManager_.listen(b.video_.remote,"disconnect",function(){return b.closeOpenSessions_()})):"webkitCurrentPlaybackTargetIsWireless"in b.video_&&b.eventManager_.listen(b.video_,"webkitcurrentplaybacktargetiswirelesschanged",function(){return b.closeOpenSessions_()});
b.manifestInitData_=b.currentDrmInfo_?b.currentDrmInfo_.initData.find(function(f){return f.initData.length>0})||null:null;c=b.currentDrmInfo_.keySystem;return(d=shaka.device.DeviceFactory.getDevice().needWaitForEncryptedEvent(c))||!b.manifestInitData_&&b.currentDrmInfo_.keySystem==="com.apple.fps"&&!b.storedPersistentSessions_.size?e.jumpTo(2):e.yield(b.attachMediaKeys_(),2)}b.createOrLoad().catch(function(){});!d&&(b.manifestInitData_||b.storedPersistentSessions_.size||b.config_.parseInbandPsshEnabled)||
b.eventManager_.listen(b.video_,"encrypted",function(f){return b.onEncryptedEvent_(f)});e.jumpToEnd()})};shaka.drm.DrmEngine.prototype.hasManifestInitData=function(){return!!this.manifestInitData_};
shaka.drm.DrmEngine.prototype.setServerCertificate=function(){var a=this,b,c,d,e,f,g;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(h){switch(h.getNextAddressJsc()){case 1:goog.asserts.assert(a.initialized_,"Must call init() before setServerCertificate");if(!a.mediaKeys_||!a.currentDrmInfo_)return h.return();if(!a.currentDrmInfo_.serverCertificateUri||a.currentDrmInfo_.serverCertificate&&a.currentDrmInfo_.serverCertificate.length){h.jumpTo(2);break}b=shaka.net.NetworkingEngine.makeRequest([a.currentDrmInfo_.serverCertificateUri],
a.config_.retryParameters);h.setCatchFinallyBlocks(3);c=a.playerInterface_.netEngine.request(shaka.net.NetworkingEngine.RequestType.SERVER_CERTIFICATE,b,{isPreload:a.isPreload_()});return h.yield(c.promise,5);case 5:d=h.getYieldResultJsc();a.currentDrmInfo_.serverCertificate=shaka.util.BufferUtils.toUint8(d.data);h.leaveTryBlock(4);break;case 3:throw e=h.enterCatchBlock(),goog.asserts.assert(e instanceof shaka.util.Error,"Wrong NetworkingEngine error type!"),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.DRM,shaka.util.Error.Code.SERVER_CERTIFICATE_REQUEST_FAILED,e);case 4:if(a.destroyer_.destroyed())return h.return();case 2:if(!a.currentDrmInfo_.serverCertificate||!a.currentDrmInfo_.serverCertificate.length)return h.return();h.setCatchFinallyBlocks(6);return h.yield(a.mediaKeys_.setServerCertificate(a.currentDrmInfo_.serverCertificate),8);case 8:(f=h.getYieldResultJsc())||shaka.log.warning("Server certificates are not supported by the key system.  The server certificate has been ignored.");
h.leaveTryBlock(0);break;case 6:throw g=h.enterCatchBlock(),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.INVALID_SERVER_CERTIFICATE,g.message);}})};
shaka.drm.DrmEngine.prototype.removeSession=function(a){var b=this,c,d,e;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){if(f.getNextAddressJsc()==1)return goog.asserts.assert(b.mediaKeys_,"Must call init() before removeSession"),f.yield(b.loadOfflineSession_(a,{initData:null,initDataType:null}),2);if(f.getNextAddressJsc()!=3){c=f.getYieldResultJsc();if(!c)return shaka.log.v2("Ignoring attempt to remove missing session",a),f.return();d=[];if(e=b.activeSessions_.get(c))e.updatePromise=
new shaka.util.PublicPromise,d.push(e.updatePromise);shaka.log.v2("Attempting to remove session",a);d.push(c.remove());return f.yield(Promise.all(d),3)}b.activeSessions_.delete(c);f.jumpToEnd()})};
shaka.drm.DrmEngine.prototype.createOrLoad=function(){var a=this,b,c,d,e,f;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(g){if(g.getNextAddressJsc()==1){if(!a.storedPersistentSessions_.size)return g.jumpTo(2);a.storedPersistentSessions_.forEach(function(h,k){a.loadOfflineSession_(k,h)});return g.yield(a.allSessionsLoaded_,3)}if(g.getNextAddressJsc()!=2){b=a.currentDrmInfo_&&a.currentDrmInfo_.keyIds||new Set([]);if(b.size>0&&a.areAllKeysUsable_())return g.return(a.allSessionsLoaded_);
a.hasInitData_=!1;a.allSessionsLoaded_=new shaka.util.PublicPromise;a.allSessionsLoaded_.catch(function(){})}c=(a.currentDrmInfo_?a.currentDrmInfo_.initData:[])||[];d=(0,$jscomp.makeIterator)(c);for(e=d.next();!e.done;e=d.next())f=e.value,a.newInitData(f.initDataType,f.initData);a.areAllSessionsLoaded_()&&a.allSessionsLoaded_.resolve();return g.return(a.allSessionsLoaded_)})};
shaka.drm.DrmEngine.prototype.updateCurrentDrmInfo=function(a){this.currentDrmInfo_&&(this.currentDrmInfo_.mediaTypes!==a.mediaTypes&&(this.currentDrmInfo_.mediaTypes=a.mediaTypes),shaka.drm.DrmUtils.isClearKeyWihRawKey(a)&&(this.currentDrmInfo_=this.createDrmInfoByInfos_(this.currentDrmInfo_.keySystem,[this.currentDrmInfo_,a])))};
shaka.drm.DrmEngine.prototype.newInitData=function(a,b){if(b.length){try{b=this.config_.initDataTransform(b,a,this.currentDrmInfo_)}catch(f){a=f;f instanceof shaka.util.Error||(a=new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.INIT_DATA_TRANSFORM_ERROR,f));this.onError_(a);return}if(this.config_.ignoreDuplicateInitData){var c=this.activeSessions_.values();c=(0,$jscomp.makeIterator)(c);for(var d=c.next();!d.done;d=c.next())if(shaka.util.BufferUtils.equal(b,
d.value.initData)){shaka.log.debug("Ignoring duplicate init data.");return}var e=!1;this.storedPersistentSessions_.forEach(function(f,g){!e&&shaka.util.BufferUtils.equal(b,f.initData)&&(e=!0)});if(e){shaka.log.debug("Ignoring duplicate init data.");return}}this.hasInitData_=!0;this.activeSessions_.size>0&&this.areAllSessionsLoaded_()&&(this.allSessionsLoaded_.resolve(),this.hasInitData_=!1,this.allSessionsLoaded_=new shaka.util.PublicPromise,this.allSessionsLoaded_.catch(function(){}));this.createSession(a,
b,this.currentDrmInfo_.sessionType)}};shaka.drm.DrmEngine.prototype.initialized=function(){return this.initialized_};shaka.drm.DrmEngine.prototype.getSessionIds=function(){var a=this.activeSessions_.keys();a=shaka.util.Iterables.map(a,function(b){return b.sessionId});return Array.from(a)};
shaka.drm.DrmEngine.prototype.getActiveSessionsMetadata=function(){var a=this,b=this.activeSessions_.keys();b=shaka.util.Iterables.map(b,function(c){var d=a.activeSessions_.get(c);return{sessionId:c.sessionId,sessionType:d.type,initData:d.initData,initDataType:d.initDataType}});return Array.from(b)};
shaka.drm.DrmEngine.prototype.getExpiration=function(){var a=Infinity,b=this.activeSessions_.keys();b=(0,$jscomp.makeIterator)(b);for(var c=b.next();!c.done;c=b.next())c=c.value,isNaN(c.expiration)||(a=Math.min(a,c.expiration));return a};shaka.drm.DrmEngine.prototype.getLicenseTime=function(){return this.licenseTimeSeconds_?this.licenseTimeSeconds_:NaN};shaka.drm.DrmEngine.prototype.getDrmInfo=function(){return this.currentDrmInfo_};shaka.drm.DrmEngine.prototype.getMediaKeys=function(){return this.mediaKeys_};
shaka.drm.DrmEngine.prototype.getKeyStatuses=function(){return shaka.util.MapUtils.asObject(this.announcedKeyStatusByKeyId_)};
shaka.drm.DrmEngine.prototype.queryMediaKeys_=function(a){var b=this,c,d,e,f,g,h,k,l;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(m){switch(m.getNextAddressJsc()){case 1:c=new Map;d=b.getKeySystemAccessFromVariants_(a,c);if(!d){if(!navigator.requestMediaKeySystemAccess)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.MISSING_EME_SUPPORT);throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,
shaka.util.Error.Code.REQUESTED_KEY_SYSTEM_CONFIG_UNAVAILABLE);}b.destroyer_.ensureNotDestroyed();m.setCatchFinallyBlocks(2);e=d.getConfiguration();shaka.log.v2("Got MediaKeySystemAccess with configuration",e);f=b.config_.keySystemsMapping[d.keySystem]||d.keySystem;b.currentDrmInfo_=b.createDrmInfoByInfos_(f,c.get(f));if(!b.currentDrmInfo_.licenseServerUri)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.NO_LICENSE_SERVER_GIVEN,b.currentDrmInfo_.keySystem);
return m.yield(d.createMediaKeys(),4);case 4:g=m.getYieldResultJsc();b.destroyer_.ensureNotDestroyed();shaka.log.info("Created MediaKeys object for key system",b.currentDrmInfo_.keySystem);b.mediaKeys_=g;if(!(b.config_.minHdcpVersion!=""&&"getStatusForPolicy"in b.mediaKeys_)){m.jumpTo(5);break}m.setCatchFinallyBlocks(6);return m.yield(b.mediaKeys_.getStatusForPolicy({minHdcpVersion:b.config_.minHdcpVersion}),8);case 8:h=m.getYieldResultJsc();if(h!="usable")throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.DRM,shaka.util.Error.Code.MIN_HDCP_VERSION_NOT_MATCH);b.destroyer_.ensureNotDestroyed();m.leaveTryBlock(5,2);break;case 6:k=m.enterCatchBlock(2);if(k instanceof shaka.util.Error)throw k;throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.ERROR_CHECKING_HDCP_VERSION,k.message);case 5:return b.initialized_=!0,b.expirationTimer_.tickEvery(b.config_.updateExpirationTime),m.yield(b.setServerCertificate(),9);case 9:b.destroyer_.ensureNotDestroyed();
m.leaveTryBlock(0);break;case 2:l=m.enterCatchBlock();b.destroyer_.ensureNotDestroyed(l);b.currentDrmInfo_=null;if(l instanceof shaka.util.Error)throw l;throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.FAILED_TO_CREATE_CDM,l.message);}})};
shaka.drm.DrmEngine.prototype.getKeySystemAccessFromVariants_=function(a,b){for(var c=(0,$jscomp.makeIterator)(a),d=c.next();!d.done;d=c.next()){d=this.getVariantDrmInfos_(d.value);d=(0,$jscomp.makeIterator)(d);for(var e=d.next();!e.done;e=d.next())e=e.value,b.has(e.keySystem)||b.set(e.keySystem,[]),b.get(e.keySystem).push(e)}if(b.size==1&&b.has(""))throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.NO_RECOGNIZED_KEY_SYSTEMS);c=this.config_.preferredKeySystems;
c.length||(d=shaka.util.MapUtils.asMap(this.config_.servers),d.size==1&&(c=Array.from(d.keys())));d=(0,$jscomp.makeIterator)(c);var f=d.next();for(e={};!f.done;e={preferredKeySystem$jscomp$1:void 0},f=d.next()){e.preferredKeySystem$jscomp$1=f.value;f=(0,$jscomp.makeIterator)(a);for(var g=f.next();!g.done;g=f.next())if(g=g.value.decodingInfos.find(function(m){return function(n){return n.supported&&n.keySystemAccess!=null&&n.keySystemAccess.keySystem==m.preferredKeySystem$jscomp$1}}(e)))return g.keySystemAccess}d=
(0,$jscomp.makeIterator)([!0,!1]);for(e=d.next();!e.done;e=d.next())for(e=e.value,f=(0,$jscomp.makeIterator)(a),g=f.next();!g.done;g=f.next()){g=(0,$jscomp.makeIterator)(g.value.decodingInfos);for(var h=g.next();!h.done;h=g.next())if(h=h.value,h.supported&&h.keySystemAccess){var k=h.keySystemAccess.keySystem;if(!c.includes(k)){var l=b.get(k);!l&&this.config_.keySystemsMapping[k]&&(l=b.get(this.config_.keySystemsMapping[k]));k=(0,$jscomp.makeIterator)(l);for(l=k.next();!l.done;l=k.next())if(!!l.value.licenseServerUri==
e)return h.keySystemAccess}}}return null};shaka.drm.DrmEngine.prototype.checkSessionsLoaded_=function(){this.areAllSessionsLoaded_()&&this.allSessionsLoaded_.resolve()};shaka.drm.DrmEngine.prototype.setLoadSessionTimeoutTimer_=function(a){var b=this;(new shaka.util.Timer(function(){a.loaded=!0;b.checkSessionsLoaded_()})).tickAfter(shaka.drm.DrmEngine.SESSION_LOAD_TIMEOUT_)};
shaka.drm.DrmEngine.prototype.loadOfflineSession_=function(a,b){var c=this,d,e,f,g,h,k,l;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(m){switch(m.getNextAddressJsc()){case 1:try{shaka.log.v1("Attempting to load an offline session",a),d=c.mediaKeys_.createSession("persistent-license")}catch(n){return e=new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.FAILED_TO_CREATE_SESSION,n.message),c.onError_(e),m.return(Promise.reject(e))}c.eventManager_.listen(d,
"message",function(n){return c.onSessionMessage_(n)});c.eventManager_.listen(d,"keystatuseschange",function(n){return c.onKeyStatusesChange_(n)});f={initData:b.initData,initDataType:b.initDataType,loaded:!1,oldExpiration:Infinity,updatePromise:null,type:"persistent-license"};c.activeSessions_.set(d,f);m.setCatchFinallyBlocks(2);return m.yield(d.load(a),4);case 4:return g=m.getYieldResultJsc(),c.destroyer_.ensureNotDestroyed(),shaka.log.v2("Loaded offline session",a,g),g||(c.activeSessions_.delete(d),
h=c.config_.persistentSessionOnlinePlayback?shaka.util.Error.Severity.RECOVERABLE:shaka.util.Error.Severity.CRITICAL,c.onError_(new shaka.util.Error(h,shaka.util.Error.Category.DRM,shaka.util.Error.Code.OFFLINE_SESSION_REMOVED)),f.loaded=!0),c.setLoadSessionTimeoutTimer_(f),c.checkSessionsLoaded_(),m.return(d);case 2:k=m.enterCatchBlock(),c.destroyer_.ensureNotDestroyed(k),c.activeSessions_.delete(d),l=c.config_.persistentSessionOnlinePlayback?shaka.util.Error.Severity.RECOVERABLE:shaka.util.Error.Severity.CRITICAL,
c.onError_(new shaka.util.Error(l,shaka.util.Error.Category.DRM,shaka.util.Error.Code.FAILED_TO_CREATE_SESSION,k.message)),f.loaded=!0,c.checkSessionsLoaded_();case 3:return m.return(Promise.resolve())}})};
shaka.drm.DrmEngine.prototype.createSession=function(a,b,c){var d=this;goog.asserts.assert(this.mediaKeys_,"mediaKeys_ should be valid when creating temporary session.");try{shaka.log.info("Creating new",c,"session");var e=this.mediaKeys_.createSession(c)}catch(f){this.onError_(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.FAILED_TO_CREATE_SESSION,f.message));return}this.eventManager_.listen(e,"message",function(f){return d.onSessionMessage_(f)});
this.eventManager_.listen(e,"keystatuseschange",function(f){return d.onKeyStatusesChange_(f)});this.activeSessions_.set(e,{initData:b,initDataType:a,loaded:!1,oldExpiration:Infinity,updatePromise:null,type:c});this.config_.logLicenseExchange&&(c=shaka.util.Uint8ArrayUtils.toBase64(b),shaka.log.info("EME init data: type=",a,"data=",c));e.generateRequest(a,b).catch(function(f){if(!d.destroyer_.destroyed()){goog.asserts.assert(f instanceof Error,"Wrong error type!");d.activeSessions_.delete(e);var g=
f.errorCode;if(g&&g.systemCode){var h=g.systemCode;h<0&&(h+=4294967296);h="0x"+h.toString(16)}d.onError_(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.FAILED_TO_GENERATE_LICENSE_REQUEST,f.message,f,h))}})};shaka.drm.DrmEngine.prototype.onSessionMessage_=function(a){this.delayLicenseRequest_()?this.mediaKeyMessageEvents_.push(a):this.sendLicenseRequest_(a)};
shaka.drm.DrmEngine.prototype.delayLicenseRequest_=function(){return this.video_?this.config_.delayLicenseRequestUntilPlayed&&this.video_.paused&&!this.initialRequestsSent_:!this.initializedForStorage_&&this.config_.delayLicenseRequestUntilPlayed};
shaka.drm.DrmEngine.prototype.waitForActiveRequests=function(){var a=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(b){return b.getNextAddressJsc()==1?!a.hasInitData_||a.delayLicenseRequest_()?b.jumpTo(0):b.yield(a.allSessionsLoaded_,3):b.yield(Promise.all(a.activeRequests_.map(function(c){return c.promise})),0)})};
shaka.drm.DrmEngine.prototype.sendLicenseRequest_=function(a){var b=this,c,d,e,f,g,h,k,l,m,n,p,q,r,t,u,v,w,x,y;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(C){switch(C.getNextAddressJsc()){case 1:c=a.target;shaka.log.v1("Sending license request for session",c.sessionId,"of type",a.messageType);b.config_.logLicenseExchange&&(d=shaka.util.Uint8ArrayUtils.toBase64(a.message),shaka.log.info("EME license request",d));e=b.activeSessions_.get(c);f=b.currentDrmInfo_.licenseServerUri;g=b.config_.advanced[b.currentDrmInfo_.keySystem];
a.messageType=="individualization-request"&&g&&g.individualizationServer&&(f=g.individualizationServer);h=shaka.net.NetworkingEngine.RequestType.LICENSE;k=shaka.net.NetworkingEngine.makeRequest([f],b.config_.retryParameters);k.body=a.message;k.method="POST";k.licenseRequestType=a.messageType;k.sessionId=c.sessionId;k.drmInfo=b.currentDrmInfo_;e&&(k.initData=e.initData,k.initDataType=e.initDataType);if(g&&g.headers)for(l in g.headers)k.headers[l]=g.headers[l];shaka.drm.DrmUtils.isClearKeySystem(b.currentDrmInfo_.keySystem)&&
b.fixClearKeyRequest_(k,b.currentDrmInfo_);shaka.drm.DrmUtils.isPlayReadyKeySystem(b.currentDrmInfo_.keySystem)&&b.unpackPlayReadyRequest_(k);m=Date.now();C.setCatchFinallyBlocks(2);p=b.playerInterface_.netEngine.request(h,k,{isPreload:b.isPreload_()});b.activeRequests_.push(p);return C.yield(p.promise,4);case 4:n=C.getYieldResultJsc();shaka.util.ArrayUtils.remove(b.activeRequests_,p);C.leaveTryBlock(3);break;case 2:q=C.enterCatchBlock();if(b.destroyer_.destroyed())return C.return();goog.asserts.assert(q instanceof
shaka.util.Error,"Wrong NetworkingEngine error type!");r={sessionId:c.sessionId,sessionType:e.type,initData:e.initData,initDataType:e.initDataType};t=new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.LICENSE_REQUEST_FAILED,q,r);b.activeSessions_.size==1?(b.onError_(t),e&&e.updatePromise&&e.updatePromise.reject(t)):(e&&e.updatePromise&&e.updatePromise.reject(t),b.activeSessions_.delete(c),b.areAllSessionsLoaded_()&&(b.allSessionsLoaded_.resolve(),
b.keyStatusTimer_.tickAfter(.1)));return C.return();case 3:if(b.destroyer_.destroyed())return C.return();b.licenseTimeSeconds_+=(Date.now()-m)/1E3;b.config_.logLicenseExchange&&(u=shaka.util.Uint8ArrayUtils.toBase64(n.data),shaka.log.info("EME license response",u));C.setCatchFinallyBlocks(5);shaka.log.v1("Updating session",c.sessionId);return C.yield(c.update(n.data),7);case 7:C.leaveTryBlock(6);break;case 5:return w=(v=C.enterCatchBlock())&&v.message||String(v),x=new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.DRM,shaka.util.Error.Code.LICENSE_RESPONSE_REJECTED,w),b.onError_(x),e&&e.updatePromise&&e.updatePromise.reject(x),C.return();case 6:if(b.destroyer_.destroyed())return C.return();y=new shaka.util.FakeEvent("drmsessionupdate");b.playerInterface_.onEvent(y);e&&(e.updatePromise&&e.updatePromise.resolve(),b.setLoadSessionTimeoutTimer_(e));C.jumpToEnd()}})};
shaka.drm.DrmEngine.prototype.unpackPlayReadyRequest_=function(a){var b=shaka.util.TXml,c=shaka.util.StringUtils.fromUTF16(a.body,!0,!0);if(c.includes("PlayReadyKeyMessage")){shaka.log.debug("Unwrapping PlayReady request.");c=b.parseXmlString(c,"PlayReadyKeyMessage");goog.asserts.assert(c,"Failed to parse PlayReady XML!");var d=b.getElementsByTagName(c,"HttpHeader");d=(0,$jscomp.makeIterator)(d);for(var e=d.next();!e.done;e=d.next()){var f=e.value;e=b.getElementsByTagName(f,"name")[0];f=b.getElementsByTagName(f,
"value")[0];goog.asserts.assert(e&&f,"Malformed PlayReady headers!");a.headers[shaka.util.TXml.getTextContents(e)]=shaka.util.TXml.getTextContents(f)}b=b.getElementsByTagName(c,"Challenge")[0];goog.asserts.assert(b,"Malformed PlayReady challenge!");goog.asserts.assert(b.attributes.encoding=="base64encoded","Unexpected PlayReady challenge encoding!");a.body=shaka.util.Uint8ArrayUtils.fromBase64(shaka.util.TXml.getTextContents(b))}else shaka.log.debug("PlayReady request is already unwrapped."),a.headers["Content-Type"]=
"text/xml; charset=utf-8"};shaka.drm.DrmEngine.prototype.fixClearKeyRequest_=function(a,b){try{var c=shaka.util.StringUtils.fromBytesAutoDetect(a.body);if(c){var d=JSON.parse(c);d.type||(d.type=b.sessionType,a.body=shaka.util.StringUtils.toUTF8(JSON.stringify(d)))}}catch(e){shaka.log.info("Error unpacking ClearKey license",e)}};
shaka.drm.DrmEngine.prototype.onKeyStatusesChange_=function(a){var b=this;a=a.target;shaka.log.v2("Key status changed for session",a.sessionId);var c=this.activeSessions_.get(a),d=!1;a.keyStatuses.forEach(function(f,g){if(typeof g=="string"){var h=g;g=f;f=h}h=shaka.device.DeviceFactory.getDevice();if(shaka.drm.DrmUtils.isPlayReadyKeySystem(b.currentDrmInfo_.keySystem)&&g.byteLength==16&&h.returnLittleEndianUsingPlayReady()){h=shaka.util.BufferUtils.toDataView(g);var k=h.getUint32(0,!0),l=h.getUint16(4,
!0),m=h.getUint16(6,!0);h.setUint32(0,k,!1);h.setUint16(4,l,!1);h.setUint16(6,m,!1)}f!="status-pending"&&(c.loaded=!0);c||goog.asserts.assert(f!="usable","Usable keys found in closed session");f=="expired"&&(d=!0);g=shaka.util.Uint8ArrayUtils.toHex(g).slice(0,32);b.keyStatusByKeyId_.set(g,f)});var e=a.expiration-Date.now();(e<0||d&&e<1E3)&&c&&!c.updatePromise&&(shaka.log.debug("Session has expired",a.sessionId),this.activeSessions_.delete(a),this.closeSession_(a));this.areAllSessionsLoaded_()&&(this.allSessionsLoaded_.resolve(),
this.keyStatusTimer_.tickAfter(shaka.drm.DrmEngine.KEY_STATUS_BATCH_TIME))};shaka.drm.DrmEngine.prototype.processKeyStatusChanges_=function(){var a=this.keyStatusByKeyId_,b=this.announcedKeyStatusByKeyId_;b.clear();a.forEach(function(c,d){return b.set(d,c)});a=Array.from(b.values());if(a.length&&a.every(function(c){return c=="expired"}))this.onError_(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.EXPIRED));this.playerInterface_.onKeyStatus(shaka.util.MapUtils.asObject(b))};
shaka.drm.DrmEngine.probeSupport=function(){var a,b,c,d,e,f,g,h,k,l,m,n,p,q,r,t,u,v,w,x,y,C,D,A,z,B,E,H,N;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(F){if(F.getNextAddressJsc()==1){a="org.w3.clearkey com.widevine.alpha com.widevine.alpha.experiment com.microsoft.playready com.microsoft.playready.hardware com.microsoft.playready.recommendation com.microsoft.playready.recommendation.3000 com.microsoft.playready.recommendation.3000.clearlead com.chromecast.playready com.apple.fps.1_0 com.apple.fps com.huawei.wiseplay".split(" ");
if(!shaka.drm.DrmUtils.isBrowserSupported()){b={};c=(0,$jscomp.makeIterator)(a);for(d=c.next();!d.done;d=c.next())e=d.value,b[e]=null;return F.return(b)}f="1.0 1.1 1.2 1.3 1.4 2.0 2.1 2.2 2.3".split(" ");g=["SW_SECURE_CRYPTO","SW_SECURE_DECODE","HW_SECURE_CRYPTO","HW_SECURE_DECODE","HW_SECURE_ALL"];h=["150","2000","3000"];k={"com.widevine.alpha":g,"com.widevine.alpha.experiment":g,"com.microsoft.playready.recommendation":h};l=[{contentType:'video/mp4; codecs="avc1.42E01E"'},{contentType:'video/webm; codecs="vp8"'}];
m=[{contentType:'audio/mp4; codecs="mp4a.40.2"'},{contentType:'audio/webm; codecs="opus"'}];n={videoCapabilities:l,audioCapabilities:m,initDataTypes:["cenc","sinf","skd","keyids"]};p=[null,"cenc","cbcs"];q=new Map;r=shaka.device.DeviceFactory.getDevice();t=function(I,L,G){var M,J,O,P,Q,K,T,U,W,X,V,S,Z;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(R){switch(R.getNextAddressJsc()){case 1:R.setCatchFinallyBlocks(2);if(!r.createMediaKeysWhenCheckingSupport())throw Error("Suppressing Firefox Windows DRM in testing!");
return R.yield(L.createMediaKeys(),5);case 5:M=R.getYieldResultJsc();case 4:R.leaveTryBlock(3);break;case 2:return R.enterCatchBlock(),R.return();case 3:O=(J=L.getConfiguration().sessionTypes)?J.includes("persistent-license"):!1;r.misreportsSupportForPersistentLicenses()&&(O=!1);P=L.getConfiguration().videoCapabilities;Q=L.getConfiguration().audioCapabilities;K={persistentState:O,encryptionSchemes:[],videoRobustnessLevels:[],audioRobustnessLevels:[],minHdcpVersions:[]};q.get(I)?K=q.get(I):q.set(I,
K);(T=P[0].encryptionScheme)&&!K.encryptionSchemes.includes(T)&&K.encryptionSchemes.push(T);(U=P[0].robustness)&&!K.videoRobustnessLevels.includes(U)&&K.videoRobustnessLevels.push(U);(W=Q[0].robustness)&&!K.audioRobustnessLevels.includes(W)&&K.audioRobustnessLevels.push(W);if(!(G&&"getStatusForPolicy"in M)){R.jumpTo(0);break}X=(0,$jscomp.makeIterator)(f);V=X.next();case 7:if(V.done){R.jumpTo(0);break}S=V.value;if(K.minHdcpVersions.includes(S)){R.jumpTo(8);break}return R.yield(M.getStatusForPolicy({minHdcpVersion:S}),
10);case 10:if(Z=R.getYieldResultJsc(),Z=="usable")K.minHdcpVersions.includes(S)||K.minHdcpVersions.push(S);else{R.jumpTo(0);break}case 8:V=X.next(),R.jumpTo(7)}})};u=function(I,L,G,M,J){J=J===void 0?!1:J;var O,P,Q,K,T,U,W,X,V,S,Z;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(R){switch(R.getNextAddressJsc()){case 1:R.setCatchFinallyBlocks(2);O=shaka.util.ObjectUtils.cloneObject(n);P=(0,$jscomp.makeIterator)(O.videoCapabilities);for(Q=P.next();!Q.done;Q=P.next())K=Q.value,K.encryptionScheme=
L,K.robustness=G;T=(0,$jscomp.makeIterator)(O.audioCapabilities);for(U=T.next();!U.done;U=T.next())W=U.value,W.encryptionScheme=L,W.robustness=M;X=shaka.util.ObjectUtils.cloneObject(O);X.persistentState="required";X.sessionTypes=["persistent-license"];V=[X,O];Z=shaka.device.DeviceFactory.getDevice();return Z.getDeviceType()==shaka.device.IDevice.DeviceType.MOBILE?R.yield(shaka.util.Functional.promiseWithTimeout(5,navigator.requestMediaKeySystemAccess(I,V)),7):R.yield(navigator.requestMediaKeySystemAccess(I,
V),6);case 6:S=R.getYieldResultJsc();R.jumpTo(5);break;case 7:S=R.getYieldResultJsc();case 5:return R.yield(t(I,S,J),8);case 8:R.leaveTryBlock(0);break;case 2:R.enterCatchBlock(),R.jumpToEnd()}})};v=function(I){return shaka.device.DeviceFactory.getDevice().getBrowserEngine()===shaka.device.IDevice.BrowserEngine.WEBKIT&&shaka.drm.DrmUtils.isClearKeySystem(I)?!1:!0};w=[];x=(0,$jscomp.makeIterator)(a);for(y=x.next();!y.done;y=x.next())if(C=y.value,q.set(C,null),v(C)){D=!0;A=(0,$jscomp.makeIterator)(p);
for(z=A.next();!z.done;z=A.next())B=z.value,w.push(u(C,B,"","",D)),D=!1;E=(0,$jscomp.makeIterator)(k[C]||[]);for(H=E.next();!H.done;H=E.next())N=H.value,w.push(u(C,null,N,"")),w.push(u(C,null,"",N))}return F.yield(Promise.all(w),2)}return F.return(shaka.util.MapUtils.asObject(q))})};
shaka.drm.DrmEngine.prototype.onPlay_=function(){for(var a=(0,$jscomp.makeIterator)(this.mediaKeyMessageEvents_),b=a.next();!b.done;b=a.next())this.sendLicenseRequest_(b.value);this.initialRequestsSent_=!0;this.mediaKeyMessageEvents_=[]};
shaka.drm.DrmEngine.prototype.closeSession_=function(a){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(b){if(b.getNextAddressJsc()==1)return b.setCatchFinallyBlocks(2),b.yield(shaka.util.Functional.promiseWithTimeout(shaka.drm.DrmEngine.CLOSE_TIMEOUT_,Promise.all([a.close().catch(function(){}),a.closed])),4);if(b.getNextAddressJsc()!=2)return b.leaveTryBlock(0);b.enterCatchBlock();shaka.log.warning("Timeout waiting for session close");b.jumpToEnd()})};
shaka.drm.DrmEngine.prototype.closeOpenSessions_=function(){var a=this,b;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){b=Array.from(a.activeSessions_.entries());a.activeSessions_.clear();return c.yield(Promise.all(b.map(function(d){d=(0,$jscomp.makeIterator)(d);var e=d.next().value;var f=d.next().value;var g;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(h){if(h.getNextAddressJsc()==1){h.setCatchFinallyBlocks(2);if(!a.initializedForStorage_&&!a.storedPersistentSessions_.has(e.sessionId)&&
f.type==="persistent-license"&&!a.config_.persistentSessionOnlinePlayback)return shaka.log.v1("Removing session",e.sessionId),h.yield(e.remove(),5);shaka.log.v1("Closing session",e.sessionId,f);return h.yield(a.closeSession_(e),5)}if(h.getNextAddressJsc()!=2)return h.leaveTryBlock(0);g=h.enterCatchBlock();shaka.log.error("Failed to close or remove the session",g);h.jumpToEnd()})})),0)})};
shaka.drm.DrmEngine.prototype.getVariantDrmInfos_=function(a){return(a.video?a.video.drmInfos:[]).concat(a.audio?a.audio.drmInfos:[])};shaka.drm.DrmEngine.prototype.pollExpiration_=function(){var a=this;this.activeSessions_.forEach(function(b,c){var d=b.oldExpiration,e=c.expiration;isNaN(e)&&(e=Infinity);e!=d&&(a.playerInterface_.onExpirationUpdated(c.sessionId,e),b.oldExpiration=e)})};
shaka.drm.DrmEngine.prototype.areAllSessionsLoaded_=function(){var a=this.activeSessions_.values();return shaka.util.Iterables.every(a,function(b){return b.loaded})};shaka.drm.DrmEngine.prototype.areAllKeysUsable_=function(){var a=this.currentDrmInfo_&&this.currentDrmInfo_.keyIds||new Set([]);a=(0,$jscomp.makeIterator)(a);for(var b=a.next();!b.done;b=a.next())if(this.keyStatusByKeyId_.get(b.value)!=="usable")return!1;return!0};
shaka.drm.DrmEngine.replaceDrmInfo_=function(a,b){var c=[];b.forEach(function(d,e){c.push({keySystem:e,licenseServerUri:d,distinctiveIdentifierRequired:!1,persistentStateRequired:!1,audioRobustness:"",videoRobustness:"",serverCertificate:null,serverCertificateUri:"",initData:[],keyIds:new Set})});a=(0,$jscomp.makeIterator)(a);for(b=a.next();!b.done;b=a.next())b=b.value,b.video&&(b.video.drmInfos=c),b.audio&&(b.audio.drmInfos=c)};
shaka.drm.DrmEngine.prototype.createDrmInfoByInfos_=function(a,b){var c=[],d=[],e=[],f=[],g=[],h=new Set,k=new Set;shaka.drm.DrmEngine.processDrmInfos_(b,c,d,f,e,g,h,k);c.length>1&&shaka.log.warning("Multiple unique encryption schemes found! Only the first will be used.");f.length>1&&shaka.log.warning("Multiple unique server certificates found! Only the first will be used.");d.length>1&&shaka.log.warning("Multiple unique license server URIs found! Only the first will be used.");e.length>1&&shaka.log.warning("Multiple unique server certificate URIs found! Only the first will be used.");
var l=this.usePersistentLicenses_?"persistent-license":"temporary";a={keySystem:a,encryptionScheme:c[0],licenseServerUri:d[0],distinctiveIdentifierRequired:b[0].distinctiveIdentifierRequired,persistentStateRequired:b[0].persistentStateRequired,sessionType:b[0].sessionType||l,audioRobustness:b[0].audioRobustness||"",videoRobustness:b[0].videoRobustness||"",serverCertificate:f[0],serverCertificateUri:e[0],initData:g,keyIds:h,mediaTypes:b[0].mediaTypes};k.size>0&&(a.keySystemUris=k);b=(0,$jscomp.makeIterator)(b);
for(k=b.next();!k.done;k=b.next())k=k.value,k.distinctiveIdentifierRequired&&(a.distinctiveIdentifierRequired=k.distinctiveIdentifierRequired),k.persistentStateRequired&&(a.persistentStateRequired=k.persistentStateRequired);return a};
shaka.drm.DrmEngine.processDrmInfos_=function(a,b,c,d,e,f,g,h){var k=[];a=(0,$jscomp.makeIterator)(a);for(var l=a.next(),m={};!l.done;m={drmInfo$jscomp$22:void 0},l=a.next()){m.drmInfo$jscomp$22=l.value;b.includes(m.drmInfo$jscomp$22.encryptionScheme)||b.push(m.drmInfo$jscomp$22.encryptionScheme);shaka.drm.DrmUtils.isClearKeySystem(m.drmInfo$jscomp$22.keySystem)&&m.drmInfo$jscomp$22.licenseServerUri.startsWith("data:application/json;base64,")?k.includes(m.drmInfo$jscomp$22.licenseServerUri)||k.push(m.drmInfo$jscomp$22.licenseServerUri):
c.includes(m.drmInfo$jscomp$22.licenseServerUri)||c.push(m.drmInfo$jscomp$22.licenseServerUri);e.includes(m.drmInfo$jscomp$22.serverCertificateUri)||e.push(m.drmInfo$jscomp$22.serverCertificateUri);m.drmInfo$jscomp$22.serverCertificate&&(d.some(function(q){return function(r){return shaka.util.BufferUtils.equal(r,q.drmInfo$jscomp$22.serverCertificate)}}(m))||d.push(m.drmInfo$jscomp$22.serverCertificate));if(m.drmInfo$jscomp$22.initData){l=(0,$jscomp.makeIterator)(m.drmInfo$jscomp$22.initData);for(var n=
l.next(),p={};!n.done;p={initDataOverride$jscomp$2:void 0},n=l.next())p.initDataOverride$jscomp$2=n.value,f.some(function(q){return function(r){var t=q.initDataOverride$jscomp$2;r=r.keyId&&r.keyId==t.keyId?!0:r.initDataType==t.initDataType&&shaka.util.BufferUtils.equal(r.initData,t.initData);return r}}(p))||f.push(p.initDataOverride$jscomp$2)}if(m.drmInfo$jscomp$22.keyIds)for(l=(0,$jscomp.makeIterator)(m.drmInfo$jscomp$22.keyIds),n=l.next();!n.done;n=l.next())g.add(n.value);if(m.drmInfo$jscomp$22.keySystemUris&&
h)for(m=(0,$jscomp.makeIterator)(m.drmInfo$jscomp$22.keySystemUris),l=m.next();!l.done;l=m.next())h.add(l.value)}if(k.length==1)c.push(k[0]);else if(k.length>0){b=[];k=(0,$jscomp.makeIterator)(k);for(d=k.next();!d.done;d=k.next())d=window.atob(d.value.split("data:application/json;base64,").pop()),d=JSON.parse(d),b.push.apply(b,(0,$jscomp.arrayFromIterable)(d.keys));k=JSON.stringify({keys:b});c.push("data:application/json;base64,"+window.btoa(k))}};
shaka.drm.DrmEngine.fillInDrmInfoDefaults_=function(a,b,c,d){var e=a.keySystem;if(e&&(!shaka.drm.DrmUtils.isClearKeySystem(e)||!a.licenseServerUri)){b.size&&b.get(e)&&(b=b.get(e),a.licenseServerUri=b);a.keyIds||(a.keyIds=new Set);if(c=c.get(e))a.distinctiveIdentifierRequired||(a.distinctiveIdentifierRequired=c.distinctiveIdentifierRequired),a.persistentStateRequired||(a.persistentStateRequired=c.persistentStateRequired),a.serverCertificate||(a.serverCertificate=c.serverCertificate),c.sessionType&&
(a.sessionType=c.sessionType),a.serverCertificateUri||(a.serverCertificateUri=c.serverCertificateUri);d[e]&&(a.keySystem=d[e]);window.cast&&window.cast.__platform__&&e=="com.microsoft.playready"&&(a.keySystem="com.chromecast.playready")}};
shaka.drm.DrmEngine.prototype.parseInbandPssh=function(a,b){if(!this.config_.parseInbandPsshEnabled||this.manifestInitData_)return Promise.resolve();var c=shaka.util.ManifestParserUtils.ContentType;if(![c.AUDIO,c.VIDEO].includes(a))return Promise.resolve();a=new shaka.util.Pssh(shaka.util.BufferUtils.toUint8(b));b=0;c=(0,$jscomp.makeIterator)(a.data);for(var d=c.next();!d.done;d=c.next())b+=d.value.length;if(b==0)return Promise.resolve();b=new Uint8Array(b);c=0;a=(0,$jscomp.makeIterator)(a.data);
for(d=a.next();!d.done;d=a.next())d=d.value,b.set(d,c),c+=d.length;this.newInitData("cenc",b);return this.allSessionsLoaded_};shaka.drm.DrmEngine.configureClearKey=function(a,b){a=shaka.util.MapUtils.asMap(a);if(a.size!=0){a=shaka.util.ManifestParserUtils.createDrmInfoFromClearKeys(a);b=(0,$jscomp.makeIterator)(b);for(var c=b.next();!c.done;c=b.next())c=c.value,c.video&&(c.video.drmInfos=[a]),c.audio&&(c.audio.drmInfos=[a])}};shaka.drm.DrmEngine.CLOSE_TIMEOUT_=1;
shaka.drm.DrmEngine.SESSION_LOAD_TIMEOUT_=5;shaka.drm.DrmEngine.KEY_STATUS_BATCH_TIME=.5;shaka.util.MediaElementEvent={CAN_PLAY:"canplay",CAN_PLAY_THROUGH:"canplaythrough",DURATION_CHANGE:"durationchange",ENCRYPTED:"encrypted",ENDED:"ended",LOADED_DATA:"loadeddata",LOADED_METADATA:"loadedmetadata",PAUSE:"pause",PLAY:"play",PLAYING:"playing",PROGRESS:"progress",RATE_CHANGE:"ratechange",SEEKED:"seeked",SEEKING:"seeking",STALLED:"stalled",TIME_UPDATE:"timeupdate",VOLUME_CHANGE:"volumechange",WAITING:"waiting"};shaka.media.BufferingObserver=function(a,b){var c=shaka.media.BufferingObserver.State;this.previousState_=c.SATISFIED;this.thresholds_=(new Map).set(c.SATISFIED,b).set(c.STARVING,a);this.lastRebufferTime_=0;this.lastReportedTime_=-1};shaka.media.BufferingObserver.prototype.setThresholds=function(a,b){var c=shaka.media.BufferingObserver.State;this.thresholds_.set(c.SATISFIED,b).set(c.STARVING,a)};
shaka.media.BufferingObserver.prototype.update=function(a,b){var c=shaka.media.BufferingObserver.State,d=this.thresholds_.get(this.previousState_);return this.setState(b||a>=d&&a>0?c.SATISFIED:c.STARVING)};shaka.media.BufferingObserver.prototype.setState=function(a){var b=shaka.media.BufferingObserver.State,c=this.previousState_!==a;this.previousState_=a;c&&a===b.SATISFIED&&(this.lastRebufferTime_=Date.now());return c};shaka.media.BufferingObserver.prototype.getState=function(){return this.previousState_};
shaka.media.BufferingObserver.prototype.getLastRebufferTime=function(){return this.lastRebufferTime_};shaka.media.BufferingObserver.prototype.resetLastRebufferTime=function(){this.lastRebufferTime_=0};
shaka.media.BufferingObserver.prototype.reportEvent=function(a,b){shaka.log.v2("BufferingObserver got event",a,"at time",b);var c=this.lastReportedTime_;this.lastReportedTime_=b;var d=void 0;switch(a){case shaka.util.MediaElementEvent.SEEKING:case shaka.util.MediaElementEvent.WAITING:this.lastReportedTime_=-1;d=shaka.media.BufferingObserver.State.STARVING;break;case shaka.util.MediaElementEvent.CAN_PLAY_THROUGH:case shaka.util.MediaElementEvent.PLAYING:case shaka.util.MediaElementEvent.SEEKED:d=shaka.media.BufferingObserver.State.SATISFIED;
break;case shaka.util.MediaElementEvent.TIME_UPDATE:c>=0&&b-c>.01&&(d=shaka.media.BufferingObserver.State.SATISFIED)}return d!==void 0?this.setState(d):!1};shaka.media.BufferingObserver.State={STARVING:0,SATISFIED:1};shaka.util.Mp4Generator=function(a){this.streamInfos_=a=a===void 0?[]:a};shaka.util.Mp4Generator.prototype.initSegment=function(){var a=shaka.util.Mp4Generator,b=this.moov_();a=a.FTYP_.value();var c=new Uint8Array(a.byteLength+b.byteLength);c.set(a);c.set(b,a.byteLength);return c};
shaka.util.Mp4Generator.prototype.moov_=function(){if(this.streamInfos_.length===0)throw Error("StreamInfos must have elements");for(var a=shaka.util.Mp4Generator,b=[],c=(0,$jscomp.makeIterator)(this.streamInfos_),d=c.next();!d.done;d=c.next())b.push(this.trak_(d.value));c=this.streamInfos_[0];return a.box.apply(a,["moov",this.mvhd_(c)].concat((0,$jscomp.arrayFromIterable)(b),[this.mvex_(),this.psshs(c.stream)]))};
shaka.util.Mp4Generator.prototype.mvhd_=function(a){var b=shaka.util.Mp4Generator,c=a.duration*a.timescale,d=Math.floor(c/(b.UINT32_MAX_+1));c=Math.floor(c%(b.UINT32_MAX_+1));a=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3].concat((0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(a.timescale,4)),(0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(d,4)),(0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(c,4)),[0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]));return b.box("mvhd",a)};shaka.util.Mp4Generator.prototype.trak_=function(a){return shaka.util.Mp4Generator.box("trak",this.tkhd_(a),this.mdia_(a))};
shaka.util.Mp4Generator.prototype.tkhd_=function(a){var b=shaka.util.Mp4Generator,c=a.id+1,d=a.stream.width||0,e=a.stream.height||0;a.type==shaka.util.ManifestParserUtils.ContentType.AUDIO&&(e=d=0);var f=a.duration*a.timescale;a=Math.floor(f/(b.UINT32_MAX_+1));f=Math.floor(f%(b.UINT32_MAX_+1));c=new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3].concat((0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(c,4)),[0,0,0,0],(0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(a,4)),(0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(f,
4)),[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0],(0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(d,2)),[0,0],(0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(e,2)),[0,0]));return b.box("tkhd",c)};shaka.util.Mp4Generator.prototype.mdia_=function(a){return shaka.util.Mp4Generator.box("mdia",this.mdhd_(a),this.hdlr_(a),this.minf_(a))};
shaka.util.Mp4Generator.prototype.mdhd_=function(a){var b=shaka.util.Mp4Generator,c=a.duration*a.timescale,d=Math.floor(c/(b.UINT32_MAX_+1));c=Math.floor(c%(b.UINT32_MAX_+1));var e=a.stream.language;e=e.charCodeAt(0)-96<<10|e.charCodeAt(1)-96<<5|e.charCodeAt(2)-96;a=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3].concat((0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(a.timescale,4)),(0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(d,4)),(0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(c,
4)),(0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(e,2)),[0,0]));return b.box("mdhd",a)};shaka.util.Mp4Generator.prototype.hdlr_=function(a){var b=shaka.util.Mp4Generator,c=shaka.util.ManifestParserUtils.ContentType,d=new Uint8Array([]);switch(a.type){case c.VIDEO:d=b.HDLR_TYPES_.video.value();break;case c.AUDIO:d=b.HDLR_TYPES_.audio.value()}return b.box("hdlr",d)};
shaka.util.Mp4Generator.prototype.minf_=function(a){var b=shaka.util.Mp4Generator,c=shaka.util.ManifestParserUtils.ContentType;switch(a.type){case c.VIDEO:return b.box("minf",b.box("vmhd",b.VMHD_.value()),b.DINF_.value(),this.stbl_(a));case c.AUDIO:return b.box("minf",b.box("smhd",b.SMHD_.value()),b.DINF_.value(),this.stbl_(a))}return new Uint8Array([])};
shaka.util.Mp4Generator.prototype.stbl_=function(a){var b=shaka.util.Mp4Generator;return b.box("stbl",this.stsd_(a),b.box("stts",b.STTS_.value()),b.box("stsc",b.STSC_.value()),b.box("stsz",b.STSZ_.value()),b.box("stco",b.STCO_.value()))};
shaka.util.Mp4Generator.prototype.stsd_=function(a){var b=shaka.util.Mp4Generator,c=shaka.util.ManifestParserUtils.ContentType,d="aac";a.codecs.includes("mp3")?d="mp3":a.codecs.includes("ac-3")?d=shaka.device.DeviceFactory.getDevice().requiresEC3InitSegments()?"ec-3":"ac-3":a.codecs.includes("ec-3")?d="ec-3":a.codecs.includes("opus")&&(d="opus");var e=new Uint8Array([]);switch(a.type){case c.VIDEO:a.codecs.includes("avc1")?e=this.avc1_(a):a.codecs.includes("hvc1")&&(e=this.hvc1_(a));break;case c.AUDIO:e=
d=="mp3"?this.mp3_(a):d=="ac-3"?this.ac3_(a):d=="ec-3"?this.ec3_(a):d=="opus"?this.opus_(a):this.mp4a_(a)}return b.box("stsd",b.STSD_.value(),e)};
shaka.util.Mp4Generator.prototype.avc1_=function(a){var b=shaka.util.Mp4Generator,c=a.stream.width||0,d=a.stream.height||0;var e=a.videoConfig.byteLength>0?b.box("avcC",a.videoConfig):b.box("avcC",this.avcC_(a));c=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].concat((0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(c,2)),(0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(d,2)),[0,72,0,0,0,72,0,0,0,0,0,0,0,1,19,118,105,100,101,111,106,115,45,99,111,110,116,114,105,98,
45,104,108,115,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]));d="avc1";var f=this.pasp_(a),g=new Uint8Array([]);b.isStreamEncrypted_(a.stream)&&(g=this.sinf(a.stream,a.codecs),d="encv");return b.box(d,c,e,f,g)};
shaka.util.Mp4Generator.prototype.avcC_=function(a){for(var b=7,c=[],d=[],e=0,f=0,g=0,h=0;h<a.videoNalus.length;h++){var k=this.hexStringToBuffer_(a.videoNalus[h]);switch(k[0]&31){case 7:c.push(k);b+=k.length+2;break;case 8:d.push(k),b+=k.length+2}}c.length>0&&(e=c[0][1],g=c[0][2],f=c[0][3]);a=new Uint8Array(b);b=0;a[b++]=1;a[b++]=e;a[b++]=g;a[b++]=f;a[b++]=255;a[b++]=224|c.length;for(e=0;e<c.length;e++)a[b++]=(c[e].length&65280)>>8,a[b++]=c[e].length&255,a.set(c[e],b),b+=c[e].length;a[b++]=d.length;
for(c=0;c<d.length;c++)a[b++]=(d[c].length&65280)>>8,a[b++]=d[c].length&255,a.set(d[c],b),b+=d[c].length;return a};
shaka.util.Mp4Generator.prototype.hvc1_=function(a){var b=shaka.util.Mp4Generator,c=a.stream.width||0,d=a.stream.height||0,e=new Uint8Array([]);a.videoConfig.byteLength>0&&(e=b.box("hvcC",a.videoConfig));c=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].concat((0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(c,2)),(0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(d,2)),[0,72,0,0,0,72,0,0,0,0,0,0,0,1,19,118,105,100,101,111,106,115,45,99,111,110,116,114,105,98,45,104,
108,115,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]));d="hvc1";var f=this.pasp_(a),g=new Uint8Array([]);b.isStreamEncrypted_(a.stream)&&(g=this.sinf(a.stream,a.codecs),d="encv");return b.box(d,c,e,f,g)};
shaka.util.Mp4Generator.prototype.pasp_=function(a){if(!a.hSpacing&&!a.vSpacing)return new Uint8Array([]);var b=shaka.util.Mp4Generator,c=a.vSpacing;a=new Uint8Array([].concat((0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(a.hSpacing,4)),(0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(c,4))));return b.box("pasp",a)};
shaka.util.Mp4Generator.prototype.audioStsd_=function(a){return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,a.stream.channelsCount||2,0,16,0,0,0,0].concat((0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(a.stream.audioSamplingRate||44100,2)),[0,0]))};shaka.util.Mp4Generator.prototype.mp3_=function(a){return shaka.util.Mp4Generator.box(".mp3",this.audioStsd_(a))};
shaka.util.Mp4Generator.prototype.ac3_=function(a){var b=shaka.util.Mp4Generator,c=b.box("dac3",a.audioConfig),d="ac-3",e=new Uint8Array([]);b.isStreamEncrypted_(a.stream)&&(e=this.sinf(a.stream,a.codecs),d="enca");return b.box(d,this.audioStsd_(a),c,e)};
shaka.util.Mp4Generator.prototype.ec3_=function(a){var b=shaka.util.Mp4Generator,c=b.box("dec3",a.audioConfig),d="ec-3",e=new Uint8Array([]);b.isStreamEncrypted_(a.stream)&&(e=this.sinf(a.stream,a.codecs),d="enca");return b.box(d,this.audioStsd_(a),c,e)};
shaka.util.Mp4Generator.prototype.opus_=function(a){var b=shaka.util.Mp4Generator,c=b.box("dOps",a.audioConfig),d="Opus",e=new Uint8Array([]);b.isStreamEncrypted_(a.stream)&&(e=this.sinf(a.stream,a.codecs),d="enca");return b.box(d,this.audioStsd_(a),c,e)};
shaka.util.Mp4Generator.prototype.mp4a_=function(a){var b=shaka.util.Mp4Generator;var c=a.audioConfig.byteLength>0?b.box("esds",a.audioConfig):b.box("esds",this.esds_(a));var d="mp4a",e=new Uint8Array([]);b.isStreamEncrypted_(a.stream)&&(e=this.sinf(a.stream,a.codecs),d="enca");return b.box(d,this.audioStsd_(a),c,e)};
shaka.util.Mp4Generator.prototype.esds_=function(a){var b=a.id+1,c=a.stream.channelsCount||2,d=a.stream.audioSamplingRate||44100,e=shaka.util.ManifestParserUtils.guessCodecs(shaka.util.ManifestParserUtils.ContentType.AUDIO,a.codecs.split(",")),f={96E3:0,88200:1,64E3:2,48E3:3,44100:4,32E3:5,24E3:6,22050:7,16E3:8,12E3:9,11025:10,8E3:11,7350:12};a=f[d];if(e==="mp4a.40.5"||e==="mp4a.40.29")a=f[d*2];d=parseInt(e.split(".").pop(),10);return new Uint8Array([0,0,0,0,3,25].concat((0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(b,
2)),[0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2,d<<3|a>>>1,a<<7|c<<3,6,1,2]))};shaka.util.Mp4Generator.prototype.mvex_=function(){for(var a=shaka.util.Mp4Generator,b=[],c=(0,$jscomp.makeIterator)(this.streamInfos_),d=c.next();!d.done;d=c.next())b.push(this.trex_(d.value));return a.box.apply(a,["mvex"].concat((0,$jscomp.arrayFromIterable)(b)))};
shaka.util.Mp4Generator.prototype.trex_=function(a){var b=shaka.util.Mp4Generator;a=new Uint8Array([0,0,0,0].concat((0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(a.id+1,4)),[0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0]));return b.box("trex",a)};
shaka.util.Mp4Generator.prototype.psshs=function(a){var b=[];if(!shaka.util.Mp4Generator.isStreamEncrypted_(a))return new Uint8Array([]);a=(0,$jscomp.makeIterator)(a.drmInfos);for(var c=a.next();!c.done;c=a.next())if(c=c.value,c.initData){c=(0,$jscomp.makeIterator)(c.initData);for(var d=c.next();!d.done;d=c.next())b.push(d.value.initData)}return shaka.util.Uint8ArrayUtils.concat.apply(shaka.util.Uint8ArrayUtils,(0,$jscomp.arrayFromIterable)(b))};
shaka.util.Mp4Generator.prototype.sinf=function(a,b){return shaka.util.Mp4Generator.box("sinf",this.frma_(b),this.schm_(a),this.schi_(a))};shaka.util.Mp4Generator.prototype.frma_=function(a){var b=a.split(".")[0];a=shaka.util.Mp4Generator;b=this.stringToCharCode_(b);b=new Uint8Array([].concat((0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(b,4))));return a.box("frma",b)};
shaka.util.Mp4Generator.prototype.schm_=function(a){var b="cenc";(a=a.drmInfos[0])&&a.encryptionScheme&&(b=a.encryptionScheme);a=shaka.util.Mp4Generator;b=this.stringToCharCode_(b);b=new Uint8Array([0,0,0,0].concat((0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(b,4)),[0,1,0,0]));return a.box("schm",b)};shaka.util.Mp4Generator.prototype.schi_=function(a){return shaka.util.Mp4Generator.box("schi",this.tenc_(a))};
shaka.util.Mp4Generator.prototype.tenc_=function(a){var b=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);a=(0,$jscomp.makeIterator)(a.drmInfos);for(var c=a.next();!c.done;c=a.next())if((c=c.value)&&c.keyIds&&c.keyIds.size){c=(0,$jscomp.makeIterator)(c.keyIds);for(var d=c.next();!d.done;d=c.next())b=this.hexStringToBuffer_(d.value)}a=shaka.util.Mp4Generator;c=new Uint8Array([0,0,0,0,0,0,1,8]);goog.asserts.assert(b,"Default KID should be non-null");return a.box("tenc",c,b)};
shaka.util.Mp4Generator.prototype.segmentData=function(){for(var a=[],b=(0,$jscomp.makeIterator)(this.streamInfos_),c=b.next();!c.done;c=b.next())c=c.value,a.push(this.moof_(c),this.mdat_(c));return shaka.util.Uint8ArrayUtils.concat.apply(shaka.util.Uint8ArrayUtils,(0,$jscomp.arrayFromIterable)(a))};shaka.util.Mp4Generator.prototype.moof_=function(a){return shaka.util.Mp4Generator.box("moof",this.mfhd_(a),this.traf_(a))};
shaka.util.Mp4Generator.prototype.mfhd_=function(a){var b=shaka.util.Mp4Generator;a=new Uint8Array([0,0,0,0].concat((0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(a.data?a.data.sequenceNumber:0,4))));return b.box("mfhd",a)};shaka.util.Mp4Generator.prototype.traf_=function(a){var b=shaka.util.Mp4Generator,c=this.sdtp_(a),d=c.length+32+20+8+16+8+8;return b.box("traf",this.tfhd_(a),this.tfdt_(a),this.trun_(a,d),c)};
shaka.util.Mp4Generator.prototype.sdtp_=function(a){var b=shaka.util.Mp4Generator;a=a.data?a.data.samples:[];for(var c=new Uint8Array(4+a.length),d=0;d<a.length;d++){var e=a[d].flags;c[d+4]=e.dependsOn<<4|e.isDependedOn<<2|e.hasRedundancy}return b.box("sdtp",c)};
shaka.util.Mp4Generator.prototype.tfhd_=function(a){var b=shaka.util.Mp4Generator;a=new Uint8Array([0,0,0,58].concat((0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(a.id+1,4)),[0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0]));return b.box("tfhd",a)};
shaka.util.Mp4Generator.prototype.tfdt_=function(a){var b=shaka.util.Mp4Generator;a=a.data?a.data.baseMediaDecodeTime:0;var c=Math.floor(a%(b.UINT32_MAX_+1));a=new Uint8Array([1,0,0,0].concat((0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(Math.floor(a/(b.UINT32_MAX_+1)),4)),(0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(c,4))));return b.box("tfdt",a)};
shaka.util.Mp4Generator.prototype.trun_=function(a,b){var c=shaka.util.ManifestParserUtils.ContentType,d=shaka.util.Mp4Generator,e=a.data?a.data.samples:[],f=e.length,g=12+16*f,h=new Uint8Array(g);b+=8+g;h.set([a.type===c.VIDEO?1:0,0,15,1].concat((0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(f,4)),(0,$jscomp.arrayFromIterable)(this.breakNumberIntoBytes_(b,4))),0);for(a=0;a<f;a++){var k=e[a];b=this.breakNumberIntoBytes_(k.duration,4);c=this.breakNumberIntoBytes_(k.size,4);g=k.flags;k=this.breakNumberIntoBytes_(k.cts,
4);h.set([].concat((0,$jscomp.arrayFromIterable)(b),(0,$jscomp.arrayFromIterable)(c),[g.isLeading<<2|g.dependsOn,g.isDependedOn<<6|g.hasRedundancy<<4|g.isNonSync,g.degradPrio&61440,g.degradPrio&15],(0,$jscomp.arrayFromIterable)(k)),12+16*a)}return d.box("trun",h)};shaka.util.Mp4Generator.prototype.mdat_=function(a){var b=shaka.util.Mp4Generator;a=(a.data?a.data.samples:[]).map(function(c){return c.data});return b.box.apply(b,["mdat"].concat((0,$jscomp.arrayFromIterable)(a)))};
shaka.util.Mp4Generator.prototype.breakNumberIntoBytes_=function(a,b){var c=[];for(--b;b>=0;b--)c.push(a>>8*b&255);return c};shaka.util.Mp4Generator.prototype.hexStringToBuffer_=function(a){for(var b=new Uint8Array(a.length/2),c=0;c<a.length/2;c+=1)b[c]=parseInt(String(a[c*2]+a[c*2+1]),16);return b};shaka.util.Mp4Generator.prototype.stringToCharCode_=function(a){for(var b=0,c=0;c<a.length;c+=1)b|=a.charCodeAt(c)<<(a.length-c-1)*8;return b};
shaka.util.Mp4Generator.box=function(a){var b=$jscomp.getRestArguments.apply(1,arguments),c=shaka.util.Mp4Generator.BOX_TYPES_.get(a);c||(c=[a.charCodeAt(0),a.charCodeAt(1),a.charCodeAt(2),a.charCodeAt(3)],shaka.util.Mp4Generator.BOX_TYPES_.set(a,c));for(var d=8,e=b.length-1;e>=0;e--)d+=b[e].byteLength;e=new Uint8Array(d);e[0]=d>>24&255;e[1]=d>>16&255;e[2]=d>>8&255;e[3]=d&255;e.set(c,4);c=0;for(d=8;c<b.length;c++)e.set(b[c],d),d+=b[c].byteLength;return e};
shaka.util.Mp4Generator.isStreamEncrypted_=function(a){return a.encrypted&&a.drmInfos.length>0};shaka.util.Mp4Generator.UINT32_MAX_=4294967295;shaka.util.Mp4Generator.BOX_TYPES_=new Map;
shaka.util.Mp4Generator.HDLR_TYPES_={video:new shaka.util.Lazy(function(){return new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0])}),audio:new shaka.util.Lazy(function(){return new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0])})};shaka.util.Mp4Generator.STTS_=new shaka.util.Lazy(function(){return new Uint8Array([0,0,0,0,0,0,0,0])});
shaka.util.Mp4Generator.STSC_=new shaka.util.Lazy(function(){return new Uint8Array([0,0,0,0,0,0,0,0])});shaka.util.Mp4Generator.STCO_=new shaka.util.Lazy(function(){return new Uint8Array([0,0,0,0,0,0,0,0])});shaka.util.Mp4Generator.STSZ_=new shaka.util.Lazy(function(){return new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0])});shaka.util.Mp4Generator.VMHD_=new shaka.util.Lazy(function(){return new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])});
shaka.util.Mp4Generator.SMHD_=new shaka.util.Lazy(function(){return new Uint8Array([0,0,0,0,0,0,0,0])});shaka.util.Mp4Generator.STSD_=new shaka.util.Lazy(function(){return new Uint8Array([0,0,0,0,0,0,0,1])});shaka.util.Mp4Generator.FTYP_=new shaka.util.Lazy(function(){var a=new Uint8Array([105,115,111,109]),b=new Uint8Array([97,118,99,49]),c=new Uint8Array([0,0,0,1]);return shaka.util.Mp4Generator.box("ftyp",a,c,a,b)});
shaka.util.Mp4Generator.DINF_=new shaka.util.Lazy(function(){var a=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]);a=shaka.util.Mp4Generator.box("dref",a);return shaka.util.Mp4Generator.box("dinf",a)});shaka.media.ContentWorkarounds=function(){};
shaka.media.ContentWorkarounds.correctEnca=function(a){a=shaka.util.BufferUtils.toUint8(a);var b=null;(new shaka.util.Mp4Parser).boxes(["moov","trak","mdia","minf","stbl"],shaka.util.Mp4Parser.children).fullBox("stsd",shaka.util.Mp4Parser.sampleDescription).box("enca",function(c){b=c.reader.getDataView();return shaka.util.Mp4Parser.audioSampleEntry(c)}).box("sinf",shaka.util.Mp4Parser.children).box("frma",function(c){c.parser.stop();shaka.util.Mp4BoxParsers.parseFRMA(c.reader).codec==="ec-3"&&b&&
b.getUint16(16)!==2&&b.setUint16(16,2)}).parse(a);return a};
shaka.media.ContentWorkarounds.fakeEncryption=function(a,b,c){var d=shaka.media.ContentWorkarounds,e=b=shaka.util.BufferUtils.toUint8(b),f=!1,g,h=[],k=[];(new shaka.util.Mp4Parser).boxes(["moov","trak","mdia","minf","stbl"],function(n){h.push(n);shaka.util.Mp4Parser.children(n)}).fullBox("stsd",function(n){g=n;h.push(n);shaka.util.Mp4Parser.sampleDescription(n)}).boxes(["encv","enca"],function(n){f=!0;n.parser.stop()}).boxes("dvav dva1 dvh1 dvhe dvc1 dvi1 hev1 hvc1 avc1 avc3".split(" "),function(n){k.push({box:n,
newType:d.BOX_TYPE_ENCV_})}).boxes("ac-3 ec-3 ac-4 Opus fLaC mp4a".split(" "),function(n){k.push({box:n,newType:d.BOX_TYPE_ENCA_})}).parse(b);if(f)return shaka.log.debug("Init segment already indicates encryption."),b;if(k.length==0||!g)throw shaka.log.error("Failed to find boxes needed to fake encryption!"),shaka.log.v2("Failed init segment (hex):",shaka.util.Uint8ArrayUtils.toHex(b)),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.CONTENT_TRANSFORMATION_FAILED,
c);k.reverse();c=(0,$jscomp.makeIterator)(k);for(var l=c.next();!l.done;l=c.next()){l=l.value;var m=shaka.util.Mp4Parser.typeToString(l.newType);shaka.log.debug('Inserting "'+m+'" box into init segment.');e=d.insertEncryptionMetadata_(a,e,g,l.box,h,l.newType)}e=d.insertPsshBoxes_(a,e);return shaka.device.DeviceFactory.getDevice().requiresClearAndEncryptedInitSegments()?(a=new Uint8Array(b.byteLength+e.byteLength),a.set(e),a.set(b,e.byteLength),a):e};
shaka.media.ContentWorkarounds.fakeMediaEncryption=function(a){a=shaka.util.BufferUtils.toUint8(a);var b=[];(new shaka.util.Mp4Parser).box("mdat",function(g){b.push(g)}).parse(a);for(var c=[],d=0;d<b.length;d++){var e=b[d-1],f=b[d];e=a.subarray(e?e.start+e.size:0,f.start+f.size);c.push(shaka.media.ContentWorkarounds.fakeMediaEncryptionInChunk_(e))}return shaka.util.Uint8ArrayUtils.concat.apply(shaka.util.Uint8ArrayUtils,(0,$jscomp.arrayFromIterable)(c))};
shaka.media.ContentWorkarounds.fakeMediaEncryptionInChunk_=function(a){var b,c,d,e,f=[];(new shaka.util.Mp4Parser).boxes(["moof","traf"],function(m){f.push(m);shaka.util.Mp4Parser.children(m)}).fullBox("tfhd",function(m){b=m;d=shaka.util.Mp4BoxParsers.parseTFHD(m.reader,m.flags)}).fullBox("trun",function(m){c=m;e=shaka.util.Mp4BoxParsers.parseTRUN(m.reader,m.version,m.flags)}).parse(a);if(d&&d.sampleDescriptionIndex!==2){var g=b.start+shaka.util.Mp4Parser.headerSize(b)+4+(d.baseDataOffset!==null?
8:0),h=shaka.util.BufferUtils.toDataView(a);if(d.sampleDescriptionIndex!==null)h.setUint32(g,2);else{shaka.media.ContentWorkarounds.updateBoxSize_(a,b.start,b.size+4);var k=h.getUint32(b.start+8);h.setUint32(b.start+8,k|2);if(e&&e.dataOffset!==null){k=e.dataOffset+4;var l=c.start+shaka.util.Mp4Parser.headerSize(c)+4;h.setInt32(l,k)}k=a.subarray(0,g);h=a.subarray(g);a=new Uint8Array(a.byteLength+4);a.set(k);k=[];for(l=3;l>=0;l--)k.push(2>>8*l&255);a.set(new Uint8Array(k),g);a.set(h,g+4);g=(0,$jscomp.makeIterator)(f);
for(h=g.next();!h.done;h=g.next())h=h.value,shaka.media.ContentWorkarounds.updateBoxSize_(a,h.start,h.size+4)}}return a};
shaka.media.ContentWorkarounds.insertEncryptionMetadata_=function(a,b,c,d,e,f){var g=shaka.media.ContentWorkarounds;f=g.createEncryptionMetadata_(a,b,d,f);a=new Uint8Array(b.byteLength+f.byteLength);d=shaka.device.DeviceFactory.getDevice().insertEncryptionDataBeforeClear()?d.start:d.start+d.size;var h=b.subarray(0,d);b=b.subarray(d);a.set(h);a.set(f,d);a.set(b,d+f.byteLength);e=(0,$jscomp.makeIterator)(e);for(b=e.next();!b.done;b=e.next())b=b.value,goog.asserts.assert(b.start<d,"Ancestor MP4 box found in the wrong location!  Modified init segment will not make sense!"),
g.updateBoxSize_(a,b.start,b.size+f.byteLength);g=shaka.util.BufferUtils.toDataView(a,c.start);c=shaka.util.Mp4Parser.headerSize(c);f=g.getUint32(c);g.setUint32(c,f+1);return a};
shaka.media.ContentWorkarounds.createEncryptionMetadata_=function(a,b,c,d){var e=shaka.media.ContentWorkarounds;a=(new shaka.util.Mp4Generator).sinf(a,c.name);b=b.subarray(c.start,c.start+c.size);var f=new Uint8Array(c.size+a.byteLength);f.set(b,0);shaka.util.BufferUtils.toDataView(f).setUint32(e.BOX_TYPE_OFFSET_,d);f.set(a,c.size);e.updateBoxSize_(f,0,f.byteLength);return f};
shaka.media.ContentWorkarounds.insertPsshBoxes_=function(a,b){a=(new shaka.util.Mp4Generator).psshs(a);if(a.byteLength===0)return b;var c=0,d=0;(new shaka.util.Mp4Parser).box("moov",function(h){c=h.start;d=h.size;h.parser.stop()}).parse(b);var e=c+d;shaka.media.ContentWorkarounds.updateBoxSize_(b,c,d+a.byteLength);var f=new Uint8Array(b.byteLength+a.byteLength),g=b.subarray(0,e);b=b.subarray(e);f.set(g);f.set(a,e);f.set(b,e+a.byteLength);return f};
shaka.media.ContentWorkarounds.updateBoxSize_=function(a,b,c){var d=shaka.media.ContentWorkarounds;a=shaka.util.BufferUtils.toDataView(a,b);b=a.getUint32(d.BOX_SIZE_OFFSET_);b!=0&&(b==1?(a.setUint32(d.BOX_SIZE_64_OFFSET_,c>>32),a.setUint32(d.BOX_SIZE_64_OFFSET_+4,c&4294967295)):a.setUint32(d.BOX_SIZE_OFFSET_,c))};
shaka.media.ContentWorkarounds.fakeEC3=function(a){var b=shaka.media.ContentWorkarounds,c=shaka.util.BufferUtils.toUint8(a),d=[];(new shaka.util.Mp4Parser).boxes(["moov","trak","mdia","minf","stbl"],function(e){d.push({start:e.start,size:e.size});shaka.util.Mp4Parser.children(e)}).box("stsd",function(e){d.push({start:e.start,size:e.size});for(var f=shaka.util.BufferUtils.toDataView(c,e.start),g=0;g<e.size-3;g++){var h=f.getUint32(g);h==b.BOX_TYPE_AC_3_?f.setUint32(g,b.BOX_TYPE_EC_3_):h==b.BOX_TYPE_DAC3_&&
f.setUint32(g,b.BOX_TYPE_DEC3_)}}).parse(c);return c};shaka.media.ContentWorkarounds.BOX_SIZE_OFFSET_=0;shaka.media.ContentWorkarounds.BOX_TYPE_OFFSET_=4;shaka.media.ContentWorkarounds.BOX_SIZE_64_OFFSET_=8;shaka.media.ContentWorkarounds.BOX_TYPE_ENCV_=1701733238;shaka.media.ContentWorkarounds.BOX_TYPE_ENCA_=1701733217;shaka.media.ContentWorkarounds.BOX_TYPE_AC_3_=1633889587;shaka.media.ContentWorkarounds.BOX_TYPE_DAC3_=1684103987;shaka.media.ContentWorkarounds.BOX_TYPE_EC_3_=1700998451;
shaka.media.ContentWorkarounds.BOX_TYPE_DEC3_=1684366131;shaka.media.TimeRangesUtils=function(){};shaka.media.TimeRangesUtils.isBufferNegligible_=function(a){return a.length==1&&a.end(0)-a.start(0)<1E-4};shaka.media.TimeRangesUtils.bufferStart=function(a){return!a||shaka.media.TimeRangesUtils.isBufferNegligible_(a)?null:a.length==1&&a.start(0)<0?0:a.length?a.start(0):null};shaka.media.TimeRangesUtils.bufferEnd=function(a){return!a||shaka.media.TimeRangesUtils.isBufferNegligible_(a)?null:a.length?a.end(a.length-1):null};
shaka.media.TimeRangesUtils.isBuffered=function(a,b){return!a||!a.length||shaka.media.TimeRangesUtils.isBufferNegligible_(a)||b>a.end(a.length-1)?!1:b>=a.start(0)};shaka.media.TimeRangesUtils.bufferedAheadOf=function(a,b){if(!a||!a.length||shaka.media.TimeRangesUtils.isBufferNegligible_(a))return 0;var c=0;a=(0,$jscomp.makeIterator)(shaka.media.TimeRangesUtils.getBufferedInfo(a));for(var d=a.next();!d.done;d=a.next()){var e=d.value;d=e.start;e=e.end;e>b&&(c+=e-Math.max(d,b))}return c};
shaka.media.TimeRangesUtils.getGapIndex=function(a,b,c){var d=shaka.media.TimeRangesUtils;if(!a||!a.length||shaka.media.TimeRangesUtils.isBufferNegligible_(a))return null;a=d.getBufferedInfo(a).findIndex(function(e,f,g){return e.start>b&&(f==0||g[f-1].end-b<=c)});return a>=0?a:null};shaka.media.TimeRangesUtils.getBufferedInfo=function(a){if(!a)return[];for(var b=[],c=0;c<a.length;c++)b.push({start:a.start(c),end:a.end(c)});return b};
shaka.media.TimeRangesUtils.computeAddedRange=function(a,b){var c=shaka.media.TimeRangesUtils;if(!a||!a.length)return null;if(!b||!b.length)return c.getBufferedInfo(b).pop();b=c.getBufferedInfo(b).reverse();a=c.getBufferedInfo(a).reverse();c=(0,$jscomp.makeIterator)(b);for(b=c.next();!b.done;b=c.next()){b=b.value;for(var d=!1,e=(0,$jscomp.makeIterator)(a),f=e.next();!f.done;f=e.next())if(f=f.value,f.end>=b.start&&f.end<=b.end&&(d=!0,b.end>f.end))return{start:f.end,end:b.end};if(!d)return b}return null};shaka.media.GapJumpingController=function(a,b,c,d){var e=this;this.onEvent_=d;this.video_=a;this.timeline_=b;this.config_=c;this.eventManager_=new shaka.util.EventManager;this.seekingEventReceived_=this.started_=!1;this.startTime_=0;this.isJumpingGap_=!1;this.stallsDetected_=this.gapsJumped_=0;this.stallDetector_=this.createStallDetector_();this.hadSegmentAppended_=!1;this.eventManager_.listen(a,"waiting",function(){return e.onPollGapJump_()});this.gapJumpTimer_=(new shaka.util.Timer(function(){e.onPollGapJump_()})).tickEvery(this.config_.gapJumpTimerTime)};
shaka.media.GapJumpingController.prototype.release=function(){this.eventManager_&&(this.eventManager_.release(),this.eventManager_=null);this.gapJumpTimer_!=null&&(this.gapJumpTimer_.stop(),this.gapJumpTimer_=null);this.stallDetector_&&(this.stallDetector_.release(),this.stallDetector_=null);this.video_=this.timeline_=this.onEvent_=null};
shaka.media.GapJumpingController.prototype.onSegmentAppended=function(){this.hadSegmentAppended_=!0;this.gapJumpTimer_&&this.gapJumpTimer_.tickEvery(this.config_.gapJumpTimerTime);this.onPollGapJump_()};shaka.media.GapJumpingController.prototype.onStarted=function(a){this.video_.seeking&&!this.seekingEventReceived_&&(this.seekingEventReceived_=!0,this.startTime_=a);this.gapJumpTimer_&&this.gapJumpTimer_.tickEvery(this.config_.gapJumpTimerTime);this.onPollGapJump_()};
shaka.media.GapJumpingController.prototype.onSeeking=function(){this.seekingEventReceived_=!0;this.hadSegmentAppended_=!1;this.gapJumpTimer_&&this.gapJumpTimer_.tickEvery(this.config_.gapJumpTimerTime);this.onPollGapJump_()};shaka.media.GapJumpingController.prototype.getGapsJumped=function(){return this.gapsJumped_};shaka.media.GapJumpingController.prototype.getStallsDetected=function(){return this.stallsDetected_};shaka.media.GapJumpingController.prototype.getIsJumpingGap=function(){return this.isJumpingGap_};
shaka.media.GapJumpingController.prototype.onPollGapJump_=function(){if(this.video_.readyState!=0){if(this.video_.seeking){if(!this.seekingEventReceived_)return}else this.seekingEventReceived_=!1;if(!this.video_.paused||this.video_.currentTime==this.startTime_&&(this.video_.autoplay||this.video_.currentTime!=this.startTime_))if(!this.stallDetector_||!this.stallDetector_.poll()){var a=this.video_.currentTime,b=this.video_.buffered,c=shaka.media.TimeRangesUtils.getGapIndex(b,a,this.config_.gapDetectionThreshold);
if(c==null&&this.stallDetector_&&!this.stallDetector_.poll())for(var d=shaka.media.TimeRangesUtils.getBufferedInfo(b),e=0;e<d.length-1;e++)if(Math.abs(a-d[e].end)<.1&&d[e+1].start>d[e].end){c=e+1;break}c==null||c==0&&!this.hadSegmentAppended_||(d=b.start(c),(e=this.config_.gapPadding)&&(d=Math.ceil((d+e)*100)/100),e=this.timeline_.getSeekRangeEnd(),d>=e||(e=d-a,e<shaka.media.GapJumpingController.BROWSER_GAP_TOLERANCE||(c==0?shaka.log.info("Jumping forward",e,"seconds because of gap before start time of",
d):shaka.log.info("Jumping forward",e,"seconds because of gap starting at",b.end(c-1),"and ending at",d),this.seek_(d),a==this.startTime_&&(this.startTime_=d),this.gapsJumped_++,this.onEvent_(new shaka.util.FakeEvent(shaka.util.FakeEvent.EventName.GapJumped)))))}}};shaka.media.GapJumpingController.prototype.seek_=function(a){var b=this;this.isJumpingGap_=!0;this.eventManager_.listenOnce(this.video_,"seeked",function(){b.isJumpingGap_=!1});this.video_.currentTime=a};
shaka.media.GapJumpingController.prototype.createStallDetector_=function(){var a=this;if(!this.config_.stallEnabled)return null;goog.asserts.assert(this.video_,"Must have video");var b=this.config_.stallThreshold,c=this.config_.stallSkip;return new shaka.media.StallDetector(new shaka.media.StallDetector.MediaElementImplementation(this.video_),b,function(d,e){var f;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(g){if(g.getNextAddressJsc()==1){goog.asserts.assert(a.video_,"Must have video");
f=shaka.media.TimeRangesUtils.getBufferedInfo(a.video_.buffered);if(!f.length)return g.return();shaka.log.debug("Stall detected at "+d+" for "+e+" seconds.");if(c)return shaka.log.debug("Seeking forward "+c+" seconds to break stall."),a.video_.currentTime+=c,g.jumpTo(2);shaka.log.debug("Wait for play to avoid reject a possible other play call.");return g.yield(a.video_.play(),3)}if(g.getNextAddressJsc()!=2){if(!a.video_)return g.return();shaka.log.debug("Pausing and unpausing to break stall.");a.video_.pause();
a.video_.play()}a.stallsDetected_++;a.onEvent_(new shaka.util.FakeEvent(shaka.util.FakeEvent.EventName.StallDetected));g.jumpToEnd()})})};shaka.media.GapJumpingController.BROWSER_GAP_TOLERANCE=.001;shaka.media.StallDetector=function(a,b,c){this.implementation_=a;this.wasMakingProgress_=a.shouldBeMakingProgress();this.value_=a.getPresentationSeconds();this.lastUpdateSeconds_=a.getWallSeconds();this.didJump_=!1;this.stallThresholdSeconds_=b;this.onStall_=c};
shaka.media.StallDetector.prototype.release=function(){this.implementation_&&this.implementation_.release();this.onStall_=this.implementation_=null};
shaka.media.StallDetector.prototype.poll=function(){var a=this.implementation_,b=a.shouldBeMakingProgress(),c=a.getPresentationSeconds(),d=a.getWallSeconds();if(this.value_!=c||this.wasMakingProgress_!=b)this.lastUpdateSeconds_=d,this.value_=c,this.wasMakingProgress_=b,this.didJump_=!1;c=d-this.lastUpdateSeconds_;if(b=c>=this.stallThresholdSeconds_&&b&&!this.didJump_){if(this.onStall_)this.onStall_(this.value_,c);this.didJump_=!0;this.value_=a.getPresentationSeconds()}return b};
shaka.media.StallDetector.Implementation=function(){};shaka.media.StallDetector.Implementation.prototype.shouldBeMakingProgress=function(){};shaka.media.StallDetector.Implementation.prototype.getPresentationSeconds=function(){};shaka.media.StallDetector.Implementation.prototype.getWallSeconds=function(){};shaka.media.StallDetector.Implementation.prototype.release=function(){};
shaka.media.StallDetector.MediaElementImplementation=function(a){var b=this;this.mediaElement_=a;this.audioEventManager_=new shaka.util.EventManager;this.audioFocusPaused_=!1;this.audioEventManager_.listen(this.mediaElement_,"audiofocuspaused",function(){shaka.log.info("Audio focus paused");b.audioFocusPaused_=!0});this.audioEventManager_.listen(this.mediaElement_,"audiofocusgranted",function(){shaka.log.info("Audio focus granted");b.audioFocusPaused_=!1});this.audioEventManager_.listen(this.mediaElement_,
"audiofocuslost",function(){shaka.log.info("Audio focus lost");b.audioFocusPaused_=!0})};shaka.media.StallDetector.MediaElementImplementation.prototype.shouldBeMakingProgress=function(){return this.mediaElement_.paused||this.mediaElement_.playbackRate==0||this.audioFocusPaused_||this.mediaElement_.buffered.length==0?!1:this.hasContentFor_(this.mediaElement_.buffered,this.mediaElement_.currentTime)};shaka.media.StallDetector.MediaElementImplementation.prototype.getPresentationSeconds=function(){return this.mediaElement_.currentTime};
shaka.media.StallDetector.MediaElementImplementation.prototype.getWallSeconds=function(){return Date.now()/1E3};shaka.media.StallDetector.MediaElementImplementation.prototype.hasContentFor_=function(a,b){a=(0,$jscomp.makeIterator)(shaka.media.TimeRangesUtils.getBufferedInfo(a));for(var c=a.next();!c.done;c=a.next())if(c=c.value,!(b<c.start-.1||b>c.end-.5))return!0;return!1};
shaka.media.StallDetector.MediaElementImplementation.prototype.release=function(){this.audioEventManager_&&this.audioEventManager_.release();this.audioEventManager_=null};shaka.media.ManifestFilterer=function(a,b,c){goog.asserts.assert(a,"Must have config");this.config_=a;this.maxHwRes_=b;this.drmEngine_=c};shaka.media.ManifestFilterer.prototype.setDrmEngine=function(a){this.drmEngine_=a};
shaka.media.ManifestFilterer.prototype.filterManifest=function(a){var b=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){if(c.getNextAddressJsc()==1)return goog.asserts.assert(a,"Manifest should exist!"),c.yield(shaka.util.StreamUtils.filterManifest(b.drmEngine_,a,b.config_.drm.preferredKeySystems,b.config_.drm.keySystemsMapping),2);b.config_.streaming.dontChooseCodecs||shaka.util.StreamUtils.chooseCodecsAndFilterManifest(a,b.config_.preferredVideoCodecs,b.config_.preferredAudioCodecs,
b.config_.preferredDecodingAttributes,b.config_.preferredTextFormats);b.checkPlayableVariants_(a);return c.return(b.filterManifestWithRestrictions(a))})};shaka.media.ManifestFilterer.prototype.applyRestrictions=function(a){return shaka.util.StreamUtils.applyRestrictions(a.variants,this.config_.restrictions,this.maxHwRes_)};
shaka.media.ManifestFilterer.prototype.filterManifestWithRestrictions=function(a){var b=this.applyRestrictions(a);if(a){var c=this.drmEngine_?this.drmEngine_.getDrmInfo():null;if(c&&this.drmEngine_.getMediaKeys()){for(var d=new Set,e=(0,$jscomp.makeIterator)(a.variants),f=e.next();!f.done;f=e.next())f=f.value,f.audio&&d.add(f.audio),f.video&&d.add(f.video);d=(0,$jscomp.makeIterator)(d);for(e=d.next();!e.done;e=d.next())this.processDrmInfos(c.keySystem,e.value)}this.checkRestrictedVariants(a)}return b};
shaka.media.ManifestFilterer.prototype.checkPlayableVariants_=function(a){if(!a.variants.some(shaka.util.StreamUtils.isPlayable))throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.CONTENT_UNSUPPORTED_BY_BROWSER);};
shaka.media.ManifestFilterer.prototype.processDrmInfos=function(a,b){b=(0,$jscomp.makeIterator)(b.drmInfos);for(var c=b.next();!c.done;c=b.next())if(c=c.value,c.keySystem==a){for(var d=(0,$jscomp.makeIterator)(c.initData||[]),e=d.next();!e.done;e=d.next())e=e.value,this.drmEngine_.newInitData(e.initDataType,e.initData);this.drmEngine_.updateCurrentDrmInfo(c)}};
shaka.media.ManifestFilterer.prototype.checkRestrictedVariants=function(a){var b=shaka.media.ManifestFilterer.restrictedStatuses,c=this.drmEngine_?this.drmEngine_.getKeyStatuses():{},d=Object.keys(c),e=d.length&&d[0]=="00";d=!1;var f=new Set,g=new Set,h=new WeakSet,k=function(m){if(m&&!h.has(m)&&(h.add(m),m.keyIds.size)){m=(0,$jscomp.makeIterator)(m.keyIds);for(var n=m.next();!n.done;n=m.next()){n=n.value;var p=c[e?"00":n];p?b.includes(p)&&g.add(p):f.add(n)}}};a=(0,$jscomp.makeIterator)(a.variants);
for(var l=a.next();!l.done;l=a.next()){l=l.value;if(!l.allowedByApplication)d=!0;else if(l.allowedByKeySystem)return;k(l.audio);k(l.video)}d={hasAppRestrictions:d,missingKeys:Array.from(f),restrictedKeyStatuses:Array.from(g)};throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.RESTRICTIONS_CANNOT_BE_MET,d);};shaka.media.ManifestFilterer.restrictedStatuses=["output-restricted","internal-error"];shaka.util.NumberUtils=function(){};shaka.util.NumberUtils.isFloatEqual=function(a,b,c){c=c===void 0?Number.EPSILON:c;if(a===b)return!0;a=Math.abs(a-b);return a<=c?!0:c!==Number.EPSILON?Math.abs(a-c)<=Number.EPSILON:!1};shaka.media.MediaSourceEngine=function(a,b,c,d,e){var f=this;this.video_=a;this.playerInterface_=c;this.config_=d;this.textDisplayer_=b;this.sourceBuffers_=new Map;this.sourceBufferTypes_=new Map;this.expectedEncryption_=new Map;this.textEngine_=null;this.segmentRelativeVttTiming_=!1;this.lcevcDec_=e||null;this.queues_=new Map;this.eventManager_=new shaka.util.EventManager;this.transmuxers_=new Map;this.captionParser_=null;this.mediaSourceOpen_=new shaka.util.PublicPromise;this.url_="";this.playbackHasBegun_=
!1;this.streamingAllowed_=!0;this.usingRemotePlayback_=!1;this.secondarySource_=this.source_=null;this.mediaSource_=this.createMediaSource(this.mediaSourceOpen_);this.playAfterReset_=this.reloadingMediaSource_=!1;this.destroyer_=new shaka.util.Destroyer(function(){return f.doDestroy_()});this.sequenceMode_=!1;this.manifestType_=shaka.media.ManifestParser.UNKNOWN;this.attemptTimestampOffsetCalculation_=this.ignoreManifestTimestampsInSegmentsMode_=!1;this.textSequenceModeOffset_=new shaka.util.PublicPromise;
this.needSplitMuxedContent_=!1;this.lastDuration_=null;this.tsParsers_=new Map;this.firstAudioReferenceStartTime_=this.firstAudioTimestamp_=this.firstVideoReferenceStartTime_=this.firstVideoTimestamp_=null;this.audioCompensation_=new shaka.util.PublicPromise;this.video_.remote&&(this.usingRemotePlayback_=this.video_.remote.state!="disconnected",this.eventManager_.listen(this.video_.remote,"connect",function(){f.usingRemotePlayback_=f.video_.remote.state!="disconnected"}),this.eventManager_.listen(this.video_.remote,
"connecting",function(){f.usingRemotePlayback_=f.video_.remote.state!="disconnected"}),this.eventManager_.listen(this.video_.remote,"disconnect",function(){f.usingRemotePlayback_=f.video_.remote.state!="disconnected"}))};
shaka.media.MediaSourceEngine.prototype.createMediaSource=function(a){var b=this;this.streamingAllowed_=!0;if(window.ManagedMediaSource){this.secondarySource_||(this.video_.disableRemotePlayback=!0);var c=new ManagedMediaSource;this.eventManager_.listen(c,"startstreaming",function(){shaka.log.info("MMS startstreaming");b.streamingAllowed_=!0});this.eventManager_.listen(c,"endstreaming",function(){shaka.log.info("MMS endstreaming");b.streamingAllowed_=!1})}else c=new MediaSource;this.eventManager_.listenOnce(c,
"sourceopen",function(){return b.onSourceOpen_(a)});this.eventManager_.listenOnce(this.video_,"playing",function(){b.playbackHasBegun_=!0});this.url_=shaka.media.MediaSourceEngine.createObjectURL(c);this.removeSources_();this.config_.useSourceElements?(this.source_=shaka.util.Dom.createSourceElement(this.url_),this.video_.appendChild(this.source_),this.secondarySource_&&this.video_.appendChild(this.secondarySource_),this.video_.load()):this.video_.src=this.url_;return c};
shaka.media.MediaSourceEngine.prototype.addSecondarySource=function(a,b){if(!this.video_||!window.ManagedMediaSource||!this.mediaSource_)shaka.log.warning("Secondary source is used only with ManagedMediaSource");else if(this.config_.useSourceElements){var c;((c=this.secondarySource_)==null?void 0:c.parentElement)===this.video_&&this.video_.removeChild(this.secondarySource_);this.secondarySource_=shaka.util.Dom.createSourceElement(a,b);this.video_.appendChild(this.secondarySource_);this.video_.disableRemotePlayback=
!1}};shaka.media.MediaSourceEngine.prototype.onSourceOpen_=function(a){goog.asserts.assert(this.url_,"Must have object URL");URL.revokeObjectURL(this.url_);a.resolve()};
shaka.media.MediaSourceEngine.probeSupport=function(){var a=shaka.util.MimeUtils,b='video/mp4; codecs="avc1.42E01E",video/mp4; codecs="avc3.42E01E",video/mp4; codecs="hev1.1.6.L93.90",video/mp4; codecs="hvc1.1.6.L93.90",video/mp4; codecs="hev1.2.4.L153.B0"; eotf="smpte2084",video/mp4; codecs="hvc1.2.4.L153.B0"; eotf="smpte2084",video/mp4; codecs="hvc1.2.20000000.L153.B0",video/mp4; codecs="hvc1.2.4.L120.b0",video/mp4; codecs="hvc1.2.4.L123.b0",video/mp4; codecs="vp9",video/mp4; codecs="vp09.00.10.08",video/mp4; codecs="av01.0.01M.08",video/mp4; codecs="av01.0.31M.10.0.111.09.16.09.0",video/mp4; codecs="av01.0.31M.10.0.112.09.18.09.0",video/mp4; codecs="dvh1.05.01",video/mp4; codecs="dvh1.08.01",video/mp4; codecs="dav1.10.01",video/mp4; codecs="dvh1.20.01",audio/mp4; codecs="mp4a.40.2",audio/mp4; codecs="ac-3",audio/mp4; codecs="ec-3",audio/mp4; codecs="ac-4.02.01.03",audio/mp4; codecs="opus",audio/mp4; codecs="flac",audio/mp4; codecs="dtsc",audio/mp4; codecs="dtse",audio/mp4; codecs="dtsx",audio/mp4; codecs="apac.31.00",video/webm; codecs="vp8",video/webm; codecs="vp9",video/webm; codecs="vp09.00.10.08",audio/webm; codecs="vorbis",audio/webm; codecs="opus",video/mp2t; codecs="avc1.42E01E",video/mp2t; codecs="avc3.42E01E",video/mp2t; codecs="hvc1.1.6.L93.90",video/mp2t; codecs="mp4a.40.2",video/mp2t; codecs="ac-3",video/mp2t; codecs="ec-3",text/vtt,application/mp4; codecs="wvtt",application/ttml+xml,application/mp4; codecs="stpp"'.split(",").concat((0,$jscomp.arrayFromIterable)(a.RAW_FORMATS)),c=
{},d=shaka.device.DeviceFactory.getDevice();b=(0,$jscomp.makeIterator)(b);for(var e=b.next();!e.done;e=b.next()){e=e.value;if(shaka.text.TextEngine.isTypeSupported(e))c[e]=!0;else if(d.supportsMediaSource()){var f=a.getBasicType(e),g=shaka.util.StreamUtils.getCorrectAudioCodecs(a.getCodecs(e),f);f=a.getFullType(f,g);c[e]=shaka.media.Capabilities.isTypeSupported(f)||shaka.transmuxer.TransmuxerEngine.isSupported(f)}else c[e]=d.supportsMediaType(e);f=e.split(";")[0];c[f]=c[f]||c[e]}return c};
shaka.media.MediaSourceEngine.prototype.destroy=function(){return this.destroyer_.destroy()};
shaka.media.MediaSourceEngine.prototype.doDestroy_=function(){var a=this,b,c,d,e,f,g,h,k,l,m,n,p,q,r,t,u,v,w,x,y,C,D;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(A){if(A.getNextAddressJsc()==1){b=shaka.util.Functional;c=[];d=(0,$jscomp.makeIterator)(a.queues_);for(e=d.next();!e.done;e=d.next())for(f=e.value,g=(0,$jscomp.makeIterator)(f),h=g.next().value,k=g.next().value,l=k[0],m=h,a.queues_.set(m,k.slice(0,1)),l&&c.push(l.p.catch(b.noop)),n=(0,$jscomp.makeIterator)(k.slice(1)),p=
n.next();!p.done;p=n.next())q=p.value,q.p.reject(shaka.util.Destroyer.destroyedError());a.textEngine_&&c.push(a.textEngine_.destroy());return A.yield(Promise.all(c),2)}r=(0,$jscomp.makeIterator)(a.transmuxers_.values());for(t=r.next();!t.done;t=r.next())u=t.value,u.destroy();a.eventManager_&&(a.eventManager_.release(),a.eventManager_=null);a.video_&&(a.removeSources_(),a.video_.load(),a.video_.disableRemotePlayback=!1);a.video_=null;a.source_=null;a.secondarySource_=null;a.config_=null;a.mediaSource_=
null;a.textEngine_=null;a.textDisplayer_=null;a.sourceBuffers_.clear();a.expectedEncryption_.clear();a.transmuxers_.clear();a.captionParser_=null;if(goog.DEBUG)for(v=(0,$jscomp.makeIterator)(a.queues_),w=v.next();!w.done;w=v.next())x=w.value,y=(0,$jscomp.makeIterator)(x),C=y.next().value,D=y.next().value,goog.asserts.assert(D.length==0,C+" queue should be empty after destroy!");a.queues_.clear();a.lcevcDec_=null;a.tsParsers_.clear();a.playerInterface_=null;A.jumpToEnd()})};
shaka.media.MediaSourceEngine.prototype.removeSources_=function(){if(this.video_){this.video_.removeAttribute("src");var a;((a=this.source_)==null?void 0:a.parentElement)===this.video_&&this.video_.removeChild(this.source_);var b;((b=this.secondarySource_)==null?void 0:b.parentElement)===this.video_&&this.video_.removeChild(this.secondarySource_)}};shaka.media.MediaSourceEngine.prototype.open=function(){return this.mediaSourceOpen_};
shaka.media.MediaSourceEngine.prototype.init=function(a,b,c,d){b=b===void 0?!1:b;c=c===void 0?shaka.media.ManifestParser.UNKNOWN:c;d=d===void 0?!1:d;var e=this,f,g,h,k,l,m;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(n){if(n.getNextAddressJsc()==1)return f=shaka.util.ManifestParserUtils.ContentType,n.yield(e.mediaSourceOpen_,2);if(n.getNextAddressJsc()!=3){if(!e.ended()&&!e.closed())return n.jumpTo(3);shaka.log.alwaysError("Expected MediaSource to be open during init(); reopening the media source.");
e.mediaSourceOpen_=new shaka.util.PublicPromise;e.mediaSource_=e.createMediaSource(e.mediaSourceOpen_);return n.yield(e.mediaSourceOpen_,3)}e.sequenceMode_=b;e.manifestType_=c;e.ignoreManifestTimestampsInSegmentsMode_=d;e.attemptTimestampOffsetCalculation_=!e.sequenceMode_&&e.manifestType_==shaka.media.ManifestParser.HLS&&!e.ignoreManifestTimestampsInSegmentsMode_;e.tsParsers_.clear();e.firstVideoTimestamp_=null;e.firstVideoReferenceStartTime_=null;e.firstAudioTimestamp_=null;e.firstAudioReferenceStartTime_=
null;e.audioCompensation_=new shaka.util.PublicPromise;g=(0,$jscomp.makeIterator)(a.keys());for(h=g.next();!h.done;h=g.next())k=h.value,l=a.get(k),e.initSourceBuffer_(k,l,l.codecs),e.needSplitMuxedContent_?(e.queues_.set(f.AUDIO,[]),e.queues_.set(f.VIDEO,[])):e.queues_.set(k,[]);(m=a.get(f.AUDIO))&&m.isAudioMuxedInVideo&&(e.needSplitMuxedContent_=!0);n.jumpToEnd()})};
shaka.media.MediaSourceEngine.prototype.initSourceBuffer_=function(a,b,c){var d=this,e=shaka.util.ManifestParserUtils.ContentType;a==e.AUDIO&&c&&(c=shaka.util.StreamUtils.getCorrectAudioCodecs(c,b.mimeType));a==e.VIDEO&&c&&b.mimeType=="video/mp4"&&(c=shaka.util.StreamUtils.getCorrectVideoCodecs(c));var f=shaka.util.MimeUtils.getFullType(b.mimeType,c);if(a==e.TEXT)this.reinitText(f,this.sequenceMode_,b.external);else{var g=this.config_.forceTransmux;if(!shaka.media.Capabilities.isTypeSupported(f)||
!this.sequenceMode_&&shaka.util.MimeUtils.RAW_FORMATS.includes(f))g=!0;var h=shaka.util.MimeUtils.getFullTypeWithAllCodecs(b.mimeType,c);if(g){g=shaka.util.ManifestParserUtils.guessCodecsSafe(e.AUDIO,(c||"").split(","));c=shaka.util.ManifestParserUtils.guessCodecsSafe(e.VIDEO,(c||"").split(","));if(g&&c){this.needSplitMuxedContent_=!0;this.initSourceBuffer_(e.AUDIO,b,g);this.initSourceBuffer_(e.VIDEO,b,c);return}if(e=shaka.transmuxer.TransmuxerEngine.findTransmuxer(h))f=e(),this.transmuxers_.set(a,
f),f=f.convertCodecs(a,h)}h=this.addExtraFeaturesToMimeType_(f);this.destroyer_.ensureNotDestroyed();try{var k=this.mediaSource_.addSourceBuffer(h)}catch(l){throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.MEDIA_SOURCE_OPERATION_THREW,l,"The mediaSource_ status was "+this.mediaSource_.readyState+" expected 'open'",null);}this.sequenceMode_&&(k.mode=shaka.media.MediaSourceEngine.SourceBufferMode_.SEQUENCE);this.eventManager_.listen(k,
"error",function(){return d.onError_(a)});this.eventManager_.listen(k,"updateend",function(){return d.onUpdateEnd_(a)});this.sourceBuffers_.set(a,k);this.sourceBufferTypes_.set(a,f);this.expectedEncryption_.set(a,!!b.drmInfos.length)}};shaka.media.MediaSourceEngine.prototype.configure=function(a){this.config_=a;this.textEngine_&&this.textEngine_.setModifyCueCallback(a.modifyCueCallback)};
shaka.media.MediaSourceEngine.prototype.isStreamingAllowed=function(){return this.streamingAllowed_&&!this.usingRemotePlayback_&&!this.reloadingMediaSource_};shaka.media.MediaSourceEngine.prototype.reinitText=function(a,b,c){this.textEngine_||(this.textEngine_=new shaka.text.TextEngine(this.textDisplayer_),this.textEngine_.setModifyCueCallback(this.config_.modifyCueCallback));this.textEngine_.initParser(a,b,c,this.segmentRelativeVttTiming_,this.manifestType_)};
shaka.media.MediaSourceEngine.prototype.ended=function(){return this.reloadingMediaSource_?!1:this.mediaSource_?this.mediaSource_.readyState=="ended":!0};shaka.media.MediaSourceEngine.prototype.closed=function(){return this.reloadingMediaSource_?!1:this.mediaSource_?this.mediaSource_.readyState=="closed":!0};
shaka.media.MediaSourceEngine.prototype.bufferStart=function(a){return this.sourceBuffers_.size?a==shaka.util.ManifestParserUtils.ContentType.TEXT?this.textEngine_.bufferStart():shaka.media.TimeRangesUtils.bufferStart(this.getBuffered_(a)):null};shaka.media.MediaSourceEngine.prototype.bufferEnd=function(a){return this.sourceBuffers_.size?a==shaka.util.ManifestParserUtils.ContentType.TEXT?this.textEngine_.bufferEnd():shaka.media.TimeRangesUtils.bufferEnd(this.getBuffered_(a)):null};
shaka.media.MediaSourceEngine.prototype.isBuffered=function(a,b){if(a==shaka.util.ManifestParserUtils.ContentType.TEXT)return this.textEngine_.isBuffered(b);a=this.getBuffered_(a);return shaka.media.TimeRangesUtils.isBuffered(a,b)};shaka.media.MediaSourceEngine.prototype.bufferedAheadOf=function(a,b){if(a==shaka.util.ManifestParserUtils.ContentType.TEXT)return this.textEngine_.bufferedAheadOf(b);a=this.getBuffered_(a);return shaka.media.TimeRangesUtils.bufferedAheadOf(a,b)};
shaka.media.MediaSourceEngine.prototype.getBufferedInfo=function(){var a=shaka.util.ManifestParserUtils.ContentType,b=shaka.media.TimeRangesUtils;a={total:this.reloadingMediaSource_?[]:b.getBufferedInfo(this.video_.buffered),audio:b.getBufferedInfo(this.getBuffered_(a.AUDIO)),video:b.getBufferedInfo(this.getBuffered_(a.VIDEO)),text:[]};if(this.textEngine_){b=this.textEngine_.bufferStart();var c=this.textEngine_.bufferEnd();b!=null&&c!=null&&a.text.push({start:b,end:c})}return a};
shaka.media.MediaSourceEngine.prototype.getBuffered_=function(a){if(this.reloadingMediaSource_||this.usingRemotePlayback_||this.closed())return null;try{return this.sourceBuffers_.get(a).buffered}catch(b){return this.sourceBuffers_.has(a)&&shaka.log.error("failed to get buffered range for "+a,b),null}};shaka.media.MediaSourceEngine.prototype.getCaptionParser=function(a){return new shaka.media.ClosedCaptionParser(a)};
shaka.media.MediaSourceEngine.prototype.getTimestampAndDispatchMetadata=function(a,b,c,d,e,f){var g=this;f=f===void 0?!1:f;var h=null,k=[],l=shaka.util.BufferUtils.toUint8(b);if(shaka.util.MimeUtils.RAW_FORMATS.includes(e))b=shaka.util.Id3Utils.getID3Frames(l),b.length&&c&&((f=b.find(function(t){return t.description==="com.apple.streaming.transportStreamTimestamp"}))&&typeof f.data=="number"&&(h=Math.round(f.data)/1E3),this.playerInterface_.onMetadata([{cueTime:c.startTime,data:l,frames:b,dts:c.startTime,
pts:c.startTime}],0,c.endTime));else if(e.includes("/mp4")&&c&&c.initSegmentReference){l=shaka.util.Mp4Parser;a=new l;var m=d.emsgSchemeIdUris!=null&&d.emsgSchemeIdUris.length>0||this.config_.dispatchAllEmsgBoxes,n=[];m&&a.fullBox("emsg",function(t){(t=g.parseEMSG_(c,d.emsgSchemeIdUris,t))&&n.push(t)});var p=c.initSegmentReference.timescale;e=p&&!isNaN(p);var q=0,r=!1;e&&a.fullBox("prft",function(t){goog.asserts.assert(typeof p=="number","Timescale should be a number!");g.parsePrft_(p,t)}).boxes(["moof",
"traf"],l.children).fullBox("tfdt",function(t){r||(goog.asserts.assert(t.version==0||t.version==1,"TFDT version can only be 0 or 1"),goog.asserts.assert(typeof p=="number","Timescale should be a number!"),q=shaka.util.Mp4BoxParsers.parseTFDTInaccurate(t.reader,t.version).baseMediaDecodeTime/p,r=!0,m||t.parser.stop())});(m||e)&&a.parse(b,!1,f);r&&c.timestampOffset==0&&(h=q);b=(0,$jscomp.makeIterator)(n);for(f=b.next();!f.done;f=b.next())this.dispatchEmsg_(f.value,c,h)}else e.includes("/mp4")||e.includes("/webm")||
!shaka.util.TsParser.probe(l)||(this.tsParsers_.has(a)||this.tsParsers_.set(a,new shaka.util.TsParser),k=this.tsParsers_.get(a),k.clearData(),k.setDiscontinuitySequence(c.discontinuitySequence),k.parse(l),b=k.getStartTime(a),b!=null&&(h=b),k=k.getMetadata());return{timestamp:h,metadata:k}};
shaka.media.MediaSourceEngine.prototype.parseEMSG_=function(a,b,c){if(c.version===0){var d=c.reader.readTerminatedString();var e=c.reader.readTerminatedString();var f=c.reader.readUint32();var g=c.reader.readUint32();var h=c.reader.readUint32();var k=c.reader.readUint32();var l=a.startTime+g/f}else f=c.reader.readUint32(),l=c.reader.readUint64()/f+a.timestampOffset,g=l-a.startTime,h=c.reader.readUint32(),k=c.reader.readUint32(),d=c.reader.readTerminatedString(),e=c.reader.readTerminatedString();a=
c.reader.readBytes(c.reader.getLength()-c.reader.getPosition(),!0);if(b&&b.includes(d)||this.config_.dispatchAllEmsgBoxes)if(d=="urn:mpeg:dash:event:2012")this.playerInterface_.onManifestUpdate();else{b=l;if(d!=="https://aomedia.org/emsg/ID3"||h!==4294967295)b+=h/f;return{startTime:l,endTime:b,schemeIdUri:d,value:e,timescale:f,presentationTimeDelta:g,eventDuration:h,id:k,messageData:a}}return null};
shaka.media.MediaSourceEngine.prototype.dispatchEmsg_=function(a,b,c){var d=shaka.util.NumberUtils.isFloatEqual(a.startTime,b.startTime+a.presentationTimeDelta/a.timescale);c&&this.manifestType_==shaka.media.ManifestParser.HLS&&!d&&(b=-c+b.startTime,a.startTime+=b,a.endTime+=b);this.playerInterface_.onEmsg(a);!a.messageData||a.schemeIdUri!="https://aomedia.org/emsg/ID3"&&a.schemeIdUri!="https://developer.apple.com/streaming/emsg-id3"||(b=shaka.util.Id3Utils.getID3Frames(a.messageData),b.length&&(c=
a.startTime,this.playerInterface_.onMetadata([{cueTime:c,data:a.messageData,frames:b,dts:c,pts:c}],0,a.endTime)))};
shaka.media.MediaSourceEngine.prototype.parsePrft_=function(a,b){goog.asserts.assert(b.version==0||b.version==1,"PRFT version can only be 0 or 1");b=shaka.util.Mp4BoxParsers.parsePRFTInaccurate(b.reader,b.version);var c=shaka.util.TimeUtils.convertNtp(b.ntpTimestamp);b={wallClockTime:c,programStartDate:new Date(c-b.mediaTime/a*1E3)};a=shaka.util.FakeEvent.EventName.Prft;b=(new Map).set("detail",b);a=new shaka.util.FakeEvent(a,b);this.playerInterface_.onEvent(a)};
shaka.media.MediaSourceEngine.prototype.appendBuffer=function(a,b,c,d,e,f,g,h,k,l){f=f===void 0?!1:f;g=g===void 0?!1:g;h=h===void 0?!1:h;k=k===void 0?!1:k;var m=this,n,p,q,r,t,u,v,w,x,y,C,D,A,z,B,E,H,N,F,I,L,G,M,J,O,P,Q;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(K){switch(K.getNextAddressJsc()){case 1:n=shaka.util.ManifestParserUtils.ContentType;if(a!=n.TEXT){K.jumpTo(2);break}if(m.manifestType_!=shaka.media.ManifestParser.HLS){K.jumpTo(3);break}return K.yield(m.textSequenceModeOffset_,
4);case 4:p=K.getYieldResultJsc(),m.textEngine_.setTimestampOffset(p);case 3:return K.yield(m.textEngine_.appendBuffer(b,c?c.startTime:null,c?c.endTime:null,c?c.getUris()[0]:null),5);case 5:return K.return();case 2:if(k||!m.needSplitMuxedContent_){K.jumpTo(6);break}return K.yield(m.appendBuffer(n.AUDIO,b,c,d,e,f,g,h,!0),7);case 7:return K.yield(m.appendBuffer(n.VIDEO,b,c,d,e,f,g,h,!0),8);case 8:return K.return();case 6:if(!m.sourceBuffers_.has(a))return shaka.log.warning("Attempted to restore a non-existent source buffer"),
K.return();q=m.sourceBuffers_.get(a).timestampOffset;r=m.sourceBufferTypes_.get(a);m.transmuxers_.has(a)&&(r=m.transmuxers_.get(a).getOriginalMimeType());if(c&&(t=m.getTimestampAndDispatchMetadata(a,b,c,d,r,h),u=t.timestamp,v=t.metadata,u!=null&&(m.firstVideoTimestamp_==null&&a==n.VIDEO&&(m.firstVideoTimestamp_=u,m.firstVideoReferenceStartTime_=c.startTime,m.firstAudioTimestamp_!=null&&(w=0,m.firstVideoReferenceStartTime_==m.firstAudioReferenceStartTime_&&(w=m.firstVideoTimestamp_-m.firstAudioTimestamp_),
m.audioCompensation_.resolve(w))),m.firstAudioTimestamp_==null&&a==n.AUDIO&&(m.firstAudioTimestamp_=u,m.firstAudioReferenceStartTime_=c.startTime,m.firstVideoTimestamp_!=null&&(x=0,m.firstVideoReferenceStartTime_==m.firstAudioReferenceStartTime_&&(x=m.firstVideoTimestamp_-m.firstAudioTimestamp_),m.audioCompensation_.resolve(x))),y=u,C=shaka.util.MimeUtils.RAW_FORMATS,!m.sequenceMode_&&C.includes(m.sourceBufferTypes_.get(a))&&(y=0),D=c.startTime-y,A=Math.abs(q-D),(A>=.001||f||g)&&(!h||D>0||!q)&&(q=
D,m.attemptTimestampOffsetCalculation_&&(m.enqueueOperation_(a,function(){return m.abort_(a)},null),m.enqueueOperation_(a,function(){return m.setTimestampOffset_(a,q)},null))),(z=a==n.VIDEO||!m.sourceBuffers_.has(n.VIDEO))&&m.textSequenceModeOffset_.resolve(q)),v.length))m.playerInterface_.onMetadata(v,q,c?c.endTime:null);e&&a==n.VIDEO&&(m.textEngine_||m.reinitText(shaka.util.MimeUtils.CEA608_CLOSED_CAPTION_MIMETYPE,m.sequenceMode_,!1),m.captionParser_||(B=r.split(";",1)[0],m.captionParser_=m.getCaptionParser(B)),
c?(E=m.captionParser_.parseFrom(b),E.length&&m.textEngine_.storeAndAppendClosedCaptions(E,q)):m.captionParser_.init(b,g,l));if(!m.transmuxers_.has(a)){K.jumpTo(9);break}return K.yield(m.transmuxers_.get(a).transmux(b,d,c,m.mediaSource_.duration,a),10);case 10:H=K.getYieldResultJsc(),ArrayBuffer.isView(H)?b=H:(N=H,N.init!=null&&(F=N.init,m.enqueueOperation_(a,function(){m.append_(a,F,q,d)},c?c.getUris()[0]:null)),b=N.data);case 9:b=m.workAroundBrokenPlatforms_(d,b,c,a);if(!c||!m.sequenceMode_||a==
n.TEXT){K.jumpTo(11);break}if(!f&&!g){K.jumpTo(11);break}I=c.startTime;if(m.manifestType_!=shaka.media.ManifestParser.HLS||m.needSplitMuxedContent_||a!=n.AUDIO||!m.sourceBuffers_.has(n.VIDEO)){K.jumpTo(13);break}return K.yield(m.audioCompensation_,14);case 14:L=K.getYieldResultJsc(),Math.abs(L)>.15&&(I-=L);case 13:m.enqueueOperation_(a,function(){return m.abort_(a)},null),m.enqueueOperation_(a,function(){return m.setTimestampOffset_(a,I)},null);case 11:return G=null,K.yield(m.enqueueOperation_(a,
function(){goog.DEBUG&&c&&!c.isPreload()&&!h&&(G=m.getBuffered_(a));m.append_(a,b,q,d)},c?c.getUris()[0]:null),15);case 15:goog.DEBUG&&c&&!c.isPreload()&&!h&&(M=m.getBuffered_(a),J=shaka.media.TimeRangesUtils.computeAddedRange(G,M))&&(O=c.endTime-c.startTime,P=J.end-J.start,Q=Math.abs(J.end-c.endTime),O>.1&&(Q>O/2||Math.abs(O-P)>.03)&&shaka.log.error("Possible encoding problem detected!","Unexpected buffered range for reference",c,"from URIs",c.getUris(),"should be",{start:c.startTime,end:c.endTime},
"but got",J)),K.jumpToEnd()}})};shaka.media.MediaSourceEngine.prototype.setSelectedClosedCaptionId=function(a){var b=this.bufferEnd(shaka.util.ManifestParserUtils.ContentType.VIDEO)||0;this.textEngine_.setSelectedClosedCaptionId(a,b)};shaka.media.MediaSourceEngine.prototype.clearSelectedClosedCaptionId=function(){this.textEngine_&&this.textEngine_.setSelectedClosedCaptionId("",0)};
shaka.media.MediaSourceEngine.prototype.remove=function(a,b,c,d){var e=this,f,g;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(h){return h.getNextAddressJsc()==1?(f=shaka.util.ManifestParserUtils.ContentType,a==f.VIDEO&&e.captionParser_&&(e.captionParser_.remove(d),g=e.textEngine_.bufferStart()||0,e.textEngine_.remove(g,c,!0)),a==f.TEXT?h.yield(e.textEngine_.remove(b,c),0):c>b?h.yield(e.enqueueOperation_(a,function(){return e.remove_(a,b,c)},null),5):h.jumpTo(0)):e.needSplitMuxedContent_?
h.yield(e.enqueueOperation_(f.AUDIO,function(){return e.remove_(f.AUDIO,b,c)},null),0):h.jumpTo(0)})};
shaka.media.MediaSourceEngine.prototype.clear=function(a){var b=this,c;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(d){return d.getNextAddressJsc()==1?(c=shaka.util.ManifestParserUtils.ContentType,a==c.TEXT?b.textEngine_?d.yield(b.textEngine_.remove(0,Infinity),0):d.return():a===c.VIDEO&&b.captionParser_&&b.textEngine_?d.yield(b.textEngine_.remove(0,Infinity,!0),4):d.jumpTo(4)):d.getNextAddressJsc()!=6?d.yield(b.enqueueOperation_(a,function(){return b.remove_(a,0,b.mediaSource_.duration)},
null),6):b.needSplitMuxedContent_?d.yield(b.enqueueOperation_(c.AUDIO,function(){return b.remove_(c.AUDIO,0,b.mediaSource_.duration)},null),0):d.jumpTo(0)})};shaka.media.MediaSourceEngine.prototype.resetCaptionParser=function(){this.captionParser_&&this.captionParser_.reset()};
shaka.media.MediaSourceEngine.prototype.flush=function(a){var b=this,c;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(d){return d.getNextAddressJsc()==1?(c=shaka.util.ManifestParserUtils.ContentType,a==c.TEXT?d.return():d.yield(b.enqueueOperation_(a,function(){return b.flush_(a)},null),2)):b.needSplitMuxedContent_?d.yield(b.enqueueOperation_(c.AUDIO,function(){return b.flush_(c.AUDIO)},null),0):d.jumpTo(0)})};
shaka.media.MediaSourceEngine.prototype.setStreamProperties=function(a,b,c,d,e,f,g,h){var k=this,l,m,n;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(p){if(p.getNextAddressJsc()==1){l=shaka.util.ManifestParserUtils.ContentType;if(a==l.TEXT)return e||k.textEngine_.setTimestampOffset(b),k.textEngine_.setAppendWindow(c,d),p.return();m=[];return p.yield(k.codecSwitchIfNecessary_(a,f,g,h),2)}n=p.getYieldResultJsc();n||(m.push(k.enqueueOperation_(a,function(){return k.abort_(a)},null)),
k.needSplitMuxedContent_&&m.push(k.enqueueOperation_(l.AUDIO,function(){return k.abort_(l.AUDIO)},null)));e||(m.push(k.enqueueOperation_(a,function(){return k.setTimestampOffset_(a,b)},null)),k.needSplitMuxedContent_&&m.push(k.enqueueOperation_(l.AUDIO,function(){return k.setTimestampOffset_(l.AUDIO,b)},null)));if(c!=0||d!=Infinity)m.push(k.enqueueOperation_(a,function(){return k.setAppendWindow_(a,c,d)},null)),k.needSplitMuxedContent_&&m.push(k.enqueueOperation_(l.AUDIO,function(){return k.setAppendWindow_(l.AUDIO,
c,d)},null));return m.length?p.yield(Promise.all(m),0):p.jumpTo(0)})};
shaka.media.MediaSourceEngine.prototype.resync=function(a,b){var c=this,d,e;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){if(f.getNextAddressJsc()==1){d=shaka.util.ManifestParserUtils.ContentType;if(a==d.TEXT)return f.return();a==d.VIDEO&&(c.textSequenceModeOffset_=new shaka.util.PublicPromise);if(!c.sequenceMode_||(e=c.bufferEnd(a))&&Math.abs(e-b)<.15)return f.return();c.enqueueOperation_(a,function(){return c.abort_(a)},null);c.needSplitMuxedContent_&&c.enqueueOperation_(d.AUDIO,
function(){return c.abort_(d.AUDIO)},null);return f.yield(c.enqueueOperation_(a,function(){return c.setTimestampOffset_(a,b)},null),2)}return c.needSplitMuxedContent_?f.yield(c.enqueueOperation_(d.AUDIO,function(){return c.setTimestampOffset_(d.AUDIO,b)},null),0):f.jumpTo(0)})};
shaka.media.MediaSourceEngine.prototype.endOfStream=function(a){var b=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){return c.yield(b.enqueueBlockingOperation_(function(){b.ended()||b.closed()||(a?b.mediaSource_.endOfStream(a):b.mediaSource_.endOfStream())}),0)})};
shaka.media.MediaSourceEngine.prototype.setDuration=function(a){var b=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){return c.yield(b.enqueueBlockingOperation_(function(){if(b.config_.durationReductionEmitsUpdateEnd&&a<b.mediaSource_.duration)for(var d=(0,$jscomp.makeIterator)(b.sourceBuffers_.keys()),e=d.next();!e.done;e=d.next()){e=e.value;var f={start:function(){},p:new shaka.util.PublicPromise,uri:null};b.queues_.get(e).unshift(f)}b.mediaSource_.duration=a;b.lastDuration_=
a}),0)})};shaka.media.MediaSourceEngine.prototype.getDuration=function(){return this.mediaSource_.duration};
shaka.media.MediaSourceEngine.prototype.setLiveSeekableRange=function(a,b){var c=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(d){if(c.destroyer_.destroyed()||c.video_.error||c.usingRemotePlayback_||c.reloadingMediaSource_)return d.return();goog.asserts.assert("setLiveSeekableRange"in c.mediaSource_,"Using setLiveSeekableRange on not supported platform");return c.ended()||c.closed()?d.return():d.yield(c.enqueueBlockingOperation_(function(){c.ended()||c.closed()||c.mediaSource_.setLiveSeekableRange(a,
b)}),0)})};
shaka.media.MediaSourceEngine.prototype.clearLiveSeekableRange=function(){var a=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(b){if(a.destroyer_.destroyed()||a.video_.error||a.usingRemotePlayback_||a.reloadingMediaSource_)return b.return();goog.asserts.assert("clearLiveSeekableRange"in a.mediaSource_,"Using clearLiveSeekableRange on not supported platform");return a.ended()||a.closed()?b.return():b.yield(a.enqueueBlockingOperation_(function(){a.ended()||a.closed()||a.mediaSource_.clearLiveSeekableRange()}),
0)})};shaka.media.MediaSourceEngine.prototype.appendDependency=function(a,b,c){this.lcevcDec_&&this.lcevcDec_.appendBuffer(a,b,c)};shaka.media.MediaSourceEngine.prototype.removeDependency=function(a,b,c){this.lcevcDec_&&this.lcevcDec_.removeBuffer(a,b,c)};shaka.media.MediaSourceEngine.prototype.append_=function(a,b,c,d){this.appendDependency(b,c,d);this.sourceBuffers_.get(a).appendBuffer(b)};
shaka.media.MediaSourceEngine.prototype.remove_=function(a,b,c){if(c<=b)this.onUpdateEnd_(a);else this.removeDependency(a,b,c),this.sourceBuffers_.get(a).remove(b,c)};shaka.media.MediaSourceEngine.prototype.abort_=function(a){var b=this.sourceBuffers_.get(a),c=b.appendWindowStart,d=b.appendWindowEnd;b.abort();b.appendWindowStart=c;b.appendWindowEnd=d;this.onUpdateEnd_(a)};
shaka.media.MediaSourceEngine.prototype.flush_=function(a){goog.asserts.assert(this.video_.buffered.length==0,"MediaSourceEngine.flush_ should only be used after clearing all data!");this.video_.currentTime-=.001;this.onUpdateEnd_(a)};shaka.media.MediaSourceEngine.prototype.setTimestampOffset_=function(a,b){b<0&&(b+=.001);this.sourceBuffers_.get(a).timestampOffset=b;this.onUpdateEnd_(a)};
shaka.media.MediaSourceEngine.prototype.setAppendWindow_=function(a,b,c){var d=this.sourceBuffers_.get(a);if(d.appendWindowEnd!==c||d.appendWindowStart!==b)d.appendWindowStart=0,d.appendWindowEnd=c,d.appendWindowStart=b;this.onUpdateEnd_(a)};
shaka.media.MediaSourceEngine.prototype.onError_=function(a){var b=this.queues_.get(a)[0];goog.asserts.assert(b,"Spurious error event!");goog.asserts.assert(!this.sourceBuffers_.get(a).updating,"SourceBuffer should not be updating on error!");b.p.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.MEDIA_SOURCE_OPERATION_FAILED,this.video_.error?this.video_.error.code:0,b.uri))};
shaka.media.MediaSourceEngine.prototype.onUpdateEnd_=function(a){if(this.reloadingMediaSource_||this.destroyer_.destroyed()){var b=this.queues_.get(a);b&&b.length&&((b=b[0])&&b.p&&b.p.resolve(),this.queues_.set(a,[]))}else b=this.queues_.get(a)[0],goog.asserts.assert(b,"Spurious updateend event!"),b&&(goog.asserts.assert(!this.sourceBuffers_.get(a).updating,"SourceBuffer should not be updating on updateend!"),b.p.resolve(),this.popFromQueue_(a))};
shaka.media.MediaSourceEngine.prototype.enqueueOperation_=function(a,b,c){this.destroyer_.ensureNotDestroyed();b={start:b,p:new shaka.util.PublicPromise,uri:c};this.queues_.get(a).push(b);this.queues_.get(a).length==1&&this.startOperation_(a);return b.p};
shaka.media.MediaSourceEngine.prototype.enqueueBlockingOperation_=function(a){var b=this,c,d,e,f,g,h,k,l,m,n,p,q,r,t,u,v,w,x,y,C,D;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(A){switch(A.getNextAddressJsc()){case 1:b.destroyer_.ensureNotDestroyed();c=[];d=Array.from(b.sourceBuffers_.keys());e=new Map;f=(0,$jscomp.makeIterator)(d);g=f.next();for(h={};!g.done;h={ready:void 0},g=f.next())k=g.value,h.ready=new shaka.util.PublicPromise,l={start:function(z){return function(){return z.ready.resolve()}}(h),
p:h.ready,uri:null},m=b.queues_.get(k),m.push(l),c.push(h.ready),e.set(k,l),m.length==1&&l.start();A.setCatchFinallyBlocks(2);return A.yield(Promise.all(c),4);case 4:A.leaveTryBlock(3);break;case 2:n=A.enterCatchBlock();if(b.destroyer_.destroyed()){p=(0,$jscomp.makeIterator)(d);for(q=p.next();!q.done;q=p.next())r=q.value,t=b.queues_.get(r),e.has(r)&&shaka.util.ArrayUtils.remove(t,e.get(r));return A.return()}throw n;case 3:if(goog.DEBUG)for(u=(0,$jscomp.makeIterator)(d),v=u.next();!v.done;v=u.next())w=
v.value,goog.asserts.assert(b.sourceBuffers_.get(w).updating==0,"SourceBuffers should not be updating after a blocking op!");A.setCatchFinallyBlocks(5,6);return A.yield(a(),6);case 6:A.enterFinallyBlock();x=(0,$jscomp.makeIterator)(d);for(y=x.next();!y.done;y=x.next())C=y.value,b.popFromQueue_(C);A.leaveFinallyBlock(0);break;case 5:throw D=A.enterCatchBlock(),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.MEDIA_SOURCE_OPERATION_THREW,
D,b.video_.error||"No error in the media element",null);}})};shaka.media.MediaSourceEngine.prototype.popFromQueue_=function(a){goog.asserts.assert(this.queues_.has(a),"Queue should exist");this.queues_.get(a).shift();this.startOperation_(a)};
shaka.media.MediaSourceEngine.prototype.startOperation_=function(a){var b=this.queues_.get(a)[0];if(b)try{b.start()}catch(c){c.name=="QuotaExceededError"?b.p.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.QUOTA_EXCEEDED_ERROR,a)):this.isStreamingAllowed()?b.p.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.MEDIA_SOURCE_OPERATION_THREW,c,this.video_.error||"No error in the media element",
b.uri)):b.p.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.STREAMING_NOT_ALLOWED,a)),this.popFromQueue_(a)}};shaka.media.MediaSourceEngine.prototype.getTextDisplayer=function(){goog.asserts.assert(this.textDisplayer_,"TextDisplayer should only be null when this is destroyed");return this.textDisplayer_};shaka.media.MediaSourceEngine.prototype.setTextDisplayer=function(a){this.textDisplayer_=a;this.textEngine_&&this.textEngine_.setDisplayer(a)};
shaka.media.MediaSourceEngine.prototype.setSegmentRelativeVttTiming=function(a){this.segmentRelativeVttTiming_=a};
shaka.media.MediaSourceEngine.prototype.workAroundBrokenPlatforms_=function(a,b,c,d){var e=shaka.util.ManifestParserUtils.ContentType;if(shaka.util.MimeUtils.getContainerType(this.sourceBufferTypes_.get(d))!="mp4")return b;var f=c===null,g=this.expectedEncryption_.get(d),h=this.playerInterface_.getKeySystem(),k=!1;c&&c.initSegmentReference&&(k=c.initSegmentReference.encrypted);c=c?c.getUris()[0]:null;var l=shaka.device.DeviceFactory.getDevice();this.config_.correctEc3Enca&&f&&d===e.AUDIO&&(b=shaka.media.ContentWorkarounds.correctEnca(b));
this.config_.insertFakeEncryptionInInit&&g&&l.requiresEncryptionInfoInAllInitSegments(h,d)&&(f?(shaka.log.debug("Forcing fake encryption information in init segment."),b=shaka.media.ContentWorkarounds.fakeEncryption(a,b,c)):!k&&l.requiresTfhdFix(d)&&(shaka.log.debug("Forcing fake encryption information in media segment."),b=shaka.media.ContentWorkarounds.fakeMediaEncryption(b)));f&&l.requiresEC3InitSegments()&&(shaka.log.debug("Forcing fake EC-3 information in init segment."),b=shaka.media.ContentWorkarounds.fakeEC3(b));
return b};
shaka.media.MediaSourceEngine.prototype.change_=function(a,b,c){if(a===shaka.util.ManifestParserUtils.ContentType.TEXT)shaka.log.debug("Change not supported for "+a);else{var d=this.sourceBufferTypes_.get(a);shaka.log.debug("Change Type: "+d+" -> "+b);shaka.device.DeviceFactory.getDevice().supportsSmoothCodecSwitching()?(this.transmuxers_.has(a)&&(this.transmuxers_.get(a).destroy(),this.transmuxers_.delete(a)),c&&this.transmuxers_.set(a,c),c=this.addExtraFeaturesToMimeType_(b),this.sourceBuffers_.get(a).changeType(c),this.sourceBufferTypes_.set(a,
b)):shaka.log.debug("Change Type not supported");this.onUpdateEnd_(a)}};shaka.media.MediaSourceEngine.prototype.changeType=function(a,b,c){var d=this;return this.enqueueOperation_(a,function(){return d.change_(a,b,c)},null)};
shaka.media.MediaSourceEngine.prototype.reset_=function(a){var b=this,c,d,e,f,g,h,k,l,m,n,p,q,r,t,u,v,w,x,y,C;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(D){if(D.getNextAddressJsc()==1){if(b.reloadingMediaSource_||b.usingRemotePlayback_)return D.return();c=shaka.util.ManifestParserUtils.ContentType;b.reloadingMediaSource_=!0;b.needSplitMuxedContent_=!1;d=b.video_.currentTime;e=b.video_.autoplay;b.video_.paused||(b.playAfterReset_=!0);b.playbackHasBegun_&&(b.video_.autoplay=!1);
D.setFinallyBlock(2);b.eventManager_.removeAll();f=(0,$jscomp.makeIterator)(b.transmuxers_.values());for(g=f.next();!g.done;g=f.next())h=g.value,h.destroy();k=(0,$jscomp.makeIterator)(b.sourceBuffers_.values());for(l=k.next();!l.done;l=k.next()){m=l.value;try{b.mediaSource_.removeSourceBuffer(m)}catch(A){shaka.log.debug("Exception on removeSourceBuffer",A)}}b.transmuxers_.clear();b.sourceBuffers_.clear();n=b.mediaSource_.duration;b.mediaSourceOpen_=new shaka.util.PublicPromise;b.mediaSource_=b.createMediaSource(b.mediaSourceOpen_);
return D.yield(b.mediaSourceOpen_,4)}if(D.getNextAddressJsc()!=2){!isNaN(n)&&n?b.mediaSource_.duration=n:!isNaN(b.lastDuration_)&&b.lastDuration_&&(b.mediaSource_.duration=b.lastDuration_);p=new shaka.util.PublicPromise;q=b.mediaSource_.sourceBuffers;r=a.size;t=0;u=function(){t++;t===r&&(p.resolve(),b.eventManager_.unlisten(q,"addsourcebuffer",u))};b.eventManager_.listen(q,"addsourcebuffer",u);v=(0,$jscomp.makeIterator)(a.keys());for(w=v.next();!w.done;w=v.next())x=w.value,y=a.get(x),b.initSourceBuffer_(x,
y,y.codecs);(C=a.get(c.AUDIO))&&C.isAudioMuxedInVideo&&(b.needSplitMuxedContent_=!0);b.needSplitMuxedContent_&&!b.queues_.has(c.AUDIO)&&b.queues_.set(c.AUDIO,[]);return D.yield(p,2)}D.enterFinallyBlock();b.reloadingMediaSource_=!1;b.destroyer_.ensureNotDestroyed();b.eventManager_.listenOnce(b.video_,shaka.util.MediaElementEvent.LOADED_METADATA,function(){b.destroyer_.destroyed()||(b.video_.currentTime=d)});b.eventManager_.listenOnce(b.video_,shaka.util.MediaElementEvent.CAN_PLAY_THROUGH,function(){b.destroyer_.destroyed()||
(b.video_.autoplay=e,b.playAfterReset_&&(b.playAfterReset_=!1,b.video_.play()))});return D.leaveFinallyBlock(0)})};shaka.media.MediaSourceEngine.prototype.reset=function(a){var b=this;return this.enqueueBlockingOperation_(function(){return b.reset_(a)})};
shaka.media.MediaSourceEngine.prototype.getRealInfo_=function(a,b,c){var d=shaka.util.ManifestParserUtils.ContentType,e=shaka.util.MimeUtils,f=!1,g=shaka.util.ManifestParserUtils.guessCodecsSafe(d.AUDIO,(c||"").split(",")),h=shaka.util.ManifestParserUtils.guessCodecsSafe(d.VIDEO,(c||"").split(",")),k=h;a==d.AUDIO&&(k=g);k||(k=c);var l=shaka.util.MimeUtils.getFullType(b,k),m=e.getBasicType(this.sourceBufferTypes_.get(a)),n=this.config_.forceTransmux;!shaka.media.Capabilities.isTypeSupported(l)||!this.sequenceMode_&&
shaka.util.MimeUtils.RAW_FORMATS.includes(l)?n=!0:n||b==m||(n=!shaka.device.DeviceFactory.getDevice().supportsContainerChangeType()&&shaka.util.MimeUtils.RAW_FORMATS.includes(b));m=shaka.transmuxer.TransmuxerEngine;if(n&&(k=shaka.util.MimeUtils.getFullTypeWithAllCodecs(b,k),n=m.findTransmuxer(k))){var p=n();g&&h&&(f=!0);l=p.convertCodecs(a,k)}!p&&a===d.VIDEO&&g&&(l=shaka.util.MimeUtils.getFullType(b,c));a=e.getNormalizedCodec(e.getCodecs(l));e=e.getBasicType(l);return{transmuxer:p,transmuxerMuxed:f,
basicType:e,codec:a,mimeType:l}};
shaka.media.MediaSourceEngine.prototype.getInfoAboutResetOrChangeType_=function(a,b,c,d){var e=shaka.util.ManifestParserUtils.ContentType;if(a==e.TEXT)return{type:shaka.media.MediaSourceEngine.ResetMode_.NONE,newMimeType:b,transmuxer:null};var f=shaka.util.MimeUtils,g=f.getNormalizedCodec(f.getCodecs(this.sourceBufferTypes_.get(a))),h=f.getBasicType(this.sourceBufferTypes_.get(a)),k=this.getRealInfo_(a,b,c),l=k.transmuxer,m=k.transmuxerMuxed,n=k.basicType,p=k.codec;k=k.mimeType;var q=!0;m&&this.sourceBufferTypes_.has(e.AUDIO)&&
(b=this.getRealInfo_(e.AUDIO,b,c),c=f.getNormalizedCodec(f.getCodecs(this.sourceBufferTypes_.get(e.AUDIO))),f=f.getBasicType(this.sourceBufferTypes_.get(e.AUDIO)),q=c==b.codec&&f==b.basicType,b.transmuxer&&b.transmuxer.destroy());if(g===p&&h===n&&q)return{type:shaka.media.MediaSourceEngine.ResetMode_.NONE,newMimeType:k,transmuxer:l};g=!0;if(this.needSplitMuxedContent_&&!d.has(e.AUDIO)||m&&l&&!this.transmuxers_.has(a))g=!1;a=shaka.device.DeviceFactory.getDevice();if(g&&this.config_.codecSwitchingStrategy===
shaka.config.CodecSwitchingStrategy.SMOOTH&&a.supportsSmoothCodecSwitching())return{type:shaka.media.MediaSourceEngine.ResetMode_.CHANGE_TYPE,newMimeType:k,transmuxer:l};l&&l.destroy();return{type:shaka.media.MediaSourceEngine.ResetMode_.RESET,newMimeType:k,transmuxer:null}};
shaka.media.MediaSourceEngine.prototype.codecSwitchIfNecessary_=function(a,b,c,d){var e=this,f,g,h,k,l,m;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(n){if(n.getNextAddressJsc()==1){f=shaka.util.ManifestParserUtils.ContentType;g=e.getInfoAboutResetOrChangeType_(a,b,c,d);h=g.type;k=g.transmuxer;l=g.newMimeType;if(m=d.get(f.AUDIO))e.needSplitMuxedContent_=m.isAudioMuxedInVideo;if(h==shaka.media.MediaSourceEngine.ResetMode_.NONE)return e.transmuxers_.has(a)&&!k?(e.transmuxers_.get(a).destroy(),
e.transmuxers_.delete(a)):!e.transmuxers_.has(a)&&k?e.transmuxers_.set(a,k):k&&(e.transmuxers_.has(a)&&e.transmuxers_.get(a).transmux!==k.transmux?(e.transmuxers_.get(a).destroy(),e.transmuxers_.set(a,k)):k.destroy()),n.return(!1);if(h==shaka.media.MediaSourceEngine.ResetMode_.CHANGE_TYPE)return n.yield(e.changeType(a,l,k),3);if(h!=shaka.media.MediaSourceEngine.ResetMode_.RESET)return n.jumpTo(3);k&&k.destroy();return n.yield(e.reset(d),3)}return n.return(!0)})};
shaka.media.MediaSourceEngine.prototype.isResetMediaSourceNecessary=function(a,b,c,d){a=this.getInfoAboutResetOrChangeType_(a,b,c,d);a.transmuxer&&a.transmuxer.destroy();return a.type==shaka.media.MediaSourceEngine.ResetMode_.RESET};shaka.media.MediaSourceEngine.prototype.updateLcevcDec=function(a){this.lcevcDec_=a};shaka.media.MediaSourceEngine.prototype.addExtraFeaturesToMimeType_=function(a){var b=this.config_.addExtraFeaturesToSourceBuffer(a);a+=b;shaka.log.debug("Using full mime type",a);return a};
shaka.media.MediaSourceEngine.createObjectURL=window.URL.createObjectURL;shaka.media.MediaSourceEngine.SourceBufferMode_={SEQUENCE:"sequence",SEGMENTS:"segments"};shaka.media.MediaSourceEngine.ResetMode_={NONE:"none",RESET:"reset",CHANGE_TYPE:"changeType"};shaka.media.PlayRateController=function(a){var b=this;this.harness_=a;this.isBuffering_=!1;this.rate_=this.harness_.getRate();this.pollRate_=.25;this.timer_=new shaka.util.Timer(function(){b.harness_.isPaused()||b.harness_.movePlayhead(b.rate_*b.pollRate_)})};shaka.media.PlayRateController.prototype.release=function(){this.set(this.getDefaultRate());this.timer_&&(this.timer_.stop(),this.timer_=null);this.harness_=null};
shaka.media.PlayRateController.prototype.setBuffering=function(a){this.isBuffering_=a;this.apply_()};shaka.media.PlayRateController.prototype.set=function(a){goog.asserts.assert(a!=0,"Should never set rate of 0 explicitly!");this.rate_=a;this.apply_()};shaka.media.PlayRateController.prototype.getRealRate=function(){return this.rate_};shaka.media.PlayRateController.prototype.getDefaultRate=function(){return this.harness_.getDefaultRate()};
shaka.media.PlayRateController.prototype.apply_=function(){this.timer_.stop();var a=this.calculateCurrentRate_();shaka.log.v1("Changing effective playback rate to",a);if(a>=0&&a<=16)try{this.applyRate_(a);return}catch(b){}this.timer_.tickEvery(this.pollRate_);this.applyRate_(0)};shaka.media.PlayRateController.prototype.calculateCurrentRate_=function(){return this.isBuffering_?0:this.rate_};
shaka.media.PlayRateController.prototype.applyRate_=function(a){var b=this.harness_.getRate();b!=a&&this.harness_.setRate(a);return b!=a};shaka.util.MediaReadyState=function(){};shaka.util.MediaReadyState.waitForReadyState=function(a,b,c,d){b==HTMLMediaElement.HAVE_NOTHING||a.readyState>=b?d():(b=shaka.util.MediaReadyState.READY_STATES_TO_EVENT_NAMES_.value().get(b),c.listenOnce(a,b,d))};
shaka.util.MediaReadyState.READY_STATES_TO_EVENT_NAMES_=new shaka.util.Lazy(function(){return new Map([[HTMLMediaElement.HAVE_METADATA,"loadedmetadata"],[HTMLMediaElement.HAVE_CURRENT_DATA,"loadeddata"],[HTMLMediaElement.HAVE_FUTURE_DATA,"canplay"],[HTMLMediaElement.HAVE_ENOUGH_DATA,"canplaythrough"]])});shaka.media.VideoWrapper=function(a,b,c,d){var e=this;this.video_=a;this.onSeek_=b;this.onStarted_=c;this.startTime_=null;this.getStartTime_=function(){e.startTime_==null&&(e.startTime_=d());return e.startTime_};this.started_=!1;this.eventManager_=new shaka.util.EventManager;this.mover_=new shaka.media.VideoWrapper.PlayheadMover(a,10);shaka.util.MediaReadyState.waitForReadyState(this.video_,HTMLMediaElement.HAVE_METADATA,this.eventManager_,function(){e.setStartTime_(e.getStartTime_())})};
shaka.media.VideoWrapper.prototype.release=function(){this.eventManager_&&(this.eventManager_.release(),this.eventManager_=null);this.mover_!=null&&(this.mover_.release(),this.mover_=null);this.onSeek_=function(){};this.video_=null};shaka.media.VideoWrapper.prototype.getTime=function(){return this.started_?this.video_.currentTime:this.getStartTime_()};
shaka.media.VideoWrapper.prototype.setTime=function(a){var b=this;this.video_.readyState>0?this.mover_.moveTo(a):shaka.util.MediaReadyState.waitForReadyState(this.video_,HTMLMediaElement.HAVE_METADATA,this.eventManager_,function(){b.setStartTime_(b.getStartTime_())})};
shaka.media.VideoWrapper.prototype.setStartTime_=function(a){var b=this;Math.abs(this.video_.currentTime-a)<.001?this.startListeningToSeeks_():(this.eventManager_.listenOnce(this.video_,"seeking",function(){b.startListeningToSeeks_()}),this.mover_.moveTo(this.video_.currentTime&&this.video_.currentTime!=0?this.video_.currentTime:a))};
shaka.media.VideoWrapper.prototype.startListeningToSeeks_=function(){var a=this;goog.asserts.assert(this.video_.readyState>0,"The media element should be ready before we listen for seeking.");this.started_=!0;this.eventManager_.listen(this.video_,"seeking",function(){return a.onSeek_()});this.onStarted_(this.video_.currentTime)};
shaka.media.VideoWrapper.PlayheadMover=function(a,b){var c=this;this.mediaElement_=a;this.maxAttempts_=b;this.targetTime_=this.originTime_=this.remainingAttempts_=0;this.timer_=new shaka.util.Timer(function(){return c.onTick_()})};shaka.media.VideoWrapper.PlayheadMover.prototype.release=function(){this.timer_&&(this.timer_.stop(),this.timer_=null);this.mediaElement_=null};
shaka.media.VideoWrapper.PlayheadMover.prototype.moveTo=function(a){this.originTime_=this.mediaElement_.currentTime;this.targetTime_=a;this.remainingAttempts_=this.maxAttempts_;this.mediaElement_.currentTime=a;this.timer_.tickEvery(.1)};
shaka.media.VideoWrapper.PlayheadMover.prototype.onTick_=function(){this.remainingAttempts_<=0?(shaka.log.warning(["Failed to move playhead from",this.originTime_,"to",this.targetTime_].join(" ")),this.timer_.stop()):this.mediaElement_.currentTime!=this.originTime_||this.mediaElement_.currentTime===this.targetTime_?this.timer_.stop():(this.mediaElement_.currentTime=this.targetTime_,this.remainingAttempts_--)};shaka.media.Playhead=function(){};shaka.media.Playhead.prototype.ready=function(){};shaka.media.Playhead.prototype.setStartTime=function(a){};shaka.media.Playhead.prototype.getStallsDetected=function(){};shaka.media.Playhead.prototype.getIsJumpingGap=function(){};shaka.media.Playhead.prototype.getGapsJumped=function(){};shaka.media.Playhead.prototype.getTime=function(){};shaka.media.Playhead.prototype.notifyOfBufferingChange=function(){};shaka.media.Playhead.prototype.isBufferedToEnd=function(){};
shaka.media.SrcEqualsPlayhead=function(a){this.mediaElement_=a;this.started_=!1;this.startTime_=null;this.eventManager_=new shaka.util.EventManager};
shaka.media.SrcEqualsPlayhead.prototype.ready=function(){var a=this;goog.asserts.assert(this.mediaElement_!=null,"Playhead should not be released before calling ready()");var b=function(){if(a.startTime_==null||a.startTime_==0&&a.mediaElement_.duration!=Infinity)a.started_=!0;else{var c=a.mediaElement_.currentTime,d=null;if(typeof a.startTime_==="number")d=a.startTime_;else if(a.startTime_ instanceof Date){var e=a.getProgramStartTime_();e!==null&&(d=a.startTime_.getTime()/1E3-e,d=a.clampTime_(d))}d==
null?a.started_=!0:(d<0&&(d=Math.max(0,c+d)),c!=d?(a.eventManager_.listenOnce(a.mediaElement_,"seeking",function(){a.started_=!0}),a.mediaElement_.currentTime=d):a.started_=!0)}};shaka.util.MediaReadyState.waitForReadyState(this.mediaElement_,HTMLMediaElement.HAVE_FUTURE_DATA,this.eventManager_,function(){b()})};shaka.media.SrcEqualsPlayhead.prototype.release=function(){this.eventManager_&&(this.eventManager_.release(),this.eventManager_=null);this.mediaElement_=null};
shaka.media.SrcEqualsPlayhead.prototype.setStartTime=function(a){this.startTime_=this.started_?this.startTime_:a};shaka.media.SrcEqualsPlayhead.prototype.getTime=function(){var a=this.started_?this.mediaElement_.currentTime:this.startTime_;a instanceof Date&&(a=a.getTime()/1E3-(this.getProgramStartTime_()||0),a=this.clampTime_(a));return a||0};shaka.media.SrcEqualsPlayhead.prototype.getStallsDetected=function(){return 0};shaka.media.SrcEqualsPlayhead.prototype.getGapsJumped=function(){return 0};
shaka.media.SrcEqualsPlayhead.prototype.getIsJumpingGap=function(){return!1};shaka.media.SrcEqualsPlayhead.prototype.notifyOfBufferingChange=function(){};shaka.media.SrcEqualsPlayhead.prototype.isBufferedToEnd=function(){goog.asserts.assert(this.mediaElement_,"We need a video element to get buffering information");var a=shaka.media.TimeRangesUtils.bufferEnd(this.mediaElement_.buffered);return a!=null&&a>=this.mediaElement_.duration-1};
shaka.media.SrcEqualsPlayhead.prototype.getProgramStartTime_=function(){if(this.mediaElement_.getStartDate){var a=this.mediaElement_.getStartDate().getTime();if(!isNaN(a))return a/1E3}return null};shaka.media.SrcEqualsPlayhead.prototype.clampTime_=function(a){var b=this.mediaElement_.seekable;b.length>0&&(a=Math.max(b.start(0),a),a=Math.min(b.end(b.length-1),a));return a};
shaka.media.MediaSourcePlayhead=function(a,b,c,d,e,f){var g=this;this.minSeekRange_=3;this.mediaElement_=a;this.timeline_=b.presentationTimeline;this.config_=c;this.onSeek_=e;this.lastCorrectiveSeek_=null;this.gapController_=new shaka.media.GapJumpingController(a,b.presentationTimeline,c,f);this.videoWrapper_=new shaka.media.VideoWrapper(a,function(){return g.onSeeking_()},function(h){return g.onStarted_(h)},function(){return g.getStartTime_(d)});this.checkWindowTimer_=new shaka.util.Timer(function(){g.onPollWindow_()})};
shaka.media.MediaSourcePlayhead.prototype.ready=function(){this.checkWindowTimer_.tickEvery(.25)};shaka.media.MediaSourcePlayhead.prototype.release=function(){this.videoWrapper_&&(this.videoWrapper_.release(),this.videoWrapper_=null);this.gapController_&&(this.gapController_.release(),this.gapController_=null);this.checkWindowTimer_&&(this.checkWindowTimer_.stop(),this.checkWindowTimer_=null);this.mediaElement_=this.videoWrapper_=this.timeline_=this.config_=null;this.onSeek_=function(){}};
shaka.media.MediaSourcePlayhead.prototype.setStartTime=function(a){this.videoWrapper_.setTime(this.getStartTime_(a))};shaka.media.MediaSourcePlayhead.prototype.getTime=function(){var a=this.videoWrapper_.getTime();return this.mediaElement_.readyState>0&&!this.mediaElement_.paused?this.clampTime_(a):a};shaka.media.MediaSourcePlayhead.prototype.getStallsDetected=function(){return this.gapController_.getStallsDetected()};shaka.media.MediaSourcePlayhead.prototype.getGapsJumped=function(){return this.gapController_.getGapsJumped()};
shaka.media.MediaSourcePlayhead.prototype.getIsJumpingGap=function(){return this.gapController_.getIsJumpingGap()};
shaka.media.MediaSourcePlayhead.prototype.getStartTime_=function(a){if(a==null)a=this.timeline_.getDuration()<Infinity?this.timeline_.getSeekRangeStart():this.timeline_.getSeekRangeEnd();else if(a instanceof Date){var b=this.timeline_.getInitialProgramDateTime()||this.timeline_.getPresentationStartTime();goog.asserts.assert(b!=null,"Presentation start time should not be null!");a=a.getTime()/1E3-b}else a<0&&(a=this.timeline_.getSeekRangeEnd()+a);return this.clampSeekToDuration_(this.clampTime_(a))};
shaka.media.MediaSourcePlayhead.prototype.notifyOfBufferingChange=function(){this.gapController_.onSegmentAppended()};
shaka.media.MediaSourcePlayhead.prototype.isBufferedToEnd=function(){goog.asserts.assert(this.mediaElement_,"We need a video element to get buffering information");goog.asserts.assert(this.timeline_,"We need a timeline to get buffering information");if(this.timeline_.isLive()){var a=this.timeline_.getSegmentAvailabilityEnd(),b=shaka.media.TimeRangesUtils.bufferEnd(this.mediaElement_.buffered);if(b!=null&&b>=a)return!0}return!1};
shaka.media.MediaSourcePlayhead.prototype.onPollWindow_=function(){if(this.mediaElement_.readyState!=0&&!this.mediaElement_.paused){var a=this.videoWrapper_.getTime(),b=this.timeline_.getSeekRangeStart(),c=this.timeline_.getSeekRangeEnd();c-b<this.minSeekRange_&&(b=c-this.minSeekRange_);a<b&&(b=this.reposition_(a),shaka.log.info("Jumping forward "+(b-a)+" seconds to catch up with the seek range."),this.mediaElement_.currentTime=b)}};shaka.media.MediaSourcePlayhead.prototype.onStarted_=function(a){this.gapController_.onStarted(a)};
shaka.media.MediaSourcePlayhead.prototype.onSeeking_=function(){this.gapController_.onSeeking();var a=this.videoWrapper_.getTime(),b=this.reposition_(a),c=shaka.media.GapJumpingController.BROWSER_GAP_TOLERANCE;if(!shaka.media.Capabilities.isInfiniteLiveStreamDurationSupported()&&Math.abs(b-a)>c){c=!1;var d=shaka.device.DeviceFactory.getDevice().seekDelay();if(d){var e=Date.now()/1E3;if(!this.lastCorrectiveSeek_||this.lastCorrectiveSeek_<e-d)this.lastCorrectiveSeek_=e,c=!0}else c=!0;if(c){this.videoWrapper_.setTime(b);
return}}shaka.log.v1("Seek to "+a);this.onSeek_()};shaka.media.MediaSourcePlayhead.prototype.clampSeekToDuration_=function(a){var b=this.timeline_.getDuration();return a>=b?(goog.asserts.assert(this.config_.durationBackoff>=0,"Duration backoff must be non-negative!"),b-this.config_.durationBackoff):a};
shaka.media.MediaSourcePlayhead.prototype.reposition_=function(a){goog.asserts.assert(this.config_,"Cannot reposition playhead when it has been destroyed");var b=this.config_.rebufferingGoal,c=this.config_.safeSeekOffset,d=this.timeline_.getSeekRangeStart(),e=this.timeline_.getSeekRangeEnd(),f=this.timeline_.getDuration();e-d<this.minSeekRange_&&(d=e-this.minSeekRange_);var g=this.timeline_.getSafeSeekRangeStart(b),h=this.timeline_.getSafeSeekRangeStart(c);b=this.timeline_.getSafeSeekRangeStart(b+
c);if(a>=f)return shaka.log.v1("Playhead past duration."),this.clampSeekToDuration_(a);if(a>e)return shaka.log.v1("Playhead past end."),e-this.config_.safeSeekEndOffset;if(a<d){if(this.timeline_.isLive()&&this.config_.returnToEndOfLiveWindowWhenOutside)return e-this.config_.safeSeekEndOffset;if(shaka.media.TimeRangesUtils.isBuffered(this.mediaElement_.buffered,h))return shaka.log.v1("Playhead before start & start is buffered"),h;shaka.log.v1("Playhead before start & start is unbuffered");return b}if(a>=
g||shaka.media.TimeRangesUtils.isBuffered(this.mediaElement_.buffered,a))return shaka.log.v1("Playhead in safe region or in buffered region."),a;shaka.log.v1("Playhead outside safe region & in unbuffered region.");return b};shaka.media.MediaSourcePlayhead.prototype.clampTime_=function(a){var b=this.timeline_.getSeekRangeStart();if(a<b)return b;b=this.timeline_.getSeekRangeEnd();return a>b?b:a};shaka.media.IPlayheadObserver=function(){};shaka.media.IPlayheadObserver.prototype.poll=function(a,b){};
shaka.media.PlayheadObserverManager=function(a){var b=this;this.mediaElement_=a;this.eventManager_=new shaka.util.EventManager;this.observers_=new Set;this.pollingLoop_=(new shaka.util.Timer(function(){b.pollAllObservers_(!1)})).tickNow();a.paused||this.pollingLoop_.tickEvery(.25);this.eventManager_.listen(a,"playing",function(){b.pollingLoop_.tickNow().tickEvery(.25)});this.eventManager_.listen(a,"pause",function(){b.pollingLoop_.stop()});this.eventManager_.listen(a,"seeked",function(){b.pollingLoop_.tickNow();
a.paused||b.pollingLoop_.tickEvery(.25)})};shaka.media.PlayheadObserverManager.prototype.release=function(){this.eventManager_&&(this.eventManager_.release(),this.eventManager_=null);this.pollingLoop_.stop();for(var a=(0,$jscomp.makeIterator)(this.observers_),b=a.next();!b.done;b=a.next())b.value.release();this.observers_.clear()};shaka.media.PlayheadObserverManager.prototype.manage=function(a){this.observers_.add(a)};shaka.media.PlayheadObserverManager.prototype.notifyOfSeek=function(a){this.pollAllObservers_(a)};
shaka.media.PlayheadObserverManager.prototype.pollAllObservers_=function(a){for(var b=this.mediaElement_.currentTime,c=(0,$jscomp.makeIterator)(this.observers_),d=c.next();!d.done;d=c.next())d.value.poll(b,a)};shaka.media.QualityObserver=function(a){shaka.util.FakeEventTarget.call(this);this.contentTypeStates_=new Map;this.getBufferedInfo_=a};$jscomp.inherits(shaka.media.QualityObserver,shaka.util.FakeEventTarget);shaka.media.QualityObserver.prototype.release=function(){this.contentTypeStates_.clear();shaka.util.FakeEventTarget.prototype.release.call(this)};
shaka.media.QualityObserver.prototype.getContentTypeState_=function(a){var b=this.contentTypeStates_.get(a);b||(b={qualityChangePositions:[],currentQuality:null,contentType:a},this.contentTypeStates_.set(a,b));return b};
shaka.media.QualityObserver.prototype.addMediaQualityChange=function(a,b){var c=this.getContentTypeState_(a.contentType);this.purgeQualityChangePositions_(c);a={mediaQuality:a,position:b};c=c.qualityChangePositions;var d=c.findIndex(function(e){return e.position>=b});d>=0?c.splice(d,c[d].position==b?1:0,a):c.push(a)};shaka.media.QualityObserver.getMediaQualityAtPosition_=function(a,b){b=b.qualityChangePositions;for(var c=b.length-1;c>=0;c--){var d=b[c];if(d.position<=a)return d.mediaQuality}return null};
shaka.media.QualityObserver.mediaQualitiesAreTheSame_=function(a,b){return a===b?!0:a&&b?a.bandwidth==b.bandwidth&&a.audioSamplingRate==b.audioSamplingRate&&a.codecs==b.codecs&&a.contentType==b.contentType&&a.frameRate==b.frameRate&&a.height==b.height&&a.mimeType==b.mimeType&&a.channelsCount==b.channelsCount&&a.pixelAspectRatio==b.pixelAspectRatio&&a.width==b.width:!1};
shaka.media.QualityObserver.prototype.poll=function(a,b){b=(0,$jscomp.makeIterator)(this.contentTypeStates_.values());for(var c=b.next();!c.done;c=b.next()){c=c.value;var d=c.currentQuality,e=shaka.media.QualityObserver.getMediaQualityAtPosition_(a,c),f=e&&!shaka.media.QualityObserver.mediaQualitiesAreTheSame_(d,e),g=e&&d&&e.label&&d.label&&d.label!==e.label,h=e&&d&&e.language&&d.language&&d.language!==e.language;d=e&&d&&e.roles&&d.roles&&!shaka.util.ArrayUtils.equal(d.roles,e.roles);(g||h||d)&&this.positionIsBuffered_(a,
e.contentType)&&(c.currentQuality=e,g=new shaka.util.FakeEvent("audiotrackchange",new Map([["quality",e],["position",a]])),this.dispatchEvent(g));f&&this.positionIsBuffered_(a,e.contentType)&&(c.currentQuality=e,shaka.log.debug("Media quality changed at position "+a+" "+JSON.stringify(e)),c=new shaka.util.FakeEvent("qualitychange",new Map([["quality",e],["position",a]])),this.dispatchEvent(c))}};
shaka.media.QualityObserver.prototype.positionIsBuffered_=function(a,b){if((b=this.getBufferedInfo_()[b])&&b.length>0){var c=b[b.length-1].end;if(a>=b[0].start&&a<c)return!0}return!1};
shaka.media.QualityObserver.prototype.purgeQualityChangePositions_=function(a){var b=this.getBufferedInfo_()[a.contentType];if(b&&b.length>0){var c=b[0].start,d=b[b.length-1].end,e=a.qualityChangePositions;a.qualityChangePositions=e.filter(function(f,g){return f.position<=c&&g+1<e.length&&e[g+1].position<=c||f.position>=d?!1:!0})}else a.qualityChangePositions=[]};
shaka.media.QualityObserver.createQualityInfo=function(a){var b={bandwidth:a.bandwidth||0,audioSamplingRate:null,codecs:a.codecs,contentType:a.type,frameRate:null,height:null,mimeType:a.mimeType,channelsCount:null,pixelAspectRatio:null,width:null,label:null,roles:a.roles,language:null};a.type==shaka.util.ManifestParserUtils.ContentType.VIDEO&&(b.frameRate=a.frameRate||null,b.height=a.height||null,b.pixelAspectRatio=a.pixelAspectRatio||null,b.width=a.width||null);a.type==shaka.util.ManifestParserUtils.ContentType.AUDIO&&
(b.audioSamplingRate=a.audioSamplingRate,b.channelsCount=a.channelsCount,b.label=a.label||null,b.language=a.language);return b};shaka.media.RegionTimeline=function(a){shaka.util.FakeEventTarget.call(this);this.regions_=new Map;this.getFilterRange_=a;this.filterTimer_=null};$jscomp.inherits(shaka.media.RegionTimeline,shaka.util.FakeEventTarget);shaka.media.RegionTimeline.prototype.release=function(){this.regions_.clear();this.releaseTimer_();shaka.util.FakeEventTarget.prototype.release.call(this)};
shaka.media.RegionTimeline.prototype.addRegion=function(a){var b=this.generateKey_(a);this.regions_.has(b)||(this.regions_.set(b,a),a=new shaka.util.FakeEvent("regionadd",new Map([["region",a]])),this.dispatchEvent(a),this.setupTimer_())};
shaka.media.RegionTimeline.prototype.filterByRange_=function(){for(var a=this.getFilterRange_(),b=(0,$jscomp.makeIterator)(this.regions_),c=b.next();!c.done;c=b.next()){var d=(0,$jscomp.makeIterator)(c.value);c=d.next().value;d=d.next().value;d.endTime<a.start&&(this.regions_.delete(c),c=new shaka.util.FakeEvent("regionremove",new Map([["region",d]])),this.dispatchEvent(c))}this.regions_.size||this.releaseTimer_()};
shaka.media.RegionTimeline.prototype.setupTimer_=function(){var a=this;this.filterTimer_||(this.filterTimer_=(new shaka.util.Timer(function(){a.filterByRange_()})).tickEvery(shaka.media.RegionTimeline.REGION_FILTER_INTERVAL))};shaka.media.RegionTimeline.prototype.releaseTimer_=function(){this.filterTimer_&&(this.filterTimer_.stop(),this.filterTimer_=null)};shaka.media.RegionTimeline.prototype.regions=function(){return this.regions_.values()};
shaka.media.RegionTimeline.prototype.generateKey_=function(a){return a.schemeIdUri+"_"+a.id+"_"+(a.startTime.toFixed(1)+"_"+a.endTime.toFixed(1))};shaka.media.RegionTimeline.REGION_FILTER_INTERVAL=2;shaka.media.SegmentPrefetch=function(a,b,c,d,e){this.prefetchLimit_=a;this.stream_=b;this.fetchDispatcher_=c;this.segmentPrefetchMap_=new Map;this.initSegmentPrefetchMap_=new Map;this.iterator_=null;this.reverse_=d;a=function(f,g){return g.fastSwitching&&f.isPartial()&&f.isLastPartial()?!1:!0};this.shouldPrefetchNextSegment_=e||a};
shaka.media.SegmentPrefetch.prototype.replaceFetchDispatcher=function(a){this.fetchDispatcher_=a;for(var b=(0,$jscomp.makeIterator)(this.segmentPrefetchMap_.values()),c=b.next();!c.done;c=b.next())c.value.replaceFetchDispatcher(a)};
shaka.media.SegmentPrefetch.prototype.prefetchSegmentsByTime=function(a,b){b=b===void 0?!1:b;goog.asserts.assert(this.prefetchLimit_>0,"SegmentPrefetch can not be used when prefetchLimit <= 0.");var c=shaka.media.SegmentPrefetch.logPrefix_(this.stream_);if(!this.stream_.segmentIndex)return shaka.log.debug(c,"missing segmentIndex"),Promise.resolve();this.iterator_||(this.iterator_=this.stream_.segmentIndex.getIteratorForTime(a,!0,this.reverse_));if(!this.iterator_)return shaka.log.debug(c,"missing iterator"),
Promise.resolve();b&&this.iterator_.next();for(a=[];this.segmentPrefetchMap_.size<this.prefetchLimit_;){b=this.iterator_.next().value;if(!b)break;c=!0;b.isPreload()&&b.endByte!=null&&(c=!1);b.getStatus()==shaka.media.SegmentReference.Status.MISSING&&(c=!1);b.getSegmentData(!1)&&(c=!1);c&&b.initSegmentReference&&a.push(this.prefetchInitSegment(b.initSegmentReference));c&&!this.segmentPrefetchMap_.has(b)&&(c=new shaka.media.SegmentPrefetchOperation(this.fetchDispatcher_),a.push(c.dispatchFetch(b,this.stream_)),
this.segmentPrefetchMap_.set(b,c));if(!this.shouldPrefetchNextSegment_(b,this.stream_))break}this.clearInitSegments_();return Promise.all(a)};
shaka.media.SegmentPrefetch.prototype.prefetchInitSegment=function(a){goog.asserts.assert(this.prefetchLimit_>0,"SegmentPrefetch can not be used when prefetchLimit <= 0.");var b=shaka.media.SegmentPrefetch.logPrefix_(this.stream_);if(!this.stream_.segmentIndex)return shaka.log.debug(b,"missing segmentIndex"),Promise.resolve();if(a.getSegmentData()||Array.from(this.initSegmentPrefetchMap_.keys()).some(function(d){return shaka.media.InitSegmentReference.equal(d,a)}))return Promise.resolve();b=new shaka.media.SegmentPrefetchOperation(this.fetchDispatcher_);
var c=b.dispatchFetch(a,this.stream_);this.initSegmentPrefetchMap_.set(a,b);return c};
shaka.media.SegmentPrefetch.prototype.getPrefetchedSegment=function(a,b){goog.asserts.assert(this.prefetchLimit_>0,"SegmentPrefetch can not be used when prefetchLimit <= 0.");var c=shaka.media.SegmentPrefetch.logPrefix_(this.stream_),d=this.segmentPrefetchMap_;a instanceof shaka.media.InitSegmentReference&&(d=this.initSegmentPrefetchMap_);if(d.has(a)){var e=d.get(a);b&&e.setStreamDataCallback(b);a instanceof shaka.media.SegmentReference?shaka.log.debug(c,"reused prefetched segment at time:",a.startTime,
"mapSize",d.size):shaka.log.debug(c,"reused prefetched init segment at time, mapSize",d.size);return e.getOperation()}a instanceof shaka.media.SegmentReference?shaka.log.debug(c,"missed segment at time:",a.startTime,"mapSize",d.size):shaka.log.debug(c,"missed init segment at time, mapSize",d.size);return null};shaka.media.SegmentPrefetch.prototype.clearMap_=function(a){a=(0,$jscomp.makeIterator)(a.keys());for(var b=a.next();!b.done;b=a.next())(b=b.value)&&this.abortPrefetchedSegment_(b)};
shaka.media.SegmentPrefetch.prototype.resetPosition=function(){this.iterator_=null};shaka.media.SegmentPrefetch.prototype.clearAll=function(){this.clearMap_(this.segmentPrefetchMap_);this.clearMap_(this.initSegmentPrefetchMap_);this.resetPosition();var a=shaka.media.SegmentPrefetch.logPrefix_(this.stream_);shaka.log.debug(a,"cleared all")};shaka.media.SegmentPrefetch.prototype.removeReference=function(a){this.abortPrefetchedSegment_(a)};
shaka.media.SegmentPrefetch.prototype.evict=function(a,b){b=b===void 0?!1:b;for(var c=(0,$jscomp.makeIterator)(this.segmentPrefetchMap_.keys()),d=c.next();!d.done;d=c.next())d=d.value,a>d.endTime&&this.abortPrefetchedSegment_(d);b&&this.clearInitSegments_()};shaka.media.SegmentPrefetch.prototype.setReverse=function(a){this.reverse_=a;this.iterator_&&this.iterator_.setReverse(a)};
shaka.media.SegmentPrefetch.prototype.clearInitSegments_=function(){if(this.segmentPrefetchMap_.size)for(var a=Array.from(this.segmentPrefetchMap_.keys()),b=(0,$jscomp.makeIterator)(this.initSegmentPrefetchMap_.keys()),c=b.next(),d={};!c.done;d={initSegmentReference$jscomp$19:void 0},c=b.next())d.initSegmentReference$jscomp$19=c.value,a.some(function(e){return function(f){return shaka.media.InitSegmentReference.equal(f.initSegmentReference,e.initSegmentReference$jscomp$19)}}(d))||this.abortPrefetchedSegment_(d.initSegmentReference$jscomp$19)};
shaka.media.SegmentPrefetch.prototype.resetLimit=function(a){goog.asserts.assert(a>=0,"The new prefetch limit must be >= 0.");var b=shaka.media.SegmentPrefetch.logPrefix_(this.stream_);shaka.log.debug(b,"resetting prefetch limit to",a);this.prefetchLimit_=a;for(b=Array.from(this.segmentPrefetchMap_.keys());b.length>a;){var c=b.pop();c&&this.abortPrefetchedSegment_(c)}this.clearInitSegments_()};
shaka.media.SegmentPrefetch.prototype.switchStream=function(a){a&&a!==this.stream_&&(this.clearAll(),this.stream_=a)};shaka.media.SegmentPrefetch.prototype.getStream=function(){return this.stream_};
shaka.media.SegmentPrefetch.prototype.abortPrefetchedSegment_=function(a){var b=shaka.media.SegmentPrefetch.logPrefix_(this.stream_),c=this.segmentPrefetchMap_;a instanceof shaka.media.InitSegmentReference&&(c=this.initSegmentPrefetchMap_);var d=c.get(a);c.delete(a);d&&(d.abort(),a instanceof shaka.media.SegmentReference?shaka.log.debug(b,"pop and abort prefetched segment at time:",a.startTime):shaka.log.debug(b,"pop and abort prefetched init segment"))};
shaka.media.SegmentPrefetch.logPrefix_=function(a){return"SegmentPrefetch("+a.type+":"+a.id+")"};shaka.media.SegmentPrefetchOperation=function(a){this.fetchDispatcher_=a;this.operation_=this.streamDataCallback_=null};shaka.media.SegmentPrefetchOperation.prototype.replaceFetchDispatcher=function(a){this.fetchDispatcher_=a};
shaka.media.SegmentPrefetchOperation.prototype.dispatchFetch=function(a,b){var c=this,d=new Uint8Array(0);this.operation_=this.fetchDispatcher_(a,b,function(e){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){if(f.getNextAddressJsc()==1)return d=d.byteLength>0?shaka.util.Uint8ArrayUtils.concat(d,e):e,c.streamDataCallback_?f.yield(c.streamDataCallback_(d),3):f.jumpTo(0);d=new Uint8Array(0);f.jumpToEnd()})});return this.operation_.promise.catch(function(e){return e instanceof shaka.util.Error&&
e.code==shaka.util.Error.Code.OPERATION_ABORTED?Promise.resolve():Promise.reject(e)})};shaka.media.SegmentPrefetchOperation.prototype.getOperation=function(){return this.operation_};shaka.media.SegmentPrefetchOperation.prototype.setStreamDataCallback=function(a){this.streamDataCallback_=a};shaka.media.SegmentPrefetchOperation.prototype.abort=function(){this.operation_&&this.operation_.abort()};shaka.media.StreamingEngine=function(a,b){var c=this;this.playerInterface_=b;this.manifest_=a;this.config_=null;this.deferredCloseSegmentIndex_=new Map;this.bufferingScale_=1;this.currentTextStream_=this.currentVariant_=null;this.textStreamSequenceId_=0;this.mediaStates_=new Map;this.startupComplete_=!1;this.failureCallbackBackoff_=null;this.fatalError_=!1;this.destroyer_=new shaka.util.Destroyer(function(){return c.doDestroy_()});this.lastMediaSourceReset_=Date.now()/1E3;this.audioPrefetchMap_=new Map;
this.spatialVideoInfo_={projection:null,hfov:null};this.playRangeStart_=0;this.playRangeEnd_=Infinity;this.lastTextMediaStateBeforeUnload_=null;this.requestedDependencySegments_=[];this.updateLiveSeekableRangeTimer_=new shaka.util.Timer(function(){if(c.manifest_&&c.playerInterface_)if(c.manifest_.presentationTimeline.isLive()){var d=c.manifest_.presentationTimeline.getSeekRangeStart(),e=c.manifest_.presentationTimeline.getSeekRangeEnd();e-d>1?c.playerInterface_.mediaSourceEngine.setLiveSeekableRange(d,
e):c.playerInterface_.mediaSourceEngine.clearLiveSeekableRange()}else c.playerInterface_.mediaSourceEngine.clearLiveSeekableRange(),c.updateLiveSeekableRangeTimer_&&c.updateLiveSeekableRangeTimer_.stop();else c.updateLiveSeekableRangeTimer_&&c.updateLiveSeekableRangeTimer_.stop()});this.boundaryTime_=null;this.crossBoundarySeek_=!1;this.crossBoundaryTimer_=new shaka.util.Timer(function(){var d=c.playerInterface_.video;!d.ended&&c.boundaryTime_&&(shaka.log.info("Crossing boundary at",c.boundaryTime_),
c.crossBoundarySeek_=!0,d.currentTime=c.boundaryTime_,c.boundaryTime_=null)});this.crossBoundaryEventManager_=new shaka.util.EventManager};shaka.media.StreamingEngine.prototype.destroy=function(){return this.destroyer_.destroy()};
shaka.media.StreamingEngine.prototype.doDestroy_=function(){var a=this,b,c,d,e,f,g,h;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(k){if(k.getNextAddressJsc()==1){a.updateLiveSeekableRangeTimer_&&a.updateLiveSeekableRangeTimer_.stop();a.updateLiveSeekableRangeTimer_=null;a.crossBoundaryTimer_&&a.crossBoundaryTimer_.stop();a.crossBoundaryTimer_=null;a.crossBoundaryEventManager_&&(a.crossBoundaryEventManager_.release(),a.crossBoundaryEventManager_=null);b=[];c=(0,$jscomp.makeIterator)(a.mediaStates_.values());
for(d=c.next();!d.done;d=c.next())e=d.value,a.cancelUpdate_(e),b.push(a.abortOperations_(e)),e.segmentPrefetch&&(e.segmentPrefetch.clearAll(),e.segmentPrefetch=null);f=(0,$jscomp.makeIterator)(a.audioPrefetchMap_.values());for(g=f.next();!g.done;g=f.next())h=g.value,h.clearAll();return k.yield(Promise.all(b),2)}a.mediaStates_.clear();a.audioPrefetchMap_.clear();a.playerInterface_=null;a.manifest_=null;a.config_=null;a.boundaryTime_=null;k.jumpToEnd()})};
shaka.media.StreamingEngine.prototype.configure=function(a){this.config_=a;this.failureCallbackBackoff_=new shaka.net.Backoff({maxAttempts:Math.max(a.retryParameters.maxAttempts,2),baseDelay:a.retryParameters.baseDelay,backoffFactor:a.retryParameters.backoffFactor,fuzzFactor:a.retryParameters.fuzzFactor,timeout:0,stallTimeout:0,connectionTimeout:0},!0);var b=shaka.util.ManifestParserUtils.ContentType;if(a.disableAudioPrefetch){var c=this.mediaStates_.get(b.AUDIO);c&&c.segmentPrefetch&&(c.segmentPrefetch.clearAll(),
c.segmentPrefetch=null);c=(0,$jscomp.makeIterator)(this.audioPrefetchMap_.keys());for(var d=c.next();!d.done;d=c.next())d=d.value,this.audioPrefetchMap_.get(d).clearAll(),this.audioPrefetchMap_.delete(d)}a.disableTextPrefetch&&(c=this.mediaStates_.get(b.TEXT))&&c.segmentPrefetch&&(c.segmentPrefetch.clearAll(),c.segmentPrefetch=null);a.disableVideoPrefetch&&(b=this.mediaStates_.get(b.VIDEO))&&b.segmentPrefetch&&(b.segmentPrefetch.clearAll(),b.segmentPrefetch=null);b=(0,$jscomp.makeIterator)(this.mediaStates_.keys());
for(c=b.next();!c.done;c=b.next())c=this.mediaStates_.get(c.value),c.segmentPrefetch?(c.segmentPrefetch.resetLimit(a.segmentPrefetchLimit),a.segmentPrefetchLimit>0||(c.segmentPrefetch.clearAll(),c.segmentPrefetch=null)):a.segmentPrefetchLimit>0&&(c.segmentPrefetch=this.createSegmentPrefetch_(c.stream));a.disableAudioPrefetch||this.updatePrefetchMapForAudio_()};
shaka.media.StreamingEngine.prototype.applyPlayRange=function(a,b){this.manifest_.presentationTimeline.isLive()||(this.playRangeStart_=a,this.playRangeEnd_=b)};
shaka.media.StreamingEngine.prototype.start=function(a){var b=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){if(c.getNextAddressJsc()==1)return goog.asserts.assert(b.config_,"StreamingEngine configure() must be called before init()!"),c.yield(b.initStreams_(a||new Map),2);b.destroyer_.ensureNotDestroyed();shaka.log.debug("init: completed initial Stream setup");b.startupComplete_=!0;c.jumpToEnd()})};shaka.media.StreamingEngine.prototype.getCurrentVariant=function(){return this.currentVariant_};
shaka.media.StreamingEngine.prototype.getCurrentTextStream=function(){return this.currentTextStream_};
shaka.media.StreamingEngine.prototype.loadNewTextStream_=function(a){var b=this,c,d,e,f,g,h,k;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(l){switch(l.getNextAddressJsc()){case 1:return c=shaka.util.ManifestParserUtils.ContentType,goog.asserts.assert(!b.mediaStates_.has(c.TEXT),"Should not call loadNewTextStream_ while streaming text!"),b.textStreamSequenceId_++,d=b.textStreamSequenceId_,l.setCatchFinallyBlocks(2),l.yield(b.playerInterface_.mediaSourceEngine.clear(c.TEXT),4);case 4:l.leaveTryBlock(3);
break;case 2:if(e=l.enterCatchBlock(),b.playerInterface_)b.playerInterface_.onError(e);case 3:f=shaka.util.MimeUtils.getFullType(a.mimeType,a.codecs),b.playerInterface_.mediaSourceEngine.reinitText(f,b.manifest_.sequenceMode,a.external),g=b.playerInterface_.mediaSourceEngine.getTextDisplayer(),(h=g.isTextVisible()||b.config_.alwaysStreamText)&&b.textStreamSequenceId_==d&&(k=b.createMediaState_(a),b.mediaStates_.set(c.TEXT,k),b.scheduleUpdate_(k,0)),l.jumpToEnd()}})};
shaka.media.StreamingEngine.prototype.unloadTextStream=function(){var a=shaka.util.ManifestParserUtils.ContentType,b=this.mediaStates_.get(a.TEXT);b&&(this.cancelUpdate_(b),this.abortOperations_(b).catch(function(){}),this.lastTextMediaStateBeforeUnload_=this.mediaStates_.get(a.TEXT),this.mediaStates_.delete(a.TEXT),b.stream&&b.stream.closeSegmentIndex&&b.stream.closeSegmentIndex());this.currentTextStream_=null};
shaka.media.StreamingEngine.prototype.setTrickPlay=function(a){var b=shaka.util.ManifestParserUtils.ContentType;this.updateSegmentIteratorReverse_();if(b=this.mediaStates_.get(b.VIDEO)){var c=b.stream;if(c)if(shaka.log.debug("setTrickPlay",a),a)(a=c.trickModeVideo)&&!b.restoreStreamAfterTrickPlay&&(shaka.log.debug("Engaging trick mode stream",a),this.switchInternal_(a,!1,0,!1),b.restoreStreamAfterTrickPlay=c);else if(a=b.restoreStreamAfterTrickPlay)shaka.log.debug("Restoring non-trick-mode stream",
a),b.restoreStreamAfterTrickPlay=null,this.switchInternal_(a,!0,0,!1)}};shaka.media.StreamingEngine.prototype.switchVariant=function(a,b,c,d,e){b=b===void 0?!1:b;c=c===void 0?0:c;d=d===void 0?!1:d;e=e===void 0?!1:e;this.currentVariant_=a;this.startupComplete_&&(a.video&&this.switchInternal_(a.video,b,c,d,e),a.audio&&this.switchInternal_(a.audio,b,c,d,e))};
shaka.media.StreamingEngine.prototype.switchTextStream=function(a){var b=this,c;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(d){if(d.getNextAddressJsc()==1){b.lastTextMediaStateBeforeUnload_=null;b.currentTextStream_=a;if(!b.startupComplete_)return d.return();c=shaka.util.ManifestParserUtils.ContentType;goog.asserts.assert(a&&a.type==c.TEXT,"Wrong stream type passed to switchTextStream!");return a.segmentIndex?d.jumpTo(2):d.yield(a.createSegmentIndex(),2)}b.switchInternal_(a,!0,
0,!1);d.jumpToEnd()})};shaka.media.StreamingEngine.prototype.reloadTextStream=function(){var a=this.mediaStates_.get(shaka.util.ManifestParserUtils.ContentType.TEXT);a&&this.switchInternal_(a.stream,!0,0,!0)};
shaka.media.StreamingEngine.prototype.handleDeferredCloseSegmentIndexes_=function(a){for(var b=(0,$jscomp.makeIterator)(this.deferredCloseSegmentIndex_.entries()),c=b.next();!c.done;c=b.next()){var d=(0,$jscomp.makeIterator)(c.value);c=d.next().value;d=d.next().value;c.includes(a.type)&&(d(),this.deferredCloseSegmentIndex_.delete(c))}};
shaka.media.StreamingEngine.prototype.switchInternal_=function(a,b,c,d,e){var f=this,g=shaka.util.ManifestParserUtils.ContentType,h=this.mediaStates_.get(a.type);h||a.type!=g.TEXT?(goog.asserts.assert(h,"switch: expected mediaState to exist"),h&&(h.restoreStreamAfterTrickPlay&&(shaka.log.debug("switch during trick play mode",a),a.trickModeVideo?(h.restoreStreamAfterTrickPlay=a,a=a.trickModeVideo,shaka.log.debug("switch found trick play stream",a)):(h.restoreStreamAfterTrickPlay=null,shaka.log.debug("switch found no special trick play stream"))),
h.stream!=a||d?(this.audioPrefetchMap_.has(a)?h.segmentPrefetch=this.audioPrefetchMap_.get(a):h.segmentPrefetch&&h.segmentPrefetch.switchStream(a),a.type==g.TEXT&&h.stream!=a&&(d=shaka.util.MimeUtils.getFullType(a.mimeType,a.codecs),this.playerInterface_.mediaSourceEngine.reinitText(d,this.manifest_.sequenceMode,a.external)),!this.audioPrefetchMap_.has(h.stream)&&h.stream.closeSegmentIndex&&(h.performingUpdate?(d=shaka.media.StreamingEngine.logPrefix_(h),this.deferredCloseSegmentIndex_.has(d)||this.deferredCloseSegmentIndex_.set(d,
h.stream.closeSegmentIndex)):h.stream.closeSegmentIndex()),d=h.stream.isAudioMuxedInVideo!=a.isAudioMuxedInVideo,h.stream=a,h.segmentIterator=null,h.adaptation=!!e,h.dependencyMediaState=a.dependencyStream?this.createMediaState_(a.dependencyStream):null,this.setupCrossBoundaryListeners_(),e=shaka.media.StreamingEngine.logPrefix_(h),shaka.log.debug("switch: switching to Stream "+e),d&&(h.lastInitSegmentReference=null,h.lastAppendWindowStart=null,h.lastAppendWindowEnd=null,a.isAudioMuxedInVideo&&(a=
null,h.type===g.VIDEO?a=this.mediaStates_.get(g.AUDIO):h.type===g.AUDIO&&(a=this.mediaStates_.get(g.VIDEO)),a&&(this.abortOperations_(a).catch(function(){}),a.lastInitSegmentReference=null,a.lastAppendWindowStart=null,a.lastAppendWindowEnd=null,this.forceClearBuffer_(a),this.makeAbortDecision_(a).catch(function(k){f.playerInterface_&&(goog.asserts.assert(k instanceof shaka.util.Error,"Wrong error type!"),f.playerInterface_.onError(k))})))),b?h.clearingBuffer?h.waitingToFlushBuffer=!0:h.performingUpdate?
(h.waitingToClearBuffer=!0,h.clearBufferSafeMargin=c,h.waitingToFlushBuffer=!0):(this.cancelUpdate_(h),this.clearBuffer_(h,!0,c).catch(function(k){f.playerInterface_&&(goog.asserts.assert(k instanceof shaka.util.Error,"Wrong error type!"),f.playerInterface_.onError(k))})):h.performingUpdate||h.updateTimer||this.scheduleUpdate_(h,0),this.makeAbortDecision_(h).catch(function(k){f.playerInterface_&&(goog.asserts.assert(k instanceof shaka.util.Error,"Wrong error type!"),f.playerInterface_.onError(k))})):
(b=shaka.media.StreamingEngine.logPrefix_(h),shaka.log.debug("switch: Stream "+b+" already active")))):this.loadNewTextStream_(a)};
shaka.media.StreamingEngine.prototype.makeAbortDecision_=function(a){var b=this,c,d,e;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){if(f.getNextAddressJsc()==1){if(!a.operation)return f.return();c=a.stream;d=a.operation;return c.segmentIndex?f.jumpTo(2):f.yield(c.createSegmentIndex(),2)}if(f.getNextAddressJsc()!=4)return e=c.dependencyStream,!e||e.segmentIndex?f.jumpTo(4):f.yield(e.createSegmentIndex(),4);if(a.operation!=d||a.stream!=c)return f.return();goog.asserts.assert(a.stream.segmentIndex,
"Segment index should exist by now!");b.shouldAbortCurrentRequest_(a)&&(shaka.log.info("Aborting current segment request."),a.operation.abort());f.jumpToEnd()})};
shaka.media.StreamingEngine.prototype.shouldAbortCurrentRequest_=function(a){goog.asserts.assert(a.operation,"Abort logic requires an ongoing operation!");goog.asserts.assert(a.stream&&a.stream.segmentIndex,"Abort logic requires a segment index");var b=this.playerInterface_.getPresentationTime(),c=this.playerInterface_.mediaSourceEngine.bufferEnd(a.type),d=this.getTimeNeeded_(a,b);d=a.stream.segmentIndex.find(d);var e=d==null?null:a.stream.segmentIndex.get(d);d=e?e.getSize():null;e&&!d&&(d=(e.getEndTime()-
e.getStartTime())*(a.stream.bandwidth||this.currentVariant_.bandwidth)/8);if(!d)return!0;(e=e.initSegmentReference)&&(d+=e.getSize()||0);e=this.playerInterface_.getBandwidthEstimate();return d*8/e<(c||0)-b-this.config_.rebufferingGoal||a.operation.getBytesRemaining()>d?!0:!1};
shaka.media.StreamingEngine.prototype.seeked=function(){if(this.playerInterface_){for(var a=this.playerInterface_.getPresentationTime(),b=shaka.util.ManifestParserUtils.ContentType,c=!1,d=(0,$jscomp.makeIterator)(this.mediaStates_.keys()),e=d.next();!e.done;e=d.next()){e=e.value;var f=this.mediaStates_.get(e),g=shaka.media.StreamingEngine.logPrefix_(f);if(!this.crossBoundarySeek_&&!this.playerInterface_.mediaSourceEngine.isBuffered(e,a)){this.lastMediaSourceReset_=0;f.segmentPrefetch&&f.segmentPrefetch.resetPosition();
if(f.type===b.AUDIO)for(var h=(0,$jscomp.makeIterator)(this.audioPrefetchMap_.values()),k=h.next();!k.done;k=h.next())k.value.resetPosition();f.segmentIterator=null;if(this.playerInterface_.mediaSourceEngine.bufferEnd(e)!=null||f.performingUpdate)this.forceClearBuffer_(f),c=!0;f.operation&&(f.operation.abort(),shaka.log.debug(g,"Aborting operation due to seek"),f.operation=null);e===b.TEXT&&this.playerInterface_.mediaSourceEngine.resetCaptionParser();f.seeked=!0}!this.crossBoundarySeek_||f.clearingBuffer||
f.performingUpdate||f.updateTimer||this.scheduleUpdate_(f,0)}this.shouldUseCrossBoundaryLogic_()&&this.forwardTimeForCrossBoundary_();c||shaka.log.debug("(all): seeked: buffered seek: presentationTime="+a)}};
shaka.media.StreamingEngine.prototype.forceClearBuffer_=function(a){var b=this,c=shaka.media.StreamingEngine.logPrefix_(a);a.clearingBuffer?shaka.log.debug(c,"clear: already clearing the buffer"):a.waitingToClearBuffer?shaka.log.debug(c,"clear: already waiting"):a.performingUpdate?(shaka.log.debug(c,"clear: currently updating"),a.waitingToClearBuffer=!0,a.clearBufferSafeMargin=0):this.playerInterface_.mediaSourceEngine.bufferStart(a.type)==null?(shaka.log.debug(c,"clear: nothing buffered"),a.updateTimer==
null&&this.scheduleUpdate_(a,0)):(shaka.log.debug(c,"clear: handling right now"),this.cancelUpdate_(a),this.clearBuffer_(a,!1,0).catch(function(d){b.playerInterface_&&(goog.asserts.assert(d instanceof shaka.util.Error,"Wrong error type!"),b.playerInterface_.onError(d))}))};
shaka.media.StreamingEngine.prototype.initStreams_=function(a){var b=this,c,d,e,f,g,h,k,l;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(m){if(m.getNextAddressJsc()==1){goog.asserts.assert(b.config_,"StreamingEngine configure() must be called before init()!");if(!b.currentVariant_)throw shaka.log.error("init: no Streams chosen"),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.STREAMING,shaka.util.Error.Code.STREAMING_ENGINE_STARTUP_INVALID_STATE);
c=b.getStreamsByType_(!0);d=b.playerInterface_.mediaSourceEngine;return m.yield(d.init(c,b.manifest_.sequenceMode,b.manifest_.type,b.manifest_.ignoreManifestTimestampsInSegmentsMode),2)}b.destroyer_.ensureNotDestroyed();b.updateDuration();e=(0,$jscomp.makeIterator)(c.keys());for(f=e.next();!f.done;f=e.next())g=f.value,h=c.get(g),b.mediaStates_.has(g)||(k=b.createMediaState_(h),a.has(h.id)&&(l=a.get(h.id),l.replaceFetchDispatcher(function(n,p,q){return b.dispatchFetch_(n,p,q)}),k.segmentPrefetch=l),
b.mediaStates_.set(g,k),b.scheduleUpdate_(k,0));b.setupCrossBoundaryListeners_();m.jumpToEnd()})};
shaka.media.StreamingEngine.prototype.createMediaState_=function(a){var b={stream:a,type:a.type,segmentIterator:null,segmentPrefetch:this.createSegmentPrefetch_(a),lastSegmentReference:null,lastInitSegmentReference:null,lastTimestampOffset:null,lastAppendWindowStart:null,lastAppendWindowEnd:null,lastCodecs:null,lastMimeType:null,restoreStreamAfterTrickPlay:null,endOfStream:!1,performingUpdate:!1,updateTimer:null,waitingToClearBuffer:!1,clearBufferSafeMargin:0,waitingToFlushBuffer:!1,clearingBuffer:!1,
seeked:!0,adaptation:!1,recovering:!1,hasError:!1,operation:null,dependencyMediaState:null};a.dependencyStream&&(b.dependencyMediaState=this.createMediaState_(a.dependencyStream));return b};
shaka.media.StreamingEngine.prototype.createSegmentPrefetch_=function(a){var b=this,c=shaka.util.ManifestParserUtils.ContentType;if(a.type===c.VIDEO&&this.config_.disableVideoPrefetch||a.type===c.AUDIO&&this.config_.disableAudioPrefetch)return null;var d=shaka.util.MimeUtils,e=d.CEA608_CLOSED_CAPTION_MIMETYPE;d=d.CEA708_CLOSED_CAPTION_MIMETYPE;return a.type===c.TEXT&&(a.mimeType==e||a.mimeType==d)||a.type===c.TEXT&&this.config_.disableTextPrefetch?null:this.audioPrefetchMap_.has(a)?this.audioPrefetchMap_.get(a):
(c=(c=this.mediaStates_.get(a.type))&&c.segmentPrefetch)&&a===c.getStream()?c:this.config_.segmentPrefetchLimit>0?(c=this.playerInterface_.getPlaybackRate()<0,new shaka.media.SegmentPrefetch(this.config_.segmentPrefetchLimit,a,function(f,g,h){return b.dispatchFetch_(f,g,h)},c,this.playerInterface_.shouldPrefetchNextSegment)):null};
shaka.media.StreamingEngine.prototype.updatePrefetchMapForAudio_=function(){for(var a=this.config_.segmentPrefetchLimit,b=this.config_.prefetchAudioLanguages,c=shaka.util.LanguageUtils,d=(0,$jscomp.makeIterator)(this.manifest_.variants),e=d.next(),f={};!e.done;f={variant$jscomp$65:void 0},e=d.next())if(f.variant$jscomp$65=e.value,f.variant$jscomp$65.audio)if(this.audioPrefetchMap_.has(f.variant$jscomp$65.audio)){if(e=this.audioPrefetchMap_.get(f.variant$jscomp$65.audio),e.resetLimit(a),!(a>0&&b.some(function(h){return function(k){return c.areLanguageCompatible(h.variant$jscomp$65.audio.language,
k)}}(f)))){var g=this.mediaStates_.get(f.variant$jscomp$65.audio.type);e!==(g&&g.segmentPrefetch)&&e.clearAll();this.audioPrefetchMap_.delete(f.variant$jscomp$65.audio)}}else a<=0||!b.some(function(h){return function(k){return c.areLanguageCompatible(h.variant$jscomp$65.audio.language,k)}}(f))||!(e=this.createSegmentPrefetch_(f.variant$jscomp$65.audio))||(f.variant$jscomp$65.audio.segmentIndex||f.variant$jscomp$65.audio.createSegmentIndex(),this.audioPrefetchMap_.set(f.variant$jscomp$65.audio,e))};
shaka.media.StreamingEngine.prototype.updateDuration=function(){var a=shaka.media.Capabilities.isInfiniteLiveStreamDurationSupported(),b=this.manifest_.presentationTimeline.getDuration();b<Infinity?(a&&(this.updateLiveSeekableRangeTimer_&&this.updateLiveSeekableRangeTimer_.stop(),this.playerInterface_.mediaSourceEngine.clearLiveSeekableRange()),this.playerInterface_.mediaSourceEngine.setDuration(b)):a?(this.updateLiveSeekableRangeTimer_&&this.updateLiveSeekableRangeTimer_.tickEvery(.5),this.playerInterface_.mediaSourceEngine.setDuration(Infinity)):
this.playerInterface_.mediaSourceEngine.setDuration(4294967296)};
shaka.media.StreamingEngine.prototype.onUpdate_=function(a){var b=this,c,d,e,f,g,h,k,l,m,n,p;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(q){switch(q.getNextAddressJsc()){case 1:b.destroyer_.ensureNotDestroyed();c=shaka.util.ManifestParserUtils.ContentType;d=shaka.media.StreamingEngine.logPrefix_(a);goog.asserts.assert(!a.performingUpdate&&a.updateTimer!=null,d+" unexpected call to onUpdate_()");if(a.performingUpdate||a.updateTimer==null)return q.return();goog.asserts.assert(!a.clearingBuffer,
d+" onUpdate_() should not be called when clearing the buffer");if(a.clearingBuffer)return q.return();a.updateTimer=null;if(!a.waitingToClearBuffer){q.jumpTo(2);break}shaka.log.debug(d,"skipping update and clearing the buffer");return q.yield(b.clearBuffer_(a,a.waitingToFlushBuffer,a.clearBufferSafeMargin),3);case 3:return q.return();case 2:b.handleDeferredCloseSegmentIndexes_(a);if(a.stream.segmentIndex){q.jumpTo(4);break}e=a.stream;q.setCatchFinallyBlocks(5);return q.yield(a.stream.createSegmentIndex(),
7);case 7:q.leaveTryBlock(6);break;case 5:return f=q.enterCatchBlock(),q.yield(b.handleStreamingError_(a,f),8);case 8:return q.return();case 6:if(e!=a.stream)return e.closeSegmentIndex&&(goog.asserts.assert(!a.stream.segmentIndex,"mediaState.stream should not have segmentIndex yet."),e.closeSegmentIndex()),a.performingUpdate||a.updateTimer||b.scheduleUpdate_(a,0),q.return();case 4:if(!a.dependencyMediaState){q.jumpTo(9);break}if(a.dependencyMediaState.stream.segmentIndex){q.jumpTo(9);break}q.setCatchFinallyBlocks(11);
return q.yield(a.dependencyMediaState.stream.createSegmentIndex(),13);case 13:q.leaveTryBlock(9);break;case 11:g=q.enterCatchBlock(),shaka.log.warning("Could not create segment index for dependency",g);case 9:q.setCatchFinallyBlocks(14);h=b.update_(a);h!=null&&(b.scheduleUpdate_(a,h),a.hasError=!1);q.leaveTryBlock(15);break;case 14:return k=q.enterCatchBlock(),q.yield(b.handleStreamingError_(a,k),16);case 16:return q.return();case 15:if(a.type===c.TEXT)return q.return();l=[];a.stream&&!a.stream.isAudioMuxedInVideo&&
l.push(a);m=a.type===c.AUDIO?c.VIDEO:c.AUDIO;(n=b.mediaStates_.get(m))&&n.stream&&!n.stream.isAudioMuxedInVideo&&l.push(n);if(!b.startupComplete_||!l.every(function(r){return r.endOfStream})){q.jumpTo(0);break}shaka.log.v1(d,"calling endOfStream()...");return q.yield(b.playerInterface_.mediaSourceEngine.endOfStream(),18);case 18:b.destroyer_.ensureNotDestroyed(),p=b.playerInterface_.mediaSourceEngine.getDuration(),p!=0&&p<b.manifest_.presentationTimeline.getDuration()&&b.manifest_.presentationTimeline.setDuration(p),
q.jumpToEnd()}})};
shaka.media.StreamingEngine.prototype.update_=function(a){goog.asserts.assert(this.manifest_,"manifest_ should not be null");goog.asserts.assert(this.config_,"config_ should not be null");var b=shaka.util.ManifestParserUtils.ContentType;if(shaka.media.StreamingEngine.isEmbeddedText_(a))return this.playerInterface_.mediaSourceEngine.setSelectedClosedCaptionId(a.stream.originalId||""),null;a.type==b.TEXT&&this.playerInterface_.mediaSourceEngine.clearSelectedClosedCaptionId();if(a.stream.isAudioMuxedInVideo&&a.type==
b.AUDIO)return null;if(a.type!=b.TEXT&&this.playerInterface_.mediaSourceEngine.closed())return this.resetMediaSource(!0),null;var c=this.config_.updateIntervalSeconds/Math.max(1,Math.abs(this.playerInterface_.getPlaybackRate()));if(!this.playerInterface_.mediaSourceEngine.isStreamingAllowed()&&a.type!=b.TEXT)return c/2;var d=shaka.media.StreamingEngine.logPrefix_(a),e=this.playerInterface_.getPresentationTime();if(a.type===b.AUDIO)for(var f=(0,$jscomp.makeIterator)(this.audioPrefetchMap_.keys()),
g=f.next();!g.done;g=f.next())g=this.audioPrefetchMap_.get(g.value),g.evict(e,!0),g.prefetchSegmentsByTime(e);f=this.getTimeNeeded_(a,e);shaka.log.v2(d,"timeNeeded="+f);var h=this.playerInterface_.mediaSourceEngine.bufferedAheadOf(a.type,e);shaka.log.v2(d,"update_:","presentationTime="+e,"bufferedAhead="+h);g=Math.max(1,Math.max(this.config_.rebufferingGoal,this.config_.bufferingGoal)*this.bufferingScale_);var k=this.manifest_.presentationTimeline.getDuration()-f,l=this.playerInterface_.mediaSourceEngine.bufferEnd(a.type);
if(k<1E-6&&l)return shaka.log.debug(d,"buffered to end of presentation"),a.endOfStream=!0,a.type==b.VIDEO&&((c=this.mediaStates_.get(b.TEXT))&&shaka.media.StreamingEngine.isEmbeddedText_(c)&&(c.endOfStream=!0),(c=this.mediaStates_.get(b.AUDIO))&&c.stream.isAudioMuxedInVideo&&(c.endOfStream=!0)),null;a.endOfStream=!1;if(h>=g)return shaka.log.v2(d,"buffering goal met"),c/2;h=!a.segmentIterator;b=this.getSegmentReferenceNeeded_(a,e,l);if(!b)return d=Infinity,(a=a.lastSegmentReference)&&(d=a.endTime-
a.startTime),Math.min(d/2,c);l=a.lastInitSegmentReference;k=b.initSegmentReference;l&&k&&shaka.media.InitSegmentReference.equal(k,l)&&(l.boundaryEnd=k.boundaryEnd);l=!1;h&&a.adaptation&&(l=!0,a.adaptation=!1);h=Infinity;k=(0,$jscomp.makeIterator)(this.mediaStates_.values());for(var m=k.next();!m.done;m=k.next())m=m.value,shaka.media.StreamingEngine.isEmbeddedText_(m)||m.stream.isAudioMuxedInVideo||m.segmentIterator&&!m.segmentIterator.current()||(m=this.getTimeNeeded_(m,e),h=Math.min(h,m));k=this.manifest_.presentationTimeline.getMaxSegmentDuration()*
shaka.media.StreamingEngine.MAX_RUN_AHEAD_SEGMENTS_;if(f>=h+k)return shaka.log.v2(d,"waiting for other streams to buffer"),c;a.segmentPrefetch&&a.segmentIterator&&!this.audioPrefetchMap_.has(a.stream)&&(a.segmentPrefetch.evict(b.startTime+.001),a.segmentPrefetch.prefetchSegmentsByTime(b.startTime).catch(function(){}));if(this.shouldUseCrossBoundaryLogic_()&&this.discardReferenceByBoundary_(a,b))return null;this.fetchAndAppend_(a,e,b,l).catch(function(){});a.dependencyMediaState&&this.fetchAndAppendDependency_(a.dependencyMediaState,
e,g);return null};shaka.media.StreamingEngine.prototype.getTimeNeeded_=function(a,b){return a.lastSegmentReference?a.lastSegmentReference.endTime:b};
shaka.media.StreamingEngine.prototype.getSegmentReferenceNeeded_=function(a,b,c){var d=shaka.media.StreamingEngine.logPrefix_(a);goog.asserts.assert(a.stream.segmentIndex,"segment index should have been generated already");if(a.segmentIterator){if((d=a.segmentIterator.current())&&a.lastSegmentReference){b=shaka.util.NumberUtils;var e=a.lastSegmentReference.endTime;b.isFloatEqual(a.lastSegmentReference.startTime,d.startTime,.002)&&b.isFloatEqual(e,d.endTime,.002)&&(d=a.segmentIterator.next().value)}return d}if(a.lastSegmentReference||
c)return b=a.lastSegmentReference?a.lastSegmentReference.endTime:c,goog.asserts.assert(b!=null,"Should have a time to search"),shaka.log.v1(d,"looking up segment from new stream endTime:",b),e=this.playerInterface_.getPlaybackRate()<0,a.stream.segmentIndex&&(a.segmentIterator=a.stream.segmentIndex.getIteratorForTime(b,!1,e)),a=a.segmentIterator&&a.segmentIterator.next().value,a==null&&shaka.log.warning(d,"cannot find segment","endTime:",b),a;var f=this.manifest_.sequenceMode||this.shouldUseCrossBoundaryLogic_()?
0:this.config_.inaccurateManifestTolerance;c=Math.max(b-f,0);var g=this.playerInterface_.mediaSourceEngine.getDuration(),h=shaka.media.StreamingEngine.LOOKUP_TIME_DURATION_THRESHOLD_;Math.abs(c-g)<h&&(f=h,c=Math.max(b-f,0));shaka.log.v1(d,"looking up segment","lookupTime:",c,"presentationTime:",b);h=this.playerInterface_.getPlaybackRate()<0;g=null;f&&(a.stream.segmentIndex&&(a.segmentIterator=a.stream.segmentIndex.getIteratorForTime(c,!1,h)),g=a.segmentIterator&&a.segmentIterator.next().value);g||
(a.stream.segmentIndex&&(a.segmentIterator=a.stream.segmentIndex.getIteratorForTime(b,!1,h)),g=a.segmentIterator&&a.segmentIterator.next().value);for(;((e=g)==null?void 0:e.getStatus())===shaka.media.SegmentReference.Status.MISSING;)h=f=void 0,g=(h=(f=a.segmentIterator)==null?void 0:f.next().value)!=null?h:null;g==null&&shaka.log.warning(d,"cannot find segment","lookupTime:",c,"presentationTime:",b);return g};
shaka.media.StreamingEngine.prototype.fetchAndAppend_=function(a,b,c,d){var e=this,f,g,h,k,l,m,n,p,q,r,t,u,v,w,x,y,C,D,A,z,B;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(E){switch(E.getNextAddressJsc()){case 1:f=shaka.util.ManifestParserUtils.ContentType;g=shaka.media.StreamingEngine;h=g.logPrefix_(a);shaka.log.v1(h,"fetchAndAppend_:","presentationTime="+b,"reference.startTime="+c.startTime,"reference.endTime="+c.endTime);k=a.stream;l=a.segmentIterator;a.performingUpdate=!0;E.setCatchFinallyBlocks(2);
if(c.getStatus()==shaka.media.SegmentReference.Status.MISSING)throw new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.NETWORK,shaka.util.Error.Code.SEGMENT_MISSING);return E.yield(e.initSourceBuffer_(a,c,d),4);case 4:e.destroyer_.ensureNotDestroyed();if(e.fatalError_)return E.return();shaka.log.v2(h,"fetching segment");m=k.mimeType=="video/mp4"||k.mimeType=="audio/mp4";n=window.ReadableStream;if((p=e.config_.lowLatencyMode&&e.manifest_.isLowLatency)&&n&&m&&(e.manifest_.type!=
shaka.media.ManifestParser.HLS||c.hasByterangeOptimization()))return t=new Uint8Array(0),v=u=!1,x=function(H){var N,F,I,L;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(G){switch(G.getNextAddressJsc()){case 1:if(u)return G.return();v=!0;e.destroyer_.ensureNotDestroyed();if(e.fatalError_)return G.return();G.setCatchFinallyBlocks(2);t=shaka.util.Uint8ArrayUtils.concat(t,H);N=!1;F=0;(new shaka.util.Mp4Parser).box("mdat",function(M){F=M.size+M.start;N=!0}).parse(t,!1,!0);if(!N){G.jumpTo(4);
break}I=t.subarray(0,F);t=t.subarray(F);return G.yield(e.append_(a,b,k,c,I,!0,d),5);case 5:a.segmentPrefetch&&a.segmentIterator&&a.segmentPrefetch.prefetchSegmentsByTime(c.startTime,!0);case 4:G.leaveTryBlock(0);break;case 2:w=L=G.enterCatchBlock(),G.jumpToEnd()}})},E.yield(e.fetch_(a,c,x),9);p&&!n&&shaka.log.warning("Low latency streaming mode is enabled, but ReadableStream is not supported by the browser.");q=e.fetch_(a,c);return E.yield(q,7);case 7:r=E.getYieldResultJsc();e.destroyer_.ensureNotDestroyed();
if(e.fatalError_)return E.return();e.destroyer_.ensureNotDestroyed();return a.waitingToClearBuffer?(shaka.log.info(h,"waitingToClearBuffer, skip append"),a.performingUpdate=!1,e.scheduleUpdate_(a,0),E.return()):E.yield(e.append_(a,b,k,c,r,!1,d),6);case 9:y=E.getYieldResultJsc();if(w)throw w;if(v){E.jumpTo(10);break}u=!0;e.destroyer_.ensureNotDestroyed();return e.fatalError_?E.return():a.waitingToClearBuffer?(shaka.log.info(h,"waitingToClearBuffer, skip append"),a.performingUpdate=!1,e.scheduleUpdate_(a,
0),E.return()):E.yield(e.append_(a,b,k,c,y,!1,d),10);case 10:a.segmentPrefetch&&a.segmentIterator&&a.segmentPrefetch.prefetchSegmentsByTime(c.startTime,!0);case 6:e.destroyer_.ensureNotDestroyed();if(e.fatalError_)return E.return();a.lastSegmentReference=c;C=l.next().value;shaka.log.v2(h,"advancing to next segment",C);a.performingUpdate=!1;a.recovering=!1;D=e.playerInterface_.mediaSourceEngine.getBufferedInfo();A=D[a.type];shaka.log.v1(h,"finished fetch and append",JSON.stringify(A));if(!a.waitingToClearBuffer)if(z=
null,a.type===f.VIDEO?z=e.mediaStates_.get(f.AUDIO):a.type===f.AUDIO&&(z=e.mediaStates_.get(f.VIDEO)),z&&z.type==f.AUDIO)e.playerInterface_.onSegmentAppended(c,a.stream,z.stream.isAudioMuxedInVideo,!1);else e.playerInterface_.onSegmentAppended(c,a.stream,a.stream.codecs.includes(","),!1);e.cancelUpdate_(a);e.scheduleUpdate_(a,0);E.leaveTryBlock(0);break;case 2:B=E.enterCatchBlock();e.destroyer_.ensureNotDestroyed(B);if(e.fatalError_)return E.return();goog.asserts.assert(B instanceof shaka.util.Error,
"Should only receive a Shaka error");a.performingUpdate=!1;if(B.code==shaka.util.Error.Code.OPERATION_ABORTED)a.performingUpdate=!1,e.cancelUpdate_(a),e.scheduleUpdate_(a,0),E.jumpTo(0);else if(a.type==f.TEXT&&e.config_.ignoreTextStreamFailures)B.code==shaka.util.Error.Code.BAD_HTTP_STATUS?shaka.log.warning(h,"Text stream failed to download. Proceeding without it."):shaka.log.warning(h,"Text stream failed to parse. Proceeding without it."),e.mediaStates_.delete(f.TEXT),E.jumpTo(0);else{if(B.code==
shaka.util.Error.Code.QUOTA_EXCEEDED_ERROR)return E.yield(e.handleQuotaExceeded_(a,B),0);shaka.log.error(h,"failed fetch and append: code="+B.code);a.hasError=!0;B.category==shaka.util.Error.Category.NETWORK&&a.segmentPrefetch&&a.segmentPrefetch.removeReference(c);B.severity=shaka.util.Error.Severity.CRITICAL;return E.yield(e.handleStreamingError_(a,B),0)}}})};
shaka.media.StreamingEngine.prototype.fetchAndAppendDependency_=function(a,b,c){var d=this,e,f,g,h,k,l,m,n,p,q,r,t,u;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(v){switch(v.getNextAddressJsc()){case 1:e=shaka.util.ManifestParserUtils.ContentType;f=a.stream;for(k=(h=(g=f.segmentIndex)&&g.getIteratorForTime(b))&&h.next().value;k&&d.requestedDependencySegments_.includes(k.startTime);)k=h&&h.next().value;if(!k){v.jumpTo(0);break}l=k.initSegmentReference;if(!l||shaka.media.InitSegmentReference.equal(l,
a.lastInitSegmentReference)){v.jumpTo(3);break}a.lastInitSegmentReference=l;v.setCatchFinallyBlocks(4);return v.yield(d.fetch_(a,l),6);case 6:m=v.getYieldResultJsc();if(!d.playerInterface_)return v.return();d.playerInterface_.mediaSourceEngine.appendDependency(m,0,f);d.requestedDependencySegments_=[];v.leaveTryBlock(3);break;case 4:throw n=v.enterCatchBlock(),a.lastInitSegmentReference=null,n;case 3:if(a.lastSegmentReference&&a.lastSegmentReference==k){v.jumpTo(0);break}a.lastSegmentReference=k;v.setCatchFinallyBlocks(8);
return v.yield(d.fetch_(a,k),10);case 10:p=v.getYieldResultJsc();if(!d.playerInterface_)return v.return();d.playerInterface_.mediaSourceEngine.appendDependency(p,0,f);d.requestedDependencySegments_.push(k.startTime);v.leaveTryBlock(9);break;case 8:throw q=v.enterCatchBlock(),a.lastSegmentReference=null,q;case 9:if(!d.playerInterface_)return v.return();if(!a.waitingToClearBuffer)if(r=null,a.type===e.VIDEO?r=d.mediaStates_.get(e.AUDIO):a.type===e.AUDIO&&(r=d.mediaStates_.get(e.VIDEO)),r&&r.type==e.AUDIO)d.playerInterface_.onSegmentAppended(k,
a.stream,r.stream.isAudioMuxedInVideo,!0);else d.playerInterface_.onSegmentAppended(k,a.stream,a.stream.codecs.includes(","),!0);t=Math.max.apply(Math,[0].concat((0,$jscomp.arrayFromIterable)(d.requestedDependencySegments_)));u=d.playerInterface_.getPresentationTime();if(u+c>t)return v.yield(d.fetchAndAppendDependency_(a,k.startTime,c),0);v.jumpTo(0)}})};
shaka.media.StreamingEngine.prototype.retry=function(a){if(this.destroyer_.destroyed())return shaka.log.error("Unable to retry after StreamingEngine is destroyed!"),!1;if(this.fatalError_)return shaka.log.error("Unable to retry after StreamingEngine encountered a fatal error!"),!1;for(var b=(0,$jscomp.makeIterator)(this.mediaStates_.values()),c=b.next();!c.done;c=b.next()){c=c.value;var d=shaka.media.StreamingEngine.logPrefix_(c);!c.hasError||c.performingUpdate||c.updateTimer||(shaka.log.info(d,"Retrying after failure..."),
c.hasError=!1,this.scheduleUpdate_(c,a))}return!0};
shaka.media.StreamingEngine.prototype.handleQuotaExceeded_=function(a,b){var c=this,d,e,f,g,h,k,l,m,n,p,q,r,t;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(u){switch(u.getNextAddressJsc()){case 1:d=shaka.media.StreamingEngine.logPrefix_(a);e=!1;f=(0,$jscomp.makeIterator)(c.mediaStates_.values());for(g=f.next();!g.done;g=f.next())if(h=g.value,h!=a&&h.recovering){e=!0;break}if(e){shaka.log.debug(d,"MediaSource threw QuotaExceededError:","waiting for another stream to recover...");u.jumpTo(2);
break}if(c.config_.avoidEvictionOnQuotaExceededError){(k=c.getDisabledTime_(b))&&shaka.log.debug(d,"Disabling stream due to quota",b);if(l=c.playerInterface_.disableStream(a.stream,k))return u.return();c.scheduleUpdate_(a,4);return u.return()}m=Math.round(100*c.bufferingScale_);if(m>20){c.bufferingScale_-=.2;u.jumpTo(3);break}if(m>4){c.bufferingScale_-=.04;u.jumpTo(3);break}(n=c.getDisabledTime_(b))&&shaka.log.debug(d,"Disabling stream due to quota",b);p=c.playerInterface_.disableStream(a.stream,
n);if(!p){shaka.log.error(d,"MediaSource threw QuotaExceededError too many times");a.hasError=!0;c.fatalError_=!0;c.playerInterface_.onError(b);u.jumpTo(5);break}c.bufferingScale_=1;q=c.playerInterface_.getPresentationTime();return u.yield(c.evict_(a,q),5);case 5:return u.return();case 3:return r=Math.round(100*c.bufferingScale_),shaka.log.warning(d,"MediaSource threw QuotaExceededError:","reducing buffering goals by "+(100-r)+"%"),a.recovering=!0,t=c.playerInterface_.getPresentationTime(),u.yield(c.evict_(a,
t),2);case 2:c.scheduleUpdate_(a,4),u.jumpToEnd()}})};
shaka.media.StreamingEngine.prototype.initSourceBuffer_=function(a,b,c){var d=this,e,f,g,h,k,l,m,n,p,q,r,t,u,v,w,x,y,C,D;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(A){switch(A.getNextAddressJsc()){case 1:e=shaka.util.ManifestParserUtils.ContentType;f=shaka.util.MimeUtils;g=shaka.media.StreamingEngine;h=g.logPrefix_(a);k=a.lastSegmentReference==null;l=[];m=Math.max(0,Math.max(b.appendWindowStart,d.playRangeStart_)-g.APPEND_WINDOW_START_FUDGE_);n=Math.min(b.appendWindowEnd,d.playRangeEnd_)+
g.APPEND_WINDOW_END_FUDGE_;goog.asserts.assert(b.startTime<=n,h+" segment should start before append window end");p=b.codecs||a.stream.codecs;q=f.getCodecBase(p);r=f.getBasicType(b.mimeType||a.stream.mimeType);t=b.timestampOffset;if(t==a.lastTimestampOffset&&m==a.lastAppendWindowStart&&n==a.lastAppendWindowEnd&&q==a.lastCodecs&&r==a.lastMimeType){A.jumpTo(2);break}shaka.log.v1(h,"setting timestamp offset to "+t);shaka.log.v1(h,"setting append window start to "+m);shaka.log.v1(h,"setting append window end to "+
n);u=a.lastCodecs&&a.lastMimeType&&d.playerInterface_.mediaSourceEngine.isResetMediaSourceNecessary(a.type,r,p,d.getStreamsByType_());if(!u){A.jumpTo(3);break}v=null;a.type===e.VIDEO?v=d.mediaStates_.get(e.AUDIO):a.type===e.AUDIO&&(v=d.mediaStates_.get(e.VIDEO));if(!v){A.jumpTo(3);break}return A.yield(d.abortOperations_(v).catch(function(){}),5);case 5:v.lastInitSegmentReference=null,v.lastAppendWindowStart=null,v.lastAppendWindowEnd=null,d.forceClearBuffer_(v);case 3:return A.yield(d.setProperties_(a,
t,m,n,b,q,r),2);case 2:return shaka.media.InitSegmentReference.equal(b.initSegmentReference,a.lastInitSegmentReference)||(a.lastInitSegmentReference=b.initSegmentReference,b.isIndependent()&&b.initSegmentReference&&(shaka.log.v1(h,"fetching init segment"),w=d.fetch_(a,b.initSegmentReference),x=function(){var z,B,E,H,N,F,I,L,G,M,J,O,P;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(Q){switch(Q.getNextAddressJsc()){case 1:return Q.setCatchFinallyBlocks(2),Q.yield(w,4);case 4:return z=
Q.getYieldResultJsc(),d.destroyer_.ensureNotDestroyed(),B=null,E=new Map,H={projection:null,hfov:null},a.stream&&(N=a.stream.videoLayout)&&(F=N.split("/"),F.includes("PROJ-RECT")?H.projection="rect":F.includes("PROJ-EQUI")?H.projection="equi":F.includes("PROJ-HEQU")?H.projection="hequ":F.includes("PROJ-PRIM")?H.projection="prim":F.includes("PROJ-AIV")&&(H.projection="hequ")),I=new shaka.util.Mp4Parser,L=shaka.util.Mp4Parser,G=shaka.util.Mp4BoxParsers,I.box("moov",L.children).box("trak",L.children).box("mdia",
L.children).fullBox("mdhd",function(K){goog.asserts.assert(K.version!=null,"MDHD is a full box and should have a valid version.");B=G.parseMDHD(K.reader,K.version).timescale}).fullBox("hdlr",function(K){goog.asserts.assert(K.version!=null,"HDLR is a full box and should have a valid version.");switch(G.parseHDLR(K.reader).handlerType){case "soun":E.set(e.AUDIO,B);break;case "vide":E.set(e.VIDEO,B)}B=null}),a.type!==e.VIDEO||H.projection||I.box("minf",L.children).box("stbl",L.children).fullBox("stsd",
L.sampleDescription).boxes("encv avc1 avc3 hev1 hvc1 dvav dva1 dvh1 dvhe dvc1 dvi1".split(" "),L.visualSampleEntry).box("vexu",L.children).box("proj",L.children).fullBox("prji",function(K){K=G.parsePRJI(K.reader);H.projection=K.projection}).box("hfov",function(K){K=G.parseHFOV(K.reader);H.hfov=K.hfov}),I.parse(z,!0,!0),a.type===e.VIDEO&&d.updateSpatialVideoInfo_(H),E.has(a.type)?b.initSegmentReference.timescale=E.get(a.type):B!=null&&(b.initSegmentReference.timescale=B),M=a.stream.segmentIndex,M instanceof
shaka.media.MetaSegmentIndex&&(J=M.getTimelineForTime(b.startTime)),shaka.log.v1(h,"appending init segment"),O=a.stream.closedCaptions&&a.stream.closedCaptions.size>0,Q.yield(d.playerInterface_.beforeAppendSegment(a.type,z),5);case 5:return Q.yield(d.playerInterface_.mediaSourceEngine.appendBuffer(a.type,z,null,a.stream,O,a.seeked,c,!1,!1,J),6);case 6:Q.leaveTryBlock(0);break;case 2:throw P=Q.enterCatchBlock(),a.lastInitSegmentReference=null,P;}})},y=b.startTime,k&&(C=d.playerInterface_.mediaSourceEngine.bufferEnd(a.type),
C!=null&&(y=C)),d.playerInterface_.onInitSegmentAppended(y,b.initSegmentReference),l.push(x()))),D=a.lastSegmentReference?a.lastSegmentReference.discontinuitySequence:-1,b.discontinuitySequence!=D&&l.push(d.playerInterface_.mediaSourceEngine.resync(a.type,b.startTime)),A.yield(Promise.all(l),0)}})};
shaka.media.StreamingEngine.prototype.setProperties_=function(a,b,c,d,e,f,g){var h=this,k,l,m,n,p;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(q){switch(q.getNextAddressJsc()){case 1:k=shaka.util.ManifestParserUtils.ContentType;l=h.getStreamsByType_();q.setCatchFinallyBlocks(2);a.lastAppendWindowStart=c;a.lastAppendWindowEnd=d;f&&(a.lastCodecs=f);g&&(a.lastMimeType=g);a.lastTimestampOffset=b;m=h.manifest_.sequenceMode||h.manifest_.type==shaka.media.ManifestParser.HLS;n=null;a.type===
k.VIDEO?n=h.mediaStates_.get(k.AUDIO):a.type===k.AUDIO&&(n=h.mediaStates_.get(k.VIDEO));if(!(n&&n.stream&&n.stream.isAudioMuxedInVideo)){q.jumpTo(4);break}return q.yield(h.playerInterface_.mediaSourceEngine.setStreamProperties(n.type,b,c,d,m,n.stream.mimeType,n.stream.codecs,l),4);case 4:return q.yield(h.playerInterface_.mediaSourceEngine.setStreamProperties(a.type,b,c,d,m,e.mimeType||a.stream.mimeType,e.codecs||a.stream.codecs,l),6);case 6:q.leaveTryBlock(0);break;case 2:throw p=q.enterCatchBlock(),
a.lastAppendWindowStart=null,a.lastAppendWindowEnd=null,a.lastCodecs=null,a.lastMimeType=null,a.lastTimestampOffset=null,p;}})};
shaka.media.StreamingEngine.prototype.append_=function(a,b,c,d,e,f,g){f=f===void 0?!1:f;g=g===void 0?!1:g;var h=this,k,l,m,n,p,q;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(r){switch(r.getNextAddressJsc()){case 1:return k=shaka.media.StreamingEngine.logPrefix_(a),l=c.closedCaptions&&c.closedCaptions.size>0,h.config_.shouldFixTimestampOffset&&(m=c.mimeType=="video/mp4"||c.mimeType=="audio/mp4",n=null,d.initSegmentReference&&(n=d.initSegmentReference.timescale),(p=m&&n&&c.type===
shaka.util.ManifestParserUtils.ContentType.VIDEO&&h.manifest_.type==shaka.media.ManifestParser.DASH)&&(new shaka.util.Mp4Parser).box("moof",shaka.util.Mp4Parser.children).box("traf",shaka.util.Mp4Parser.children).fullBox("tfdt",function(t){var u,v,w,x,y,C;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(D){goog.asserts.assert(t.version!=null,"TFDT is a full box and should have a valid version.");u=shaka.util.Mp4BoxParsers.parseTFDTInaccurate(t.reader,t.version);v=u.baseMediaDecodeTime;
if(!v)return D.return();goog.asserts.assert(typeof n=="number","Should be an number!");w=-v/n;x=Number(a.lastTimestampOffset)||0;if(!(x<w))return D.jumpTo(0);y=a.lastAppendWindowStart;C=a.lastAppendWindowEnd;goog.asserts.assert(typeof y=="number","Should be an number!");goog.asserts.assert(typeof C=="number","Should be an number!");return D.yield(h.setProperties_(a,w,y,C,d),0)})}).parse(e,!1,f)),r.yield(h.evict_(a,b),2);case 2:return h.destroyer_.ensureNotDestroyed(),q=a.seeked,a.seeked=!1,r.yield(h.playerInterface_.beforeAppendSegment(a.type,
e),3);case 3:return r.yield(h.playerInterface_.mediaSourceEngine.appendBuffer(a.type,e,d,c,l,q,g,f),4);case 4:h.destroyer_.ensureNotDestroyed(),shaka.log.v2(k,"appended media segment"),r.jumpToEnd()}})};
shaka.media.StreamingEngine.prototype.evict_=function(a,b){var c=this,d,e,f,g,h,k,l,m,n,p;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(q){if(q.getNextAddressJsc()==1){c.lastTextMediaStateBeforeUnload_==a&&(c.lastTextMediaStateBeforeUnload_=null);d=a.stream.segmentIndex;d instanceof shaka.media.MetaSegmentIndex&&(d.evict(c.manifest_.presentationTimeline.getSegmentAvailabilityStart()),e=[],d.forEachIndex(function(r){e.push(r.continuityTimeline())}));f=shaka.media.StreamingEngine.logPrefix_(a);
shaka.log.v2(f,"checking buffer length");g=Math.max(c.config_.bufferBehind*c.bufferingScale_,c.manifest_.presentationTimeline.getMaxSegmentDuration());h=c.playerInterface_.mediaSourceEngine.bufferStart(a.type);if(h==null)return shaka.log.v2(f,"buffer behind okay because nothing buffered:","presentationTime="+b,"bufferBehind="+g),q.return();k=b-h;l=c.config_.evictionGoal;m=c.manifest_.presentationTimeline.getSeekRangeStart();n=c.manifest_.presentationTimeline.getSeekRangeEnd();p=k-g;n-m>l&&(p=Math.max(k-
g,m-l-h));if(p<=l)return shaka.log.v2(f,"buffer behind okay:","presentationTime="+b,"bufferedBehind="+k,"bufferBehind="+g,"evictionGoal="+l,"underflow="+Math.abs(p)),q.return();shaka.log.v1(f,"buffer behind too large:","presentationTime="+b,"bufferedBehind="+k,"bufferBehind="+g,"evictionGoal="+l,"overflow="+p);return q.yield(c.playerInterface_.mediaSourceEngine.remove(a.type,h,h+p,e),2)}if(q.getNextAddressJsc()!=4)return c.destroyer_.ensureNotDestroyed(),shaka.log.v1(f,"evicted "+p+" seconds"),c.lastTextMediaStateBeforeUnload_?
q.yield(c.evict_(c.lastTextMediaStateBeforeUnload_,b),4):q.jumpTo(0);c.destroyer_.ensureNotDestroyed();q.jumpToEnd()})};shaka.media.StreamingEngine.isEmbeddedText_=function(a){var b=shaka.util.MimeUtils,c=b.CEA608_CLOSED_CAPTION_MIMETYPE;b=b.CEA708_CLOSED_CAPTION_MIMETYPE;return a&&a.type==shaka.util.ManifestParserUtils.ContentType.TEXT&&(a.stream.mimeType==c||a.stream.mimeType==b)};
shaka.media.StreamingEngine.prototype.fetch_=function(a,b,c){var d=this,e,f,g,h,k;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(l){switch(l.getNextAddressJsc()){case 1:if(e=b.getSegmentData())return l.return(e);f=null;a.segmentPrefetch&&(f=a.segmentPrefetch.getPrefetchedSegment(b,c));f||(f=d.dispatchFetch_(b,a.stream,c));g=0;a.segmentIterator&&(g=a.segmentIterator.currentPosition());a.operation=f;return l.yield(f.promise,2);case 2:h=l.getYieldResultJsc();a.operation=null;k=h.data;
if(!b.aesKey){l.jumpTo(3);break}return l.yield(shaka.media.SegmentUtils.aesDecrypt(k,b.aesKey,g),4);case 4:k=l.getYieldResultJsc();case 3:return l.return(k)}})};shaka.media.StreamingEngine.prototype.dispatchFetch_=function(a,b,c,d){goog.asserts.assert(this.playerInterface_.netEngine,"Must have net engine");return shaka.media.StreamingEngine.dispatchFetch(a,b,c||null,this.config_.retryParameters,this.playerInterface_.netEngine)};
shaka.media.StreamingEngine.dispatchFetch=function(a,b,c,d,e,f){f=f===void 0?!1:f;var g=shaka.net.NetworkingEngine.RequestType.SEGMENT,h=a instanceof shaka.media.SegmentReference?a:void 0,k=h?shaka.net.NetworkingEngine.AdvancedRequestType.MEDIA_SEGMENT:shaka.net.NetworkingEngine.AdvancedRequestType.INIT_SEGMENT;c=shaka.net.NetworkingUtils.createSegmentRequest(a.getUris(),a.startByte,a.endByte,d,c);c.contentType=b.type;shaka.log.v2("fetching: reference=",a);return e.request(g,c,{type:k,stream:b,segment:h,
isPreload:f})};
shaka.media.StreamingEngine.prototype.clearBuffer_=function(a,b,c){var d=this,e,f,g;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(h){if(h.getNextAddressJsc()==1)return e=shaka.media.StreamingEngine.logPrefix_(a),goog.asserts.assert(!a.performingUpdate&&a.updateTimer==null,e+" unexpected call to clearBuffer_()"),a.waitingToClearBuffer=!1,a.waitingToFlushBuffer=!1,a.clearBufferSafeMargin=0,a.clearingBuffer=!0,a.lastSegmentReference=null,a.segmentIterator=null,shaka.log.debug(e,"clearing buffer"),
a.segmentPrefetch&&!d.audioPrefetchMap_.has(a.stream)&&a.segmentPrefetch.clearAll(),c?(f=d.playerInterface_.getPresentationTime(),g=d.playerInterface_.mediaSourceEngine.getDuration(),h.yield(d.playerInterface_.mediaSourceEngine.remove(a.type,f+c,g),3)):h.yield(d.playerInterface_.mediaSourceEngine.clear(a.type),4);if(h.getNextAddressJsc()!=3)return d.destroyer_.ensureNotDestroyed(),b?h.yield(d.playerInterface_.mediaSourceEngine.flush(a.type),3):h.jumpTo(3);d.destroyer_.ensureNotDestroyed();shaka.log.debug(e,
"cleared buffer");a.clearingBuffer=!1;a.endOfStream=!1;a.performingUpdate||a.updateTimer||d.scheduleUpdate_(a,0);h.jumpToEnd()})};
shaka.media.StreamingEngine.prototype.scheduleUpdate_=function(a,b){var c=this,d=shaka.media.StreamingEngine.logPrefix_(a),e=a.type;e!=shaka.util.ManifestParserUtils.ContentType.TEXT||this.mediaStates_.has(e)?(shaka.log.v2(d,"updating in "+b+" seconds"),goog.asserts.assert(a.updateTimer==null,d+" did not expect update to be scheduled"),a.updateTimer=(new shaka.util.Timer(function(){var f;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(g){if(g.getNextAddressJsc()==1)return g.setCatchFinallyBlocks(2),
g.yield(c.onUpdate_(a),4);if(g.getNextAddressJsc()!=2)return g.leaveTryBlock(0);f=g.enterCatchBlock();if(c.playerInterface_)c.playerInterface_.onError(f);g.jumpToEnd()})})).tickAfter(b)):shaka.log.v1(d,"Text stream is unloaded. No update is needed.")};shaka.media.StreamingEngine.prototype.cancelUpdate_=function(a){a.updateTimer!=null&&(a.updateTimer.stop(),a.updateTimer=null)};
shaka.media.StreamingEngine.prototype.abortOperations_=function(a){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(b){return a.operation?b.yield(a.operation.abort(),0):b.jumpTo(0)})};
shaka.media.StreamingEngine.prototype.handleStreamingError_=function(a,b){var c=this,d,e,f,g,h,k;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(l){switch(l.getNextAddressJsc()){case 1:return d=shaka.media.StreamingEngine.logPrefix_(a),b.code==shaka.util.Error.Code.STREAMING_NOT_ALLOWED?(a.performingUpdate=!1,c.cancelUpdate_(a),c.scheduleUpdate_(a,0),l.return()):l.yield(c.failureCallbackBackoff_.attempt(),2);case 2:c.destroyer_.ensureNotDestroyed();if(b.category===shaka.util.Error.Category.NETWORK&&
b.code!=shaka.util.Error.Code.TIMEOUT){if(a.restoreStreamAfterTrickPlay)return c.setTrickPlay(!1),l.return();(e=c.getDisabledTime_(b))&&shaka.log.debug(d,"Disabling stream due to error",b);b.handled=c.playerInterface_.disableStream(a.stream,e);b.handled&&(b.severity=shaka.util.Error.Severity.RECOVERABLE)}if(b.handled||b.code!=shaka.util.Error.Code.SEGMENT_MISSING){l.jumpTo(3);break}f=c.playerInterface_.getPresentationTime();g=c.playerInterface_.mediaSourceEngine.bufferEnd(a.type);for(h=c.getSegmentReferenceNeeded_(a,
f,g);((k=h)==null?void 0:k.getStatus())===shaka.media.SegmentReference.Status.MISSING;)a.lastSegmentReference=h,h=c.getSegmentReferenceNeeded_(a,f,g);if(!h){l.jumpTo(3);break}return l.yield(c.playerInterface_.mediaSourceEngine.resync(a.type,h.startTime),5);case 5:return a.performingUpdate=!1,a.hasError=!1,c.cancelUpdate_(a),c.scheduleUpdate_(a,0),l.return();case 3:if(!b.handled||b.code!=shaka.util.Error.Code.SEGMENT_MISSING)c.playerInterface_.onError(b);b.handled||c.config_.failureCallback(b);l.jumpToEnd()}})};
shaka.media.StreamingEngine.prototype.getDisabledTime_=function(a){return this.config_.maxDisabledTime===0&&a.code==shaka.util.Error.Code.SEGMENT_MISSING?1:this.config_.maxDisabledTime};
shaka.media.StreamingEngine.prototype.resetMediaSource=function(a,b){a=a===void 0?!1:a;var c=this,d,e,f,g,h,k;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(l){if(l.getNextAddressJsc()==1){d=Date.now()/1E3;e=c.config_.minTimeBetweenRecoveries;if(!a&&(!c.config_.allowMediaSourceRecoveries||d-c.lastMediaSourceReset_<e))return l.return(!1);c.lastMediaSourceReset_=d;f=shaka.util.ManifestParserUtils.ContentType;if(g=c.mediaStates_.get(f.AUDIO))c.cancelUpdate_(g),g.operation&&(g.operation.abort(),
g.operation=null),g.lastInitSegmentReference=null,g.lastAppendWindowStart=null,g.lastAppendWindowEnd=null,g.lastInitSegmentReference=null,g.lastAppendWindowStart=null,g.lastAppendWindowEnd=null,g.performingUpdate=!1,g.waitingToClearBuffer=!1,g.clearBufferSafeMargin=0,g.waitingToFlushBuffer=!1,g.clearingBuffer=!1,g.segmentIterator&&g.segmentIterator.resetToLastIndependent();if(h=c.mediaStates_.get(f.VIDEO))c.cancelUpdate_(h),h.operation&&(h.operation.abort(),h.operation=null),h.lastInitSegmentReference=
null,h.lastAppendWindowStart=null,h.lastAppendWindowEnd=null,h.performingUpdate=!1,h.waitingToClearBuffer=!1,h.clearBufferSafeMargin=0,h.waitingToFlushBuffer=!1,h.clearingBuffer=!1,h.segmentIterator&&h.segmentIterator.resetToLastIndependent();k=c.playerInterface_.video.paused;return l.yield(c.playerInterface_.mediaSourceEngine.reset(c.getStreamsByType_()),2)}!h||h.clearingBuffer||h.performingUpdate||h.updateTimer||c.scheduleUpdate_(h,0);!g||g.clearingBuffer||g.performingUpdate||g.updateTimer||c.scheduleUpdate_(g,
0);k||c.playerInterface_.video.play();return l.return(!0)})};
shaka.media.StreamingEngine.prototype.updateSpatialVideoInfo_=function(a){if(this.spatialVideoInfo_.projection!=a.projection||this.spatialVideoInfo_.hfov!=a.hfov){var b=shaka.util.FakeEvent.EventName;if(a.projection!=null||a.hfov!=null){b=b.SpatialVideoInfoEvent;var c=(new Map).set("detail",a);b=new shaka.util.FakeEvent(b,c)}else b=new shaka.util.FakeEvent(b.NoSpatialVideoInfoEvent);b.cancelable=!0;this.playerInterface_.onEvent(b);this.spatialVideoInfo_=a}};
shaka.media.StreamingEngine.prototype.updateSegmentIteratorReverse_=function(){for(var a=this.playerInterface_.getPlaybackRate()<0,b=(0,$jscomp.makeIterator)(this.mediaStates_.values()),c=b.next();!c.done;c=b.next())c=c.value,c.segmentIterator&&c.segmentIterator.setReverse(a),c.segmentPrefetch&&c.segmentPrefetch.setReverse(a);b=(0,$jscomp.makeIterator)(this.audioPrefetchMap_.values());for(c=b.next();!c.done;c=b.next())c.value.setReverse(a)};
shaka.media.StreamingEngine.prototype.shouldUseCrossBoundaryLogic_=function(){if(this.config_.crossBoundaryStrategy!==shaka.config.CrossBoundaryStrategy.KEEP)return!0;var a=shaka.device.DeviceFactory.getDevice();if(!a.supportsSmoothCodecSwitching()){a=(0,$jscomp.makeIterator)(this.mediaStates_.keys());for(var b=a.next();!b.done;b=a.next())if(b=this.mediaStates_.get(b.value),b.type!==shaka.util.ManifestParserUtils.ContentType.TEXT&&(b=b.stream)&&b.fullMimeTypes&&b.fullMimeTypes.size>1)return!0}else if(!a.supportsContainerChangeType())for(a=
(0,$jscomp.makeIterator)(this.mediaStates_.keys()),b=a.next();!b.done;b=a.next())if(b=this.mediaStates_.get(b.value),b.type!==shaka.util.ManifestParserUtils.ContentType.TEXT&&(b=b.stream)&&b.fullMimeTypes&&b.fullMimeTypes.size>1){a=new Set;b=(0,$jscomp.makeIterator)(b.fullMimeTypes);for(var c=b.next();!c.done;c=b.next())a.add(shaka.util.MimeUtils.getContainerType(c.value));return a.size>1}return!1};
shaka.media.StreamingEngine.prototype.setupCrossBoundaryListeners_=function(){var a=this;this.crossBoundaryEventManager_.removeAll();this.shouldUseCrossBoundaryLogic_()&&(this.crossBoundaryEventManager_.listen(this.playerInterface_.video,"waiting",function(){return a.forwardTimeForCrossBoundary_()}),this.crossBoundaryEventManager_.listen(this.playerInterface_.video,"timeupdate",function(){return a.forwardTimeForCrossBoundary_()}))};
shaka.media.StreamingEngine.prototype.forwardTimeForCrossBoundary_=function(){if(this.shouldUseCrossBoundaryLogic_()){this.crossBoundaryTimer_.stop();var a=this.playerInterface_.getPresentationTime(),b=shaka.util.ManifestParserUtils.ContentType;if((b=this.mediaStates_.get(b.VIDEO)||this.mediaStates_.get(b.AUDIO))&&(b=b.lastInitSegmentReference)&&b.boundaryEnd!==null){var c=shaka.media.StreamingEngine.CROSS_BOUNDARY_END_THRESHOLD_;a=b.boundaryEnd-a;a<0||a>c||(this.boundaryTime_=b.boundaryEnd+shaka.media.StreamingEngine.APPEND_WINDOW_END_FUDGE_,
this.crossBoundaryTimer_.tickAfter(a))}}};
shaka.media.StreamingEngine.prototype.discardReferenceByBoundary_=function(a,b){var c=this,d=shaka.util.ManifestParserUtils.ContentType;if(a.type===d.TEXT)return!1;var e=a.lastInitSegmentReference;if(!e)return!1;var f=shaka.config.CrossBoundaryStrategy,g=shaka.media.StreamingEngine.logPrefix_(a),h=b.initSegmentReference,k=e.boundaryEnd!==h.boundaryEnd;this.config_.crossBoundaryStrategy===f.RESET_TO_ENCRYPTED&&(e.encrypted||h.encrypted||(k=!1),e.encrypted&&(shaka.log.debug(g,"stream is encrypted, discard crossBoundaryStrategy"),
this.config_.crossBoundaryStrategy=f.KEEP));this.config_.crossBoundaryStrategy===f.RESET_ON_ENCRYPTION_CHANGE&&e.encrypted==h.encrypted&&(k=!1);if(this.config_.crossBoundaryStrategy===f.KEEP&&e.mimeType&&h.mimeType){var l=shaka.util.MimeUtils;f=l.getNormalizedCodec(l.getCodecs(e.mimeType));l=l.getNormalizedCodec(l.getCodecs(h.mimeType));e.mimeType==h.mimeType&&f==l&&(k=!1)}(this.mediaStates_.get(d.VIDEO)||this.mediaStates_.get(d.AUDIO))===a&&k&&(this.crossBoundarySeek_||a.seeked)&&(shaka.log.debug(g,
"reset mediaSource","from=",a.lastInitSegmentReference,"to=",b.initSegmentReference),this.crossBoundarySeek_=!1,this.resetMediaSource(!0).then(function(){var m=shaka.util.FakeEvent.EventName.BoundaryCrossed,n=(new Map).set("oldEncrypted",e.encrypted).set("newEncrypted",h.encrypted);c.playerInterface_.onEvent(new shaka.util.FakeEvent(m,n))}));return k};
shaka.media.StreamingEngine.prototype.getStreamsByType_=function(a){var b=this;a=a===void 0?!1:a;var c=shaka.util.ManifestParserUtils.ContentType,d=function(g){if(g.fullMimeTypes&&g.fullMimeTypes.size>1&&b.mediaStates_.has(g.type)){var h=b.mediaStates_.get(g.type),k=b.playerInterface_.mediaSourceEngine.bufferEnd(h.type),l=b.playerInterface_.getPresentationTime();(h=b.getSegmentReferenceNeeded_(h,l,k))&&h.codecs&&h.mimeType&&(g.codecs=h.codecs,g.mimeType=h.mimeType)}},e=new Map,f=this.currentVariant_.audio;
f&&(d(f),e.set(c.AUDIO,f));if(f=this.currentVariant_.video)d(f),e.set(c.VIDEO,f);a&&this.currentTextStream_&&e.set(c.TEXT,this.currentTextStream_);return e};shaka.media.StreamingEngine.logPrefix_=function(a){return"("+a.type+":"+a.stream.id+")"};shaka.media.StreamingEngine.APPEND_WINDOW_START_FUDGE_=.1;shaka.media.StreamingEngine.APPEND_WINDOW_END_FUDGE_=.1;shaka.media.StreamingEngine.MAX_RUN_AHEAD_SEGMENTS_=1;shaka.media.StreamingEngine.CROSS_BOUNDARY_END_THRESHOLD_=1;
shaka.media.StreamingEngine.LOOKUP_TIME_DURATION_THRESHOLD_=1;shaka.util.StateHistory=function(){this.open_=null;this.closed_=[]};shaka.util.StateHistory.prototype.update=function(a){return this.open_==null?(this.start_(a),!0):this.update_(a)};shaka.util.StateHistory.prototype.getTimeSpentIn=function(a){var b=0;this.open_&&this.open_.state==a&&(b+=this.open_.duration);for(var c=(0,$jscomp.makeIterator)(this.closed_),d=c.next();!d.done;d=c.next())d=d.value,b+=d.state==a?d.duration:0;return b};
shaka.util.StateHistory.prototype.getCopy=function(){for(var a=function(e){return{timestamp:e.timestamp,state:e.state,duration:e.duration}},b=[],c=(0,$jscomp.makeIterator)(this.closed_),d=c.next();!d.done;d=c.next())b.push(a(d.value));this.open_&&b.push(a(this.open_));return b};
shaka.util.StateHistory.prototype.start_=function(a){goog.asserts.assert(this.open_==null,"There must be no open entry in order when we start");shaka.log.v1("Changing Player state to",a);this.open_={timestamp:this.getNowInSeconds_(),state:a,duration:0}};
shaka.util.StateHistory.prototype.update_=function(a){goog.asserts.assert(this.open_,"There must be an open entry in order to update it");var b=this.getNowInSeconds_();this.open_.duration=b-this.open_.timestamp;if(this.open_.state==a)return!1;shaka.log.v1("Changing Player state to",a);this.closed_.push(this.open_);this.open_={timestamp:b,state:a,duration:0};return!0};shaka.util.StateHistory.prototype.getNowInSeconds_=function(){return Date.now()/1E3};shaka.util.SwitchHistory=function(){this.currentText_=this.currentVariant_=null;this.history_=[]};shaka.util.SwitchHistory.prototype.updateCurrentVariant=function(a,b){this.currentVariant_!=a&&(this.currentVariant_=a,this.history_.push({timestamp:this.getNowInSeconds_(),id:a.id,type:"variant",fromAdaptation:b,bandwidth:a.bandwidth}))};
shaka.util.SwitchHistory.prototype.updateCurrentText=function(a,b){this.currentText_!=a&&(this.currentText_=a,this.history_.push({timestamp:this.getNowInSeconds_(),id:a.id,type:"text",fromAdaptation:b,bandwidth:null}))};shaka.util.SwitchHistory.prototype.getCopy=function(){for(var a=[],b=(0,$jscomp.makeIterator)(this.history_),c=b.next();!c.done;c=b.next())a.push(this.clone_(c.value));return a};shaka.util.SwitchHistory.prototype.getNowInSeconds_=function(){return Date.now()/1E3};
shaka.util.SwitchHistory.prototype.clone_=function(a){return{timestamp:a.timestamp,id:a.id,type:a.type,fromAdaptation:a.fromAdaptation,bandwidth:a.bandwidth}};shaka.util.Stats=function(){this.height_=this.width_=NaN;this.currentCodecs_="";this.bytesDownloaded_=this.manifestSizeBytes_=this.bandwidthEstimate_=this.currentStreamBandwidth_=this.maxSegmentDurationSeconds_=this.liveLatencySeconds_=this.licenseTimeSeconds_=this.drmTimeSeconds_=this.manifestTimeSeconds_=this.loadLatencySeconds_=this.completionPercent_=this.totalGapsJumped_=this.totalStallsDetected_=this.totalCorruptedFrames_=this.totalDecodedFrames_=this.totalDroppedFrames_=NaN;this.nonFatalErrorCount_=
0;this.manifestGapCount_=this.manifestPeriodCount_=NaN;this.stateHistory_=new shaka.util.StateHistory;this.switchHistory_=new shaka.util.SwitchHistory};shaka.util.Stats.prototype.setDroppedFrames=function(a,b){this.totalDroppedFrames_=a;this.totalDecodedFrames_=b};shaka.util.Stats.prototype.setCorruptedFrames=function(a){this.totalCorruptedFrames_=a};shaka.util.Stats.prototype.setStallsDetected=function(a){this.totalStallsDetected_=a};
shaka.util.Stats.prototype.setGapsJumped=function(a){this.totalGapsJumped_=a};shaka.util.Stats.prototype.setResolution=function(a,b){this.width_=a;this.height_=b};shaka.util.Stats.prototype.setCodecs=function(a){this.currentCodecs_=a};shaka.util.Stats.prototype.setLoadLatency=function(a){a>=0&&(this.loadLatencySeconds_=a)};shaka.util.Stats.prototype.setManifestTime=function(a){a>=0&&(this.manifestTimeSeconds_=a)};
shaka.util.Stats.prototype.setCompletionPercent=function(a){isNaN(this.completionPercent_)?this.completionPercent_=a:this.completionPercent_=Math.max(this.completionPercent_,a)};shaka.util.Stats.prototype.setDrmTime=function(a){a>=0&&(this.drmTimeSeconds_=a)};shaka.util.Stats.prototype.setLicenseTime=function(a){a>=0&&(this.licenseTimeSeconds_=a)};shaka.util.Stats.prototype.setLiveLatency=function(a){a>=0&&(this.liveLatencySeconds_=a)};
shaka.util.Stats.prototype.setMaxSegmentDuration=function(a){a>=0&&(this.maxSegmentDurationSeconds_=a)};shaka.util.Stats.prototype.setCurrentStreamBandwidth=function(a){this.currentStreamBandwidth_=a};shaka.util.Stats.prototype.setBandwidthEstimate=function(a){this.bandwidthEstimate_=a};shaka.util.Stats.prototype.setManifestSize=function(a){this.manifestSizeBytes_=a};
shaka.util.Stats.prototype.addBytesDownloaded=function(a){isNaN(this.bytesDownloaded_)?this.bytesDownloaded_=a:this.bytesDownloaded_+=a};shaka.util.Stats.prototype.addNonFatalError=function(){this.nonFatalErrorCount_++};shaka.util.Stats.prototype.setManifestPeriodCount=function(a){this.manifestPeriodCount_=a};shaka.util.Stats.prototype.setManifestGapCount=function(a){this.manifestGapCount_=a};shaka.util.Stats.prototype.getStateHistory=function(){return this.stateHistory_};
shaka.util.Stats.prototype.getSwitchHistory=function(){return this.switchHistory_};
shaka.util.Stats.prototype.getBlob=function(){return{width:this.width_,height:this.height_,currentCodecs:this.currentCodecs_,streamBandwidth:this.currentStreamBandwidth_,decodedFrames:this.totalDecodedFrames_,droppedFrames:this.totalDroppedFrames_,corruptedFrames:this.totalCorruptedFrames_,stallsDetected:this.totalStallsDetected_,gapsJumped:this.totalGapsJumped_,estimatedBandwidth:this.bandwidthEstimate_,completionPercent:this.completionPercent_,loadLatency:this.loadLatencySeconds_,manifestTimeSeconds:this.manifestTimeSeconds_,
drmTimeSeconds:this.drmTimeSeconds_,playTime:this.stateHistory_.getTimeSpentIn("playing"),pauseTime:this.stateHistory_.getTimeSpentIn("paused"),bufferingTime:this.stateHistory_.getTimeSpentIn("buffering"),licenseTime:this.licenseTimeSeconds_,liveLatency:this.liveLatencySeconds_,maxSegmentDuration:this.maxSegmentDurationSeconds_,manifestSizeBytes:this.manifestSizeBytes_,bytesDownloaded:this.bytesDownloaded_,nonFatalErrorCount:this.nonFatalErrorCount_,manifestPeriodCount:this.manifestPeriodCount_,manifestGapCount:this.manifestGapCount_,
stateHistory:this.stateHistory_.getCopy(),switchHistory:this.switchHistory_.getCopy()}};
shaka.util.Stats.getEmptyBlob=function(){return{width:NaN,height:NaN,currentCodecs:"",streamBandwidth:NaN,decodedFrames:NaN,droppedFrames:NaN,corruptedFrames:NaN,stallsDetected:NaN,gapsJumped:NaN,estimatedBandwidth:NaN,completionPercent:NaN,loadLatency:NaN,manifestTimeSeconds:NaN,drmTimeSeconds:NaN,playTime:NaN,pauseTime:NaN,bufferingTime:NaN,licenseTime:NaN,liveLatency:NaN,maxSegmentDuration:NaN,manifestSizeBytes:NaN,bytesDownloaded:NaN,nonFatalErrorCount:NaN,manifestPeriodCount:NaN,manifestGapCount:NaN,
switchHistory:[],stateHistory:[]}};shaka.media.PreloadManager=function(a,b,c,d){shaka.util.FakeEventTarget.call(this);this.assetUri_=a;this.mimeType_=b;this.networkingEngine_=d.networkingEngine;this.startTime_=c;this.currentAdaptationSetCriteria_=null;this.startTimeOfDrm_=0;this.createDrmEngine_=d.createDrmEngine;this.manifestFilterer_=d.manifestFilterer;this.manifestPlayerInterface_=d.manifestPlayerInterface;this.config_=d.config;this.parser_=this.parserFactory_=this.manifest_=null;this.parserEntrusted_=!1;this.regionTimeline_=d.regionTimeline;
this.regionTimelineEntrusted_=!1;this.drmEngine_=null;this.drmEngineEntrusted_=!1;this.abrManager_=null;this.segmentPrefetchById_=new Map;this.segmentPrefetchEntrusted_=!1;this.qualityObserver_=d.qualityObserver;this.stats_=new shaka.util.Stats;this.manifestPromise_=new shaka.util.PublicPromise;this.successPromise_=new shaka.util.PublicPromise;this.eventHandoffTarget_=null;this.destroyed_=!1;this.allowPrefetch_=d.allowPrefetch;this.prefetchedTextStream_=this.prefetchedVariant_=null;this.hasBeenAttached_=
!1;this.queuedOperations_=[];this.latePhaseQueuedOperations_=[];this.isPreload_=!0};$jscomp.inherits(shaka.media.PreloadManager,shaka.util.FakeEventTarget);shaka.media.PreloadManager.prototype.markIsLoad=function(){this.isPreload_=!1};shaka.media.PreloadManager.prototype.addQueuedOperation=function(a,b){(a=a?this.latePhaseQueuedOperations_:this.queuedOperations_)?a.push(b):b()};
shaka.media.PreloadManager.prototype.stopQueuingLatePhaseQueuedOperations=function(){if(this.latePhaseQueuedOperations_)for(var a=(0,$jscomp.makeIterator)(this.latePhaseQueuedOperations_),b=a.next();!b.done;b=a.next())b=b.value,b();this.latePhaseQueuedOperations_=null};
shaka.media.PreloadManager.prototype.setEventHandoffTarget=function(a){this.eventHandoffTarget_=a;this.hasBeenAttached_=!0;if(this.queuedOperations_){a=(0,$jscomp.makeIterator)(this.queuedOperations_);for(var b=a.next();!b.done;b=a.next())b=b.value,b()}this.queuedOperations_=null};shaka.media.PreloadManager.prototype.setOffsetToStartTime=function(a){this.startTime_&&a&&(typeof this.startTime_==="number"?this.startTime_+=a:this.startTime_.setTime(this.startTime_.getTime()+a*1E3))};
shaka.media.PreloadManager.prototype.getStartTime=function(){return this.startTime_};shaka.media.PreloadManager.prototype.getStartTimeOfDRM=function(){return this.startTimeOfDrm_};shaka.media.PreloadManager.prototype.getMimeType=function(){return this.mimeType_};shaka.media.PreloadManager.prototype.getAssetUri=function(){return this.assetUri_};shaka.media.PreloadManager.prototype.getManifest=function(){return this.manifest_};shaka.media.PreloadManager.prototype.getParserFactory=function(){return this.parserFactory_};
shaka.media.PreloadManager.prototype.getCurrentAdaptationSetCriteria=function(){return this.currentAdaptationSetCriteria_};shaka.media.PreloadManager.prototype.receiveParser=function(){this.parserEntrusted_=!0;return this.parser_};shaka.media.PreloadManager.prototype.getParser=function(){return this.parser_};shaka.media.PreloadManager.prototype.receiveRegionTimeline=function(){this.regionTimelineEntrusted_=!0;return this.regionTimeline_};shaka.media.PreloadManager.prototype.getRegionTimeline=function(){return this.regionTimeline_};
shaka.media.PreloadManager.prototype.getQualityObserver=function(){return this.qualityObserver_};shaka.media.PreloadManager.prototype.getStats=function(){return this.stats_};shaka.media.PreloadManager.prototype.getManifestFilterer=function(){return this.manifestFilterer_};shaka.media.PreloadManager.prototype.receiveDrmEngine=function(){this.drmEngineEntrusted_=!0;return this.drmEngine_};shaka.media.PreloadManager.prototype.getDrmEngine=function(){return this.drmEngine_};
shaka.media.PreloadManager.prototype.setPrefetchVariant=function(a){this.prefetchedVariant_=a};shaka.media.PreloadManager.prototype.getPrefetchedVariant=function(){return this.prefetchedVariant_};shaka.media.PreloadManager.prototype.getPrefetchedVariantTrack=function(){return this.prefetchedVariant_?shaka.util.StreamUtils.variantToTrack(this.prefetchedVariant_):null};
shaka.media.PreloadManager.prototype.getPrefetchedTextTrack=function(){return this.prefetchedTextStream_?shaka.util.StreamUtils.textStreamToTrack(this.prefetchedTextStream_):null};shaka.media.PreloadManager.prototype.receiveSegmentPrefetchesById=function(){this.segmentPrefetchEntrusted_=!0;return this.segmentPrefetchById_};shaka.media.PreloadManager.prototype.attachAdaptationSetCriteria=function(a){this.currentAdaptationSetCriteria_=a};
shaka.media.PreloadManager.prototype.attachManifest=function(a,b,c){this.manifest_=a;this.parser_=b;this.parserFactory_=c};
shaka.media.PreloadManager.prototype.start=function(){var a=this;(function(){var b;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){switch(c.getNextAddressJsc()){case 1:return c.yield(Promise.resolve(),2);case 2:return c.setCatchFinallyBlocks(3),c.yield(a.parseManifestInner_(),5);case 5:a.throwIfDestroyed_();if(shaka.drm.DrmUtils.isMediaKeysPolyfilled("webkit")){c.jumpTo(6);break}return c.yield(a.initializeDrm(),7);case 7:a.throwIfDestroyed_();case 6:return c.yield(a.validatePrefetchedVariant_(),
8);case 8:a.throwIfDestroyed_();if(!a.allowPrefetch_){c.jumpTo(9);break}return c.yield(a.prefetchInner_(),10);case 10:a.throwIfDestroyed_();case 9:if(!a.allowPrefetch_||!a.drmEngine_){c.jumpTo(11);break}return c.yield(a.drmEngine_.waitForActiveRequests(),12);case 12:a.throwIfDestroyed_();case 11:a.successPromise_.resolve();c.leaveTryBlock(0);break;case 3:b=c.enterCatchBlock(),b instanceof shaka.util.Error&&(b.code==shaka.util.Error.Code.OPERATION_ABORTED||b.code==shaka.util.Error.Code.OBJECT_DESTROYED)||
a.successPromise_.reject(b),c.jumpToEnd()}})})()};shaka.media.PreloadManager.prototype.dispatchEvent=function(a){return this.eventHandoffTarget_?this.eventHandoffTarget_.dispatchEvent(a):shaka.util.FakeEventTarget.prototype.dispatchEvent.call(this,a)};
shaka.media.PreloadManager.prototype.onError=function(a){a.severity===shaka.util.Error.Severity.CRITICAL&&(this.successPromise_.reject(a),this.destroy());var b=this.makeEvent_(shaka.util.FakeEvent.EventName.Error,(new Map).set("detail",a));this.dispatchEvent(b);b.defaultPrevented&&(a.handled=!0)};
shaka.media.PreloadManager.prototype.throwIfDestroyed_=function(){if(this.isDestroyed())throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.PLAYER,shaka.util.Error.Code.OBJECT_DESTROYED);};shaka.media.PreloadManager.prototype.makeStateChangeEvent_=function(a){this.dispatchEvent(new shaka.util.FakeEvent(shaka.util.FakeEvent.EventName.OnStateChange,(new Map).set("state",a)))};
shaka.media.PreloadManager.prototype.makeEvent_=function(a,b){return new shaka.util.FakeEvent(a,b)};
shaka.media.PreloadManager.prototype.parseManifestInner_=function(){var a=this,b,c,d,e,f,g;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(h){switch(h.getNextAddressJsc()){case 1:a.makeStateChangeEvent_("manifest-parser");a.parser_||(a.parserFactory_=shaka.media.ManifestParser.getFactory(a.assetUri_,a.mimeType_),goog.asserts.assert(a.parserFactory_,"Must have manifest parser"),a.parser_=a.parserFactory_(),a.parser_.configure(a.config_.manifest,function(){return a.isPreload_}));b=Date.now()/
1E3;a.makeStateChangeEvent_("manifest");if(a.manifest_){h.jumpTo(2);break}return h.yield(a.parser_.start(a.assetUri_,a.manifestPlayerInterface_),3);case 3:return a.manifest_=h.getYieldResultJsc(),shaka.media.PreloadManager.filterForAVVariants_(a.manifest_),h.yield(a.chooseInitialVariant_(),2);case 2:return a.manifestPromise_.resolve(),c=a.makeEvent_(shaka.util.FakeEvent.EventName.ManifestParsed),h.yield(Promise.resolve(),5);case 5:a.dispatchEvent(c);if(a.manifest_.variants.length==0)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.NO_VARIANTS);shaka.media.PreloadManager.filterForAVVariants_(a.manifest_);d=a.manifestFilterer_.applyRestrictions(a.manifest_);if(!d){h.jumpTo(6);break}e=a.makeEvent_(shaka.util.FakeEvent.EventName.TracksChanged);return h.yield(Promise.resolve(),7);case 7:a.throwIfDestroyed_(),a.dispatchEvent(e);case 6:f=Date.now()/1E3,g=f-b,a.stats_.setManifestTime(g),h.jumpToEnd()}})};
shaka.media.PreloadManager.prototype.initializeDrm=function(a){var b=this,c,d,e,f;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(g){switch(g.getNextAddressJsc()){case 1:if(!b.manifest_||b.drmEngine_)return g.return();b.makeStateChangeEvent_("drm-engine");b.startTimeOfDrm_=Date.now()/1E3;b.drmEngine_=b.createDrmEngine_();b.manifestFilterer_.setDrmEngine(b.drmEngine_);b.drmEngine_.configure(b.config_.drm,function(){return b.isPreload_});c=shaka.util.StreamUtils.getPlayableVariants(b.manifest_.variants);
d=!0;b.manifest_&&b.manifest_.presentationTimeline&&(d=b.manifest_.presentationTimeline.isLive());return g.yield(b.drmEngine_.initForPlayback(c,b.manifest_.offlineSessionIds,d),2);case 2:b.throwIfDestroyed_();if(!a){g.jumpTo(3);break}return g.yield(b.drmEngine_.attach(a),4);case 4:b.throwIfDestroyed_();case 3:return g.yield(b.manifestFilterer_.filterManifest(b.manifest_),5);case 5:e=g.getYieldResultJsc();if(!e){g.jumpTo(0);break}f=b.makeEvent_(shaka.util.FakeEvent.EventName.TracksChanged);return g.yield(Promise.resolve(),
7);case 7:b.dispatchEvent(f),g.jumpToEnd()}})};shaka.media.PreloadManager.prototype.reconfigure=function(a){this.config_=a};shaka.media.PreloadManager.prototype.configure=function(a,b){a=shaka.util.ConfigUtils.convertToConfigObject(a,b);shaka.util.PlayerConfiguration.mergeConfigObjects(this.config_,a)};shaka.media.PreloadManager.prototype.getConfiguration=function(){return shaka.util.ObjectUtils.cloneObject(this.config_)};
shaka.media.PreloadManager.prototype.chooseInitialVariant_=function(){var a=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(b){a.currentAdaptationSetCriteria_||(a.currentAdaptationSetCriteria_=a.config_.adaptationSetCriteriaFactory(),a.currentAdaptationSetCriteria_.configure({language:a.config_.preferredAudioLanguage,role:a.config_.preferredAudioRole,videoRole:a.config_.preferredVideoRole,channelCount:0,hdrLevel:a.config_.preferredVideoHdrLevel,spatialAudio:a.config_.preferSpatialAudio,
videoLayout:a.config_.preferredVideoLayout,audioLabel:a.config_.preferredAudioLabel,videoLabel:a.config_.preferredVideoLabel,codecSwitchingStrategy:a.config_.mediaSource.codecSwitchingStrategy,audioCodec:"",activeAudioCodec:"",activeAudioChannelCount:0,preferredAudioCodecs:a.config_.preferredAudioCodecs,preferredAudioChannelCount:a.config_.preferredAudioChannelCount}));if(!a.shouldCreateSegmentIndexBeforeDrmEngineInitialization_())return b.jumpTo(0);a.prefetchedVariant_=a.configureAbrManagerAndChooseVariant_();
return a.prefetchedVariant_?b.yield(a.createSegmentIndexFromVariant_(a.prefetchedVariant_),0):b.jumpTo(0)})};shaka.media.PreloadManager.prototype.shouldCreateSegmentIndexBeforeDrmEngineInitialization_=function(){if(this.prefetchedVariant_)return!1;goog.asserts.assert(this.manifest_,"The manifest should already be parsed.");return this.manifest_.variants.length?this.manifest_.variants.length==1||this.manifest_.type==shaka.media.ManifestParser.HLS?!0:!1:!1};
shaka.media.PreloadManager.prototype.validatePrefetchedVariant_=function(){var a=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(b){if(b.getNextAddressJsc()==1)return!a.prefetchedVariant_||a.manifest_.variants.includes(a.prefetchedVariant_)?b.jumpTo(0):b.yield(a.closeSegmentIndexFromVariant_(a.prefetchedVariant_),3);a.prefetchedVariant_=a.configureAbrManagerAndChooseVariant_();return a.prefetchedVariant_?b.yield(a.createSegmentIndexFromVariant_(a.prefetchedVariant_),0):b.jumpTo(0)})};
shaka.media.PreloadManager.prototype.prefetchInner_=function(){var a=this,b,c,d,e,f;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(g){!a.prefetchedVariant_&&(b=a.configureAbrManagerAndChooseVariant_())&&(a.prefetchedVariant_=b);if(!a.prefetchedVariant_)return g.jumpTo(0);c=a.manifest_.presentationTimeline.isLive();d=[];e=a.prefetchedVariant_;e.video&&d.push(a.prefetchStream_(e.video,c));e.audio&&d.push(a.prefetchStream_(e.audio,c));(f=a.chooseTextStream_())&&shaka.util.StreamUtils.shouldInitiallyShowText(e.audio,
f,a.config_)&&(d.push(a.prefetchStream_(f,c)),a.prefetchedTextStream_=f);return g.yield(Promise.all(d),0)})};
shaka.media.PreloadManager.prototype.configureAbrManagerAndChooseVariant_=function(){goog.asserts.assert(this.currentAdaptationSetCriteria_,"Must have an AdaptationSetCriteria");if(!this.abrManager_){var a=this.config_.abrFactory;this.abrManager_=a();this.abrManager_.configure(this.config_.abr)}a=shaka.util.StreamUtils.getPlayableVariants(this.manifest_.variants);a=this.currentAdaptationSetCriteria_.create(a);this.abrManager_.setVariants(Array.from(a.values()));return this.abrManager_.chooseVariant(!0)};
shaka.media.PreloadManager.prototype.chooseTextStream_=function(){return shaka.util.StreamUtils.filterStreamsByLanguageAndRole(this.manifest_.textStreams,this.config_.preferredTextLanguage,this.config_.preferredTextRole,this.config_.preferForcedSubs)[0]||null};
shaka.media.PreloadManager.prototype.prefetchStream_=function(a,b){var c=this,d,e,f,g,h;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(k){if(k.getNextAddressJsc()==1)return d=c.config_.streaming.segmentPrefetchLimit||2,e=new shaka.media.SegmentPrefetch(d,a,function(l,m,n){return shaka.media.StreamingEngine.dispatchFetch(l,m,n||null,c.config_.streaming.retryParameters,c.networkingEngine_,c.isPreload_)},!1),c.segmentPrefetchById_.set(a.id,e),a.segmentIndex?k.jumpTo(2):k.yield(a.createSegmentIndex(),
2);f=typeof c.startTime_==="number"?c.startTime_:0;g=a.segmentIndex.getIteratorForTime(f);h=null;g&&(h=g.current(),h||(h=g.next().value));h||(h=a.segmentIndex.earliestReference());return h?b?h.initSegmentReference?k.yield(e.prefetchInitSegment(h.initSegmentReference),0):k.jumpTo(0):k.yield(e.prefetchSegmentsByTime(h.startTime),0):k.jumpTo(0)})};
shaka.media.PreloadManager.prototype.createSegmentIndexFromVariant_=function(a){var b,c,d,e;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){b=[];c=(0,$jscomp.makeIterator)([a.video,a.audio]);for(d=c.next();!d.done;d=c.next())(e=d.value)&&!e.segmentIndex&&b.push(e.createSegmentIndex());return b.length>0?f.yield(Promise.all(b),0):f.jumpTo(0)})};
shaka.media.PreloadManager.prototype.closeSegmentIndexFromVariant_=function(a){var b,c,d,e;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){b=[];c=(0,$jscomp.makeIterator)([a.video,a.audio]);for(d=c.next();!d.done;d=c.next())(e=d.value)&&e.segmentIndex&&e.closeSegmentIndex&&b.push(e.closeSegmentIndex());return b.length>0?f.yield(Promise.all(b),0):f.jumpTo(0)})};shaka.media.PreloadManager.prototype.waitForFinish=function(){return this.successPromise_};
shaka.media.PreloadManager.prototype.waitForManifest=function(){return Promise.race([this.manifestPromise_,this.successPromise_])};
shaka.media.PreloadManager.prototype.destroy=function(){var a=this,b,c,d;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(e){if(e.getNextAddressJsc()==1)return a.destroyed_=!0,!a.parser_||a.parserEntrusted_?e.jumpTo(2):e.yield(a.parser_.stop(),2);if(e.getNextAddressJsc()!=4)return a.abrManager_&&a.abrManager_.release(),a.regionTimeline_&&!a.regionTimelineEntrusted_&&a.regionTimeline_.release(),!a.drmEngine_||a.drmEngineEntrusted_?e.jumpTo(4):e.yield(a.drmEngine_.destroy(),4);if(a.segmentPrefetchById_.size>
0&&!a.segmentPrefetchEntrusted_)for(b=(0,$jscomp.makeIterator)(a.segmentPrefetchById_.values()),c=b.next();!c.done;c=b.next())d=c.value,d.clearAll();e.jumpToEnd()})};shaka.media.PreloadManager.prototype.isDestroyed=function(){return this.destroyed_};shaka.media.PreloadManager.prototype.hasBeenAttached=function(){return this.hasBeenAttached_};
shaka.media.PreloadManager.filterForAVVariants_=function(a){var b=function(c){return c.video&&c.audio||c.video&&c.video.codecs.includes(",")};a.variants.some(b)&&(shaka.log.debug("Found variant with audio and video content, so filtering out audio-only content."),a.variants=a.variants.filter(b))};goog.exportSymbol("shaka.media.PreloadManager",shaka.media.PreloadManager);goog.exportProperty(shaka.media.PreloadManager.prototype,"destroy",shaka.media.PreloadManager.prototype.destroy);
goog.exportProperty(shaka.media.PreloadManager.prototype,"waitForFinish",shaka.media.PreloadManager.prototype.waitForFinish);goog.exportProperty(shaka.media.PreloadManager.prototype,"getPrefetchedTextTrack",shaka.media.PreloadManager.prototype.getPrefetchedTextTrack);goog.exportProperty(shaka.media.PreloadManager.prototype,"getPrefetchedVariantTrack",shaka.media.PreloadManager.prototype.getPrefetchedVariantTrack);shaka.media.RegionObserver=function(a,b){shaka.util.FakeEventTarget.call(this);var c=this;this.timeline_=a;this.startsPastZero_=b;this.oldPosition_=new Map;var d=shaka.media.RegionObserver.RelativePosition_;a=d.BEFORE_THE_REGION;b=d.IN_THE_REGION;d=d.AFTER_THE_REGION;this.rules_=[{weWere:null,weAre:b,invoke:function(e,f){return c.onEvent_("enter",e,f)}},{weWere:a,weAre:b,invoke:function(e,f){return c.onEvent_("enter",e,f)}},{weWere:d,weAre:b,invoke:function(e,f){return c.onEvent_("enter",e,f)}},{weWere:b,
weAre:a,invoke:function(e,f){return c.onEvent_("exit",e,f)}},{weWere:b,weAre:d,invoke:function(e,f){return c.onEvent_("exit",e,f)}},{weWere:a,weAre:d,invoke:function(e,f){if(f)c.onEvent_("skip",e,f);else c.onEvent_("enter",e,f),c.onEvent_("exit",e,f)}},{weWere:d,weAre:a,invoke:function(e,f){return c.onEvent_("skip",e,f)}}];this.eventManager_=new shaka.util.EventManager;this.eventManager_.listen(this.timeline_,"regionremove",function(e){c.oldPosition_.delete(e.region)})};
$jscomp.inherits(shaka.media.RegionObserver,shaka.util.FakeEventTarget);shaka.media.RegionObserver.prototype.release=function(){this.timeline_=null;this.oldPosition_.clear();this.eventManager_.release();this.eventManager_=null;shaka.util.FakeEventTarget.prototype.release.call(this)};
shaka.media.RegionObserver.prototype.poll=function(a,b){var c=shaka.media.RegionObserver;if(!this.startsPastZero_||a!=0){this.startsPastZero_=!1;for(var d=(0,$jscomp.makeIterator)(this.timeline_.regions()),e=d.next();!e.done;e=d.next()){e=e.value;var f=this.oldPosition_.get(e),g=c.determinePositionRelativeTo_(e,a);this.oldPosition_.set(e,g);for(var h=(0,$jscomp.makeIterator)(this.rules_),k=h.next();!k.done;k=h.next())k=k.value,k.weWere==f&&k.weAre==g&&k.invoke(e,b)}}};
shaka.media.RegionObserver.prototype.onEvent_=function(a,b,c){a=new shaka.util.FakeEvent(a,new Map([["region",b],["seeking",c]]));this.dispatchEvent(a)};shaka.media.RegionObserver.determinePositionRelativeTo_=function(a,b){var c=shaka.media.RegionObserver.RelativePosition_;return b<a.startTime?c.BEFORE_THE_REGION:b>a.endTime?c.AFTER_THE_REGION:c.IN_THE_REGION};shaka.media.RegionObserver.RelativePosition_={BEFORE_THE_REGION:1,IN_THE_REGION:2,AFTER_THE_REGION:3};shaka.net.HttpPluginUtils=function(){};
shaka.net.HttpPluginUtils.makeResponse=function(a,b,c,d,e,f,g){goog.asserts.assert(b,"Data should be non-null!");if(c>=200&&c<=299&&c!=202||c==304)return{uri:e||d,originalUri:d,data:b,status:c,headers:a,fromCache:!!a["x-shaka-from-cache"],originalRequest:f};f=null;try{f=shaka.util.StringUtils.fromBytesAutoDetect(b)}catch(h){}shaka.log.debug("HTTP error text:",f);throw new shaka.util.Error(c==401||c==403?shaka.util.Error.Severity.CRITICAL:shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.NETWORK,
shaka.util.Error.Code.BAD_HTTP_STATUS,d,c,f,a,g,e||d);};shaka.net.HttpFetchPlugin=function(){};
shaka.net.HttpFetchPlugin.parse=function(a,b,c,d,e,f){var g=new shaka.net.HttpFetchPlugin.Headers_;try{shaka.util.MapUtils.asMap(b.headers).forEach(function(m,n){g.append(n,m)})}catch(m){return shaka.log.debug("Failed to create headers:",m),shaka.util.AbortableOperation.failed(new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.NETWORK,shaka.util.Error.Code.HTTP_ERROR,a,m,c))}var h=new shaka.net.HttpFetchPlugin.AbortController_,k={canceled:!1,timedOut:!1};a=shaka.net.HttpFetchPlugin.request_(a,
b,c,{body:b.body||void 0,headers:g,method:b.method,signal:h.signal,credentials:b.allowCrossSiteCredentials?"include":void 0},k,d,e,b.streamDataCallback,f.minBytesForProgressEvents||0);a=new shaka.util.AbortableOperation(a,function(){k.canceled=!0;h.abort();return Promise.resolve()});if(b=b.retryParameters.timeout){var l=new shaka.util.Timer(function(){k.timedOut=!0;h.abort()});l.tickAfter(b/1E3);a.finally(function(){l.stop()})}return a};
shaka.net.HttpFetchPlugin.request_=function(a,b,c,d,e,f,g,h,k){var l,m,n,p,q,r,t,u,v,w,x,y,C,D,A;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(z){switch(z.getNextAddressJsc()){case 1:return l=shaka.net.HttpFetchPlugin.fetch_,m=shaka.net.HttpFetchPlugin.ReadableStream_,p=new ArrayBuffer(0),r=q=0,t={},u=Date.now(),z.setCatchFinallyBlocks(2),z.yield(l(a,d),4);case 4:n=z.getYieldResultJsc();t=shaka.net.HttpFetchPlugin.headersToGenericObject_(n.headers);g(t);if(d.method=="HEAD"){z.jumpTo(5);
break}goog.asserts.assert(n.body,"non-HEAD responses should have a body");w=(v=n.headers.get("Content-Length"))?parseInt(v,10):0;if(!n.body)return z.yield(n.arrayBuffer(),9);x=n.clone().body.getReader();y=function(B){var E=function(){var H,N,F,I,L;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(G){switch(G.getNextAddressJsc()){case 1:return G.setCatchFinallyBlocks(2),G.yield(x.read(),4);case 4:H=G.getYieldResultJsc();G.leaveTryBlock(3);break;case 2:return N=G.enterCatchBlock(),shaka.log.v1("error reading from stream",
N.message),G.return();case 3:if(H.done){G.jumpTo(5);break}q+=H.value.byteLength;if(!h){G.jumpTo(5);break}return G.yield(h(H.value),5);case 5:F=Date.now();I=q-r;if(F-u>100&&I>=k||H.done)L=H.done?0:w-q,f(F-u,I,L),r=q,u=F;H.done?(goog.asserts.assert(!H.value,'readObj should be unset when "done" is true.'),B.close()):(B.enqueue(H.value),E());G.jumpToEnd()}})};E()};new m({start:y});return z.yield(n.arrayBuffer(),8);case 8:p=z.getYieldResultJsc();z.jumpTo(5);break;case 9:p=z.getYieldResultJsc(),C=Date.now(),
f(C-u,p.byteLength,0);case 5:b.headers.Range&&(D=b.headers.Range.replace("bytes=","").split("-").filter(function(B){return B}).map(function(B){return parseInt(B,10)}),D.length==2&&p.byteLength!=D[1]-D[0]+1&&shaka.log.alwaysWarn("Payload length does not match range requested bytes",b,n));z.leaveTryBlock(3);break;case 2:A=z.enterCatchBlock();if(e.canceled)throw new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.NETWORK,shaka.util.Error.Code.OPERATION_ABORTED,a,c);if(e.timedOut)throw new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,
shaka.util.Error.Category.NETWORK,shaka.util.Error.Code.TIMEOUT,a,c);throw new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.NETWORK,shaka.util.Error.Code.HTTP_ERROR,a,A,c);case 3:return z.return(shaka.net.HttpPluginUtils.makeResponse(t,p,n.status,a,n.url,b,c))}})};shaka.net.HttpFetchPlugin.headersToGenericObject_=function(a){var b={};a.forEach(function(c,d){b[d.trim()]=c});return b};
shaka.net.HttpFetchPlugin.isSupported=function(){if(window.ReadableStream)try{new ReadableStream({})}catch(a){return!1}else return!1;if(window.Response){if(!(new Response("")).body)return!1}else return!1;return!(!window.fetch||"polyfill"in window.fetch||!window.AbortController)};goog.exportSymbol("shaka.net.HttpFetchPlugin",shaka.net.HttpFetchPlugin);goog.exportProperty(shaka.net.HttpFetchPlugin,"isSupported",shaka.net.HttpFetchPlugin.isSupported);
goog.exportProperty(shaka.net.HttpFetchPlugin,"parse",shaka.net.HttpFetchPlugin.parse);shaka.net.HttpFetchPlugin.fetch_=window.fetch;shaka.net.HttpFetchPlugin.AbortController_=window.AbortController;shaka.net.HttpFetchPlugin.ReadableStream_=window.ReadableStream;shaka.net.HttpFetchPlugin.Headers_=window.Headers;
shaka.net.HttpFetchPlugin.isSupported()&&(shaka.net.NetworkingEngine.registerScheme("http",shaka.net.HttpFetchPlugin.parse,shaka.net.NetworkingEngine.PluginPriority.PREFERRED,!0),shaka.net.NetworkingEngine.registerScheme("https",shaka.net.HttpFetchPlugin.parse,shaka.net.NetworkingEngine.PluginPriority.PREFERRED,!0),shaka.net.NetworkingEngine.registerScheme("blob",shaka.net.HttpFetchPlugin.parse,shaka.net.NetworkingEngine.PluginPriority.PREFERRED,!0));shaka.net.HttpXHRPlugin=function(){};
shaka.net.HttpXHRPlugin.parse=function(a,b,c,d,e,f){var g=new shaka.net.HttpXHRPlugin.Xhr_,h=Date.now(),k=0,l=new Promise(function(m,n){g.open(b.method,a,!0);g.responseType="arraybuffer";g.timeout=b.retryParameters.timeout;g.withCredentials=b.allowCrossSiteCredentials;var p={};g.onabort=function(){n(new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.NETWORK,shaka.util.Error.Code.OPERATION_ABORTED,a,c))};g.onreadystatechange=function(t){g.readyState===XMLHttpRequest.HEADERS_RECEIVED&&
(p=shaka.net.HttpXHRPlugin.headersToGenericObject_(g),e(p))};g.onload=function(t){goog.asserts.assert(g.response instanceof ArrayBuffer,"XHR should have a response by now!");t=g.response;try{var u=shaka.net.HttpPluginUtils.makeResponse(p,t,g.status,a,g.responseURL,b,c);m(u)}catch(v){goog.asserts.assert(v instanceof shaka.util.Error,"Wrong error type!"),n(v)}};g.onerror=function(t){n(new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.NETWORK,shaka.util.Error.Code.HTTP_ERROR,
a,t,c))};g.ontimeout=function(t){n(new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.NETWORK,shaka.util.Error.Code.TIMEOUT,a,c))};g.onprogress=function(t){var u=Date.now(),v=f.minBytesForProgressEvents||0,w=t.loaded-k;if(u-h>100&&w>=v||t.lengthComputable&&t.loaded==t.total)d(u-h,w,g.readyState==4?0:t.total-t.loaded),k=t.loaded,h=u};for(var q in b.headers)try{var r=q.toLowerCase();g.setRequestHeader(r,b.headers[q])}catch(t){throw new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,
shaka.util.Error.Category.NETWORK,shaka.util.Error.Code.HTTP_ERROR,a,t,c);}g.send(b.body)});return new shaka.util.AbortableOperation(l,function(){g.abort();return Promise.resolve()})};shaka.net.HttpXHRPlugin.headersToGenericObject_=function(a){var b=a.getAllResponseHeaders().trim().split("\r\n");a={};b=(0,$jscomp.makeIterator)(b);for(var c=b.next();!c.done;c=b.next()){c=c.value;var d=c.indexOf(": ");d!==-1&&(a[c.slice(0,d).toLowerCase()]=c.slice(d+2))}return a};
goog.exportSymbol("shaka.net.HttpXHRPlugin",shaka.net.HttpXHRPlugin);goog.exportProperty(shaka.net.HttpXHRPlugin,"parse",shaka.net.HttpXHRPlugin.parse);shaka.net.HttpXHRPlugin.Xhr_=window.XMLHttpRequest;shaka.net.NetworkingEngine.registerScheme("http",shaka.net.HttpXHRPlugin.parse,shaka.net.NetworkingEngine.PluginPriority.FALLBACK,!0);shaka.net.NetworkingEngine.registerScheme("https",shaka.net.HttpXHRPlugin.parse,shaka.net.NetworkingEngine.PluginPriority.FALLBACK,!0);
shaka.net.NetworkingEngine.registerScheme("blob",shaka.net.HttpXHRPlugin.parse,shaka.net.NetworkingEngine.PluginPriority.FALLBACK,!0);/*
 @license
 Copyright 2013 Ali Al Dallal

 Licensed under the MIT license.

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 SOFTWARE.
*/
for(var mozilla={LanguageMapping:{ach:"Lwo",ady:"\u0410\u0434\u044b\u0433\u044d\u0431\u0437\u044d",af:"Afrikaans","af-NA":"Afrikaans (Namibia)","af-ZA":"Afrikaans (South Africa)",ak:"T\u0255\u0265i",ar:"\u0627\u0644\u0639\u0631\u0628\u064a\u0629","ar-AR":"\u0627\u0644\u0639\u0631\u0628\u064a\u0629","ar-MA":"\u0627\u0644\u0639\u0631\u0628\u064a\u0629","ar-SA":"\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u0627\u0644\u0633\u0639\u0648\u062f\u064a\u0629)","ay-BO":"Aymar aru",az:"Az\u0259rbaycan dili",
"az-AZ":"Az\u0259rbaycan dili","be-BY":"\u0411\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f",bg:"\u0411\u044a\u043b\u0433\u0430\u0440\u0441\u043a\u0438","bg-BG":"\u0411\u044a\u043b\u0433\u0430\u0440\u0441\u043a\u0438",bn:"\u09ac\u09be\u0982\u09b2\u09be","bn-IN":"\u09ac\u09be\u0982\u09b2\u09be (\u09ad\u09be\u09b0\u09a4)","bn-BD":"\u09ac\u09be\u0982\u09b2\u09be(\u09ac\u09be\u0982\u09b2\u09be\u09a6\u09c7\u09b6)","bs-BA":"Bosanski",ca:"Catal\u00e0","ca-ES":"Catal\u00e0",cak:"Maya Kaqchikel",
"ck-US":"\u13e3\u13b3\u13a9 (tsalagi)",cs:"\u010ce\u0161tina","cs-CZ":"\u010ce\u0161tina",cy:"Cymraeg","cy-GB":"Cymraeg",da:"Dansk","da-DK":"Dansk",de:"Deutsch","de-AT":"Deutsch (\u00d6sterreich)","de-DE":"Deutsch (Deutschland)","de-CH":"Deutsch (Schweiz)",dsb:"Dolnoserb\u0161\u0107ina",el:"\u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac","el-GR":"\u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac",en:"English","en-GB":"English (UK)","en-AU":"English (Australia)","en-CA":"English (Canada)","en-IE":"English (Ireland)",
"en-IN":"English (India)","en-PI":"English (Pirate)","en-UD":"English (Upside Down)","en-US":"English (US)","en-ZA":"English (South Africa)","en@pirate":"English (Pirate)",eo:"Esperanto","eo-EO":"Esperanto",es:"Espa\u00f1ol","es-AR":"Espa\u00f1ol (Argentine)","es-419":"Espa\u00f1ol (Latinoam\u00e9rica)","es-CL":"Espa\u00f1ol (Chile)","es-CO":"Espa\u00f1ol (Colombia)","es-EC":"Espa\u00f1ol (Ecuador)","es-ES":"Espa\u00f1ol (Espa\u00f1a)","es-LA":"Espa\u00f1ol (Latinoam\u00e9rica)","es-NI":"Espa\u00f1ol (Nicaragua)",
"es-MX":"Espa\u00f1ol (M\u00e9xico)","es-US":"Espa\u00f1ol (Estados Unidos)","es-VE":"Espa\u00f1ol (Venezuela)",et:"eesti keel","et-EE":"Eesti (Estonia)",eu:"Euskara","eu-ES":"Euskara",fa:"\u0641\u0627\u0631\u0633\u06cc","fa-IR":"\u0641\u0627\u0631\u0633\u06cc","fb-LT":"Leet Speak",ff:"Fulah",fi:"Suomi","fi-FI":"Suomi","fo-FO":"F\u00f8royskt",fr:"Fran\u00e7ais","fr-CA":"Fran\u00e7ais (Canada)","fr-FR":"Fran\u00e7ais (France)","fr-BE":"Fran\u00e7ais (Belgique)","fr-CH":"Fran\u00e7ais (Suisse)","fy-NL":"Frysk",
ga:"Gaeilge","ga-IE":"Gaeilge (Gaelic)",gl:"Galego","gl-ES":"Galego","gn-PY":"Ava\u00f1e'\u1ebd","gu-IN":"\u0a97\u0ac1\u0a9c\u0ab0\u0abe\u0aa4\u0ac0","gx-GR":"\u1f19\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ae \u1f00\u03c1\u03c7\u03b1\u03af\u03b1",he:"\u05e2\u05d1\u05e8\u05d9\u05ea\u200f","he-IL":"\u05e2\u05d1\u05e8\u05d9\u05ea\u200f",hi:"\u0939\u093f\u0928\u094d\u0926\u0940","hi-IN":"\u0939\u093f\u0928\u094d\u0926\u0940",hr:"Hrvatski","hr-HR":"Hrvatski",hsb:"Hornjoserb\u0161\u0107ina",ht:"Krey\u00f2l",
hu:"Magyar","hu-HU":"Magyar","hy-AM":"\u0540\u0561\u0575\u0565\u0580\u0565\u0576",id:"Bahasa Indonesia","id-ID":"Bahasa Indonesia",is:"\u00cdslenska","is-IS":"\u00cdslenska (Iceland)",it:"Italiano","it-IT":"Italiano",ja:"\u65e5\u672c\u8a9e","ja-JP":"\u65e5\u672c\u8a9e","jv-ID":"Basa Jawa","ka-GE":"\u10e5\u10d0\u10e0\u10d7\u10e3\u10da\u10d8","kk-KZ":"\u049a\u0430\u0437\u0430\u049b\u0448\u0430",km:"\u1797\u17b6\u179f\u17b6\u1781\u17d2\u1798\u17c2\u179a","km-KH":"\u1797\u17b6\u179f\u17b6\u1781\u17d2\u1798\u17c2\u179a",
kab:"Taqbaylit",kn:"\u0c95\u0ca8\u0ccd\u0ca8\u0ca1","kn-IN":"\u0c95\u0ca8\u0ccd\u0ca8\u0ca1 (India)",ko:"\ud55c\uad6d\uc5b4","ko-KR":"\ud55c\uad6d\uc5b4 (\u97e9\u56fd)",ku:"Kurd\u00ee","ku-TR":"Kurd\u00ee",la:"Latin","la-VA":"Latin",lb:"L\u00ebtzebuergesch","li-NL":"L\u00e8mb\u00f6rgs",lt:"Lietuvi\u0173","lt-LT":"Lietuvi\u0173",lv:"Latvie\u0161u","lv-LV":"Latvie\u0161u",mai:"\u092e\u0948\u0925\u093f\u0932\u0940, \u09ae\u09c8\u09a5\u09bf\u09b2\u09c0","mg-MG":"Malagasy",mk:"\u041c\u0430\u043a\u0435\u0434\u043e\u043d\u0441\u043a\u0438",
"mk-MK":"\u041c\u0430\u043a\u0435\u0434\u043e\u043d\u0441\u043a\u0438 (\u041c\u0430\u043a\u0435\u0434\u043e\u043d\u0441\u043a\u0438)",ml:"\u0d2e\u0d32\u0d2f\u0d3e\u0d33\u0d02","ml-IN":"\u0d2e\u0d32\u0d2f\u0d3e\u0d33\u0d02","mn-MN":"\u041c\u043e\u043d\u0433\u043e\u043b",mr:"\u092e\u0930\u093e\u0920\u0940","mr-IN":"\u092e\u0930\u093e\u0920\u0940",ms:"Bahasa Melayu","ms-MY":"Bahasa Melayu",mt:"Malti","mt-MT":"Malti",my:"\u1017\u1019\u102c\u1005\u1000\u102c",nb:"Norsk (bokm\u00e5l)","nb-NO":"Norsk (bokm\u00e5l)",
ne:"\u0928\u0947\u092a\u093e\u0932\u0940","ne-NP":"\u0928\u0947\u092a\u093e\u0932\u0940",nl:"Nederlands","nl-BE":"Nederlands (Belgi\u00eb)","nl-NL":"Nederlands (Nederland)","nn-NO":"Norsk (nynorsk)",no:"Norsk",oc:"Occitan","or-IN":"\u0b13\u0b21\u0b3c\u0b3f\u0b06",pa:"\u0a2a\u0a70\u0a1c\u0a3e\u0a2c\u0a40","pa-IN":"\u0a2a\u0a70\u0a1c\u0a3e\u0a2c\u0a40 (\u0a2d\u0a3e\u0a30\u0a24 \u0a28\u0a42\u0a70)",pl:"Polski","pl-PL":"Polski","ps-AF":"\u067e\u069a\u062a\u0648",pt:"Portugu\u00eas","pt-BR":"Portugu\u00eas (Brasil)",
"pt-PT":"Portugu\u00eas (Portugal)","qu-PE":"Qhichwa","rm-CH":"Rumantsch",ro:"Rom\u00e2n\u0103","ro-RO":"Rom\u00e2n\u0103",ru:"\u0420\u0443\u0441\u0441\u043a\u0438\u0439","ru-RU":"\u0420\u0443\u0441\u0441\u043a\u0438\u0439","sa-IN":"\u0938\u0902\u0938\u094d\u0915\u0943\u0924\u092e\u094d","se-NO":"Davvis\u00e1megiella","si-LK":"\u0db4\u0dc5\u0dcf\u0dad",sk:"Sloven\u010dina","sk-SK":"Sloven\u010dina (Slovakia)",sl:"Sloven\u0161\u010dina","sl-SI":"Sloven\u0161\u010dina","so-SO":"Soomaaliga",sq:"Shqip",
"sq-AL":"Shqip",sr:"\u0421\u0440\u043f\u0441\u043a\u0438","sr-RS":"\u0421\u0440\u043f\u0441\u043a\u0438 (Serbia)",su:"Basa Sunda",sv:"Svenska","sv-SE":"Svenska",sw:"Kiswahili","sw-KE":"Kiswahili",ta:"\u0ba4\u0bae\u0bbf\u0bb4\u0bcd","ta-IN":"\u0ba4\u0bae\u0bbf\u0bb4\u0bcd",te:"\u0c24\u0c46\u0c32\u0c41\u0c17\u0c41","te-IN":"\u0c24\u0c46\u0c32\u0c41\u0c17\u0c41",tg:"\u0437\u0430\u0431\u043e\u0301\u043d\u0438 \u0442\u043e\u04b7\u0438\u043a\u04e3\u0301","tg-TJ":"\u0442\u043e\u04b7\u0438\u043a\u04e3",th:"\u0e20\u0e32\u0e29\u0e32\u0e44\u0e17\u0e22",
"th-TH":"\u0e20\u0e32\u0e29\u0e32\u0e44\u0e17\u0e22 (\u0e1b\u0e23\u0e30\u0e40\u0e17\u0e28\u0e44\u0e17\u0e22)",tl:"Filipino","tl-PH":"Filipino",tlh:"tlhIngan-Hol",tr:"T\u00fcrk\u00e7e","tr-TR":"T\u00fcrk\u00e7e","tt-RU":"\u0442\u0430\u0442\u0430\u0440\u0447\u0430",uk:"\u0423\u043a\u0440\u0430\u0457\u043d\u0441\u044c\u043a\u0430","uk-UA":"\u0423\u043a\u0440\u0430\u0457\u043d\u0441\u044c\u043a\u0430",ur:"\u0627\u0631\u062f\u0648","ur-PK":"\u0627\u0631\u062f\u0648",uz:"O'zbek","uz-UZ":"O'zbek",vi:"Ti\u1ebfng Vi\u1ec7t",
"vi-VN":"Ti\u1ebfng Vi\u1ec7t","xh-ZA":"isiXhosa",yi:"\u05d9\u05d9\u05b4\u05d3\u05d9\u05e9","yi-DE":"\u05d9\u05d9\u05b4\u05d3\u05d9\u05e9 (German)",zh:"\u4e2d\u6587","zh-HANS":"\u4e2d\u6587\u7b80\u4f53","zh-HANT":"\u4e2d\u6587\u7e41\u9ad4","zh-CN":"\u4e2d\u6587\uff08\u4e2d\u56fd\uff09","zh-HK":"\u4e2d\u6587\uff08\u9999\u6e2f\uff09","zh-SG":"\u4e2d\u6587\uff08\u65b0\u52a0\u5761\uff09","zh-TW":"\u4e2d\u6587\uff08\u53f0\u7063\uff09","zu-ZA":"isiZulu"}},$jscomp$iter$379=(0,$jscomp.makeIterator)(Object.keys(mozilla.LanguageMapping)),
$jscomp$key$2089745539$0$key$jscomp$113=$jscomp$iter$379.next();!$jscomp$key$2089745539$0$key$jscomp$113.done;$jscomp$key$2089745539$0$key$jscomp$113=$jscomp$iter$379.next()){var key$jscomp$113=$jscomp$key$2089745539$0$key$jscomp$113.value;mozilla.LanguageMapping[key$jscomp$113.toLowerCase()]=mozilla.LanguageMapping[key$jscomp$113]};shaka.text.Utils=function(){};
shaka.text.Utils.flattenPayload_=function(a,b){if(a.lineBreak)return"\n";if(a.nestedCues.length)return a.nestedCues.map(function(g){return shaka.text.Utils.flattenPayload_(g,a)}).join("");if(!a.payload)return a.payload;var c=[],d=a.fontWeight>=shaka.text.Cue.fontWeight.BOLD,e=a.fontStyle==shaka.text.Cue.fontStyle.ITALIC,f=a.textDecoration.includes(shaka.text.Cue.textDecoration.UNDERLINE);d&&c.push(["b"]);e&&c.push(["i"]);f&&c.push(["u"]);e=a.color;e==""&&b&&(e=b.color);d="";(e=shaka.text.Utils.getColorName_(e))&&
(d+="."+e);e=a.backgroundColor;e==""&&b&&(e=b.backgroundColor);(b=shaka.text.Utils.getColorName_(e))&&(d+=".bg_"+b);d&&c.push(["c",d]);return c.reduceRight(function(g,h){var k=(0,$jscomp.makeIterator)(h);h=k.next().value;k=k.next().value;return"<"+h+(k===void 0?"":k)+">"+g+"</"+h+">"},a.payload)};
shaka.text.Utils.getColorName_=function(a){a=a.toLowerCase();var b=a.replace(/\s/g,"").match(/^rgba?\((\d+),(\d+),(\d+),?([^,\s)]+)?/i);b?a="#"+(parseInt(b[1],10)|256).toString(16).slice(1)+(parseInt(b[2],10)|256).toString(16).slice(1)+(parseInt(b[3],10)|256).toString(16).slice(1):a.startsWith("#")&&a.length>7&&(a=a.slice(0,7));switch(a){case "white":case "#fff":case "#ffffff":return"white";case "lime":case "#0f0":case "#00ff00":return"lime";case "cyan":case "#0ff":case "#00ffff":return"cyan";case "red":case "#f00":case "#ff0000":return"red";
case "yellow":case "#ff0":case "#ffff00":return"yellow";case "magenta":case "#f0f":case "#ff00ff":return"magenta";case "blue":case "#00f":case "#0000ff":return"blue";case "black":case "#000":case "#000000":return"black"}return null};
shaka.text.Utils.getCuesToFlatten=function(a,b){var c=[];a=(0,$jscomp.makeIterator)(shaka.text.Utils.removeDuplicates(a));for(var d=a.next();!d.done;d=a.next())if(d=d.value,d.isContainer)c.push.apply(c,(0,$jscomp.arrayFromIterable)(shaka.text.Utils.getCuesToFlatten(d.nestedCues,d)));else{var e=d.clone();e.nestedCues=[];e.payload=shaka.text.Utils.flattenPayload_(d,b);c.push(e)}return c};
shaka.text.Utils.removeDuplicates=function(a){var b=[];a=(0,$jscomp.makeIterator)(a);for(var c=a.next(),d={};!c.done;d={cue$jscomp$19:void 0},c=a.next())d.cue$jscomp$19=c.value,b.some(function(e){return function(f){return shaka.text.Cue.equal(e.cue$jscomp$19,f)}}(d))||b.push(d.cue$jscomp$19);return b};
shaka.text.Utils.mapShakaCueToNativeCue=function(a){if(a.startTime>=a.endTime)return shaka.log.warning("Invalid cue times: "+a.startTime+" - "+a.endTime),null;var b=shaka.text.Cue,c=new VTTCue(a.startTime,a.endTime,a.payload),d=function(e){for(var f=5381,g=e.length;g;)f=f*33^e.charCodeAt(--g);return(f>>>0).toString()};c.id=d(a.startTime.toString())+d(a.endTime.toString())+d(a.payload);c.lineAlign=a.lineAlign;c.positionAlign=a.positionAlign;a.size&&(c.size=a.size);try{c.align=a.textAlign}catch(e){}a.textAlign==
"center"&&c.align!="center"&&(c.align="middle");a.writingMode==b.writingMode.VERTICAL_LEFT_TO_RIGHT?c.vertical="lr":a.writingMode==b.writingMode.VERTICAL_RIGHT_TO_LEFT&&(c.vertical="rl");a.lineInterpretation==b.lineInterpretation.PERCENTAGE&&(c.snapToLines=!1);a.line!=null&&(c.line=a.line);a.position!=null&&(c.position=a.position);return c};
shaka.text.Utils.mapNativeCueToShakaCue=function(a){if(a.endTime===Infinity||a.endTime<a.startTime)return null;var b=new shaka.text.Cue(a.startTime,a.endTime,a.text);b.line=typeof a.line==="number"?a.line:null;a.lineAlign&&(b.lineAlign=a.lineAlign);b.lineInterpretation=a.snapToLines?shaka.text.Cue.lineInterpretation.LINE_NUMBER:shaka.text.Cue.lineInterpretation.PERCENTAGE;b.position=typeof a.position==="number"?a.position:null;a.positionAlign&&(b.positionAlign=a.positionAlign);b.size=a.size;b.textAlign=
a.align;a.vertical==="lr"?b.writingMode=shaka.text.Cue.writingMode.VERTICAL_LEFT_TO_RIGHT:a.vertical==="rl"&&(b.writingMode=shaka.text.Cue.writingMode.VERTICAL_RIGHT_TO_LEFT);a.region&&(b.region.id=a.region.id,b.region.height=a.region.lines,b.region.heightUnits=shaka.text.CueRegion.units.LINES,b.region.regionAnchorX=a.region.regionAnchorX,b.region.regionAnchorY=a.region.regionAnchorY,b.region.scroll=a.region.scroll,b.region.viewportAnchorX=a.region.viewportAnchorX,b.region.viewportAnchorY=a.region.viewportAnchorY,
b.region.viewportAnchorUnits=shaka.text.CueRegion.units.PERCENTAGE,b.region.width=a.region.width,b.region.widthUnits=shaka.text.CueRegion.units.PERCENTAGE);shaka.text.Cue.parseCuePayload(b);return b};
shaka.text.Utils.appendCuesToTextTrack=function(a,b){var c=shaka.text.Utils.getCuesToFlatten(b),d=[];b=a.cues?Array.from(a.cues):[];c=(0,$jscomp.makeIterator)(c);for(var e=c.next(),f={};!e.done;f={inCue:void 0},e=c.next())f.inCue=e.value,!b.some(function(g){return function(h){return h.startTime==g.inCue.startTime&&h.endTime==g.inCue.endTime&&h.text==g.inCue.payload?!0:!1}}(f))&&f.inCue.payload&&(e=shaka.text.Utils.mapShakaCueToNativeCue(f.inCue))&&d.push(e);b=d.slice().sort(function(g,h){return g.startTime!=
h.startTime?g.startTime-h.startTime:g.endTime!=h.endTime?g.endTime-h.startTime:"line"in VTTCue.prototype?d.indexOf(h)-d.indexOf(g):d.indexOf(g)-d.indexOf(h)});b=(0,$jscomp.makeIterator)(b);for(c=b.next();!c.done;c=b.next())a.addCue(c.value)};
shaka.text.Utils.removeCuesFromTextTrack=function(a,b){var c=!1;a.mode==="disabled"&&(c=!0,a.mode="hidden",goog.asserts.assert(a.cues,'Cues should be accessible when mode is set to "hidden".'));for(var d=0;d<a.cues.length;){var e=a.cues[d];b(e)?a.removeCue(e):d++}c&&(a.mode="disabled")};shaka.text.NativeTextDisplayer=function(a){var b=this;this.player_=a;this.eventManager_=new shaka.util.EventManager;this.video_=null;this.trackNodes_=new Map;this.trackId_=-1;this.visible_=!1;this.timer_=null;this.onUnloading_=function(){var c;(c=b.timer_)==null||c.stop();b.timer_=null;b.eventManager_.unlisten(b.player_,shaka.util.FakeEvent.EventName.TextChanged,b.onTextChanged_);b.eventManager_.unlisten(b.video_.textTracks,"change",b.onChange_);c=(0,$jscomp.makeIterator)(b.trackNodes_.values());
for(var d=c.next();!d.done;d=c.next())d.value.remove();b.trackNodes_.clear();b.trackId_=-1;b.video_=null};this.onTextChanged_=function(){var c=new Map,d=b.player_.getTextTracks();d=(0,$jscomp.makeIterator)(d);for(var e=d.next();!e.done;e=d.next()){e=e.value;if(b.trackNodes_.has(e.id)){var f=b.trackNodes_.get(e.id);e.active||f.track.mode==="disabled"||(f.track.mode="disabled");b.trackNodes_.delete(e.id)}else{f=b.video_.ownerDocument.createElement("track");f.kind=shaka.text.NativeTextDisplayer.getTrackKind_(e);
f.label=shaka.text.NativeTextDisplayer.getTrackLabel_(e);if(e.language)if(e.language in mozilla.LanguageMapping)f.srclang=e.language;else{var g=shaka.util.LanguageUtils.getBase(e.language),h=void 0;f.srclang=(h=g)!=null?h:"und"}else f.srclang="und";f.src="data:,WEBVTT";f.track.mode="disabled";b.video_.appendChild(f)}c.set(e.id,f);e.active&&(b.trackId_=e.id)}d=(0,$jscomp.makeIterator)(b.trackNodes_.values());for(e=d.next();!e.done;e=d.next())e.value.remove();b.trackId_>-1&&(c.has(b.trackId_)?(d=c.get(b.trackId_).track,
d.mode==="disabled"&&(d.mode=b.visible_?"showing":"hidden")):b.trackId_=-1);b.trackNodes_=c};this.onChange_=function(){if(!b.timer_){var c=b.video_;b.timer_=(new shaka.util.Timer(function(){b.timer_=null;if(b.video_===c){var d=-1,e=!1;if(b.trackNodes_.has(b.trackId_)){var f=b.trackNodes_.get(b.trackId_);f.track.mode==="showing"?(d=b.trackId_,e=!0):f.track.mode==="hidden"&&(d=b.trackId_)}if(!e)for(e=(0,$jscomp.makeIterator)(b.trackNodes_),f=e.next();!f.done;f=e.next()){var g=(0,$jscomp.makeIterator)(f.value);
f=g.next().value;g=g.next().value;if(g.track.mode==="showing"){d=f;break}else d<0&&g.track.mode==="hidden"&&(d=f)}e=(0,$jscomp.makeIterator)(b.trackNodes_);for(f=e.next();!f.done;f=e.next())g=(0,$jscomp.makeIterator)(f.value),f=g.next().value,g=g.next().value,f!==d&&g.track.mode!=="disabled"&&(g.track.mode="disabled");b.trackId_!==d&&(b.trackId_=d,d>-1&&b.player_.selectTextTrack({id:d}));b.player_.setTextTrackVisibility(d>-1&&b.trackNodes_.get(d).track.mode==="showing")}})).tickAfter(0)}};this.eventManager_.listen(a,
shaka.util.FakeEvent.EventName.Loaded,function(){return b.enableTextDisplayer()});this.enableTextDisplayer()};shaka.text.NativeTextDisplayer.prototype.configure=function(a){};shaka.text.NativeTextDisplayer.prototype.remove=function(a,b){if(this.player_)this.trackNodes_.has(this.trackId_)&&shaka.text.Utils.removeCuesFromTextTrack(this.trackNodes_.get(this.trackId_).track,function(c){return c.startTime<b&&c.endTime>a});else return!1;return!0};
shaka.text.NativeTextDisplayer.prototype.append=function(a){this.trackNodes_.has(this.trackId_)&&shaka.text.Utils.appendCuesToTextTrack(this.trackNodes_.get(this.trackId_).track,a)};shaka.text.NativeTextDisplayer.prototype.destroy=function(){if(this.player_){if(this.video_)this.onUnloading_();this.player_=null}var a;(a=this.timer_)==null||a.stop();this.timer_=null;var b;(b=this.eventManager_)==null||b.release();this.eventManager_=null;return Promise.resolve()};
shaka.text.NativeTextDisplayer.prototype.isTextVisible=function(){return this.visible_};
shaka.text.NativeTextDisplayer.prototype.setTextVisibility=function(a){this.visible_=a;if(this.trackNodes_.has(this.trackId_)){var b=this.trackNodes_.get(this.trackId_).track;b.mode!=="disabled"&&(a=a?"showing":"hidden",b.mode!==a&&(b.mode=a))}else if(this.player_&&this.player_.getLoadMode()===3)if(b=Array.from(this.player_.getMediaElement().textTracks).filter(function(d){return["captions","subtitles","forced"].includes(d.kind)}),a){a=null;b=(0,$jscomp.makeIterator)(b);for(var c=b.next();!c.done;c=
b.next())if(c=c.value,c.mode==="showing"){a=null;break}else a||c.mode!=="hidden"||(a=c);a&&(a.mode="showing")}else for(a=(0,$jscomp.makeIterator)(b),b=a.next();!b.done;b=a.next())b=b.value,b.mode==="showing"&&(b.mode="hidden")};shaka.text.NativeTextDisplayer.prototype.setTextLanguage=function(a){};
shaka.text.NativeTextDisplayer.prototype.enableTextDisplayer=function(){!this.video_&&this.player_&&this.player_.getLoadMode()===2&&(this.video_=this.player_.getMediaElement(),this.eventManager_.listenOnce(this.player_,shaka.util.FakeEvent.EventName.Unloading,this.onUnloading_),this.eventManager_.listen(this.player_,shaka.util.FakeEvent.EventName.TextChanged,this.onTextChanged_),this.eventManager_.listen(this.video_.textTracks,"change",this.onChange_),this.onTextChanged_())};
shaka.text.NativeTextDisplayer.getTrackKind_=function(a){var b=shaka.device.DeviceFactory.getDevice();return a.forced&&b.getBrowserEngine()===shaka.device.IDevice.BrowserEngine.WEBKIT?"forced":a.kind===shaka.util.ManifestParserUtils.TextStreamKind.CLOSED_CAPTION?"captions":"subtitles"};
shaka.text.NativeTextDisplayer.getTrackLabel_=function(a){if(a.label)var b=a.label;else if(a.language)if(a.language in mozilla.LanguageMapping)b=mozilla.LanguageMapping[a.language];else{var c=shaka.util.LanguageUtils.getBase(a.language);c in mozilla.LanguageMapping&&(b=mozilla.LanguageMapping[c]+" ("+a.language+")")}b||(b=a.originalTextId,a.language&&a.language!==a.originalTextId&&(b+=" ("+a.language+")"));return b};goog.exportSymbol("shaka.text.NativeTextDisplayer",shaka.text.NativeTextDisplayer);
goog.exportProperty(shaka.text.NativeTextDisplayer.prototype,"enableTextDisplayer",shaka.text.NativeTextDisplayer.prototype.enableTextDisplayer);goog.exportProperty(shaka.text.NativeTextDisplayer.prototype,"setTextLanguage",shaka.text.NativeTextDisplayer.prototype.setTextLanguage);goog.exportProperty(shaka.text.NativeTextDisplayer.prototype,"setTextVisibility",shaka.text.NativeTextDisplayer.prototype.setTextVisibility);goog.exportProperty(shaka.text.NativeTextDisplayer.prototype,"isTextVisible",shaka.text.NativeTextDisplayer.prototype.isTextVisible);
goog.exportProperty(shaka.text.NativeTextDisplayer.prototype,"destroy",shaka.text.NativeTextDisplayer.prototype.destroy);goog.exportProperty(shaka.text.NativeTextDisplayer.prototype,"append",shaka.text.NativeTextDisplayer.prototype.append);goog.exportProperty(shaka.text.NativeTextDisplayer.prototype,"remove",shaka.text.NativeTextDisplayer.prototype.remove);goog.exportProperty(shaka.text.NativeTextDisplayer.prototype,"configure",shaka.text.NativeTextDisplayer.prototype.configure);shaka.text.SimpleTextDisplayer=function(a,b){shaka.Deprecate.deprecateFeature(5,"SimpleTextDisplayer","Please migrate to NativeTextDisplayer");this.video_=a;this.textTrackLabel_=b;this.textTrack_=null;a=(0,$jscomp.makeIterator)(Array.from(this.video_.textTracks));for(b=a.next();!b.done;b=a.next())b=b.value,b.kind!=="metadata"&&b.kind!=="chapters"&&(b.mode="disabled",b.label==this.textTrackLabel_&&(this.textTrack_=b));this.textTrack_&&(this.textTrack_.mode="hidden")};
shaka.text.SimpleTextDisplayer.prototype.configure=function(a){};shaka.text.SimpleTextDisplayer.prototype.remove=function(a,b){if(!this.textTrack_)return!1;shaka.text.Utils.removeCuesFromTextTrack(this.textTrack_,function(c){return c.startTime<b&&c.endTime>a});return!0};shaka.text.SimpleTextDisplayer.prototype.append=function(a){this.textTrack_&&shaka.text.Utils.appendCuesToTextTrack(this.textTrack_,a)};
shaka.text.SimpleTextDisplayer.prototype.destroy=function(){this.textTrack_&&(shaka.text.Utils.removeCuesFromTextTrack(this.textTrack_,function(a){return!0}),this.textTrack_.mode="disabled");this.textTrack_=this.video_=null;return Promise.resolve()};shaka.text.SimpleTextDisplayer.prototype.isTextVisible=function(){return this.textTrack_?this.textTrack_.mode=="showing":!1};
shaka.text.SimpleTextDisplayer.prototype.setTextVisibility=function(a){a&&!this.textTrack_&&this.createTextTrack_();this.textTrack_&&(this.textTrack_.mode=a?"showing":"hidden")};shaka.text.SimpleTextDisplayer.prototype.setTextLanguage=function(a){};shaka.text.SimpleTextDisplayer.prototype.enableTextDisplayer=function(){this.createTextTrack_()};
shaka.text.SimpleTextDisplayer.prototype.createTextTrack_=function(){this.video_&&!this.textTrack_&&(this.textTrack_=this.video_.addTextTrack("subtitles",this.textTrackLabel_),this.textTrack_.mode="hidden")};goog.exportSymbol("shaka.text.SimpleTextDisplayer",shaka.text.SimpleTextDisplayer);goog.exportProperty(shaka.text.SimpleTextDisplayer.prototype,"enableTextDisplayer",shaka.text.SimpleTextDisplayer.prototype.enableTextDisplayer);
goog.exportProperty(shaka.text.SimpleTextDisplayer.prototype,"setTextLanguage",shaka.text.SimpleTextDisplayer.prototype.setTextLanguage);goog.exportProperty(shaka.text.SimpleTextDisplayer.prototype,"setTextVisibility",shaka.text.SimpleTextDisplayer.prototype.setTextVisibility);goog.exportProperty(shaka.text.SimpleTextDisplayer.prototype,"isTextVisible",shaka.text.SimpleTextDisplayer.prototype.isTextVisible);goog.exportProperty(shaka.text.SimpleTextDisplayer.prototype,"destroy",shaka.text.SimpleTextDisplayer.prototype.destroy);
goog.exportProperty(shaka.text.SimpleTextDisplayer.prototype,"append",shaka.text.SimpleTextDisplayer.prototype.append);goog.exportProperty(shaka.text.SimpleTextDisplayer.prototype,"remove",shaka.text.SimpleTextDisplayer.prototype.remove);goog.exportProperty(shaka.text.SimpleTextDisplayer.prototype,"configure",shaka.text.SimpleTextDisplayer.prototype.configure);shaka.text.StubTextDisplayer=function(){};shaka.text.StubTextDisplayer.prototype.configure=function(a){};shaka.text.StubTextDisplayer.prototype.remove=function(a,b){};shaka.text.StubTextDisplayer.prototype.append=function(a){};shaka.text.StubTextDisplayer.prototype.destroy=function(){};shaka.text.StubTextDisplayer.prototype.isTextVisible=function(){return!1};shaka.text.StubTextDisplayer.prototype.setTextVisibility=function(a){};shaka.text.StubTextDisplayer.prototype.setTextLanguage=function(a){};
shaka.text.StubTextDisplayer.prototype.enableTextDisplayer=function(){};goog.exportSymbol("shaka.text.StubTextDisplayer",shaka.text.StubTextDisplayer);goog.exportProperty(shaka.text.StubTextDisplayer.prototype,"enableTextDisplayer",shaka.text.StubTextDisplayer.prototype.enableTextDisplayer);goog.exportProperty(shaka.text.StubTextDisplayer.prototype,"setTextLanguage",shaka.text.StubTextDisplayer.prototype.setTextLanguage);
goog.exportProperty(shaka.text.StubTextDisplayer.prototype,"setTextVisibility",shaka.text.StubTextDisplayer.prototype.setTextVisibility);goog.exportProperty(shaka.text.StubTextDisplayer.prototype,"isTextVisible",shaka.text.StubTextDisplayer.prototype.isTextVisible);goog.exportProperty(shaka.text.StubTextDisplayer.prototype,"destroy",shaka.text.StubTextDisplayer.prototype.destroy);goog.exportProperty(shaka.text.StubTextDisplayer.prototype,"append",shaka.text.StubTextDisplayer.prototype.append);
goog.exportProperty(shaka.text.StubTextDisplayer.prototype,"remove",shaka.text.StubTextDisplayer.prototype.remove);goog.exportProperty(shaka.text.StubTextDisplayer.prototype,"configure",shaka.text.StubTextDisplayer.prototype.configure);shaka.text.UITextDisplayer=function(a,b){var c=this;goog.asserts.assert(b,"videoContainer should be valid.");this.isTextVisible_=!1;this.cues_=[];this.video_=a;this.videoContainer_=b;this.config_=this.aspectRatio_=null;this.textContainer_=shaka.util.Dom.createHTMLElement("div");this.textContainer_.classList.add("shaka-text-container");this.textContainer_.style.textAlign="center";this.textContainer_.style.display="flex";this.textContainer_.style.flexDirection="column";this.textContainer_.style.alignItems=
"center";this.textContainer_.style.justifyContent="flex-end";this.captionsTimer_=new shaka.util.Timer(function(){c.video_.paused||c.updateCaptions_()});this.configureCaptionsTimer_();this.currentCuesMap_=new Map;this.eventManager_=new shaka.util.EventManager;this.eventManager_.listen(document,"fullscreenchange",function(){c.updateCaptions_(!0)});this.eventManager_.listen(this.video_,"seeking",function(){c.updateCaptions_(!0)});this.eventManager_.listen(this.video_,"ratechange",function(){c.configureCaptionsTimer_()});
this.eventManager_.listen(this.video_,"resize",function(){var d=c.video_,e=d.videoWidth;d=d.videoHeight;c.aspectRatio_=e&&d?e/d:null});this.pendingResize_=!1;this.resizeObserver_=null;"ResizeObserver"in window&&(this.resizeObserver_=new ResizeObserver(function(){c.pendingResize_||(c.pendingResize_=!0,requestAnimationFrame(function(){c.pendingResize_=!1;c.textContainer_&&c.textContainer_.parentElement&&c.isTextVisible_&&c.updateCaptions_(!0)}))}),goog.asserts.assert(this.videoContainer_,"this.videoContainer_ must be non-null"),
this.resizeObserver_.observe(this.videoContainer_));this.regionElements_=new Map};shaka.text.UITextDisplayer.prototype.configure=function(a){this.config_=a;this.configureCaptionsTimer_();this.updateCaptions_(!0)};
shaka.text.UITextDisplayer.prototype.append=function(a){var b=[].concat((0,$jscomp.arrayFromIterable)(this.cues_));a=(0,$jscomp.makeIterator)(shaka.text.Utils.removeDuplicates(a));for(var c=a.next(),d={};!c.done;d={cue$jscomp$27:void 0},c=a.next())d.cue$jscomp$27=c.value,b.some(function(e){return function(f){return shaka.text.Cue.equal(f,e.cue$jscomp$27)}}(d))||this.cues_.push(d.cue$jscomp$27);this.cues_.length&&this.configureCaptionsTimer_();this.updateCaptions_()};
shaka.text.UITextDisplayer.prototype.destroy=function(){if(!this.textContainer_)return Promise.resolve();this.textContainer_.parentElement&&this.videoContainer_.removeChild(this.textContainer_);this.textContainer_=null;this.isTextVisible_=!1;this.cues_=[];this.captionsTimer_&&(this.captionsTimer_.stop(),this.captionsTimer_=null);this.currentCuesMap_.clear();this.eventManager_&&(this.eventManager_.release(),this.eventManager_=null);this.resizeObserver_&&(this.resizeObserver_.disconnect(),this.resizeObserver_=
null);return Promise.resolve()};shaka.text.UITextDisplayer.prototype.remove=function(a,b){if(!this.textContainer_)return!1;var c=this.cues_.length;this.cues_=this.cues_.filter(function(d){return d.startTime<a||d.endTime>=b});this.updateCaptions_(c>this.cues_.length);this.cues_.length||this.configureCaptionsTimer_();return!0};shaka.text.UITextDisplayer.prototype.isTextVisible=function(){return this.isTextVisible_};
shaka.text.UITextDisplayer.prototype.setTextVisibility=function(a){(this.isTextVisible_=a)?(this.textContainer_.parentElement||this.videoContainer_.appendChild(this.textContainer_),this.updateCaptions_(!0)):this.textContainer_.parentElement&&this.videoContainer_.removeChild(this.textContainer_)};shaka.text.UITextDisplayer.prototype.setTextLanguage=function(a){a&&a!="und"?this.textContainer_.setAttribute("lang",a):this.textContainer_.setAttribute("lang","")};
shaka.text.UITextDisplayer.prototype.enableTextDisplayer=function(){};shaka.text.UITextDisplayer.prototype.configureCaptionsTimer_=function(){this.captionsTimer_&&(this.cues_.length?this.captionsTimer_.tickEvery((this.config_?this.config_.captionsUpdatePeriod:.25)/Math.max(1,Math.abs(this.video_.playbackRate))):this.captionsTimer_.stop())};shaka.text.UITextDisplayer.prototype.isElementUnderTextContainer_=function(a){for(;a!=null;){if(a==this.textContainer_)return!0;a=a.parentElement}return!1};
shaka.text.UITextDisplayer.prototype.updateCuesRecursive_=function(a,b,c,d){var e=!1,f=[],g=[];a=(0,$jscomp.makeIterator)(a);for(var h=a.next();!h.done;h=a.next()){h=h.value;d.push(h);var k=this.currentCuesMap_.get(h),l=h.startTime<=c&&h.endTime>c,m=k?k.wrapper:null;k&&(f.push(k.cueElement),k.regionElement&&f.push(k.regionElement),l||(e=!0,this.currentCuesMap_.delete(h),k=null));l&&(g.push(h),k?this.isElementUnderTextContainer_(m)||(e=!0):(this.createCue_(h,d),k=this.currentCuesMap_.get(h),m=k.wrapper,
e=!0));h.nestedCues.length>0&&m&&this.updateCuesRecursive_(h.nestedCues,m,c,d);k=d.pop();goog.asserts.assert(k==h,"Parent cues should be kept in order")}if(e){c=(0,$jscomp.makeIterator)(f);for(d=c.next();!d.done;d=c.next())d=d.value,d.parentElement&&d.parentElement.removeChild(d);g.sort(function(n,p){return n.startTime!=p.startTime?n.startTime-p.startTime:n.endTime-p.endTime});g=(0,$jscomp.makeIterator)(g);for(c=g.next();!c.done;c=g.next())c=this.currentCuesMap_.get(c.value),goog.asserts.assert(c,
"cueRegistry should exist."),c.regionElement?(c.regionElement.contains(b)&&c.regionElement.removeChild(b),b.appendChild(c.regionElement),c.regionElement.appendChild(c.cueElement)):b.appendChild(c.cueElement)}};
shaka.text.UITextDisplayer.prototype.updateCaptions_=function(a){if(this.textContainer_){var b=this.video_.currentTime;if(!this.isTextVisible_||(a===void 0?0:a)){a=(0,$jscomp.makeIterator)(this.regionElements_.values());for(var c=a.next();!c.done;c=a.next())shaka.util.Dom.removeAllChildren(c.value);shaka.util.Dom.removeAllChildren(this.textContainer_);this.currentCuesMap_.clear();this.regionElements_.clear()}if(this.isTextVisible_){a=new Map;if(goog.DEBUG){c=(0,$jscomp.makeIterator)(this.currentCuesMap_.keys());
for(var d=c.next();!d.done;d=c.next())d=d.value,a.set(d,this.currentCuesMap_.get(d))}this.updateCuesRecursive_(this.cues_,this.textContainer_,b,[]);if(goog.DEBUG)for(b=(0,$jscomp.makeIterator)(a.keys()),c=b.next();!c.done;c=b.next())c=c.value,this.currentCuesMap_.has(c)||(c=a.get(c).cueElement,goog.asserts.assert(!c.parentNode,"Cue was not properly removed!"))}}};
shaka.text.UITextDisplayer.prototype.generateRegionId_=function(a){var b=shaka.text.CueRegion.units.PERCENTAGE;return a.id+"_"+a.width+"x"+a.height+(a.heightUnits==b?"%":"px")+"-"+a.viewportAnchorX+"x"+a.viewportAnchorY+(a.viewportAnchorUnits==b?"%":"px")+"-"+a.regionAnchorX+"x"+a.regionAnchorY};
shaka.text.UITextDisplayer.prototype.getRegionElement_=function(a){var b=a.region,c=this.aspectRatio_===4/3?2.5:1.9,d=this.generateRegionId_(b);if(this.regionElements_.has(d))return this.regionElements_.get(d);var e=shaka.util.Dom.createHTMLElement("span"),f=shaka.text.CueRegion.units.LINES,g=shaka.text.CueRegion.units.PERCENTAGE,h=shaka.text.CueRegion.units.PX,k=b.heightUnits==g?"%":"px",l=b.widthUnits==g?"%":"px",m=b.viewportAnchorUnits==g?"%":"px";e.id="shaka-text-region---"+d;e.classList.add("shaka-text-region");
e.style.position="absolute";g=b.height;var n=b.width;b.heightUnits===f&&(g=b.height*5.33,k="%");b.widthUnits===f&&(n=b.width*c,l="%");e.style.height=g+k;e.style.width=n+l;b.viewportAnchorUnits===f?(c=b.viewportAnchorY/75*100,f=b.viewportAnchorX/(this.aspectRatio_===4/3?160:210)*100,c-=b.regionAnchorY*g/100,f-=b.regionAnchorX*n/100,e.style.top=c+"%",e.style.left=f+"%"):(e.style.top=b.viewportAnchorY-b.regionAnchorY*g/100+m,e.style.left=b.viewportAnchorX-b.regionAnchorX*n/100+m);b.heightUnits!==h&&
b.widthUnits!==h&&b.viewportAnchorUnits!==h&&(b=parseInt(e.style.top.slice(0,-1),10)||0,g=parseInt(e.style.left.slice(0,-1),10)||0,h=parseInt(e.style.height.slice(0,-1),10)||0,n=parseInt(e.style.width.slice(0,-1),10)||0,g=Math.max(0,Math.min(100-n,g)),e.style.top=Math.max(0,Math.min(100-h,b))+"%",e.style.left=g+"%");e.style.display="flex";e.style.flexDirection="column";e.style.alignItems="center";e.style.justifyContent=a.displayAlign==shaka.text.Cue.displayAlign.BEFORE?"flex-start":a.displayAlign==
shaka.text.Cue.displayAlign.CENTER?"center":"flex-end";this.regionElements_.set(d,e);return e};
shaka.text.UITextDisplayer.prototype.createCue_=function(a,b){var c=b.length>1,d=c?"span":"div";a.lineBreak&&(d="br");a.rubyTag&&(d=a.rubyTag);c=!c&&a.nestedCues.length>0;var e=shaka.util.Dom.createHTMLElement(d);d!="br"&&this.setCaptionStyles_(e,a,b,c);b=null;a.region&&a.region.id&&(b=this.getRegionElement_(a));d=e;c&&(d=shaka.util.Dom.createHTMLElement("span"),d.classList.add("shaka-text-wrapper"),d.style.backgroundColor=a.backgroundColor,d.style.lineHeight="normal",e.appendChild(d));this.currentCuesMap_.set(a,
{cueElement:e,wrapper:d,regionElement:b})};
shaka.text.UITextDisplayer.prototype.computeCuePositionAlignment_=function(a){var b=shaka.text.Cue,c=a.direction,d=a.positionAlign;a=a.textAlign;return d!==b.positionAlign.AUTO?d:a===b.textAlign.LEFT||a===b.textAlign.START&&c===b.direction.HORIZONTAL_LEFT_TO_RIGHT||a===b.textAlign.END&&c===b.direction.HORIZONTAL_RIGHT_TO_LEFT?b.positionAlign.LEFT:a===b.textAlign.RIGHT||a===b.textAlign.START&&c===b.direction.HORIZONTAL_RIGHT_TO_LEFT||a===b.textAlign.END&&c===b.direction.HORIZONTAL_LEFT_TO_RIGHT?b.positionAlign.RIGHT:
b.positionAlign.CENTER};
shaka.text.UITextDisplayer.prototype.setCaptionStyles_=function(a,b,c,d){var e=shaka.text.Cue,f=a.style,g=b.nestedCues.length==0,h=c.length>1;f.whiteSpace="pre-wrap";var k=b.payload.replace(/\s+$/g,function(m){return"\u00a0".repeat(m.length)});f.webkitTextStrokeColor=b.textStrokeColor;f.webkitTextStrokeWidth=b.textStrokeWidth;f.color=b.color;f.direction=b.direction;f.opacity=b.opacity;f.paddingLeft=shaka.text.UITextDisplayer.convertLengthValue_(b.linePadding,b,this.videoContainer_);f.paddingRight=
shaka.text.UITextDisplayer.convertLengthValue_(b.linePadding,b,this.videoContainer_);f.textCombineUpright=b.textCombineUpright;f.textShadow=b.textShadow;if(b.backgroundImage)k=b.backgroundImage.replace(/['"()\\]/g,""),f.backgroundImage="url('"+k+"')",f.backgroundRepeat="no-repeat",f.backgroundSize="contain",f.backgroundPosition="center",b.backgroundColor&&(f.backgroundColor=b.backgroundColor),f.width="100%",f.height="100%";else{if(b.nestedCues.length)var l=a;else l=shaka.util.Dom.createHTMLElement("span"),
a.appendChild(l);b.border&&(l.style.border=b.border);d||((a=shaka.text.UITextDisplayer.inheritProperty_(c,function(m){return m.backgroundColor}))?l.style.backgroundColor=a:k&&(l.style.backgroundColor="rgba(0, 0, 0, 0.8)"));k&&(l.setAttribute("translate","no"),l.textContent=k)}if(h&&!c[c.length-1].isContainer)f.display="inline";else{f.display="flex";f.flexDirection="column";f.alignItems="center";if(b.textAlign==e.textAlign.LEFT||b.textAlign==e.textAlign.START)f.width="100%",f.alignItems="flex-start";
else if(b.textAlign==e.textAlign.RIGHT||b.textAlign==e.textAlign.END)f.width="100%",f.alignItems="flex-end";f.justifyContent=b.displayAlign==e.displayAlign.BEFORE?"flex-start":b.displayAlign==e.displayAlign.CENTER?"center":"flex-end"}g||(f.margin="0");f.fontFamily=b.fontFamily;f.fontWeight=b.fontWeight.toString();f.fontStyle=b.fontStyle;f.letterSpacing=b.letterSpacing;c=this.config_?this.config_.fontScaleFactor:1;if(c!==1||b.fontSize)f.fontSize=shaka.text.UITextDisplayer.convertLengthValue_(b.fontSize||
"1em",b,this.videoContainer_,c);c=b.line;c!=null&&(g=b.lineInterpretation,g==e.lineInterpretation.LINE_NUMBER&&(g=e.lineInterpretation.PERCENTAGE,h=16,this.aspectRatio_&&this.aspectRatio_<1&&(h=32),c=c<0?100+c/h*100:c/h*100),g==e.lineInterpretation.PERCENTAGE&&(f.position="absolute",b.writingMode==e.writingMode.HORIZONTAL_TOP_TO_BOTTOM?(f.width="100%",b.lineAlign==e.lineAlign.START?f.top=c+"%":b.lineAlign==e.lineAlign.END&&(f.bottom=100-c+"%")):b.writingMode==e.writingMode.VERTICAL_LEFT_TO_RIGHT?
(f.height="100%",b.lineAlign==e.lineAlign.START?f.left=c+"%":b.lineAlign==e.lineAlign.END&&(f.right=100-c+"%")):(f.height="100%",b.lineAlign==e.lineAlign.START?f.right=c+"%":b.lineAlign==e.lineAlign.END&&(f.left=100-c+"%"))));f.lineHeight=b.lineHeight;c=this.computeCuePositionAlignment_(b);c==e.positionAlign.LEFT?(f.cssFloat="left",b.position!==null&&(f.position="absolute",b.writingMode==e.writingMode.HORIZONTAL_TOP_TO_BOTTOM?(f.left=b.position+"%",f.width="auto"):f.top=b.position+"%")):c==e.positionAlign.RIGHT?
(f.cssFloat="right",b.position!==null&&(f.position="absolute",b.writingMode==e.writingMode.HORIZONTAL_TOP_TO_BOTTOM?(f.right=100-b.position+"%",f.width="auto"):f.bottom=b.position+"%")):b.position!==null&&b.position!=50&&(f.position="absolute",b.writingMode==e.writingMode.HORIZONTAL_TOP_TO_BOTTOM?(f.left=b.position+"%",f.width="auto"):f.top=b.position+"%",b.size&&(f.transform="translateX(-50%)"));f.textAlign=b.textAlign;f.textDecoration=b.textDecoration.join(" ");f.writingMode=b.writingMode;"writingMode"in
document.documentElement.style&&f.writingMode==b.writingMode||(f.webkitWritingMode=b.writingMode);b.size&&(b.writingMode==e.writingMode.HORIZONTAL_TOP_TO_BOTTOM?f.width=b.size+"%":f.height=b.size+"%")};shaka.text.UITextDisplayer.getLengthValueInfo_=function(a){return(a=(new RegExp(/(\d*\.?\d+)([a-z]+|%+)/)).exec(a))?{value:Number(a[1]),unit:a[2]}:null};
shaka.text.UITextDisplayer.convertLengthValue_=function(a,b,c,d){d=d===void 0?1:d;var e=shaka.text.UITextDisplayer.getLengthValueInfo_(a);if(!e)return a;a=e.unit;d*=e.value;switch(a){case "%":return shaka.text.UITextDisplayer.getAbsoluteLengthInPixels_(d/100,b,c);case "c":return shaka.text.UITextDisplayer.getAbsoluteLengthInPixels_(d,b,c);default:return d+a}};shaka.text.UITextDisplayer.getAbsoluteLengthInPixels_=function(a,b,c){return c.clientHeight*a/b.cellResolution.rows+"px"};
shaka.text.UITextDisplayer.inheritProperty_=function(a,b){for(var c=a.length-1;c>=0;c--){var d=b(a[c]);if(d||d===0)return d}return null};goog.exportSymbol("shaka.text.UITextDisplayer",shaka.text.UITextDisplayer);goog.exportProperty(shaka.text.UITextDisplayer.prototype,"enableTextDisplayer",shaka.text.UITextDisplayer.prototype.enableTextDisplayer);goog.exportProperty(shaka.text.UITextDisplayer.prototype,"setTextLanguage",shaka.text.UITextDisplayer.prototype.setTextLanguage);
goog.exportProperty(shaka.text.UITextDisplayer.prototype,"setTextVisibility",shaka.text.UITextDisplayer.prototype.setTextVisibility);goog.exportProperty(shaka.text.UITextDisplayer.prototype,"isTextVisible",shaka.text.UITextDisplayer.prototype.isTextVisible);goog.exportProperty(shaka.text.UITextDisplayer.prototype,"remove",shaka.text.UITextDisplayer.prototype.remove);goog.exportProperty(shaka.text.UITextDisplayer.prototype,"destroy",shaka.text.UITextDisplayer.prototype.destroy);
goog.exportProperty(shaka.text.UITextDisplayer.prototype,"append",shaka.text.UITextDisplayer.prototype.append);goog.exportProperty(shaka.text.UITextDisplayer.prototype,"configure",shaka.text.UITextDisplayer.prototype.configure);shaka.text.WebVttGenerator=function(){};
shaka.text.WebVttGenerator.convert=function(a,b){var c=function(f){for(var g=f,h=(0,$jscomp.makeIterator)(b),k=h.next();!k.done;k=h.next())k=k.value,k.end&&k.start<f&&(g+=k.end-k.start);f=Math.floor(g/3600);h=Math.floor(g/60%60);k=Math.floor(g%60);g=Math.floor(g*1E3%1E3);return(f<10?"0":"")+f+":"+(h<10?"0":"")+h+":"+(k<10?"0":"")+k+"."+(g<100?g<10?"00":"0":"")+g},d=shaka.text.Utils.getCuesToFlatten(a);a="WEBVTT\n\n";d=(0,$jscomp.makeIterator)(d);for(var e=d.next();!e.done;e=d.next())e=e.value,a+=
c(e.startTime)+" --\x3e "+c(e.endTime)+function(f){var g=[],h=shaka.text.Cue;switch(f.textAlign){case h.textAlign.LEFT:g.push("align:left");break;case h.textAlign.RIGHT:g.push("align:right");break;case h.textAlign.CENTER:g.push("align:middle");break;case h.textAlign.START:g.push("align:start");break;case h.textAlign.END:g.push("align:end")}switch(f.writingMode){case h.writingMode.VERTICAL_LEFT_TO_RIGHT:g.push("vertical:lr");break;case h.writingMode.VERTICAL_RIGHT_TO_LEFT:g.push("vertical:rl")}return g.length?
" "+g.join(" "):""}(e)+"\n",a+=e.payload+"\n\n";return a};goog.exportSymbol("shaka.text.WebVttGenerator",shaka.text.WebVttGenerator);shaka.util.CmcdManager=function(a,b){this.config_=b;this.player_=a;this.requestTimestampMap_=new Map;this.sf_=void 0;this.playbackStarted_=!1;this.buffering_=!0;this.lowLatency_=this.starved_=!1;this.playbackPlayingTime_=this.playbackPlayTime_=void 0;this.startTimeOfLoad_=0;this.msdSent_={request:!1,response:!1,event:!1};this.cmcdSequenceNumbers_={};this.eventManager_=new shaka.util.EventManager;this.eventTimers_=[];this.video_=null};
shaka.util.CmcdManager.prototype.setMediaElement=function(a){this.video_=a;this.setupEventListeners_()};shaka.util.CmcdManager.prototype.configure=function(a){this.config_=a;this.setupEventModeTimeInterval_()};
shaka.util.CmcdManager.prototype.reset=function(){this.requestTimestampMap_.clear();this.playbackStarted_=!1;this.buffering_=!0;this.lowLatency_=this.starved_=!1;this.startTimeOfLoad_=this.playbackPlayingTime_=this.playbackPlayTime_=0;this.msdSent_={request:!1,response:!1,event:!1};this.stopAndClearEventTimers_();this.cmcdSequenceNumbers_={};this.video_=null;this.eventManager_.removeAll()};
shaka.util.CmcdManager.prototype.setBuffering=function(a){a||this.playbackStarted_||(this.playbackStarted_=!0);this.playbackStarted_&&a&&(this.starved_=!0,this.reportEvent_("ps",{sta:"r"}));this.buffering_=a};
shaka.util.CmcdManager.prototype.setLowLatency=function(a){this.lowLatency_=a;a=shaka.util.CmcdManager.StreamingFormat;this.lowLatency_?this.sf_==a.DASH?this.sf_=a.LOW_LATENCY_DASH:this.sf_==a.HLS&&(this.sf_=a.LOW_LATENCY_HLS):this.sf_==a.LOW_LATENCY_DASH?this.sf_=a.DASH:this.sf_==a.LOW_LATENCY_HLS&&(this.sf_=a.HLS)};
shaka.util.CmcdManager.prototype.setStartTimeOfLoad=function(a){var b=this;if(this.config_&&this.config_.enabled&&(this.reportEvent_("ps",{sta:"d"}),this.video_&&this.video_.autoplay)){var c=this.video_.play();c&&c.then(function(){b.startTimeOfLoad_=a}).catch(function(d){b.startTimeOfLoad_=0})}};
shaka.util.CmcdManager.prototype.applyRequestData=function(a,b,c){c=c===void 0?{}:c;if(this.config_.enabled)if(b.method==="HEAD")this.applyRequest_(b,{});else{var d=shaka.net.NetworkingEngine.RequestType,e=shaka.util.CmcdManager.ObjectType;switch(a){case d.MANIFEST:this.applyManifestData(b,c);break;case d.SEGMENT:this.applyRequestSegmentData(b,c);break;case d.LICENSE:case d.SERVER_CERTIFICATE:case d.KEY:this.applyRequest_(b,{ot:e.KEY});break;case d.TIMING:this.applyRequest_(b,{ot:e.OTHER})}}};
shaka.util.CmcdManager.prototype.applyResponseData=function(a,b,c){c=c===void 0?{}:c;if(this.getResponseModeEnabledTargets().length!==0){var d=shaka.net.NetworkingEngine.RequestType;switch(a){case d.SEGMENT:this.applyResponseSegmentData(b,c)}}};
shaka.util.CmcdManager.prototype.applyManifestData=function(a,b){try{this.config_.enabled&&(b.type&&(this.sf_=this.getStreamFormat_(b.type)),this.applyRequest_(a,{ot:shaka.util.CmcdManager.ObjectType.MANIFEST,su:!this.playbackStarted_}))}catch(c){shaka.log.warnOnce("CMCD_MANIFEST_ERROR","Could not generate manifest CMCD data.",c)}};
shaka.util.CmcdManager.prototype.applyResponseSegmentData=function(a,b){try{var c=this.getDataForSegment_(b,a.uri);a.originalRequest&&a.originalRequest.timeToFirstByte!=null&&(c.ttfb=a.originalRequest.timeToFirstByte);a.timeMs!=null&&(c.ttlb=a.timeMs);c.url=this.removeCmcdQueryFromUri_(a.originalUri||a.uri);this.requestTimestampMap_.has(a.originalRequest)?(c.ts=this.requestTimestampMap_.get(a.originalRequest),this.requestTimestampMap_.delete(a.originalRequest)):c.ts||(c.ts=Date.now());this.applyResponse_(a,
c)}catch(d){shaka.log.warnOnce("CMCD_SEGMENT_ERROR","Could not generate response segment CMCD data.",d)}};shaka.util.CmcdManager.prototype.applyRequestSegmentData=function(a,b){try{if(this.config_.enabled){var c=this.getDataForSegment_(b,a.uris[0]);c.ts=Date.now();this.requestTimestampMap_.has(a)&&this.requestTimestampMap_.delete(a);this.requestTimestampMap_.set(a,c.ts);this.applyRequest_(a,c)}}catch(d){shaka.log.warnOnce("CMCD_SEGMENT_ERROR","Could not generate segment CMCD data.",d)}};
shaka.util.CmcdManager.prototype.applyTextData=function(a){try{this.config_.enabled&&this.applyRequest_(a,{ot:shaka.util.CmcdManager.ObjectType.CAPTION,su:!0})}catch(b){shaka.log.warnOnce("CMCD_TEXT_ERROR","Could not generate text CMCD data.",b)}};shaka.util.CmcdManager.prototype.removeCmcdQueryFromUri_=function(a){if(!a.includes("CMCD="))return a;try{var b=new URL(a);b.searchParams.delete("CMCD");return b.toString()}catch(c){return shaka.log.error("Failed to parse URI for CMCD removal:",a,c),a}};
shaka.util.CmcdManager.prototype.appendSrcData=function(a,b){try{if(!this.config_.enabled)return a;var c=this.createData_();c.ot=this.getObjectTypeFromMimeType_(b);c.su=!0;var d=shaka.util.CmcdManager.toQuery(c);return shaka.util.CmcdManager.appendQueryToUri(a,d)}catch(e){return shaka.log.warnOnce("CMCD_SRC_ERROR","Could not generate src CMCD data.",e),a}};
shaka.util.CmcdManager.prototype.appendTextTrackData=function(a){try{if(!this.config_.enabled)return a;var b=this.createData_();b.ot=shaka.util.CmcdManager.ObjectType.CAPTION;b.su=!0;var c=shaka.util.CmcdManager.toQuery(b);return shaka.util.CmcdManager.appendQueryToUri(a,c)}catch(d){return shaka.log.warnOnce("CMCD_TEXT_TRACK_ERROR","Could not generate text track CMCD data.",d),a}};
shaka.util.CmcdManager.prototype.onPlaybackPlay_=function(){this.playbackPlayTime_||(this.playbackPlayTime_=Date.now(),this.reportEvent_("ps",{sta:"s"}))};shaka.util.CmcdManager.prototype.onPlaybackPlaying_=function(){this.playbackPlayingTime_||(this.playbackPlayingTime_=Date.now())};
shaka.util.CmcdManager.prototype.setupEventListeners_=function(){var a=this;this.eventManager_.listen(this.video_,"playing",function(){a.onPlaybackPlaying_();a.reportEvent_("ps",{sta:"p"})});this.eventManager_.listen(this.video_,"volumechange",function(){a.reportEvent_(a.video_.muted?"m":"um")});this.eventManager_.listen(this.video_,"play",function(){a.onPlaybackPlay_()});this.eventManager_.listen(this.video_,"pause",function(){a.reportEvent_("ps",{sta:"a"})});this.eventManager_.listen(this.player_,
"buffering",function(){a.reportEvent_("ps",{sta:"w"})});this.eventManager_.listen(this.video_,"seeking",function(){return a.reportEvent_("ps",{sta:"k"})});this.eventManager_.listen(document,"fullscreenchange",function(){a.reportEvent_(document.fullscreenElement?"pe":"pc")});var b=this.video_;(b.webkitPresentationMode||b.webkitSupportsFullscreen)&&this.eventManager_.listen(b,"webkitpresentationmodechanged",function(){b.webkitPresentationMode?a.reportEvent_(b.webkitPresentationMode!=="inline"?"pe":
"pc"):b.webkitSupportsFullscreen&&a.reportEvent_(b.webkitDisplayingFullscreen?"pe":"pc")});this.eventManager_.listen(this.video_,"enterpictureinpicture",function(){a.reportEvent_("pe")});this.eventManager_.listen(this.video_,"leavepictureinpicture",function(){a.reportEvent_("pc")});"documentPictureInPicture"in window&&this.eventManager_.listen(window.documentPictureInPicture,"enter",function(c){a.reportEvent_("pe");a.eventManager_.listenOnce(c.window,"pagehide",function(){a.reportEvent_("pc")})});
this.eventManager_.listen(document,"visibilitychange",function(){document.hidden?a.reportEvent_("b",{bg:!0}):a.reportEvent_("b")});this.eventManager_.listen(this.player_,"complete",function(){a.reportEvent_("ps",{sta:"e"})})};
shaka.util.CmcdManager.prototype.setupEventModeTimeInterval_=function(){var a=this;this.stopAndClearEventTimers_();var b=this.getEventModeEnabledTargets_();b=(0,$jscomp.makeIterator)(b);for(var c=b.next();!c.done;c=b.next())if(c=c.value.timeInterval,c===void 0&&(c=shaka.util.CmcdManager.CmcdV2Constants.TIME_INTERVAL_DEFAULT_VALUE),c>=1){var d=new shaka.util.Timer(function(){return a.reportEvent_(shaka.util.CmcdManager.CmcdV2Keys.TIME_INTERVAL_EVENT)});d.tickEvery(c);this.eventTimers_.push(d)}};
shaka.util.CmcdManager.prototype.stopAndClearEventTimers_=function(){if(this.eventTimers_)for(var a=(0,$jscomp.makeIterator)(this.eventTimers_),b=a.next();!b.done;b=a.next())b.value.stop();this.eventTimers_=[]};shaka.util.CmcdManager.prototype.getEventModeEnabledTargets_=function(){var a=this.config_.targets;return a?a.filter(function(b){return b.mode===shaka.util.CmcdManager.CmcdMode.EVENT&&b.enabled}):[]};
shaka.util.CmcdManager.prototype.getResponseModeEnabledTargets=function(){var a=this.config_.targets;return a?a.filter(function(b){return b.mode===shaka.util.CmcdManager.CmcdMode.RESPONSE&&b.enabled===!0}):[]};shaka.util.CmcdManager.prototype.createData_=function(){this.config_.sessionId||(this.config_.sessionId=window.crypto.randomUUID());return{v:this.config_.version,sf:this.sf_,sid:this.config_.sessionId,cid:this.config_.contentId,mtp:this.player_.getBandwidthEstimate()/1E3}};
shaka.util.CmcdManager.prototype.reportEvent_=function(a,b){b=b===void 0?{}:b;a={e:a,ts:Date.now()};b=Object.assign(a,b);b=this.getGenericData_(b,shaka.util.CmcdManager.CmcdMode.EVENT);a=this.config_.targets;if(!(this.config_.version<shaka.util.CmcdManager.Version.VERSION_2)&&a){var c=this.getEventModeEnabledTargets_();a=Array.from(new Set([].concat((0,$jscomp.arrayFromIterable)(shaka.util.CmcdManager.CmcdKeys.V2CommonKeys),(0,$jscomp.arrayFromIterable)(shaka.util.CmcdManager.CmcdKeys.V2EventKeys))));
c=(0,$jscomp.makeIterator)(c);for(var d=c.next();!d.done;d=c.next()){d=d.value;var e=this.checkValidKeys_(d.includeKeys||[],a,shaka.util.CmcdManager.CmcdMode.EVENT);e.includes(shaka.util.CmcdManager.CmcdV2Keys.TIMESTAMP)||e.push(shaka.util.CmcdManager.CmcdV2Keys.TIMESTAMP);e=this.filterKeys_(b,e);this.isValidEvent_(d.events||[],e)&&this.sendCmcdRequest_(e,d)}}};
shaka.util.CmcdManager.prototype.applyRequest_=function(a,b){if(this.config_.enabled){b=this.getGenericData_(b,shaka.util.CmcdManager.CmcdMode.REQUEST);var c=this.getCmcdTargetHash_({mode:shaka.util.CmcdManager.CmcdMode.REQUEST,useHeaders:this.config_.useHeaders,includeKeys:this.config_.includeKeys||[]});this.cmcdSequenceNumbers_[c]||(this.cmcdSequenceNumbers_[c]={request:1,response:1});b.sn=this.cmcdSequenceNumbers_[c].request++;c=this.config_.includeKeys||[];var d=this.config_.version==shaka.util.CmcdManager.Version.VERSION_2?
Array.from(new Set([].concat((0,$jscomp.arrayFromIterable)(shaka.util.CmcdManager.CmcdKeys.V2CommonKeys),(0,$jscomp.arrayFromIterable)(shaka.util.CmcdManager.CmcdKeys.V2RequestModeKeys)))):shaka.util.CmcdManager.CmcdKeys.V1Keys;c=this.checkValidKeys_(c,d,shaka.util.CmcdManager.CmcdMode.REQUEST);b=this.filterKeys_(b,c);this.applyCmcdDataToRequest_(b,a,this.config_.useHeaders)}};
shaka.util.CmcdManager.prototype.applyResponse_=function(a,b){var c=this.getResponseModeEnabledTargets();if(c.length!==0){var d=this.config_.version==shaka.util.CmcdManager.Version.VERSION_2?Array.from(new Set([].concat((0,$jscomp.arrayFromIterable)(shaka.util.CmcdManager.CmcdKeys.V2CommonKeys),(0,$jscomp.arrayFromIterable)(shaka.util.CmcdManager.CmcdKeys.V2ResponseModeKeys)))):shaka.util.CmcdManager.CmcdKeys.V1Keys;b.rc=a.status||0;b=this.getGenericData_(b,shaka.util.CmcdManager.CmcdMode.RESPONSE);
a.headers&&a.headers["CMSD-Static"]&&(b.cmsds=btoa(a.headers["CMSD-Static"]));a.headers&&a.headers["CMSD-Dynamic"]&&(b.cmsdd=btoa(a.headers["CMSD-Dynamic"]));c=(0,$jscomp.makeIterator)(c);for(var e=c.next();!e.done;e=c.next()){e=e.value;var f=this.checkValidKeys_(e.includeKeys||[],d,shaka.util.CmcdManager.CmcdMode.RESPONSE),g=this.getCmcdTargetHash_(e);this.cmcdSequenceNumbers_[g]||(this.cmcdSequenceNumbers_[g]={request:1,response:1});b.sn=this.cmcdSequenceNumbers_[g].response++;f=this.filterKeys_(b,
f);this.sendCmcdRequest_(f,e,a)}}};
shaka.util.CmcdManager.prototype.sendCmcdRequest_=function(a,b,c){var d=shaka.net.NetworkingEngine.defaultRetryParameters(),e=b.url;if(b.useHeaders){a=shaka.util.CmcdManager.toHeaders(a);if(!Object.keys(a).length)return;c&&Object.assign(c.headers,a);c=shaka.net.NetworkingEngine.makeRequest([e],d);Object.assign(c.headers,a)}else{a=shaka.util.CmcdManager.toQuery(a);if(!a)return;e=shaka.util.CmcdManager.appendQueryToUri(e,a);c&&(c.uri=e);c=shaka.net.NetworkingEngine.makeRequest([e],d)}d=shaka.net.NetworkingEngine.RequestType.CMCD;
this.player_.getNetworkingEngine().request(d,c)};shaka.util.CmcdManager.prototype.applyCmcdDataToRequest_=function(a,b,c){if(c){a=shaka.util.CmcdManager.toHeaders(a);if(!Object.keys(a).length)return;Object.assign(b.headers,a)}else{var d=shaka.util.CmcdManager.toQuery(a);if(!d)return;b.uris=b.uris.map(function(e){return shaka.util.CmcdManager.appendQueryToUri(e,d)})}this.getResponseModeEnabledTargets().length>0||!this.requestTimestampMap_.has(b)||this.requestTimestampMap_.delete(b)};
shaka.util.CmcdManager.prototype.checkValidKeys_=function(a,b,c){if(!a||a.length===0)return b;for(var d=(0,$jscomp.makeIterator)(a),e=d.next();!e.done;e=d.next())e=e.value,b.includes(e)||shaka.log.error('CMCD Key "'+e+'" is not allowed for '+c+" mode");return a=a.filter(function(f){return b.includes(f)})};shaka.util.CmcdManager.prototype.filterKeys_=function(a,b){return Object.keys(a).reduce(function(c,d){b.includes(d)&&(c[d]=a[d]);return c},{})};
shaka.util.CmcdManager.prototype.isValidEvent_=function(a,b){var c=shaka.util.CmcdManager.CmcdKeys.CmcdV2Events,d=shaka.util.CmcdManager.CmcdKeys.CmcdV2PlayStates,e=b.e;b=b.sta;return e&&(!c.includes(e)||!(e!=="ps"||b&&d.includes(b))||a&&a.length>0&&!a.includes(e))?!1:!0};
shaka.util.CmcdManager.prototype.getObjectType_=function(a){if(a.type===shaka.net.NetworkingEngine.AdvancedRequestType.INIT_SEGMENT)return shaka.util.CmcdManager.ObjectType.INIT;if(a=a.stream){var b=a.type;if(b=="video")return a.codecs&&a.codecs.includes(",")?shaka.util.CmcdManager.ObjectType.MUXED:shaka.util.CmcdManager.ObjectType.VIDEO;if(b=="audio")return shaka.util.CmcdManager.ObjectType.AUDIO;if(b=="text")return a.mimeType==="application/mp4"?shaka.util.CmcdManager.ObjectType.TIMED_TEXT:shaka.util.CmcdManager.ObjectType.CAPTION}};
shaka.util.CmcdManager.prototype.getObjectTypeFromMimeType_=function(a){switch(a.toLowerCase()){case "audio/mp4":case "audio/webm":case "audio/ogg":case "audio/mpeg":case "audio/aac":case "audio/flac":case "audio/wav":return shaka.util.CmcdManager.ObjectType.AUDIO;case "video/webm":case "video/mp4":case "video/mpeg":case "video/mp2t":return shaka.util.CmcdManager.ObjectType.MUXED;case "application/x-mpegurl":case "application/vnd.apple.mpegurl":case "audio/x-mpegurl":case "application/dash+xml":case "video/vnd.mpeg.dash.mpd":case "application/vnd.ms-sstr+xml":return shaka.util.CmcdManager.ObjectType.MANIFEST}};
shaka.util.CmcdManager.prototype.getCmcdTargetHash_=function(a){var b=Object.keys(a).sort().reduce(function(c,d){d!=="enabled"&&(c[d]=a[d]);return c},{});return JSON.stringify(b)};shaka.util.CmcdManager.prototype.getBufferLength_=function(a){a=this.player_.getBufferedInfo()[a];if(!a.length)return NaN;var b=this.getCurrentTime_();return(a=a.find(function(c){return c.start<=b&&c.end>=b}))?(a.end-b)*1E3:NaN};
shaka.util.CmcdManager.prototype.getRemainingBufferLength_=function(a){a=this.player_.getBufferedInfo()[a];if(!a.length)return 0;var b=this.getCurrentTime_();return(a=a.find(function(c){return c.start<=b&&c.end>=b}))?(a.end-b)*1E3:0};shaka.util.CmcdManager.prototype.calculateMSD_=function(){if(this.playbackPlayingTime_&&this.playbackPlayTime_)return this.playbackPlayingTime_-(this.startTimeOfLoad_||this.playbackPlayTime_)};
shaka.util.CmcdManager.prototype.calculateRtp_=function(a,b){var c=this.player_.getPlaybackRate()||1,d=this.getRemainingBufferLength_(a.type)||500;return(a=a.bandwidth)?a*(b.endTime-b.startTime)/1E3/(d/c/1E3)*this.config_.rtpSafetyFactor:NaN};
shaka.util.CmcdManager.prototype.getStreamFormat_=function(a){var b=shaka.net.NetworkingEngine.AdvancedRequestType;switch(a){case b.MPD:return this.lowLatency_?shaka.util.CmcdManager.StreamingFormat.LOW_LATENCY_DASH:shaka.util.CmcdManager.StreamingFormat.DASH;case b.MASTER_PLAYLIST:case b.MEDIA_PLAYLIST:return this.lowLatency_?shaka.util.CmcdManager.StreamingFormat.LOW_LATENCY_HLS:shaka.util.CmcdManager.StreamingFormat.HLS;case b.MSS:return shaka.util.CmcdManager.StreamingFormat.SMOOTH}};
shaka.util.CmcdManager.prototype.getStreamType_=function(){return this.player_.isLive()?shaka.util.CmcdManager.StreamType.LIVE:shaka.util.CmcdManager.StreamType.VOD};
shaka.util.CmcdManager.prototype.getTopBandwidth_=function(a){var b=this.player_.getVariantTracks();if(!b.length)return NaN;var c=b[0];b=(0,$jscomp.makeIterator)(b);for(var d=b.next();!d.done;d=b.next())d=d.value,d.type==="variant"&&d.bandwidth>c.bandwidth&&(c=d);b=shaka.util.CmcdManager.ObjectType;switch(a){case b.VIDEO:return c.videoBandwidth||NaN;case b.AUDIO:return c.audioBandwidth||NaN;default:return c.bandwidth}};
shaka.util.CmcdManager.prototype.getDataForSegment_=function(a,b){var c=a.segment,d=0;c&&(d=c.endTime-c.startTime);d={d:d*1E3,st:this.getStreamType_()};d.ot=this.getObjectType_(a);var e=shaka.util.CmcdManager.ObjectType,f=d.ot===e.VIDEO||d.ot===e.AUDIO||d.ot===e.MUXED||d.ot===e.TIMED_TEXT;if(a=a.stream){var g=this.player_.getPlaybackRate();if(f&&(d.bl=this.getBufferLength_(a.type),d.ot!==e.TIMED_TEXT)){var h=this.getRemainingBufferLength_(a.type);d.dl=g?h/Math.abs(g):h}a.bandwidth&&(d.br=a.bandwidth/
1E3);a.segmentIndex&&c&&((g=a.segmentIndex.getIteratorForTime(c.endTime,!0,g<0))&&(g=g.next().value)&&g!=c&&(b&&!shaka.util.ArrayUtils.equal(c.getUris(),g.getUris())&&(d.nor=shaka.util.CmcdManager.urlToRelativePath(g.getUris()[0],b)),!g.startByte&&!g.endByte||c.startByte==g.startByte&&c.endByte==g.endByte||(b=g.startByte+"-",g.endByte&&(b+=g.endByte),d.nrr=b)),c=this.calculateRtp_(a,c),isNaN(c)||(d.rtp=c))}f&&d.ot!==e.TIMED_TEXT&&(d.tb=this.getTopBandwidth_(d.ot)/1E3);return d};
shaka.util.CmcdManager.prototype.getCurrentTime_=function(){return this.video_?this.video_.currentTime:0};
shaka.util.CmcdManager.prototype.getGenericData_=function(a,b){Object.assign(a,this.createData_());a.pr=this.player_.getPlaybackRate();var c=a.ot===shaka.util.CmcdManager.ObjectType.VIDEO||a.ot===shaka.util.CmcdManager.ObjectType.MUXED;this.starved_&&c&&(a.bs=!0,a.su=!0,this.starved_=!1);a.su==null&&(a.su=this.buffering_);this.player_.isLive()&&(c=this.player_.getLiveLatency(),a.ltc=c||void 0);document.hidden&&(a.bg=!0);c=this.calculateMSD_();c==void 0||this.msdSent_[b]||(a.msd=c,this.msdSent_[b]=
!0);return a};
shaka.util.CmcdManager.serialize=function(a){var b=[],c=function(m){return!Number.isNaN(m)&&m!=null&&m!==""&&m!==!1},d=function(m){return Math.round(m)},e=function(m){return d(m/100)*100};e={br:d,d:d,bl:e,dl:e,mtp:e,nor:function(m){return encodeURIComponent(m)},rtp:e,tb:d,ttfb:d,ttlb:d};var f=Object.keys(a||{}).sort();f=(0,$jscomp.makeIterator)(f);for(var g=f.next();!g.done;g=f.next()){g=g.value;var h=a[g];if(c(h)&&(g!=="v"||h!==1)&&(g!="pr"||h!==1)){var k=e[g];k&&(h=k(h));k=typeof h;var l=void 0;
l=k==="string"&&g!=="ot"&&g!=="sf"&&g!=="st"?g+"="+JSON.stringify(h):k==="boolean"?g:k==="symbol"?g+"="+h.description:g+"="+h;b.push(l)}}return b.join(",")};
shaka.util.CmcdManager.toHeaders=function(a){var b=Object.keys(a),c={},d=["Object","Request","Session","Status"],e=[{},{},{},{}],f={br:0,d:0,ot:0,tb:0,url:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,ltc:1,ttfb:1,ttlb:1,ts:1,rc:1,cmsdd:1,cmsds:1,sn:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,msd:2,bs:3,rtp:3,bg:3};b=(0,$jscomp.makeIterator)(b);for(var g=b.next();!g.done;g=b.next())g=g.value,e[f[g]!=null?f[g]:1][g]=a[g];for(a=0;a<e.length;a++)(f=shaka.util.CmcdManager.serialize(e[a]))&&(c["CMCD-"+d[a]]=f);return c};
shaka.util.CmcdManager.toQuery=function(a){return shaka.util.CmcdManager.serialize(a)};shaka.util.CmcdManager.appendQueryToUri=function(a,b){if(!b||a.includes("offline:"))return a;a=new goog.Uri(a);a.getQueryData().set("CMCD",b);return a.toString()};
shaka.util.CmcdManager.urlToRelativePath=function(a,b){var c=new URL(a);b=new URL(b);if(c.origin!==b.origin)return a;a=c.pathname.split("/").slice(1);b=b.pathname.split("/").slice(1,-1);for(var d=Math.min(a.length,b.length),e=0;e<d&&a[e]===b[e];e++)a.shift(),b.shift();for(;b.length;)b.shift(),a.unshift("..");return a.join("/")+c.search+c.hash};shaka.util.CmcdManager.ObjectType={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"};
shaka.util.CmcdManager.Version={VERSION_1:1,VERSION_2:2};shaka.util.CmcdManager.StreamType={VOD:"v",LIVE:"l"};shaka.util.CmcdManager.StreamingFormat={DASH:"d",LOW_LATENCY_DASH:"ld",HLS:"h",LOW_LATENCY_HLS:"lh",SMOOTH:"s",OTHER:"o"};goog.exportSymbol("shaka.util.CmcdManager.StreamingFormat",shaka.util.CmcdManager.StreamingFormat);
shaka.util.CmcdManager.CmcdKeys={V1Keys:"br bl bs cid d dl mtp nor nrr ot pr rtp sf sid st su tb v".split(" "),V2CommonKeys:"br ab bl tbl bs cdn cid ltc mtp pr sf sid bg sta st ts tpb tb lb tab lab pt ec msd v sn".split(" "),V2RequestModeKeys:"ab bl tbl bs cdn cid d dl ltc mtp nor ot pr rtp sf sid bg sta st su ts tpb tb lb tab lab pt ec msd v".split(" "),V2ResponseModeKeys:"d dl nor ot rtp rc su ttfb ttfbb ttlb url cmsdd cmsds".split(" "),V2EventKeys:["e","sta"],CmcdV2Events:"ps e t c b m um pe pc".split(" "),
CmcdV2PlayStates:"spawkrfeqd".split("")};shaka.util.CmcdManager.CmcdV2Constants={TIME_INTERVAL_DEFAULT_VALUE:10};shaka.util.CmcdManager.CmcdV2Keys={TIMESTAMP:"ts",TIME_INTERVAL_EVENT:"t"};shaka.util.CmcdManager.CmcdMode={REQUEST:"request",RESPONSE:"response",EVENT:"event"};shaka.util.CmsdManager=function(a){this.config_=a;this.dynamicParams_=this.staticParams_=null};shaka.util.CmsdManager.prototype.configure=function(a){this.config_=a};shaka.util.CmsdManager.prototype.reset=function(){this.dynamicParams_=this.staticParams_=null};
shaka.util.CmsdManager.prototype.processHeaders=function(a){if(this.config_.enabled){var b=shaka.util.CmsdManager,c=a[b.CMSD_STATIC_HEADER_NAME_];c&&(c=this.parseCMSDStatic_(c))&&(this.staticParams_=c);if(a=a[b.CMSD_DYNAMIC_HEADER_NAME_])if(a=this.parseCMSDDynamic_(a))this.dynamicParams_=a}};
shaka.util.CmsdManager.prototype.getMaxBitrate=function(){var a=shaka.util.CmsdManager.KEYS_.MAX_SUGGESTED_BITRATE;return this.config_.enabled&&this.config_.applyMaximumSuggestedBitrate&&this.dynamicParams_&&this.dynamicParams_.has(a)?this.dynamicParams_.get(a)*1E3:null};
shaka.util.CmsdManager.prototype.getEstimatedThroughput=function(){var a=shaka.util.CmsdManager.KEYS_.ESTIMATED_THROUGHPUT;return this.config_.enabled&&this.dynamicParams_&&this.dynamicParams_.has(a)?this.dynamicParams_.get(a)*1E3:null};shaka.util.CmsdManager.prototype.getResponseDelay=function(){var a=shaka.util.CmsdManager.KEYS_.RESPONSE_DELAY;return this.config_.enabled&&this.dynamicParams_&&this.dynamicParams_.has(a)?this.dynamicParams_.get(a):null};
shaka.util.CmsdManager.prototype.getRoundTripTime=function(){var a=shaka.util.CmsdManager.KEYS_.ROUND_TRIP_TIME;return this.config_.enabled&&this.dynamicParams_&&this.dynamicParams_.has(a)?this.dynamicParams_.get(a):null};shaka.util.CmsdManager.prototype.getBandwidthEstimate=function(a){var b=this.getEstimatedThroughput();if(!b)return a;var c=this.config_.estimatedThroughputWeightRatio;return c>0&&c<=1?a*(1-c)+b*c:a};
shaka.util.CmsdManager.prototype.parseCMSDStatic_=function(a){try{var b=new Map,c=a.split(",");for(a=0;a<c.length;a++){var d=c[a].split("="),e=d[0],f=this.parseParameterValue_(d[1]);b.set(e,f)}return b}catch(g){return shaka.log.warning("Failed to parse CMSD-Static response header value:",g),null}};
shaka.util.CmsdManager.prototype.parseCMSDDynamic_=function(a){try{var b=new Map,c=a.split(";");for(a=1;a<c.length;a++){var d=c[a].split("="),e=d[0],f=this.parseParameterValue_(d[1]);b.set(e,f)}return b}catch(g){return shaka.log.warning("Failed to parse CMSD-Dynamic response header value:",g),null}};shaka.util.CmsdManager.prototype.parseParameterValue_=function(a){return a?a.toLowerCase()==="false"?!1:/^[-0-9]/.test(a)?parseInt(a,10):a.replace(/["]+/g,""):!0};
goog.exportSymbol("shaka.util.CmsdManager",shaka.util.CmsdManager);goog.exportProperty(shaka.util.CmsdManager.prototype,"getBandwidthEstimate",shaka.util.CmsdManager.prototype.getBandwidthEstimate);goog.exportProperty(shaka.util.CmsdManager.prototype,"getRoundTripTime",shaka.util.CmsdManager.prototype.getRoundTripTime);goog.exportProperty(shaka.util.CmsdManager.prototype,"getResponseDelay",shaka.util.CmsdManager.prototype.getResponseDelay);
goog.exportProperty(shaka.util.CmsdManager.prototype,"getEstimatedThroughput",shaka.util.CmsdManager.prototype.getEstimatedThroughput);goog.exportProperty(shaka.util.CmsdManager.prototype,"getMaxBitrate",shaka.util.CmsdManager.prototype.getMaxBitrate);shaka.util.CmsdManager.CMSD_STATIC_HEADER_NAME_="cmsd-static";shaka.util.CmsdManager.CMSD_DYNAMIC_HEADER_NAME_="cmsd-dynamic";
shaka.util.CmsdManager.KEYS_={AVAILABILITY_TIME:"at",DURESS:"du",ENCODED_BITRATE:"br",ESTIMATED_THROUGHPUT:"etp",HELD_TIME:"ht",INTERMEDIARY_IDENTIFIER:"n",MAX_SUGGESTED_BITRATE:"mb",NEXT_OBJECT_RESPONSE:"nor",NEXT_RANGE_RESPONSE:"nrr",OBJECT_DURATION:"d",OBJECT_TYPE:"ot",RESPONSE_DELAY:"rd",ROUND_TRIP_TIME:"rtt",STARTUP:"su",STREAM_TYPE:"st",STREAMING_FORMAT:"sf",VERSION:"v"};shaka.util.Mutex=function(){this.acquiredIdentifier=null;this.unlockQueue=[]};shaka.util.Mutex.prototype.acquire=function(a){var b=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){if(c.getNextAddressJsc()==1)return shaka.log.v2(a+" has requested mutex"),b.acquiredIdentifier?c.yield(new Promise(function(d){return b.unlockQueue.push(d)}),2):c.jumpTo(2);b.acquiredIdentifier=a;shaka.log.v2(a+" has acquired mutex");c.jumpToEnd()})};
shaka.util.Mutex.prototype.release=function(){shaka.log.v2(this.acquiredIdentifier+" has released mutex");this.unlockQueue.length>0?this.unlockQueue.shift()():this.acquiredIdentifier=null};shaka.util.Mutex.prototype.releaseAll=function(){for(;this.acquiredIdentifier;)this.release()};shaka.Player=function(a,b,c){b=b===void 0?null:b;shaka.util.FakeEventTarget.call(this);var d=this;this.loadMode_=shaka.Player.LoadMode.NOT_LOADED;this.video_=null;this.videoContainer_=b;this.isTextVisible_=!1;this.globalEventManager_=new shaka.util.EventManager;this.attachEventManager_=new shaka.util.EventManager;this.loadEventManager_=new shaka.util.EventManager;this.trickPlayEventManager_=new shaka.util.EventManager;this.adManagerEventManager_=new shaka.util.EventManager;this.playhead_=this.mediaSourceEngine_=
this.drmEngine_=this.networkingEngine_=null;this.operationId_=0;this.mutex_=new shaka.util.Mutex;this.startTime_=this.mimeType_=this.assetUri_=this.manifest_=this.parserFactory_=this.parser_=this.streamingEngine_=this.qualityObserver_=this.lcevcDec_=this.lcevcCanvas_=this.cmsdManager_=this.cmcdManager_=this.emsgRegionTimeline_=this.metadataRegionTimeline_=this.regionTimeline_=this.bufferObserver_=this.bufferPoller_=this.playRateController_=this.playheadObservers_=null;this.fullyLoaded_=!1;this.abrManagerFactory_=
this.abrManager_=null;this.nextExternalStreamId_=1E9;this.externalSrcEqualsThumbnailsStreams_=[];this.deferredCloseSegmentIndex_=new Map;this.externalChaptersStreams_=[];this.completionPercent_=-1;this.config_=this.defaultConfig_();this.lowLatencyConfig_=shaka.util.PlayerConfiguration.createDefaultForLL();this.currentTargetLatency_=null;this.rebufferingCount_=-1;this.targetLatencyReached_=null;this.maxHwRes_={width:Infinity,height:Infinity};this.manifestFilterer_=new shaka.media.ManifestFilterer(this.config_,
this.maxHwRes_,null);this.createdPreloadManagers_=[];this.stats_=null;this.currentAdaptationSetCriteria_=this.config_.adaptationSetCriteriaFactory();this.currentAdaptationSetCriteria_.configure({language:this.config_.preferredAudioLanguage,role:this.config_.preferredAudioRole,videoRole:this.config_.preferredVideoRole,channelCount:0,hdrLevel:this.config_.preferredVideoHdrLevel,spatialAudio:this.config_.preferSpatialAudio,videoLayout:this.config_.preferredVideoLayout,audioLabel:this.config_.preferredAudioLabel,
videoLabel:this.config_.preferredVideoLabel,codecSwitchingStrategy:this.config_.mediaSource.codecSwitchingStrategy,audioCodec:"",activeAudioCodec:"",activeAudioChannelCount:0,preferredAudioCodecs:this.config_.preferredAudioCodecs,preferredAudioChannelCount:this.config_.preferredAudioChannelCount});this.currentTextLanguage_=this.config_.preferredTextLanguage;this.currentTextRole_=this.config_.preferredTextRole;this.currentTextForced_=this.config_.preferForcedSubs;this.cleanupOnUnload_=[];c&&c(this);
this.cmcdManager_=this.createCmcd_();this.cmsdManager_=this.createCmsd_();this.networkingEngine_=this.createNetworkingEngine();this.preloadDueAdManagerVideo_=this.preloadDueAdManager_=this.queueManager_=this.adManager_=null;this.preloadDueAdManagerVideoEnded_=!1;this.externalSrcEqualsTextTracks_=[];this.preloadDueAdManagerTimer_=new shaka.util.Timer(function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(e){if(e.getNextAddressJsc()==1){if(!d.preloadDueAdManager_)return e.jumpTo(0);
goog.asserts.assert(d.preloadDueAdManagerVideo_,"Must have video");return e.yield(d.attach(d.preloadDueAdManagerVideo_,!0),3)}if(e.getNextAddressJsc()!=4)return e.yield(d.load(d.preloadDueAdManager_),4);d.preloadDueAdManagerVideoEnded_?d.preloadDueAdManagerVideo_.pause():d.preloadDueAdManagerVideo_.play();d.preloadDueAdManager_=null;d.preloadDueAdManagerVideoEnded_=!1;e.jumpToEnd()})});shaka.Player.adManagerFactory_&&(this.adManager_=shaka.Player.adManagerFactory_(),this.adManager_.configure(this.config_.ads),
this.adManagerEventManager_.listen(this.adManager_,"ad-content-pause-requested",function(e){var f,g;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(h){if(h.getNextAddressJsc()==1){d.preloadDueAdManagerTimer_.stop();if(d.preloadDueAdManager_)return h.jumpTo(0);d.preloadDueAdManagerVideo_=d.video_;d.preloadDueAdManagerVideoEnded_=d.isEnded();f=e.saveLivePosition||!1;g=!0;d.isLive()&&(g=f);return h.yield(d.detachAndSavePreload(!0,g),3)}d.preloadDueAdManager_=h.getYieldResultJsc();h.jumpToEnd()})}),
this.adManagerEventManager_.listen(this.adManager_,"ad-content-resume-requested",function(e){e=e.offset||0;d.preloadDueAdManager_&&d.preloadDueAdManager_.setOffsetToStartTime(e);d.preloadDueAdManagerTimer_.tickAfter(.1)}),this.adManagerEventManager_.listen(this.adManager_,"ad-content-attach-requested",function(e){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){if(f.getNextAddressJsc()==1)return d.video_||!d.preloadDueAdManagerVideo_?f.jumpTo(0):f.yield(d.attach(d.preloadDueAdManagerVideo_,
!0),3);d.preloadDueAdManagerVideo_=null;f.jumpToEnd()})}));shaka.Player.queueManagerFactory_&&(this.queueManager_=shaka.Player.queueManagerFactory_(this),this.queueManager_.configure(this.config_.queue));this.globalEventManager_.listen(window,"online",function(){d.restoreDisabledVariants_();d.retryStreaming()});this.checkVariantsTimer_=new shaka.util.Timer(function(){return d.checkVariants_()});this.preloadNextUrl_=null;a&&(shaka.Deprecate.deprecateFeature(5,"Player w/ mediaElement","Please migrate from initializing Player with a mediaElement; use the attach method instead."),
this.attach(a,!0));this.textDisplayer_=null};$jscomp.inherits(shaka.Player,shaka.util.FakeEventTarget);shaka.Player.prototype.createLcevcDec_=function(a,b){this.lcevcDec_==null&&(this.lcevcDec_=new shaka.lcevc.Dec(this.video_,this.lcevcCanvas_,a,b),this.mediaSourceEngine_&&this.mediaSourceEngine_.updateLcevcDec(this.lcevcDec_))};shaka.Player.prototype.closeLcevcDec_=function(){this.lcevcDec_!=null&&(this.lcevcDec_.hideCanvas(),this.lcevcDec_.release(),this.lcevcDec_=null)};
shaka.Player.prototype.setupLcevc_=function(a,b){b||a.lcevc.enabled?(this.closeLcevcDec_(),this.createLcevcDec_(a.lcevc,b)):this.closeLcevcDec_()};shaka.Player.makeEvent_=function(a,b){return new shaka.util.FakeEvent(a,b)};
shaka.Player.prototype.destroy=function(){var a=this,b;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){switch(c.getNextAddressJsc()){case 1:if(a.loadMode_==shaka.Player.LoadMode.DESTROYED)return c.return();a.closeLcevcDec_();b=a.detach();a.loadMode_=shaka.Player.LoadMode.DESTROYED;return c.yield(b,2);case 2:return c.yield(a.destroyAllPreloads(),3);case 3:a.globalEventManager_&&(a.globalEventManager_.release(),a.globalEventManager_=null);a.attachEventManager_&&(a.attachEventManager_.release(),
a.attachEventManager_=null);a.loadEventManager_&&(a.loadEventManager_.release(),a.loadEventManager_=null);a.trickPlayEventManager_&&(a.trickPlayEventManager_.release(),a.trickPlayEventManager_=null);a.adManagerEventManager_&&(a.adManagerEventManager_.release(),a.adManagerEventManager_=null);a.abrManagerFactory_=null;a.config_=null;a.stats_=null;a.videoContainer_=null;a.cmcdManager_=null;a.cmsdManager_=null;if(!a.networkingEngine_){c.jumpTo(4);break}return c.yield(a.networkingEngine_.destroy(),5);
case 5:a.networkingEngine_=null;case 4:a.abrManager_&&(a.abrManager_.release(),a.abrManager_=null),a.queueManager_&&(a.queueManager_.destroy(),a.queueManager_=null),shaka.util.FakeEventTarget.prototype.release.call(a),c.jumpToEnd()}})};shaka.Player.registerSupportPlugin=function(a,b){shaka.Player.supportPlugins_.set(a,b)};shaka.Player.setAdManagerFactory=function(a){shaka.Player.adManagerFactory_=a};shaka.Player.setQueueManagerFactory=function(a){shaka.Player.queueManagerFactory_=a};
shaka.Player.isBrowserSupported=function(){window.Promise||shaka.log.alwaysWarn("A Promise implementation or polyfill is required");if(!(window.Promise&&window.Uint8Array&&Array.prototype.forEach)||(navigator.userAgent||"").includes("Trident/"))return!1;var a=shaka.device.DeviceFactory.getDevice();return a.supportsMediaSource()?!0:a.supportsMediaType("application/x-mpegurl")};
shaka.Player.probeSupport=function(a){a=a===void 0?!0:a;var b,c,d,e,f,g,h;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(k){switch(k.getNextAddressJsc()){case 1:goog.asserts.assert(shaka.Player.isBrowserSupported(),"Must have basic support");b={};if(!a){k.jumpTo(2);break}return k.yield(shaka.drm.DrmEngine.probeSupport(),3);case 3:b=k.getYieldResultJsc();case 2:return c=shaka.media.ManifestParser.probeSupport(),d=shaka.media.MediaSourceEngine.probeSupport(),e=shaka.device.DeviceFactory.getDevice(),
goog.asserts.assert(e,"device must be non-null"),k.yield(e.detectMaxHardwareResolution(),4);case 4:return f=k.getYieldResultJsc(),g={manifest:c,media:d,drm:b,hardwareResolution:f},h=shaka.Player.supportPlugins_,h.forEach(function(l,m){g[m]=l()}),k.return(g)}})};shaka.Player.prototype.makeStateChangeEvent_=function(a){this.dispatchEvent(shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.OnStateChange,(new Map).set("state",a)))};
shaka.Player.prototype.attach=function(a,b){b=b===void 0?!0:b;var c=this,d,e,f,g;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(h){switch(h.getNextAddressJsc()){case 1:if(c.loadMode_==shaka.Player.LoadMode.DESTROYED)throw c.createAbortLoadError_();d=c.video_&&c.video_==a;if(!c.video_||c.video_==a){h.jumpTo(2);break}return h.yield(c.detach(),2);case 2:return h.yield(c.atomicOperationAcquireMutex_("attach"),4);case 4:if(h.getYieldResultJsc())return h.return();h.setCatchFinallyBlocks(5,
6);d||(c.makeStateChangeEvent_("attach"),e=function(k){return c.onVideoError_(k)},c.attachEventManager_.listen(a,"error",e),c.video_=a,c.cmcdManager_&&c.cmcdManager_.setMediaElement(a));f=shaka.device.DeviceFactory.getDevice();if(!b||!f.supportsMediaSource()||c.mediaSourceEngine_){h.jumpTo(6);break}return h.yield(c.initializeMediaSourceEngineInner_(),6);case 6:h.enterFinallyBlock();c.mutex_.release();h.leaveFinallyBlock(0);break;case 5:return g=h.enterCatchBlock(),h.yield(c.detach(),10);case 10:throw g;
}})};shaka.Player.prototype.attachCanvas=function(a){this.lcevcCanvas_=a};
shaka.Player.prototype.detach=function(a){a=a===void 0?!1:a;var b=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){if(c.getNextAddressJsc()==1){if(b.loadMode_==shaka.Player.LoadMode.DESTROYED)throw b.createAbortLoadError_();return c.yield(b.unload(!1,a),2)}if(c.getNextAddressJsc()!=3)return c.yield(b.atomicOperationAcquireMutex_("detach"),3);if(c.getYieldResultJsc())return c.return();try{b.video_&&(b.attachEventManager_.removeAll(),b.video_=null),b.makeStateChangeEvent_("detach"),
b.adManager_&&!a&&b.adManager_.release()}finally{b.mutex_.release()}c.jumpToEnd()})};shaka.Player.prototype.atomicOperationAcquireMutex_=function(a){var b=this,c;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(d){return d.getNextAddressJsc()==1?(c=++b.operationId_,d.yield(b.mutex_.acquire(a),2)):c!=b.operationId_?(b.mutex_.release(),d.return(!0)):d.return(!1)})};
shaka.Player.prototype.unload=function(a,b){a=a===void 0?!0:a;b=b===void 0?!1:b;var c=this,d,e,f,g,h,k,l,m,n,p,q,r,t,u,v,w,x;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(y){switch(y.getNextAddressJsc()){case 1:return c.loadMode_!=shaka.Player.LoadMode.DESTROYED&&(c.loadMode_=shaka.Player.LoadMode.NOT_LOADED),y.yield(c.atomicOperationAcquireMutex_("unload"),2);case 2:if(y.getYieldResultJsc())return y.return();y.setFinallyBlock(3);c.fullyLoaded_=!1;c.makeStateChangeEvent_("unload");
c.closeLcevcDec_();d=c.cleanupOnUnload_.map(function(C){return C()});c.cleanupOnUnload_=[];return y.yield(Promise.all(d),5);case 5:c.dispatchEvent(shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.Unloading));c.regionTimeline_&&(c.regionTimeline_.release(),c.regionTimeline_=null);c.metadataRegionTimeline_&&(c.metadataRegionTimeline_.release(),c.metadataRegionTimeline_=null);c.emsgRegionTimeline_&&(c.emsgRegionTimeline_.release(),c.emsgRegionTimeline_=null);c.video_&&(c.loadEventManager_.removeAll(),
c.trickPlayEventManager_.removeAll());c.checkVariantsTimer_.stop();c.playheadObservers_&&(c.playheadObservers_.release(),c.playheadObservers_=null);c.bufferPoller_&&(c.bufferPoller_.stop(),c.bufferPoller_=null);if(!c.parser_){y.jumpTo(6);break}return y.yield(c.parser_.stop(),7);case 7:c.parser_=null,c.parserFactory_=null;case 6:c.abrManager_&&c.abrManager_.stop();if(!c.streamingEngine_){y.jumpTo(8);break}return y.yield(c.streamingEngine_.destroy(),9);case 9:c.streamingEngine_=null;case 8:c.playRateController_&&
(c.playRateController_.release(),c.playRateController_=null);c.playhead_&&(c.playhead_.release(),c.playhead_=null);if(!shaka.drm.DrmUtils.isMediaKeysPolyfilled("webkit")||!c.drmEngine_){y.jumpTo(10);break}return y.yield(c.drmEngine_.destroy(),11);case 11:c.drmEngine_=null;case 10:if(!c.mediaSourceEngine_){y.jumpTo(12);break}return y.yield(c.mediaSourceEngine_.destroy(),13);case 13:c.mediaSourceEngine_=null;case 12:if(c.adManager_&&!b)c.adManager_.onAssetUnload();c.preloadDueAdManager_&&!b&&(c.preloadDueAdManager_.destroy(),
c.preloadDueAdManager_=null);b||c.preloadDueAdManagerTimer_.stop();c.cmcdManager_&&c.cmcdManager_.reset();c.cmsdManager_&&c.cmsdManager_.reset();if(!c.textDisplayer_){y.jumpTo(14);break}return y.yield(c.textDisplayer_.destroy(),15);case 15:c.textDisplayer_=null;case 14:c.isTextVisible_=!1;if(c.video_){e=(0,$jscomp.makeIterator)(c.externalSrcEqualsTextTracks_);for(f=e.next();!f.done;f=e.next())g=f.value,g.src.startsWith("blob:")&&URL.revokeObjectURL(g.src),g.remove();c.externalSrcEqualsTextTracks_=
[];shaka.util.Dom.clearSourceFromVideo(c.video_)&&c.video_.load()}if(!c.drmEngine_){y.jumpTo(16);break}return y.yield(c.drmEngine_.destroy(),17);case 17:c.drmEngine_=null;case 16:c.preloadNextUrl_&&c.assetUri_!=c.preloadNextUrl_.getAssetUri()&&(c.preloadNextUrl_.isDestroyed()||c.preloadNextUrl_.destroy(),c.preloadNextUrl_=null);c.assetUri_=null;c.mimeType_=null;c.bufferObserver_=null;if(c.manifest_){h=(0,$jscomp.makeIterator)(c.manifest_.variants);for(k=h.next();!k.done;k=h.next())for(l=k.value,m=
(0,$jscomp.makeIterator)([l.audio,l.video]),n=m.next();!n.done;n=m.next())(p=n.value)&&p.segmentIndex&&p.segmentIndex.release();q=(0,$jscomp.makeIterator)(c.manifest_.textStreams);for(r=q.next();!r.done;r=q.next())t=r.value,t.segmentIndex&&t.segmentIndex.release()}c.config_&&c.config_.streaming.clearDecodingCache&&(shaka.util.StreamUtils.clearDecodingConfigCache(),shaka.drm.DrmUtils.clearMediaKeySystemAccessMap());c.manifest_=null;c.stats_=new shaka.util.Stats;c.lastTextFactory_=null;c.targetLatencyReached_=
null;c.currentTargetLatency_=null;c.rebufferingCount_=-1;c.externalSrcEqualsThumbnailsStreams_=[];u=(0,$jscomp.makeIterator)(c.deferredCloseSegmentIndex_.values());for(v=u.next();!v.done;v=u.next())w=v.value,w.stop();c.deferredCloseSegmentIndex_.clear();c.externalChaptersStreams_=[];c.completionPercent_=-1;c.networkingEngine_&&c.networkingEngine_.clearCommonAccessTokenMap();c.updateBufferState_();case 3:y.enterFinallyBlock();c.mutex_.release();y.leaveFinallyBlock(4);break;case 4:x=shaka.device.DeviceFactory.getDevice();
if(a&&x.supportsMediaSource()&&!c.mediaSourceEngine_&&c.video_)return y.yield(c.initializeMediaSourceEngineInner_(),0);y.jumpTo(0)}})};shaka.Player.prototype.updateStartTime=function(a){this.startTime_=a};
shaka.Player.prototype.load=function(a,b,c){b=b===void 0?null:b;var d=this,e,f,g,h,k,l,m,n,p,q,r,t,u,v,w;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(x){switch(x.getNextAddressJsc()){case 1:if(d.loadMode_==shaka.Player.LoadMode.DESTROYED)throw d.createAbortLoadError_();if(d.video_||!d.preloadDueAdManagerVideo_){x.jumpTo(2);break}return x.yield(d.attach(d.preloadDueAdManagerVideo_,!0),3);case 3:d.preloadDueAdManagerVideo_=null;case 2:e=null;f="";c=(g=c)==null?void 0:g.toLowerCase();
if(a instanceof shaka.media.PreloadManager){if(a.isDestroyed())throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.PLAYER,shaka.util.Error.Code.PRELOAD_DESTROYED);e=a;f=e.getAssetUri()||""}else f=a||"";return x.yield(d.mutex_.acquire("load"),4);case 4:d.mutex_.release();if(!d.video_)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.PLAYER,shaka.util.Error.Code.NO_VIDEO_ELEMENT);if(!d.assetUri_){x.jumpTo(5);break}d.assetUri_=
f;return x.yield(d.unload(!1),5);case 5:h=++d.operationId_;k=function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(y){if(y.getNextAddressJsc()==1)return d.operationId_==h?y.jumpTo(0):e?y.yield(e.destroy(),3):y.jumpTo(3);throw d.createAbortLoadError_();})};l=function(y,C){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(D){switch(D.getNextAddressJsc()){case 1:return D.setFinallyBlock(2),D.yield(d.mutex_.acquire(C),4);case 4:return D.yield(k(),5);case 5:return D.yield(y(),
6);case 6:return D.yield(k(),7);case 7:e&&d.config_&&e.reconfigure(d.config_);case 2:D.enterFinallyBlock(),d.mutex_.release(),D.leaveFinallyBlock(0)}})};x.setCatchFinallyBlocks(7,8);b==null&&e&&(b=e.getStartTime());d.startTime_=b;d.fullyLoaded_=!1;d.dispatchEvent(shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.Loading));if(e){c=e.getMimeType();x.jumpTo(10);break}if(c){x.jumpTo(10);break}return x.yield(l(function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(y){if(y.getNextAddressJsc()==
1)return y.yield(d.guessMimeType_(f),2);c=y.getYieldResultJsc();y.jumpToEnd()})},"guessMimeType_"),10);case 10:m=!!e;if(e){e.setEventHandoffTarget(d);d.stats_=e.getStats();x.jumpTo(13);break}return x.yield(d.preloadInner_(f,b,c,!0,d.config_),14);case 14:(e=x.getYieldResultJsc())?(e.markIsLoad(),e.setEventHandoffTarget(d),d.stats_=e.getStats(),e.start(),e.waitForFinish().catch(function(){})):d.stats_=new shaka.util.Stats;case 13:n=!e;p=Date.now()/1E3;d.stats_=e?e.getStats():new shaka.util.Stats;d.assetUri_=
f;d.mimeType_=c||null;d.updateBufferState_();q=function(){var y=d.video_?d.video_.buffered:null;return{start:shaka.media.TimeRangesUtils.bufferStart(y)||0,end:shaka.media.TimeRangesUtils.bufferEnd(y)||0}};d.metadataRegionTimeline_=new shaka.media.RegionTimeline(q);d.metadataRegionTimeline_.addEventListener("regionadd",function(y){d.dispatchMetadataEvent_(y.region,shaka.util.FakeEvent.EventName.MetadataAdded)});if(n)return x.yield(l(function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(y){goog.asserts.assert(c,
"We should know the mimeType by now!");return y.yield(d.initializeSrcEqualsDrmInner_(c),0)})},"initializeSrcEqualsDrmInner_"),25);d.emsgRegionTimeline_=new shaka.media.RegionTimeline(q);return x.yield(l(function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(y){if(y.getNextAddressJsc()==1)return y.yield(e.waitForManifest(),2);d.parserFactory_=e.getParserFactory();d.parser_=e.receiveParser();d.manifest_=e.getManifest();y.jumpToEnd()})},"waitForFinish"),17);case 17:if(d.mediaSourceEngine_){x.jumpTo(18);
break}return x.yield(l(function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(y){return y.yield(d.initializeMediaSourceEngineInner_(),0)})},"initializeMediaSourceEngineInner_"),18);case 18:return d.manifest_&&d.manifest_.textStreams.length&&(d.textDisplayer_.enableTextDisplayer?d.textDisplayer_.enableTextDisplayer():shaka.Deprecate.deprecateFeature(5,"Text displayer w/ enableTextDisplayer",'Text displayer should have a "enableTextDisplayer" method!')),x.yield(l(function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(y){return y.yield(e.waitForFinish(),
0)})},"waitForFinish"),20);case 20:d.config_=e.getConfiguration();d.manifestFilterer_=e.getManifestFilterer();d.parser_&&d.parser_.setMediaElement&&d.video_&&d.parser_.setMediaElement(d.video_);d.regionTimeline_=e.receiveRegionTimeline();d.qualityObserver_=e.getQualityObserver();if(r=e.getCurrentAdaptationSetCriteria())d.currentAdaptationSetCriteria_=r;m&&d.video_&&d.video_.nodeName==="AUDIO"&&(d.makeManifestAudioOnly_(),d.configure("manifest.disableVideo",!0));if(e.getDrmEngine()){x.jumpTo(21);break}return x.yield(l(function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(y){return y.yield(e.initializeDrm(d.video_),
0)})},"drmEngine_.init"),21);case 21:return d.drmEngine_=e.receiveDrmEngine(),x.yield(l(function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(y){return y.yield(d.drmEngine_.attach(d.video_),0)})},"drmEngine_.attach"),23);case 23:return t=d.config_.abrFactory,d.abrManager_&&d.abrManagerFactory_==t||(d.abrManagerFactory_=t,d.abrManager_&&d.abrManager_.release(),d.abrManager_=t(),typeof d.abrManager_.setMediaElement!="function"&&(shaka.Deprecate.deprecateFeature(5,"AbrManager w/o setMediaElement",
"Please use an AbrManager with setMediaElement function."),d.abrManager_.setMediaElement=function(){}),typeof d.abrManager_.setCmsdManager!="function"&&(shaka.Deprecate.deprecateFeature(5,"AbrManager w/o setCmsdManager","Please use an AbrManager with setCmsdManager function."),d.abrManager_.setCmsdManager=function(){}),typeof d.abrManager_.trySuggestStreams!="function"&&(shaka.Deprecate.deprecateFeature(5,"AbrManager w/o trySuggestStreams","Please use an AbrManager with trySuggestStreams function."),
d.abrManager_.trySuggestStreams=function(){}),d.abrManager_.configure(d.config_.abr)),u=e.receiveSegmentPrefetchesById(),v=e.getPrefetchedVariant(),x.yield(l(function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(y){return y.yield(d.loadInner_(p,v,u),0)})},"loadInner_"),24);case 24:e.stopQueuingLatePhaseQueuedOperations();d.mimeType_&&shaka.device.DeviceFactory.getDevice().supportsAirPlay()&&shaka.util.MimeUtils.isHlsType(d.mimeType_)&&d.mediaSourceEngine_.addSecondarySource(d.assetUri_,
d.mimeType_);x.jumpTo(16);break;case 25:return x.yield(l(function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(y){goog.asserts.assert(c,"We should know the mimeType by now!");return y.yield(d.srcEqualsInner_(p,c),0)})},"srcEqualsInner_"),16);case 16:d.dispatchEvent(shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.Loaded));case 8:x.enterFinallyBlock();if(!e){x.jumpTo(27);break}return x.yield(e.destroy(),27);case 27:d.preloadNextUrl_=null;x.leaveFinallyBlock(0);break;case 7:w=
x.enterCatchBlock();if(!w||w.code==shaka.util.Error.Code.LOAD_INTERRUPTED){x.jumpTo(29);break}return x.yield(d.unload(!1),29);case 29:throw w;}})};shaka.Player.prototype.makeManifestAudioOnly_=function(){for(var a=(0,$jscomp.makeIterator)(this.manifest_.variants),b=a.next();!b.done;b=a.next())b=b.value,b.video&&(b.video.closeSegmentIndex(),b.video=null),b.bandwidth=b.audio&&b.audio.bandwidth?b.audio.bandwidth:0;this.manifest_.variants=this.manifest_.variants.filter(function(c){return c.audio})};
shaka.Player.prototype.unloadAndSavePreload=function(a,b,c){a=a===void 0?!0:a;b=b===void 0?!1:b;c=c===void 0?!1:c;var d=this,e;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){return f.getNextAddressJsc()==1?f.yield(d.savePreload_(c),2):f.getNextAddressJsc()!=3?(e=f.getYieldResultJsc(),f.yield(d.unload(a,b),3)):f.return(e)})};
shaka.Player.prototype.detachAndSavePreload=function(a,b){a=a===void 0?!1:a;b=b===void 0?!1:b;var c=this,d;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(e){return e.getNextAddressJsc()==1?e.yield(c.savePreload_(b),2):e.getNextAddressJsc()!=3?(d=e.getYieldResultJsc(),e.yield(c.detach(a),3)):e.return(d)})};
shaka.Player.prototype.savePreload_=function(a){a=a===void 0?!1:a;var b=this,c,d,e;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){if(f.getNextAddressJsc()==1){c=null;if(!(b.manifest_&&b.parser_&&b.parserFactory_&&b.assetUri_&&b.config_))return f.jumpTo(2);d=b.video_.currentTime;a||(d=null);return f.yield(b.makePreloadManager_(b.assetUri_,d,b.mimeType_,b.config_,!0,!1),3)}f.getNextAddressJsc()!=2&&(c=f.getYieldResultJsc(),b.createdPreloadManagers_.push(c),b.parser_&&b.parser_.setMediaElement&&
b.parser_.setMediaElement(null),(e=b.streamingEngine_?b.streamingEngine_.getCurrentVariant():null)&&c.setPrefetchVariant(e),c.attachManifest(b.manifest_,b.parser_,b.parserFactory_),c.attachAdaptationSetCriteria(b.currentAdaptationSetCriteria_),c.start(),b.manifest_=null,b.parser_=null,b.parserFactory_=null,b.abrManager_=null,b.abrManagerFactory_=null);return f.return(c)})};
shaka.Player.prototype.preload=function(a,b,c,d){b=b===void 0?null:b;var e=this,f,g,h;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(k){if(k.getNextAddressJsc()==1)return goog.asserts.assert(e.config_,"Config must not be null!"),c=(f=c)==null?void 0:f.toLowerCase(),g=e.defaultConfig_(),shaka.util.PlayerConfiguration.mergeConfigObjects(g,d||e.config_,e.defaultConfig_()),k.yield(e.preloadInner_(a,b,c,!1,g),2);if(h=k.getYieldResultJsc())h.start();else e.onError_(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.PLAYER,shaka.util.Error.Code.SRC_EQUALS_PRELOAD_NOT_SUPPORTED));return k.return(h)})};shaka.Player.prototype.destroyAllPreloads=function(){var a=this,b,c,d,e;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){b=[];c=(0,$jscomp.makeIterator)(a.createdPreloadManagers_);for(d=c.next();!d.done;d=c.next())e=d.value,e.isDestroyed()||b.push(e.destroy());a.createdPreloadManagers_=[];return f.yield(Promise.all(b),0)})};
shaka.Player.prototype.preloadInner_=function(a,b,c,d,e){d=d===void 0?!1:d;var f=this,g,h,k,l;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(m){if(m.getNextAddressJsc()==1)return goog.asserts.assert(f.networkingEngine_,"Should have a net engine!"),goog.asserts.assert(f.config_,"Config must not be null!"),c?m.jumpTo(2):m.yield(f.guessMimeType_(a),3);m.getNextAddressJsc()!=2&&(c=m.getYieldResultJsc());if(g=f.shouldUseSrcEquals_(c))return m.return(null);h=e||f.config_;k=!1;d&&f.video_&&
f.video_.nodeName==="AUDIO"&&(k=!0);l=f.makePreloadManager_(a,b,c||null,h,!d,k);l=d?l.then(function(n){n.markIsLoad();return n}):l.then(function(n){f.createdPreloadManagers_.push(n);return n});return m.return(l)})};
shaka.Player.prototype.makePreloadManager_=function(a,b,c,d,e,f){e=e===void 0?!0:e;f=f===void 0?!1:f;var g=this,h,k,l,m,n,p,q,r,t,u,v,w,x,y,C;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(D){if(D.getNextAddressJsc()==1){goog.asserts.assert(g.networkingEngine_,"Must have net engine");h=null;k=shaka.util.ObjectUtils.cloneObject(d);f&&(k.manifest.disableVideo=!0);l=function(){goog.asserts.assert(h,"Must have preload manager");return h.hasBeenAttached()&&h.isDestroyed()?null:h};m=function(){return l()?
l().getConfiguration():g.config_};if(g.maxHwRes_.width!=Infinity||g.maxHwRes_.height!=Infinity||g.config_.ignoreHardwareResolution)return D.jumpTo(2);n=shaka.device.DeviceFactory.getDevice();goog.asserts.assert(n,"device must be non-null");return D.yield(n.detectMaxHardwareResolution(),3)}D.getNextAddressJsc()!=2&&(p=D.getYieldResultJsc(),g.maxHwRes_.width=p.width,g.maxHwRes_.height=p.height);q=new shaka.media.ManifestFilterer(k,g.maxHwRes_,null);r={networkingEngine:g.networkingEngine_,filter:function(A){var z,
B;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(E){if(E.getNextAddressJsc()==1)return E.yield(q.filterManifest(A),2);if(E.getNextAddressJsc()!=4){z=E.getYieldResultJsc();if(!z)return E.jumpTo(0);B=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.TracksChanged);return E.yield(Promise.resolve(),4)}h.dispatchEvent(B);E.jumpToEnd()})},makeTextStreamsForClosedCaptions:function(A){return g.makeTextStreamsForClosedCaptions_(A)},onTimelineRegionAdded:function(A){h.getRegionTimeline().addRegion(A)},
onEvent:function(A){return h.dispatchEvent(A)},onError:function(A){return h.onError(A)},isLowLatencyMode:function(){return m().streaming.lowLatencyMode},updateDuration:function(){g.streamingEngine_&&h.hasBeenAttached()&&g.streamingEngine_.updateDuration()},newDrmInfo:function(A){var z=h.getDrmEngine(),B=z?z.getDrmInfo():null;B&&z.getMediaKeys()&&q.processDrmInfos(B.keySystem,A)},onManifestUpdated:function(){var A=shaka.util.FakeEvent.EventName.ManifestUpdated,z=(new Map).set("isLive",g.isLive());
h.dispatchEvent(shaka.Player.makeEvent_(A,z));h.addQueuedOperation(!1,function(){if(g.adManager_)g.adManager_.onManifestUpdated(g.isLive())})},getBandwidthEstimate:function(){return g.abrManager_.getBandwidthEstimate()},onMetadata:function(A,z,B,E){var H=A;if(A=="com.apple.hls.interstitial"||A=="com.apple.hls.overlay")H="com.apple.quicktime.HLS",A={startTime:z,endTime:B,values:E},g.adManager_&&(goog.asserts.assert(g.video_,"Must have video"),g.adManager_.onHLSInterstitialMetadata(g,g.video_,A));E=
(0,$jscomp.makeIterator)(E);A=E.next();for(var N={};!A.done;N={payload$jscomp$7:void 0},A=E.next())N.payload$jscomp$7=A.value,N.payload$jscomp$7.name!="ID"&&h.addQueuedOperation(!1,function(F){return function(){g.addMetadataToRegionTimeline_(z,B,H,F.payload$jscomp$7)}}(N))},disableStream:function(A){return g.disableStream(A,g.config_.streaming.maxDisabledTime)},addFont:function(A,z){return g.addFont(A,z)}};t=new shaka.media.RegionTimeline(function(){return g.seekRange()});t.addEventListener("regionadd",
function(A){var z=A.region;g.onRegionEvent_(shaka.util.FakeEvent.EventName.TimelineRegionAdded,z,h);h.addQueuedOperation(!1,function(){g.adManager_&&(g.adManager_.onDashTimedMetadata(z),goog.asserts.assert(g.video_,"Must have video"),g.adManager_.onDASHInterstitialMetadata(g,g.video_,z))})});u=null;k.streaming.observeQualityChanges&&(u=new shaka.media.QualityObserver(function(){return g.getBufferedInfo()}),u.addEventListener("qualitychange",function(A){g.onMediaQualityChange_(A.quality,A.position)}),
u.addEventListener("audiotrackchange",function(A){g.onMediaQualityChange_(A.quality,A.position,!0)}));v=!0;w={netEngine:g.networkingEngine_,onError:function(A){return h.onError(A)},onKeyStatus:function(A){h.addQueuedOperation(!0,function(){if(g.drmEngine_)g.onKeyStatus_(A)})},onExpirationUpdated:function(A,z){var B=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.ExpirationUpdated);h.dispatchEvent(B);if((B=h.getParser())&&B.onExpirationUpdated)B.onExpirationUpdated(A,z)},onEvent:function(A){h.dispatchEvent(A);
A.type==shaka.util.FakeEvent.EventName.DrmSessionUpdate&&v&&(v=!1,A=Date.now()/1E3-h.getStartTimeOfDRM(),(g.stats_||h.getStats()).setDrmTime(A),g.lcevcDec_&&g.lcevcDec_.hideCanvas())}};x=g.createNetworkingEngine(l);g.networkingEngine_.copyFiltersInto(x);y=function(){return g.createDrmEngine(w)};C={config:k,manifestPlayerInterface:r,regionTimeline:t,qualityObserver:u,createDrmEngine:y,manifestFilterer:q,networkingEngine:x,allowPrefetch:e};h=new shaka.media.PreloadManager(a,c,b,C);return D.return(h)})};
shaka.Player.prototype.guessMimeType_=function(a){var b=this,c,d,e,f;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(g){if(g.getNextAddressJsc()==1)return goog.asserts.assert(b.networkingEngine_,"Should have a net engine!"),c=b.config_.manifest.retryParameters,g.yield(shaka.net.NetworkingUtils.getMimeType(a,b.networkingEngine_,c),2);d=g.getYieldResultJsc();shaka.util.MimeUtils.isHlsType(d)?(e=shaka.device.DeviceFactory.getDevice(),e.getBrowserEngine()===shaka.device.IDevice.BrowserEngine.WEBKIT&&
(d="application/vnd.apple.mpegurl")):d==="video/quicktime"&&(f=shaka.device.DeviceFactory.getDevice(),f.getBrowserEngine()===shaka.device.IDevice.BrowserEngine.CHROMIUM&&(d="video/mp4"));return g.return(d)})};
shaka.Player.prototype.shouldUseSrcEquals_=function(a){var b=shaka.util.MimeUtils;if(!shaka.device.DeviceFactory.getDevice().supportsMediaSource())return!0;if(a){var c=(this.video_||shaka.util.Dom.anyMediaElement()).canPlayType(a)!="";if(!c)return!1;var d=shaka.media.ManifestParser.isSupported(a);if(!d)return!0;goog.asserts.assert(c&&d,"Both native and MSE playback should be possible!");if(b.isHlsType(a))return shaka.device.DeviceFactory.getDevice().getBrowserEngine()===shaka.device.IDevice.BrowserEngine.WEBKIT&&
(this.config_.drm.servers["com.apple.fps"]||this.config_.drm.servers["com.apple.fps.1_0"])?this.config_.streaming.useNativeHlsForFairPlay:this.config_.streaming.preferNativeHls;if(b.isDashType(a))return this.config_.streaming.preferNativeDash}return!1};
shaka.Player.prototype.createAndConfigureTextDisplayer_=function(a){var b=this.config_.textDisplayFactory;this.lastTextFactory_!==b||(a===void 0?0:a)?(a=this.textDisplayer_,this.textDisplayer_=b(),this.textDisplayer_.configure?this.textDisplayer_.configure(this.config_.textDisplayer):shaka.Deprecate.deprecateFeature(5,"Text displayer w/ configure",'Text displayer should have a "configure" method!'),this.textDisplayer_.setTextLanguage||shaka.Deprecate.deprecateFeature(5,"Text displayer w/ setTextLanguage",
'Text displayer should have a "setTextLanguage" method!'),a?(this.textDisplayer_.setTextVisibility(a.isTextVisible()),a.destroy().catch(function(){})):this.textDisplayer_.setTextVisibility(this.isTextVisible_),this.mediaSourceEngine_&&this.mediaSourceEngine_.setTextDisplayer(this.textDisplayer_),this.lastTextFactory_=b,this.streamingEngine_&&this.streamingEngine_.reloadTextStream()):this.textDisplayer_&&this.textDisplayer_.configure&&this.textDisplayer_.configure(this.config_.textDisplayer)};
shaka.Player.prototype.initializeMediaSourceEngineInner_=function(){var a=this,b,c,d,e;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){if(f.getNextAddressJsc()==1)return b=shaka.device.DeviceFactory.getDevice(),goog.asserts.assert(b.supportsMediaSource(),"We should not be initializing media source on a platform that does not support media source."),goog.asserts.assert(a.video_,"We should have a media element when initializing media source."),goog.asserts.assert(a.mediaSourceEngine_==
null,"We should not have a media source engine yet."),a.makeStateChangeEvent_("media-source"),a.config_.mediaSource.useSourceElements&&shaka.util.Dom.clearSourceFromVideo(a.video_),a.createAndConfigureTextDisplayer_(),goog.asserts.assert(a.textDisplayer_,"Text displayer should be created already"),c=a.createMediaSourceEngine(a.video_,a.textDisplayer_,{getKeySystem:function(){return a.keySystem()},onMetadata:function(g,h,k){a.processTimedMetadataMediaSrc_(g,h,k)},onEmsg:function(g){a.addEmsgToRegionTimeline_(g)},
onEvent:function(g){return a.dispatchEvent(g)},onManifestUpdate:function(){return a.onManifestUpdate_()}},a.lcevcDec_,a.config_.mediaSource),d=a.config_.manifest,e=d.segmentRelativeVttTiming,c.setSegmentRelativeVttTiming(e),f.yield(c.open(),2);a.mediaSourceEngine_=c;f.jumpToEnd()})};
shaka.Player.prototype.setupPlayRateController_=function(a){var b=this;this.playRateController_=new shaka.media.PlayRateController({getRate:function(){return a.playbackRate},getDefaultRate:function(){return a.defaultPlaybackRate},setRate:function(c){a.playbackRate=c},movePlayhead:function(c){var d=a.currentTime;if(shaka.media.TimeRangesUtils.isBuffered(a.buffered,d)&&!(a.readyState<=HTMLMediaElement.HAVE_CURRENT_DATA)){c=d+c;var e=b.seekRange();c<e.start?d!==e.start&&(a.currentTime=e.start):c>e.end?
d!==e.end&&(a.currentTime=e.end):a.currentTime=c}},isPaused:function(){return a.paused}})};
shaka.Player.prototype.addBasicMediaListeners_=function(a,b){var c=this,d=function(){return c.updateStateHistory_()};this.loadEventManager_.listen(a,"playing",d);this.loadEventManager_.listen(a,"pause",d);this.loadEventManager_.listen(a,"ended",d);this.loadEventManager_.listen(a,"ratechange",function(){return c.onRateChange_()});a.remote&&(this.loadEventManager_.listen(a.remote,"connect",function(){if(c.streamingEngine_&&a.remote.state=="connected")c.onTextChanged_();c.onTracksChanged_()}),this.loadEventManager_.listen(a.remote,
"connecting",function(){return c.onTracksChanged_()}),this.loadEventManager_.listen(a.remote,"disconnect",function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){if(f.getNextAddressJsc()==1)return c.streamingEngine_&&a.remote.state=="disconnected"?f.yield(c.streamingEngine_.resetMediaSource(),3):f.jumpTo(2);if(f.getNextAddressJsc()!=2)c.onTextChanged_();c.onTracksChanged_();f.jumpToEnd()})}));a.audioTracks&&(this.loadEventManager_.listen(a.audioTracks,"addtrack",function(){return c.onTracksChanged_()}),
this.loadEventManager_.listen(a.audioTracks,"removetrack",function(){return c.onTracksChanged_()}),this.loadEventManager_.listen(a.audioTracks,"change",function(){return c.onTracksChanged_()}));a.videoTracks&&(this.loadEventManager_.listen(a.videoTracks,"addtrack",function(){return c.onTracksChanged_()}),this.loadEventManager_.listen(a.videoTracks,"removetrack",function(){return c.onTracksChanged_()}),this.loadEventManager_.listen(a.videoTracks,"change",function(){return c.onTracksChanged_()}));(a.webkitPresentationMode||
a.webkitSupportsFullscreen)&&this.loadEventManager_.listen(a,"webkitpresentationmodechanged",function(){c.videoContainer_&&c.createAndConfigureTextDisplayer_(!0)});if(a.textTracks){var e=function(){if(c.loadMode_===shaka.Player.LoadMode.SRC_EQUALS&&c.textDisplayer_ instanceof shaka.text.NativeTextDisplayer)c.onTextChanged_();c.onTracksChanged_()};this.loadEventManager_.listen(a.textTracks,"addtrack",function(f){if(f.track)switch(f=f.track,goog.asserts.assert(f instanceof TextTrack,"Wrong track type!"),
f.kind){case "metadata":c.processTimedMetadataSrcEquals_(f);break;case "chapters":c.activateChaptersTrack_(f);break;default:e()}});this.loadEventManager_.listen(a.textTracks,"removetrack",e);this.loadEventManager_.listen(a.textTracks,"change",e)}a.preload!="none"&&this.loadEventManager_.listenOnce(a,"loadedmetadata",function(){var f=Date.now()/1E3-b;c.stats_.setLoadLatency(f)})};
shaka.Player.prototype.loadInner_=function(a,b,c){var d=this,e,f,g,h,k,l,m,n,p,q,r,t,u,v,w,x,y,C,D,A,z,B,E,H,N,F,I,L,G,M;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(J){switch(J.getNextAddressJsc()){case 1:goog.asserts.assert(d.video_,"We should have a media element by now.");goog.asserts.assert(d.manifest_,"The manifest should already be parsed.");goog.asserts.assert(d.assetUri_,"We should have an asset uri by now.");goog.asserts.assert(d.abrManager_,"We should have an abr manager by now.");
d.makeStateChangeEvent_("load");e=d.video_;d.setupPlayRateController_(e);d.addBasicMediaListeners_(e,a);"onchange"in window.screen&&d.loadEventManager_.listen(window.screen,"change",function(){if(d.currentAdaptationSetCriteria_.getConfiguration){var O=d.currentAdaptationSetCriteria_.getConfiguration();O.hdrLevel=="AUTO"?d.updateAbrManagerVariants_():d.config_.preferredVideoHdrLevel=="AUTO"&&d.config_.abr.enabled&&(O.hdrLevel="AUTO",d.currentAdaptationSetCriteria_.configure(O),d.updateAbrManagerVariants_())}});
f=!1;g=(0,$jscomp.makeIterator)(d.manifest_.variants);for(h=g.next();!h.done;h=g.next())k=h.value,(l=k.video&&k.video.dependencyStream)&&(f=shaka.lcevc.Dec.isStreamSupported(l));d.setupLcevc_(d.config_,f);d.currentTextLanguage_=d.config_.preferredTextLanguage;d.currentTextRole_=d.config_.preferredTextRole;d.currentTextForced_=d.config_.preferForcedSubs;shaka.Player.applyPlayRange_(d.manifest_.presentationTimeline,d.config_.playRangeStart,d.config_.playRangeEnd);d.abrManager_.init(function(O,P,Q){return d.switch_(O,
P,Q)});d.abrManager_.setMediaElement(e);d.abrManager_.setCmsdManager(d.cmsdManager_);d.streamingEngine_=d.createStreamingEngine();d.streamingEngine_.configure(d.config_.streaming);d.loadMode_=shaka.Player.LoadMode.MEDIA_SOURCE;d.dispatchEvent(shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.Streaming));m=b;case 2:p=d.streamingEngine_.getCurrentVariant();p||(q=d.chooseVariant_(!0),b||(m=q),goog.asserts.assert(m,"Must choose an initial variant!"));r=[];n=p||m;t=(0,$jscomp.makeIterator)([n.video,
n.audio]);for(u=t.next();!u.done;u=t.next())(v=u.value)&&!v.segmentIndex&&(r.push(v.createSegmentIndex()),v.dependencyStream&&r.push(v.dependencyStream.createSegmentIndex()));if(!(r.length>0)){J.jumpTo(4);break}return J.yield(Promise.all(r),4);case 4:if(!n||n.disabledUntilTime!=0){J.jumpTo(2);break}d.updateAbrManagerVariants_();if(d.parser_&&d.parser_.onInitialVariantChosen)d.parser_.onInitialVariantChosen(n);d.manifest_.isLowLatency&&(d.config_.streaming.lowLatencyMode?d.configure(d.lowLatencyConfig_):
shaka.log.alwaysWarn("Low-latency live stream detected, but low-latency streaming mode is not enabled in Shaka Player. Set streaming.lowLatencyMode configuration to true, and see https://bit.ly/3clctcj for details."));d.cmcdManager_&&(d.cmcdManager_.setLowLatency(d.manifest_.isLowLatency&&d.config_.streaming.lowLatencyMode),d.cmcdManager_.setStartTimeOfLoad(a*1E3));shaka.Player.applyPlayRange_(d.manifest_.presentationTimeline,d.config_.playRangeStart,d.config_.playRangeEnd);d.streamingEngine_.applyPlayRange(d.config_.playRangeStart,
d.config_.playRangeEnd);d.fullyLoaded_=!0;d.dispatchEvent(shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.CanUpdateStartTime));w=function(O){d.playhead_=d.createPlayhead(O);d.playheadObservers_=d.createPlayheadObserversForMSE_(O);d.startBufferManagement_(e,!1)};d.config_.streaming.startAtSegmentBoundary||(x=d.startTime_,x==null&&d.manifest_.startTime&&(x=d.manifest_.startTime),w(x));if(p){J.jumpTo(7);break}goog.asserts.assert(m,"Must have chosen an initial variant!");if(!d.config_.streaming.startAtSegmentBoundary){J.jumpTo(8);
break}y=d.manifest_.presentationTimeline;d.startTime_ instanceof Date&&(D=y.getInitialProgramDateTime()||y.getPresentationStartTime(),goog.asserts.assert(D!=null,"Presentation start time should not be null!"),A=d.startTime_.getTime()/1E3-D,A!=null&&(C=A));C==null&&(C=typeof d.startTime_==="number"?d.startTime_:d.isLive()?Infinity:d.video_.currentTime);d.startTime_==null&&d.manifest_.startTime&&(C=d.manifest_.startTime);z=y.getSeekRangeStart();B=y.getSeekRangeEnd();C<z?C=z:C>B&&(C=B);return J.yield(d.adjustStartTime_(m,
C),9);case 9:E=J.getYieldResultJsc(),w(E);case 8:d.switchVariant_(m,!0,!1,0);case 7:return d.playhead_.ready(),H=d.getTextTracks().find(function(O){return O.active}),H||((N=d.chooseTextStream_())&&d.addTextStreamToSwitchHistory_(N,!0),m&&d.setInitialTextState_(m,N),N&&d.shouldStreamText_()&&(d.streamingEngine_.switchTextStream(N),d.setTextDisplayerLanguage_())),J.yield(d.streamingEngine_.start(c),10);case 10:d.config_.abr.enabled&&(d.abrManager_.enable(),d.onAbrStatusChanged_());d.onTracksChanged_();
F=d.manifest_.variants.some(function(O){return O.primary});d.config_.preferredAudioLanguage||F||shaka.log.warning("No preferred audio language set.  We have chosen an arbitrary language initially");if((I=d.isLive())&&(d.config_.streaming.liveSync&&d.config_.streaming.liveSync.enabled||d.manifest_.serviceDescription||d.config_.streaming.liveSync.panicMode)||d.config_.streaming.vodDynamicPlaybackRate)L=function(){return d.onTimeUpdate_()},d.loadEventManager_.listen(e,"timeupdate",L);I||(G=function(){return d.onVideoProgress_()},
d.loadEventManager_.listen(e,"timeupdate",G),d.onVideoProgress_(),d.manifest_.nextUrl&&(d.config_.streaming.preloadNextUrlWindow>0&&(M=function(){var O;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(P){if(P.getNextAddressJsc()==1){O=d.seekRange().end-d.video_.currentTime;if(isNaN(O)||!(O<=d.config_.streaming.preloadNextUrlWindow))return P.jumpTo(0);d.loadEventManager_.unlisten(e,"timeupdate",M);goog.asserts.assert(d.manifest_.nextUrl,"this.manifest_.nextUrl should be valid.");return P.yield(d.preload(d.manifest_.nextUrl),
4)}d.preloadNextUrl_=P.getYieldResultJsc();P.jumpToEnd()})},d.loadEventManager_.listen(e,"timeupdate",M)),d.loadEventManager_.listen(e,"ended",function(){d.load(d.preloadNextUrl_||d.manifest_.nextUrl)})));if(d.adManager_)d.adManager_.onManifestUpdated(I);J.jumpToEnd()}})};
shaka.Player.prototype.initializeSrcEqualsDrmInner_=function(a){var b=this,c,d,e;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){return f.getNextAddressJsc()==1?(goog.asserts.assert(b.networkingEngine_,"|onInitializeSrcEqualsDrm_| should never be called after |destroy|"),goog.asserts.assert(b.config_,"|onInitializeSrcEqualsDrm_| should never be called after |destroy|"),c=Date.now()/1E3,d=!0,b.drmEngine_=b.createDrmEngine({netEngine:b.networkingEngine_,onError:function(g){b.onError_(g)},
onKeyStatus:function(g){},onExpirationUpdated:function(g,h){g=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.ExpirationUpdated);b.dispatchEvent(g)},onEvent:function(g){b.dispatchEvent(g);g.type==shaka.util.FakeEvent.EventName.DrmSessionUpdate&&d&&(d=!1,g=Date.now()/1E3-c,b.stats_.setDrmTime(g))}}),b.drmEngine_.configure(b.config_.drm),e=shaka.util.StreamUtils.createEmptyVariant([a]),b.drmEngine_.setSrcEquals(!0),f.yield(b.drmEngine_.initForPlayback([e],[]),2)):f.yield(b.drmEngine_.attach(b.video_),
0)})};
shaka.Player.prototype.srcEqualsInner_=function(a,b){var c=this,d,e,f,g,h,k,l,m,n,p,q,r;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(t){switch(t.getNextAddressJsc()){case 1:c.makeStateChangeEvent_("src-equals");goog.asserts.assert(c.video_,"We should have a media element when loading.");goog.asserts.assert(c.assetUri_,"We should have a valid uri when loading.");d=c.video_;c.playhead_=new shaka.media.SrcEqualsPlayhead(d);e=!1;c.cleanupOnUnload_.push(function(){e=!0});c.dispatchEvent(shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.CanUpdateStartTime));c.startTime_!=
null&&c.playhead_.setStartTime(c.startTime_);c.playheadObservers_=c.createPlayheadObserversForSrcEquals_(c.startTime_||0);c.setupPlayRateController_(d);c.startBufferManagement_(d,!0);d.textTracks&&(c.createAndConfigureTextDisplayer_(),f=function(u){if(!(c.textDisplayer_ instanceof shaka.text.NativeTextDisplayer)){var v=c.getFilteredTextTracks_().find(function(w){return w.mode!=="disabled"});v&&(v.mode=u?"showing":"hidden");c.textDisplayer_ instanceof shaka.text.SimpleTextDisplayer&&(v=c.getGeneratedTextTrack_())&&
(v.mode=!u&&c.textDisplayer_.isTextVisible()?"showing":"hidden")}},c.loadEventManager_.listen(d,"enterpictureinpicture",function(){return f(!0)}),c.loadEventManager_.listen(d,"leavepictureinpicture",function(){return f(!1)}),d.remote?(c.loadEventManager_.listen(d.remote,"connect",function(){return f(!1)}),c.loadEventManager_.listen(d.remote,"connecting",function(){return f(!1)}),c.loadEventManager_.listen(d.remote,"disconnect",function(){return f(!1)})):"webkitCurrentPlaybackTargetIsWireless"in d&&
c.loadEventManager_.listen(d,"webkitcurrentplaybacktargetiswirelesschanged",function(){return f(!1)}),g=d,(g.webkitPresentationMode||g.webkitSupportsFullscreen)&&c.loadEventManager_.listen(g,"webkitpresentationmodechanged",function(){g.webkitPresentationMode?f(g.webkitPresentationMode!=="inline"):g.webkitSupportsFullscreen&&f(g.webkitDisplayingFullscreen)}));c.addBasicMediaListeners_(d,a);h=c.cmcdManager_.appendSrcData(c.assetUri_,b);!h.includes("#t=")&&(c.config_.playRangeStart>0||isFinite(c.config_.playRangeEnd))&&
(h+="#t=",c.config_.playRangeStart>0&&(h+=c.config_.playRangeStart),isFinite(c.config_.playRangeEnd)&&(h+=","+c.config_.playRangeEnd));if(!c.mediaSourceEngine_){t.jumpTo(2);break}return t.yield(c.mediaSourceEngine_.destroy(),3);case 3:c.mediaSourceEngine_=null;case 2:return shaka.util.Dom.clearSourceFromVideo(d),d.src=h,k=shaka.device.DeviceFactory.getDevice(),k.getDeviceType()==shaka.device.IDevice.DeviceType.TV&&d.load(),d.preload!="none"&&!d.autoplay&&shaka.util.MimeUtils.isHlsType(b)&&k.getBrowserEngine()===
shaka.device.IDevice.BrowserEngine.WEBKIT&&d.load(),c.loadMode_=shaka.Player.LoadMode.SRC_EQUALS,c.dispatchEvent(shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.Streaming)),l=function(){return new Promise(function(u){var v=new shaka.util.Timer(u);c.loadEventManager_.listen(d.textTracks,"change",function(){return v.tickAfter(.5)});v.tickAfter(.5)})},m=new shaka.util.PublicPromise,shaka.util.MediaReadyState.waitForReadyState(d,HTMLMediaElement.HAVE_METADATA,c.loadEventManager_,function(){return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(u){if(u.getNextAddressJsc()==
1)return c.playhead_.ready(),c.mimeType_&&shaka.util.MimeUtils.isHlsType(c.mimeType_)?u.yield(l(),3):(m.resolve(),u.jumpTo(0));m.resolve();u.jumpToEnd()})}),shaka.util.MediaReadyState.waitForReadyState(d,HTMLMediaElement.HAVE_CURRENT_DATA,c.loadEventManager_,function(){var u,v,w,x,y;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(C){if(C.getNextAddressJsc()==1)return C.yield(l(),2);if(e)return C.return();c.setupPreferredAudioOnSrc_();u=c.getFilteredTextTracks_();u.some(function(D){return D.mode===
"showing"})&&(c.isTextVisible_=!0,c.textDisplayer_.setTextVisibility(!0));if(!(c.textDisplayer_ instanceof shaka.text.NativeTextDisplayer))for(u.length&&(c.textDisplayer_.enableTextDisplayer?c.textDisplayer_.enableTextDisplayer():shaka.Deprecate.deprecateFeature(5,"Text displayer w/ enableTextDisplayer",'Text displayer should have a "enableTextDisplayer" method')),v=!1,w=(0,$jscomp.makeIterator)(u),x=w.next();!x.done;x=w.next())y=x.value,y.mode!=="disabled"&&(v?(y.mode="disabled",shaka.log.alwaysWarn("Found more than one enabled text track, disabling it",
y)):(c.enableNativeTrack_(y),v=!0));c.setupPreferredTextOnSrc_();C.jumpToEnd()})}),d.error?m.reject(c.videoErrorToShakaError_()):d.preload=="none"&&(shaka.log.alwaysWarn('With <video preload="none">, the browser will not load anything until play() is called. We are unable to measure load latency in a meaningful way, and we cannot provide track info yet. Please do not use preload="none" with Shaka Player.'),m.resolve()),c.loadEventManager_.listenOnce(d,"error",function(){m.reject(c.videoErrorToShakaError_())}),
t.yield(shaka.util.Functional.promiseWithTimeout(c.config_.streaming.loadTimeout,m),4);case 4:if((n=c.isLive())&&(c.config_.streaming.liveSync&&c.config_.streaming.liveSync.enabled||c.config_.streaming.liveSync.panicMode)||c.config_.streaming.vodDynamicPlaybackRate)p=function(){return c.onTimeUpdate_()},c.loadEventManager_.listen(d,"timeupdate",p);n||(q=function(){return c.onVideoProgress_()},c.loadEventManager_.listen(d,"timeupdate",q),c.onVideoProgress_());c.adManager_&&(c.adManager_.onManifestUpdated(n),
n&&(r=c.seekRange().end,c.loadEventManager_.listen(d,"progress",function(){var u=c.seekRange().end;r!=u&&(c.adManager_.onManifestUpdated(c.isLive()),r=u)})));c.fullyLoaded_=!0;t.jumpToEnd()}})};shaka.Player.prototype.setupPreferredAudioOnSrc_=function(){var a=this.config_.preferredAudioLanguage;a!=""&&this.selectAudioLanguage(a,this.config_.preferredAudioRole)};
shaka.Player.prototype.setupPreferredTextOnSrc_=function(){var a=this.config_.preferredTextLanguage;a!=""&&this.selectTextLanguage(a,this.config_.preferredTextRole,this.config_.preferForcedSubs)};
shaka.Player.prototype.processTimedMetadataSrcEquals_=function(a){var b=this;if(a.kind=="metadata"){a.mode="hidden";this.loadEventManager_.listen(a,"cuechange",function(){if(a.activeCues)for(var d=(0,$jscomp.makeIterator)(a.activeCues),e=d.next();!e.done;e=d.next())if(e=e.value,b.addMetadataToRegionTimeline_(e.startTime,e.endTime,e.type,e.value),b.adManager_)b.adManager_.onCueMetadataChange(e.value);if(a.cues){d=[];e=(0,$jscomp.makeIterator)(a.cues);for(var f=e.next(),g={};!f.done;g={cue$jscomp$42:void 0},
f=e.next())g.cue$jscomp$42=f.value,g.cue$jscomp$42.type=="com.apple.quicktime.HLS"&&g.cue$jscomp$42.startTime!=null&&(f=d.find(function(h){return function(k){return k.startTime==h.cue$jscomp$42.startTime&&k.endTime==h.cue$jscomp$42.endTime}}(g)),f||(f={startTime:g.cue$jscomp$42.startTime,endTime:g.cue$jscomp$42.endTime,values:[]},d.push(f)),f.values.push(g.cue$jscomp$42.value));d=(0,$jscomp.makeIterator)(d);for(e=d.next();!e.done;e=d.next())e=e.value,e.values.some(function(h){return h.key=="X-ASSET-URI"||
h.key=="X-ASSET-LIST"})&&b.adManager_&&(g=e.startTime==0&&!b.isLive(),e.values.push({key:"CUE",description:"",data:g?"ONCE,PRE":"ONCE",mimeType:null,pictureType:null}),goog.asserts.assert(b.video_,"Must have video"),b.adManager_.onHLSInterstitialMetadata(b,b.video_,e))}});var c=(new shaka.util.Timer(function(){var d=b.getMetadataTracks_();d=(0,$jscomp.makeIterator)(d);for(var e=d.next();!e.done;e=d.next())e.value.mode="hidden"})).tickNow().tickAfter(.5);this.cleanupOnUnload_.push(function(){c.stop()})}};
shaka.Player.prototype.processTimedMetadataMediaSrc_=function(a,b,c){a=(0,$jscomp.makeIterator)(a);for(var d=a.next();!d.done;d=a.next())if(d=d.value,d.data&&typeof d.cueTime=="number"&&d.frames){var e=d.cueTime+b,f=c;f&&e>f&&(f=e);for(var g=(0,$jscomp.makeIterator)(d.frames),h=g.next();!h.done;h=g.next())this.addMetadataToRegionTimeline_(e,f,"org.id3",h.value);if(this.adManager_)this.adManager_.onHlsTimedMetadata(d,e)}};
shaka.Player.prototype.dispatchMetadataEvent_=function(a,b){a=(new Map).set("startTime",a.startTime).set("endTime",a.endTime).set("metadataType",a.schemeIdUri).set("payload",a.payload);this.dispatchEvent(shaka.Player.makeEvent_(b,a))};
shaka.Player.prototype.addMetadataToRegionTimeline_=function(a,b,c,d){this.metadataRegionTimeline_&&(goog.asserts.assert(!b||a<=b,"Metadata start time should be less or equal to the end time!"),a={schemeIdUri:c,startTime:a,endTime:b||Infinity,id:"",payload:d},a.id=JSON.stringify(a),this.metadataRegionTimeline_.addRegion(a))};
shaka.Player.prototype.dispatchEmsgEvent_=function(a){var b=shaka.util.FakeEvent.EventName.Emsg;a=a.emsg;a=(new Map).set("detail",a);this.dispatchEvent(shaka.Player.makeEvent_(b,a))};shaka.Player.prototype.addEmsgToRegionTimeline_=function(a){this.emsgRegionTimeline_&&this.emsgRegionTimeline_.addRegion({schemeIdUri:a.schemeIdUri,startTime:a.startTime,endTime:a.endTime,id:String(a.id),emsg:a})};
shaka.Player.prototype.activateChaptersTrack_=function(a){if(a&&a.kind=="chapters"){a.mode="hidden";var b=(new shaka.util.Timer(function(){a.mode="hidden"})).tickNow().tickAfter(.5);this.cleanupOnUnload_.push(function(){b.stop()})}};shaka.Player.prototype.releaseAllMutexes=function(){this.mutex_.releaseAll()};shaka.Player.prototype.createDrmEngine=function(a){return new shaka.drm.DrmEngine(a)};
shaka.Player.prototype.createNetworkingEngine=function(a){var b=this;a||(a=function(){return null});var c=function(f){a()?a().addQueuedOperation(!0,f):f()},d=function(f){a()?a().dispatchEvent(f):b.dispatchEvent(f)},e=new shaka.net.NetworkingEngine(function(f,g,h,k,l){c(function(){b.abrManager_&&b.abrManager_.segmentDownloaded(f,g,h,k,l)})},function(f,g,h){var k=shaka.util.FakeEvent.EventName.DownloadHeadersReceived;g=(new Map).set("headers",f).set("request",g).set("requestType",h);d(shaka.Player.makeEvent_(k,
g));c(function(){b.cmsdManager_&&b.cmsdManager_.processHeaders(f)})},function(f,g){var h=shaka.util.FakeEvent.EventName.DownloadCompleted;f=(new Map).set("request",f).set("response",g);d(shaka.Player.makeEvent_(h,f))},function(f,g,h,k){var l=shaka.util.FakeEvent.EventName.DownloadFailed;f=(new Map).set("request",f).set("error",g).set("httpResponseCode",h).set("aborted",k);d(shaka.Player.makeEvent_(l,f))},function(f,g,h){c(function(){b.cmcdManager_&&b.cmcdManager_.applyRequestData(f,g,h)})},function(f,
g,h,k){f=a()?a().getParser():b.parser_;f&&f.banLocation&&f.banLocation(k)},function(f,g,h){if(g.data){var k=g.data.byteLength;var l=a()?a().getStats():b.stats_;l&&(l.addBytesDownloaded(k),f===shaka.net.NetworkingEngine.RequestType.MANIFEST&&l.setManifestSize(k));b.cmcdManager_.applyResponseData(f,g,h)}});e.configure(this.config_.networking);return e};
shaka.Player.prototype.createPlayhead=function(a){var b=this;goog.asserts.assert(this.manifest_,"Must have manifest");goog.asserts.assert(this.video_,"Must have video");return new shaka.media.MediaSourcePlayhead(this.video_,this.manifest_,this.config_.streaming,a,function(){return b.onSeek_()},function(c){return b.dispatchEvent(c)})};
shaka.Player.prototype.createPlayheadObserversForMSE_=function(a){var b=this;goog.asserts.assert(this.manifest_,"Must have manifest");goog.asserts.assert(this.regionTimeline_,"Must have region timeline");goog.asserts.assert(this.metadataRegionTimeline_,"Must have metadata region timeline");goog.asserts.assert(this.emsgRegionTimeline_,"Must have emsg region timeline");goog.asserts.assert(this.video_,"Must have video element");var c=this.isLive()||typeof a==="number"&&a>0;a=new shaka.media.RegionObserver(this.regionTimeline_,
c);a.addEventListener("enter",function(f){b.onRegionEvent_(shaka.util.FakeEvent.EventName.TimelineRegionEnter,f.region)});a.addEventListener("exit",function(f){b.onRegionEvent_(shaka.util.FakeEvent.EventName.TimelineRegionExit,f.region)});a.addEventListener("skip",function(f){var g=f.region;f.seeking||(b.onRegionEvent_(shaka.util.FakeEvent.EventName.TimelineRegionEnter,g),b.onRegionEvent_(shaka.util.FakeEvent.EventName.TimelineRegionExit,g))});var d=new shaka.media.RegionObserver(this.metadataRegionTimeline_,
c);d.addEventListener("enter",function(f){b.dispatchMetadataEvent_(f.region,shaka.util.FakeEvent.EventName.Metadata)});c=new shaka.media.RegionObserver(this.emsgRegionTimeline_,c);c.addEventListener("enter",function(f){b.dispatchEmsgEvent_(f.region)});var e=new shaka.media.PlayheadObserverManager(this.video_);e.manage(a);e.manage(d);e.manage(c);this.qualityObserver_&&e.manage(this.qualityObserver_);return e};
shaka.Player.prototype.createPlayheadObserversForSrcEquals_=function(a){var b=this;goog.asserts.assert(this.metadataRegionTimeline_,"Must have metadata region timeline");goog.asserts.assert(this.video_,"Must have video element");a=new shaka.media.RegionObserver(this.metadataRegionTimeline_,a instanceof Date||a>0);a.addEventListener("enter",function(d){b.dispatchMetadataEvent_(d.region,shaka.util.FakeEvent.EventName.Metadata)});var c=new shaka.media.PlayheadObserverManager(this.video_);c.manage(a);
return c};
shaka.Player.prototype.startBufferManagement_=function(a,b){var c=this,d=shaka.util.MediaElementEvent;goog.asserts.assert(!this.bufferObserver_,"No buffering observer should exist before initialization.");goog.asserts.assert(!this.bufferPoller_,"No buffer timer should exist before initialization.");this.bufferObserver_=new shaka.media.BufferingObserver(1,2);this.bufferObserver_.setState(shaka.media.BufferingObserver.State.STARVING);this.updateBufferingSettings_();this.updateBufferState_();this.bufferPoller_=
new shaka.util.Timer(function(){c.pollBufferState_()});this.config_.streaming.rebufferingGoal&&this.bufferPoller_.tickEvery(.25);this.loadEventManager_.listen(a,d.WAITING,function(e){return c.pollBufferState_(d.WAITING)});this.loadEventManager_.listen(a,d.CAN_PLAY_THROUGH,function(e){return c.pollBufferState_(d.CAN_PLAY_THROUGH)});this.loadEventManager_.listen(a,d.PLAYING,function(e){return c.pollBufferState_(d.PLAYING)});this.loadEventManager_.listen(a,d.SEEKED,function(e){return c.pollBufferState_(d.SEEKED)});
this.loadEventManager_.listen(a,d.TIME_UPDATE,function(e){return c.pollBufferState_(d.TIME_UPDATE)});b&&(this.loadEventManager_.listen(a,d.PROGRESS,function(e){return c.pollBufferState_(d.PROGRESS)}),this.loadEventManager_.listen(a,d.STALLED,function(e){return c.pollBufferState_(d.STALLED)}))};shaka.Player.prototype.updateBufferingSettings_=function(){var a=this.config_.streaming.rebufferingGoal;this.bufferObserver_.setThresholds(a,Math.min(shaka.Player.TYPICAL_BUFFERING_THRESHOLD_,a/2))};
shaka.Player.prototype.pollBufferState_=function(a){goog.asserts.assert(this.video_,"Need a media element to update the buffering observer");goog.asserts.assert(this.bufferObserver_,"Need a buffering observer to update");if(this.config_.streaming.rebufferingGoal){a=this.mediaSourceEngine_?this.mediaSourceEngine_.ended():!1;a=this.isEnded()||a||this.playhead_.isBufferedToEnd();var b=shaka.media.TimeRangesUtils.bufferedAheadOf(this.video_.buffered,this.video_.currentTime);this.bufferObserver_.update(b,
a)&&this.updateBufferState_()}else a&&this.bufferObserver_.reportEvent(a,this.video_.currentTime)&&this.updateBufferState_()};shaka.Player.prototype.createMediaSourceEngine=function(a,b,c,d,e){return new shaka.media.MediaSourceEngine(a,b,c,e,d)};shaka.Player.prototype.createCmcd_=function(){return new shaka.util.CmcdManager(this,this.config_.cmcd)};shaka.Player.prototype.createCmsd_=function(){return new shaka.util.CmsdManager(this.config_.cmsd)};
shaka.Player.prototype.createStreamingEngine=function(){var a=this;goog.asserts.assert(this.abrManager_&&this.mediaSourceEngine_&&this.manifest_&&this.video_,"Must not be destroyed");return new shaka.media.StreamingEngine(this.manifest_,{getPresentationTime:function(){return a.playhead_?a.playhead_.getTime():0},getBandwidthEstimate:function(){return a.abrManager_.getBandwidthEstimate()},getPlaybackRate:function(){return a.getPlaybackRate()},video:this.video_,mediaSourceEngine:this.mediaSourceEngine_,
netEngine:this.networkingEngine_,onError:function(b){return a.onError_(b)},onEvent:function(b){return a.dispatchEvent(b)},onSegmentAppended:function(b,c,d,e){a.onSegmentAppended_(b.startTime,b.endTime,c.type,d,e);a.abrManager_&&c.fastSwitching&&b.isPartial()&&b.isLastPartial()&&a.abrManager_.trySuggestStreams()},onInitSegmentAppended:function(b,c){(c=c.getMediaQuality())&&a.qualityObserver_&&a.qualityObserver_.addMediaQualityChange(c,b)},beforeAppendSegment:function(b,c){return a.drmEngine_.parseInbandPssh(b,
c)},disableStream:function(b,c){return a.disableStream(b,c)},shouldPrefetchNextSegment:function(b,c){return a.config_.abr.enabled&&c.fastSwitching&&b.isPartial()&&b.isLastPartial()?!1:!0}})};
shaka.Player.prototype.configure=function(a,b){goog.asserts.assert(this.config_,"Config must not be null!");goog.asserts.assert(typeof a=="object"||arguments.length==2,"String configs should have values!");var c=this.getConfiguration();arguments.length==2&&typeof a=="string"&&(a=shaka.util.ConfigUtils.convertToConfigObject(a,b));goog.asserts.assert(typeof a=="object","Should be an object!");"preferredVariantRole"in a&&(shaka.Deprecate.deprecateFeature(5,"preferredVariantRole configuration","Please Use preferredAudioRole instead."),
a.preferredAudioRole=a.preferredVariantRole,delete a.preferredVariantRole);a.streaming&&"forceTransmuxTS"in a.streaming&&(shaka.Deprecate.deprecateFeature(5,"streaming.forceTransmuxTS configuration","Please Use mediaSource.forceTransmux instead."),a.mediaSource=a.mediaSource||{},a.mediaSource.mediaSource=a.streaming.forceTransmuxTS,delete a.streaming.forceTransmuxTS);a.streaming&&"forceTransmux"in a.streaming&&(shaka.Deprecate.deprecateFeature(5,"streaming.forceTransmux configuration","Please Use mediaSource.forceTransmux instead."),
a.mediaSource=a.mediaSource||{},a.mediaSource.mediaSource=a.streaming.forceTransmux,delete a.streaming.forceTransmux);if(a.streaming&&"useNativeHlsOnSafari"in a.streaming){shaka.Deprecate.deprecateFeature(5,"streaming.useNativeHlsOnSafari configuration","Please Use streaming.useNativeHlsForFairPlay or streaming.preferNativeHls instead.");var d=shaka.device.DeviceFactory.getDevice();a.streaming.preferNativeHls=a.streaming.useNativeHlsOnSafari&&d.getBrowserEngine()===shaka.device.IDevice.BrowserEngine.WEBKIT;
delete a.streaming.useNativeHlsOnSafari}a.streaming&&typeof a.streaming.liveSync=="boolean"&&(shaka.Deprecate.deprecateFeature(5,"streaming.liveSync","Please Use streaming.liveSync.enabled instead."),d=a.streaming.liveSync,a.streaming.liveSync={},a.streaming.liveSync.enabled=d);if(a.streaming&&!(a.streaming.liveSync&&"targetLatency"in a.streaming.liveSync)&&("liveSyncMinLatency"in a.streaming||"liveSyncMaxLatency"in a.streaming)){d=a.streaming.liveSyncMinLatency||0;var e=Math.abs((a.streaming.liveSyncMaxLatency||
1)-d)/2;a.streaming.liveSync=a.streaming.liveSync||{};a.streaming.liveSync.targetLatency=d+e;a.streaming.liveSync.targetLatencyTolerance=e}a.streaming&&"liveSyncMaxLatency"in a.streaming&&(shaka.Deprecate.deprecateFeature(5,"streaming.liveSyncMaxLatency","Please Use streaming.liveSync.targetLatency and streaming.liveSync.targetLatencyTolerance instead. Or, set the values in your DASH manifest"),delete a.streaming.liveSyncMaxLatency);a.streaming&&"liveSyncMinLatency"in a.streaming&&(shaka.Deprecate.deprecateFeature(5,
"streaming.liveSyncMinLatency","Please Use streaming.liveSync.targetLatency and streaming.liveSync.targetLatencyTolerance instead. Or, set the values in your DASH manifest"),delete a.streaming.liveSyncMinLatency);a.streaming&&"liveSyncTargetLatency"in a.streaming&&(shaka.Deprecate.deprecateFeature(5,"streaming.liveSyncTargetLatency","Please Use streaming.liveSync.targetLatency instead."),a.streaming.liveSync=a.streaming.liveSync||{},a.streaming.liveSync.targetLatency=a.streaming.liveSyncTargetLatency,
delete a.streaming.liveSyncTargetLatency);a.streaming&&"liveSyncTargetLatencyTolerance"in a.streaming&&(shaka.Deprecate.deprecateFeature(5,"streaming.liveSyncTargetLatencyTolerance","Please Use streaming.liveSync.targetLatencyTolerance instead."),a.streaming.liveSync=a.streaming.liveSync||{},a.streaming.liveSync.targetLatencyTolerance=a.streaming.liveSyncTargetLatencyTolerance,delete a.streaming.liveSyncTargetLatencyTolerance);a.streaming&&"liveSyncPlaybackRate"in a.streaming&&(shaka.Deprecate.deprecateFeature(5,
"streaming.liveSyncPlaybackRate","Please Use streaming.liveSync.maxPlaybackRate instead."),a.streaming.liveSync=a.streaming.liveSync||{},a.streaming.liveSync.maxPlaybackRate=a.streaming.liveSyncPlaybackRate,delete a.streaming.liveSyncPlaybackRate);a.streaming&&"liveSyncMinPlaybackRate"in a.streaming&&(shaka.Deprecate.deprecateFeature(5,"streaming.liveSyncMinPlaybackRate","Please Use streaming.liveSync.minPlaybackRate instead."),a.streaming.liveSync=a.streaming.liveSync||{},a.streaming.liveSync.minPlaybackRate=
a.streaming.liveSyncMinPlaybackRate,delete a.streaming.liveSyncMinPlaybackRate);a.streaming&&"liveSyncPanicMode"in a.streaming&&(shaka.Deprecate.deprecateFeature(5,"streaming.liveSyncPanicMode","Please Use streaming.liveSync.panicMode instead."),a.streaming.liveSync=a.streaming.liveSync||{},a.streaming.liveSync.panicMode=a.streaming.liveSyncPanicMode,delete a.streaming.liveSyncPanicMode);a.streaming&&"liveSyncPanicThreshold"in a.streaming&&(shaka.Deprecate.deprecateFeature(5,"streaming.liveSyncPanicThreshold",
"Please Use streaming.liveSync.panicThreshold instead."),a.streaming.liveSync=a.streaming.liveSync||{},a.streaming.liveSync.panicThreshold=a.streaming.liveSyncPanicThreshold,delete a.streaming.liveSyncPanicThreshold);if(a.mediaSource&&"sourceBufferExtraFeatures"in a.mediaSource){shaka.Deprecate.deprecateFeature(5,"mediaSource.sourceBufferExtraFeatures configuration","Please Use mediaSource.addExtraFeaturesToSourceBuffer() instead.");var f=a.mediaSource.sourceBufferExtraFeatures;a.mediaSource.addExtraFeaturesToSourceBuffer=
function(){return f};delete a.mediaSource.sourceBufferExtraFeatures}a.manifest&&a.manifest.hls&&"useSafariBehaviorForLive"in a.manifest.hls&&(shaka.Deprecate.deprecateFeature(5,"manifest.hls.useSafariBehaviorForLive configuration","Please Use liveSync config to keep on live Edge instead."),delete a.manifest.hls.useSafariBehaviorForLive);a.streaming&&"parsePrftBox"in a.streaming&&(shaka.Deprecate.deprecateFeature(5,"streaming.parsePrftBox configuration","Now fired without needing a configuration."),
delete a.streaming.parsePrftBox);a.manifest&&a.manifest.dash&&"enableAudioGroups"in a.manifest.dash&&(shaka.Deprecate.deprecateFeature(5,"manifest.dash.enableAudioGroups configuration","Please Use manifest.enableAudioGroups instead."),a.manifest.enableAudioGroups=a.manifest.dash.enableAudioGroups,delete a.manifest.dash.enableAudioGroups);a.streaming&&"dispatchAllEmsgBoxes"in a.streaming&&(shaka.Deprecate.deprecateFeature(5,"streaming.dispatchAllEmsgBoxes configuration","Please Use mediaSource.dispatchAllEmsgBoxes instead."),
a.mediaSource=a.mediaSource||{},a.mediaSource.dispatchAllEmsgBoxes=a.streaming.dispatchAllEmsgBoxes,delete a.streaming.dispatchAllEmsgBoxes);a.streaming&&"autoLowLatencyMode"in a.streaming&&(shaka.Deprecate.deprecateFeature(5,"streaming.autoLowLatencyMode configuration","Please Use streaming.lowLatencyMode instead."),a.streaming.lowLatencyMode=a.streaming.autoLowLatencyMode,delete a.streaming.autoLowLatencyMode);a.manifest&&a.manifest.dash&&"ignoreSupplementalCodecs"in a.manifest.dash&&(shaka.Deprecate.deprecateFeature(5,
"manifest.dash.ignoreSupplementalCodecs configuration","Please Use manifest.ignoreSupplementalCodecs instead."),a.manifest.ignoreSupplementalCodecs=a.manifest.dash.ignoreSupplementalCodecs,delete a.manifest.dash.ignoreSupplementalCodecs);a.manifest&&a.manifest.hls&&"ignoreSupplementalCodecs"in a.manifest.hls&&(shaka.Deprecate.deprecateFeature(5,"manifest.hls.ignoreSupplementalCodecs configuration","Please Use manifest.ignoreSupplementalCodecs instead."),a.manifest.ignoreSupplementalCodecs=a.manifest.hls.ignoreSupplementalCodecs,
delete a.manifest.hls.ignoreSupplementalCodecs);a.manifest&&a.manifest.dash&&"updatePeriod"in a.manifest.dash&&(shaka.Deprecate.deprecateFeature(5,"manifest.dash.updatePeriod configuration","Please Use manifest.updatePeriod instead."),a.manifest.updatePeriod=a.manifest.dash.updatePeriod,delete a.manifest.dash.updatePeriod);a.manifest&&a.manifest.hls&&"updatePeriod"in a.manifest.hls&&(shaka.Deprecate.deprecateFeature(5,"manifest.hls.updatePeriod configuration","Please Use manifest.updatePeriod instead."),
a.manifest.updatePeriod=a.manifest.hls.updatePeriod,delete a.manifest.hls.updatePeriod);a.manifest&&a.manifest.dash&&"ignoreDrmInfo"in a.manifest.dash&&(shaka.Deprecate.deprecateFeature(5,"manifest.dash.ignoreDrmInfo configuration","Please Use manifest.ignoreDrmInfo instead."),a.manifest.ignoreDrmInfo=a.manifest.dash.ignoreDrmInfo,delete a.manifest.dash.ignoreDrmInfo);if(a.drm&&a.drm.advanced){d=!1;for(var g in a.drm.advanced){var h=a.drm.advanced[g];e=h.videoRobustness;h=h.audioRobustness;"videoRobustness"in
a.drm.advanced[g]&&!Array.isArray(a.drm.advanced[g].videoRobustness)&&(a.drm.advanced[g].videoRobustness=[e],d=!0);"audioRobustness"in a.drm.advanced[g]&&!Array.isArray(a.drm.advanced[g].audioRobustness)&&(a.drm.advanced[g].audioRobustness=[h],d=!0)}d&&shaka.Deprecate.deprecateFeature(5,"AdvancedDrmConfiguration's videoRobustness and audioRobustness","These properties are no longer strings but array of strings, please update your usage of these properties.")}a.streaming&&"forceHTTP"in a.streaming&&
(shaka.Deprecate.deprecateFeature(5,"streaming.forceHTTP configuration","Please Use networking.forceHTTP instead."),a.networking=a.networking||{},a.networking.forceHTTP=a.streaming.forceHTTP,delete a.streaming.forceHTTP);a.streaming&&"forceHTTPS"in a.streaming&&(shaka.Deprecate.deprecateFeature(5,"streaming.forceHTTPS configuration","Please Use networking.forceHTTP instead."),a.networking=a.networking||{},a.networking.forceHTTPS=a.streaming.forceHTTPS,delete a.streaming.forceHTTPS);a.streaming&&"minBytesForProgressEvents"in
a.streaming&&(shaka.Deprecate.deprecateFeature(5,"streaming.minBytesForProgressEvents configuration","Please Use networking.minBytesForProgressEvents instead."),a.networking=a.networking||{},a.networking.minBytesForProgressEvents=a.streaming.minBytesForProgressEvents,delete a.streaming.minBytesForProgressEvents);g=shaka.util.PlayerConfiguration.mergeConfigObjects(this.config_,a,this.defaultConfig_());this.applyConfig_(c);return g};
shaka.Player.prototype.configurationForLowLatency=function(a){this.lowLatencyConfig_=a};
shaka.Player.prototype.applyConfig_=function(a){this.manifestFilterer_=new shaka.media.ManifestFilterer(this.config_,this.maxHwRes_,this.drmEngine_);if(this.parser_){var b=shaka.util.ObjectUtils.cloneObject(this.config_.manifest);this.video_&&this.video_.nodeName==="AUDIO"&&(b.disableVideo=!0);this.parser_.configure(b)}this.drmEngine_&&this.drmEngine_.configure(this.config_.drm);if(this.streamingEngine_){this.streamingEngine_.configure(this.config_.streaming);try{if(this.loadMode_!=shaka.Player.LoadMode.DESTROYED&&
this.manifestFilterer_.filterManifestWithRestrictions(this.manifest_))this.onTracksChanged_()}catch(c){this.onError_(c)}this.abrManager_&&this.updateAbrManagerVariants_();!(b=this.streamingEngine_.getCurrentVariant())||b.allowedByApplication&&b.allowedByKeySystem||(shaka.log.debug("Choosing new variant after changing configuration"),this.chooseVariantAndSwitch_())}this.networkingEngine_&&this.networkingEngine_.configure(this.config_.networking);this.mediaSourceEngine_&&(this.mediaSourceEngine_.configure(this.config_.mediaSource),
this.mediaSourceEngine_.setSegmentRelativeVttTiming(this.config_.manifest.segmentRelativeVttTiming));this.textDisplayer_&&this.createAndConfigureTextDisplayer_();this.abrManager_&&(this.abrManager_.configure(this.config_.abr),this.config_.abr.enabled?this.abrManager_.enable():this.abrManager_.disable(),this.onAbrStatusChanged_());this.bufferObserver_&&this.updateBufferingSettings_();this.bufferPoller_&&(this.config_.streaming.rebufferingGoal?this.bufferPoller_.tickEvery(.25):this.bufferPoller_.stop());
this.manifest_&&shaka.Player.applyPlayRange_(this.manifest_.presentationTimeline,this.config_.playRangeStart,this.config_.playRangeEnd);this.adManager_&&this.adManager_.configure(this.config_.ads);this.cmcdManager_&&this.cmcdManager_.configure(this.config_.cmcd);this.cmsdManager_&&this.cmsdManager_.configure(this.config_.cmsd);this.queueManager_&&this.queueManager_.configure(this.config_.queue);this.applyCriteriaConfigChanges_(a)};
shaka.Player.prototype.applyCriteriaConfigChanges_=function(a){if(this.loadMode_==shaka.Player.LoadMode.MEDIA_SOURCE&&this.currentAdaptationSetCriteria_.getConfiguration){var b=this.currentAdaptationSetCriteria_.getConfiguration();goog.asserts.assert(b,"criteriaConfig must not be null!");var c=!1;a.preferredVideoHdrLevel!=this.config_.preferredVideoHdrLevel&&b.hdrLevel!=this.config_.preferredVideoHdrLevel&&(b.hdrLevel=this.config_.preferredVideoHdrLevel,c=!0);a.preferredVideoLayout!=this.config_.preferredVideoLayout&&
b.videoLayout!=this.config_.preferredVideoLayout&&(b.videoLayout=this.config_.preferredVideoLayout,c=!0);a.preferSpatialAudio!=this.config_.preferSpatialAudio&&b.spatialAudio!=this.config_.preferSpatialAudio&&(b.spatialAudio=this.config_.preferSpatialAudio,c=!0);a.preferredVideoRole!=this.config_.preferredVideoRole&&b.videoRole!=this.config_.preferredVideoRole&&(b.videoRole=this.config_.preferredVideoRole,c=!0);c&&(this.currentAdaptationSetCriteria_.configure(b),this.chooseVariantAndSwitch_())}};
shaka.Player.prototype.getConfiguration=function(){goog.asserts.assert(this.config_,"Config must not be null!");var a=this.defaultConfig_();shaka.util.PlayerConfiguration.mergeConfigObjects(a,this.config_,this.defaultConfig_());return a};shaka.Player.prototype.getConfigurationForLowLatency=function(){return this.lowLatencyConfig_};
shaka.Player.prototype.getNonDefaultConfiguration=function(){goog.asserts.assert(this.config_,"Config must not be null!");var a=this.defaultConfig_();shaka.util.PlayerConfiguration.mergeConfigObjects(a,this.config_,this.defaultConfig_());return shaka.util.ConfigUtils.getDifferenceFromConfigObjects(this.config_,this.defaultConfig_())};shaka.Player.prototype.getSharedConfiguration=function(){goog.asserts.assert(this.config_,"Cannot call getSharedConfiguration after call destroy!");return this.config_};
shaka.Player.prototype.getBufferFullness=function(){if(this.video_){var a=this.video_.buffered.length;a=a?this.video_.buffered.end(a-1):0;var b=Math.min(this.video_.currentTime+this.config_.streaming.bufferingGoal,this.seekRange().end);if(a>=b)return 1;if(!(a<=this.video_.currentTime)&&a<b)return(a-this.video_.currentTime)/(b-this.video_.currentTime)}return 0};
shaka.Player.prototype.resetConfiguration=function(){goog.asserts.assert(this.config_,"Cannot be destroyed");var a=this.getConfiguration(),b;for(b in this.config_)delete this.config_[b];shaka.util.PlayerConfiguration.mergeConfigObjects(this.config_,this.defaultConfig_(),this.defaultConfig_());this.applyConfig_(a)};shaka.Player.prototype.getLoadMode=function(){return this.loadMode_};shaka.Player.prototype.getManifestType=function(){return this.manifest_?this.manifest_.type:null};
shaka.Player.prototype.getMediaElement=function(){return this.video_};shaka.Player.prototype.getNetworkingEngine=function(){return this.networkingEngine_};shaka.Player.prototype.getAssetUri=function(){return this.assetUri_};shaka.Player.prototype.getAdManager=function(){return this.adManager_?this.adManager_:null};shaka.Player.prototype.getQueueManager=function(){return this.queueManager_?this.queueManager_:null};
shaka.Player.prototype.isLive=function(){return this.manifest_&&!this.isRemotePlayback()?this.manifest_.presentationTimeline.isLive():this.video_&&(this.video_.src||this.isRemotePlayback())?this.video_.duration==Infinity:!1};shaka.Player.prototype.isInProgress=function(){return this.manifest_?this.manifest_.presentationTimeline.isInProgress():!1};
shaka.Player.prototype.isAudioOnly=function(){if(this.manifest_&&!this.isRemotePlayback()){var a=this.manifest_.variants;return a.length?!a[0].video:!1}return this.video_&&(this.video_.src||this.isRemotePlayback())?this.video_.videoTracks?this.video_.videoTracks.length==0:this.video_.videoHeight==0:!1};
shaka.Player.prototype.isVideoOnly=function(){if(this.manifest_&&!this.isRemotePlayback()){var a=this.manifest_.variants;if(!a.length)return!1;a=a[0];return a.audio||!a.video?!1:!a.video.codecs.includes(",")}return this.video_&&(this.video_.src||this.isRemotePlayback())&&this.video_.audioTracks?this.video_.audioTracks.length==0:!1};
shaka.Player.prototype.seekRange=function(){if(this.manifest_&&!this.isRemotePlayback()){if(!this.fullyLoaded_&&this.manifest_.type==shaka.media.ManifestParser.HLS)return{start:0,end:0};var a=this.manifest_.presentationTimeline;return{start:a.getSeekRangeStart(),end:a.getSeekRangeEnd()}}if(this.video_&&(this.video_.src||this.isRemotePlayback())&&(a=this.video_.seekable)&&a.length){var b=this.config_?this.config_.playRangeStart:0;b=Math.max(a.start(0),b);var c=this.config_?this.config_.playRangeEnd:
Infinity;a=Math.min(a.end(a.length-1),c);return{start:b,end:a}}return{start:0,end:0}};shaka.Player.prototype.goToLive=function(){this.isLive()?this.video_.currentTime=this.seekRange().end:shaka.log.warning("goToLive is for live streams!")};shaka.Player.prototype.isFullyLoaded=function(){return this.fullyLoaded_};shaka.Player.prototype.keySystem=function(){return shaka.drm.DrmUtils.keySystem(this.drmInfo())};
shaka.Player.prototype.drmInfo=function(){return this.drmEngine_?this.drmEngine_.getDrmInfo():null};shaka.Player.prototype.getDrmEngine=function(){return this.drmEngine_};shaka.Player.prototype.getExpiration=function(){return this.drmEngine_?this.drmEngine_.getExpiration():Infinity};shaka.Player.prototype.getActiveSessionsMetadata=function(){return this.drmEngine_?this.drmEngine_.getActiveSessionsMetadata():[]};
shaka.Player.prototype.getKeyStatuses=function(){return this.drmEngine_?this.drmEngine_.getKeyStatuses():{}};shaka.Player.prototype.isBuffering=function(){var a=shaka.media.BufferingObserver.State;return this.bufferObserver_?this.bufferObserver_.getState()==a.STARVING:!!this.assetUri_};shaka.Player.prototype.getPlaybackRate=function(){return this.video_?this.playRateController_?this.playRateController_.getRealRate():1:0};
shaka.Player.prototype.useTrickPlayTrackIfAvailable=function(a){this.loadMode_==shaka.Player.LoadMode.MEDIA_SOURCE&&this.streamingEngine_&&this.streamingEngine_.setTrickPlay(a)};
shaka.Player.prototype.trickPlay=function(a,b){b=b===void 0?!0:b;goog.asserts.assert(a!=0,"Should never set a trick play rate of 0!");if(a==0)shaka.log.alwaysWarn("A trick play rate of 0 is unsupported!");else{var c=this.video_.playbackRate,d=this.playRateController_.getRealRate();this.playRateController_.set(a);this.loadMode_==shaka.Player.LoadMode.MEDIA_SOURCE&&(this.abrManager_.playbackRateChanged(a),this.useTrickPlayTrackIfAvailable(b&&a!=1));this.setupTrickPlayEventListeners_(a);if(c===0&&this.video_.playbackRate===
0&&a!=d)this.onRateChange_()}};shaka.Player.prototype.cancelTrickPlay=function(){var a=this.playRateController_.getDefaultRate();this.loadMode_==shaka.Player.LoadMode.SRC_EQUALS&&this.playRateController_.set(a);this.loadMode_==shaka.Player.LoadMode.MEDIA_SOURCE&&(this.playRateController_.set(a),this.abrManager_.playbackRateChanged(a),this.useTrickPlayTrackIfAvailable(!1));this.trickPlayEventManager_.removeAll()};
shaka.Player.prototype.getVariantTracks=function(){if(this.manifest_&&!this.isRemotePlayback()){for(var a=this.streamingEngine_?this.streamingEngine_.getCurrentVariant():null,b=[],c=0,d=(0,$jscomp.makeIterator)(this.manifest_.variants),e=d.next();!e.done;e=d.next())if(e=e.value,shaka.util.StreamUtils.isPlayable(e)){var f=shaka.util.StreamUtils.variantToTrack(e);f.active=e==a;f.active||c==1||a==null||e.video!=a.video||e.audio!=a.audio||(f.active=!0);f.active&&c++;b.push(f)}goog.asserts.assert(c<=1,
"It should only have one active track");return b}if(this.video_&&this.video_.audioTracks){var g=this.getActiveHtml5VideoTrack_();a=Array.from(this.video_.audioTracks);return a.length?a.map(function(h){return shaka.util.StreamUtils.html5TrackToShakaTrack(h,g)}):g?[shaka.util.StreamUtils.html5TrackToShakaTrack(null,g)]:[]}return[]};
shaka.Player.prototype.getTextTracks=function(){if(this.manifest_){if(this.isRemotePlayback())return[];for(var a=this.streamingEngine_?this.streamingEngine_.getCurrentTextStream():null,b=[],c=(0,$jscomp.makeIterator)(this.manifest_.textStreams),d=c.next();!d.done;d=c.next()){d=d.value;var e=shaka.util.StreamUtils.textStreamToTrack(d);e.active=d==a;b.push(e)}return b}if(this.video_&&this.video_.src&&this.video_.textTracks){a=this.getFilteredTextTracks_();var f=shaka.util.StreamUtils;return a.map(function(g){return f.html5TextTrackToTrack(g)})}return[]};
shaka.Player.prototype.getImageTracks=function(){var a=shaka.util.StreamUtils,b=this.externalSrcEqualsThumbnailsStreams_;this.manifest_&&(b=this.manifest_.imageStreams);return b.map(function(c){return a.imageStreamToTrack(c)})};
shaka.Player.prototype.getAllThumbnails=function(a){var b=this,c,d;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(e){if(e.getNextAddressJsc()==1)return e.yield(b.getBestImageStream_(a),2);c=e.getYieldResultJsc();if(!c)return e.return(null);d=[];c.segmentIndex.forEachTopLevelReference(function(f){var g=b.parseTilesLayout_(f.getTilesLayout()||c.tilesLayout);if(g)for(var h=g.rows*g.columns,k=(f.trueEndTime-f.startTime)/h,l=0;l<h;l++){var m=b.getThumbnailByReference_(f,c,f.startTime+l*
k,g);if(!m)break;d.push(m)}});return e.return(d)})};shaka.Player.prototype.parseTilesLayout_=function(a){if(!a)return null;var b=/(\d+)x(\d+)/.exec(a);if(!b)return shaka.log.warning("Tiles layout does not contain a valid format  (columns x rows)"),null;a=parseInt(b[1],10);b=parseInt(b[2],10);return{columns:a,rows:b}};
shaka.Player.prototype.getThumbnails=function(a,b){var c=this,d,e,f,g;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(h){if(h.getNextAddressJsc()==1)return h.yield(c.getBestImageStream_(a),2);d=h.getYieldResultJsc();if(!d)return h.return(null);e=d.segmentIndex.find(b);if(e==null)return h.return(null);f=d.segmentIndex.get(e);return(g=c.parseTilesLayout_(f.getTilesLayout()||d.tilesLayout))?h.return(c.getThumbnailByReference_(f,d,b,g)):h.return(null)})};
shaka.Player.prototype.getBestImageStream_=function(a){var b=this,c,d,e;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(f){if(f.getNextAddressJsc()==1){if(b.loadMode_!=shaka.Player.LoadMode.MEDIA_SOURCE&&b.loadMode_!=shaka.Player.LoadMode.SRC_EQUALS)return f.return(null);c=b.externalSrcEqualsThumbnailsStreams_;b.manifest_&&(c=b.manifest_.imageStreams);d=c[0];if(!d)return f.return(null);a!=null&&(d=c.find(function(g){return g.id==a}));return d?d.segmentIndex?f.jumpTo(2):f.yield(d.createSegmentIndex(),
2):f.return(null)}d.closeSegmentIndex&&(b.deferredCloseSegmentIndex_.has(d)||(e=new shaka.util.Timer(function(){d&&(d.closeSegmentIndex(),b.deferredCloseSegmentIndex_.delete(d))}),b.deferredCloseSegmentIndex_.set(d,e)),b.deferredCloseSegmentIndex_.get(d).tickAfter(5));return f.return(d)})};
shaka.Player.prototype.getThumbnailByReference_=function(a,b,c,d){var e=shaka.util.NumberUtils,f=b.width||0,g=b.height||0,h=f/d.columns,k=g/d.rows,l=d.columns*d.rows,m=a.trueEndTime-a.startTime;m=a.getTileDuration()||m/l;var n=a.startTime,p=0,q=0;l>1&&(q=Math.floor((c-a.startTime)/m+1E-4),n=a.startTime+q*m,p=q%d.columns*h,q=Math.floor(q/d.columns)*k);if(n>=a.endTime||e.isFloatEqual(n,a.endTime,1E-4))return null;d=!1;if(e=a.getThumbnailSprite())d=!0,k=e.height,p=e.positionX,q=e.positionY,h=e.width;
return{segment:a,imageHeight:g,imageWidth:f,height:k,positionX:p,positionY:q,startTime:n,duration:m,uris:a.getUris(),startByte:a.getStartByte(),endByte:a.getEndByte(),width:h,sprite:d,mimeType:a.mimeType||b.mimeType,codecs:a.codecs||b.codecs}};
shaka.Player.prototype.selectTextTrack=function(a){var b=this,c=function(){var d=b.manifest_.textStreams.find(function(e){return e.id==a.id});d?d==b.streamingEngine_.getCurrentTextStream()?shaka.log.debug("Text track already selected."):(b.addTextStreamToSwitchHistory_(d,!1),b.streamingEngine_.switchTextStream(d),b.onTextChanged_(),b.setTextDisplayerLanguage_(),b.currentTextLanguage_=d.language):b.isRemotePlayback()||shaka.log.error("No stream with id",a.id)};if(this.manifest_&&this.playhead_&&(c(),
!this.isRemotePlayback()))return;(function(){if(b.video_&&b.video_.textTracks){var d=b.getFilteredTextTracks_(),e=d.find(function(h){return shaka.util.StreamUtils.html5TrackId(h)===a.id});if(e){if(b.textDisplayer_ instanceof shaka.text.NativeTextDisplayer){d=(0,$jscomp.makeIterator)(d);for(var f=d.next();!f.done;f=d.next()){f=f.value;var g=f===e?b.isTextVisible_?"showing":"hidden":"disabled";f.mode!==g&&(f.mode=g)}}else d=d.find(function(h){return h.mode!=="disabled"}),d!==e&&(d&&(d.mode="disabled",
b.loadEventManager_.unlisten(d,"cuechange"),b.textDisplayer_.remove(0,Infinity)),e&&b.enableNativeTrack_(e));b.onTextChanged_();b.setTextDisplayerLanguage_()}else shaka.log.error("No track with id",a.id)}})()};
shaka.Player.prototype.enableNativeTrack_=function(a){var b=this;this.loadEventManager_.listen(a,"cuechange",function(){b.textDisplayer_.remove(0,Math.max(0,b.video_.currentTime-b.config_.streaming.bufferBehind));var c={periodStart:0,segmentStart:0,segmentEnd:b.video_.duration,vttOffset:0},d=[],e=Array.from(a.activeCues||[]);e=(0,$jscomp.makeIterator)(e);for(var f=e.next();!f.done;f=e.next())if(f=shaka.text.Utils.mapNativeCueToShakaCue(f.value)){var g=b.config_.mediaSource.modifyCueCallback;g&&g(f,
null,c);d.push(f)}b.textDisplayer_.append(d)});a.mode=document.pictureInPictureElement?"showing":"hidden"};
shaka.Player.prototype.selectVariantTrack=function(a,b,c){var d=this;b=b===void 0?!1:b;c=c===void 0?0:c;var e=function(){var f=d.manifest_.variants.find(function(h){return h.id==a.id});if(f)if(shaka.util.StreamUtils.isPlayable(f)){var g=d.streamingEngine_.getCurrentVariant();d.config_.abr.enabled&&(g.video!=f.video||g.audio&&f.audio&&g.audio.language==f.audio.language&&g.audio.channelsCount==f.audio.channelsCount&&g.audio.label==f.audio.label)&&shaka.log.alwaysWarn("Changing tracks while abr manager is enabled will likely result in the selected track being overridden. Consider disabling abr before calling selectVariantTrack().");
d.isRemotePlayback()?d.switchVariant_(f,!1,!1,0):d.switchVariant_(f,!1,b||!1,c||0);d.currentAdaptationSetCriteria_.configure({language:f.language,role:f.audio&&f.audio.roles&&f.audio.roles[0]||"",videoRole:f.video&&f.video.roles&&f.video.roles[0]||"",channelCount:f.audio&&f.audio.channelsCount?f.audio.channelsCount:0,hdrLevel:f.video&&f.video.hdr?f.video.hdr:"",spatialAudio:f.audio&&f.audio.spatialAudio?f.audio.spatialAudio:!1,videoLayout:f.video&&f.video.videoLayout?f.video.videoLayout:"",audioLabel:f.audio&&
f.audio.label?f.audio.label:"",videoLabel:f.video&&f.video.label?f.video.label:"",codecSwitchingStrategy:d.config_.mediaSource.codecSwitchingStrategy,audioCodec:f.audio&&f.audio.codecs?f.audio.codecs:"",activeAudioCodec:g.audio&&g.audio.codecs?g.audio.codecs:"",activeAudioChannelCount:g.audio&&g.audio.channelsCount?g.audio.channelsCount:0,preferredAudioCodecs:d.config_.preferredAudioCodecs,preferredAudioChannelCount:d.config_.preferredAudioChannelCount});d.updateAbrManagerVariants_()}else shaka.log.error("Unable to switch to restricted track",
a.id);else d.isRemotePlayback()||shaka.log.error("No variant with id",a.id)};if(this.manifest_&&this.playhead_&&(e(),!this.isRemotePlayback()))return;(function(){if(a.originalAudioId&&d.video_&&d.video_.audioTracks){var f=Array.from(d.video_.audioTracks);f=(0,$jscomp.makeIterator)(f);for(var g=f.next();!g.done;g=f.next())if(g=g.value,shaka.util.StreamUtils.html5TrackId(g)==a.id){d.switchHtml5Track_(g);break}}})()};
shaka.Player.prototype.selectAudioTrack=function(a,b){var c=this;b=b===void 0?0:b;var d=function(){var e=c.currentAdaptationSetCriteria_.getConfiguration();e.audioCodec=a.codecs||"";e.audioLabel=a.label||"";e.channelCount=a.channelsCount||0;e.language=a.language;e.role=a.roles[0]||"";e.spatialAudio=a.spatialAudio;var f=c.streamingEngine_.getCurrentVariant();if(f=f&&f.audio)e.activeAudioCodec=f.codecs||"",e.activeAudioChannelCount=f.channelsCount||0;c.currentAdaptationSetCriteria_.configure(e);c.chooseVariantAndSwitch_(!0,
b,!1,!1)};if(this.manifest_&&this.playhead_&&(d(),!this.isRemotePlayback()))return;(function(){if(c.video_&&c.video_.audioTracks){var e=shaka.util.LanguageUtils,f=e.normalize(a.language),g=Array.from(c.video_.audioTracks),h=null;g=(0,$jscomp.makeIterator)(g);for(var k=g.next();!k.done;k=g.next()){k=k.value;var l=k.language||"und";if(k.label==a.label&&e.normalize(l)==f&&k.kind==a.roles[0]){h=k;break}}h&&c.switchHtml5Track_(h)}})()};
shaka.Player.prototype.getAudioTracks=function(){if(this.manifest_&&!this.isRemotePlayback()){var a=this.getVariantTracks();if(!a.length)return[];var b=a.find(function(f){return f.active});if(!b)return[];var c=a;this.loadMode_!=shaka.Player.LoadMode.MEDIA_SOURCE||this.isRemotePlayback()||(c=a.filter(function(f){return f.originalVideoId===b.originalVideoId&&(f.audioCodec||shaka.util.MimeUtils.RAW_FORMATS.includes(f.audioMimeType||""))}));if(!c.length)return[];a=new Map;c=(0,$jscomp.makeIterator)(c);
for(var d=c.next();!d.done;d=c.next()){var e=d.value;d=[e.language,e.originalLanguage,e.label||"",(e.audioRoles||[]).join(","),e.channelsCount,e.spatialAudio,e.audioCodec||"",e.accessibilityPurpose||""].join("_");e={active:e.active,language:e.language,label:e.label,mimeType:e.audioMimeType,codecs:e.audioCodec,primary:e.primary,roles:e.audioRoles||[],accessibilityPurpose:e.accessibilityPurpose,channelsCount:e.channelsCount,audioSamplingRate:e.audioSamplingRate,spatialAudio:e.spatialAudio,originalLanguage:e.originalLanguage};
a.has(d)?!a.get(d).active&&e.active&&a.set(d,e):a.set(d,e)}return Array.from(a.values())}return this.video_&&this.video_.audioTracks?Array.from(this.video_.audioTracks).map(function(f){return shaka.util.StreamUtils.html5AudioTrackToTrack(f)}):[]};
shaka.Player.prototype.selectVideoTrack=function(a,b,c){b=b===void 0?!1:b;c=c===void 0?0:c;var d=shaka.util.ArrayUtils,e=shaka.util.MimeUtils,f=this.getVariantTracks();if(f.length){var g=f.find(function(k){return k.active});if(g){f=f.filter(function(k){return(k.videoBandwidth||k.bandwidth)==a.bandwidth&&k.width==a.width&&k.height==a.height&&k.frameRate==a.frameRate&&k.pixelAspectRatio==a.pixelAspectRatio&&k.hdr==a.hdr&&k.colorGamut==a.colorGamut&&k.videoLayout==a.videoLayout&&k.videoMimeType==a.mimeType&&
k.videoCodec==a.codecs&&d.equal(k.videoRoles,a.roles)&&k.videoLabel==a.label});var h;(h=f.length==1?f[0]:f.find(function(k){return k.audioId===g.audioId}))||(h=f.find(function(k){return k.language==g.language&&k.label===g.label&&k.channelsCount===g.channelsCount&&k.spatialAudio===g.spatialAudio&&k.audioMimeType===g.audioMimeType&&e.getNormalizedCodec(k.audioCodec||"")===e.getNormalizedCodec(g.audioCodec||"")&&d.equal(k.audioRoles,g.audioRoles)}));h&&!h.active&&this.selectVariantTrack(h,b,c)}}};
shaka.Player.prototype.getVideoTracks=function(){if(this.loadMode_==shaka.Player.LoadMode.SRC_EQUALS||this.isRemotePlayback())return[];var a=this.getVariantTracks();if(!a.length)return[];var b=a.find(function(f){return f.active});if(!b)return[];var c=a;this.isVideoOnly()||(c=a.filter(function(f){var g=shaka.util.ArrayUtils,h=shaka.util.MimeUtils;return f.videoCodec&&f.audioGroupId===b.audioGroupId&&f.originalAudioId===b.originalAudioId?f.audioId===b.audioId?!0:f.language===b.language&&f.label===b.label&&
f.channelsCount===b.channelsCount&&f.spatialAudio===b.spatialAudio&&f.audioMimeType===b.audioMimeType&&h.getNormalizedCodec(f.audioCodec||"")===h.getNormalizedCodec(b.audioCodec||"")&&g.equal(f.audioRoles,b.audioRoles):!1}));if(!c.length)return[];a=new Map;c=(0,$jscomp.makeIterator)(c);for(var d=c.next();!d.done;d=c.next()){d=d.value;var e=d.originalVideoId;e||d.videoId==null||(e=String(d.videoId));e&&a.set(e,{active:d.active,bandwidth:d.videoBandwidth||d.bandwidth,width:d.width,height:d.height,frameRate:d.frameRate,
pixelAspectRatio:d.pixelAspectRatio,hdr:d.hdr,colorGamut:d.colorGamut,videoLayout:d.videoLayout,mimeType:d.videoMimeType,codecs:d.videoCodec,roles:d.videoRoles||[],label:d.videoLabel})}return Array.from(a.values())};shaka.Player.prototype.getAudioLanguagesAndRoles=function(){return shaka.Player.getLanguageAndRolesFrom_(this.getVariantTracks())};shaka.Player.prototype.getTextLanguagesAndRoles=function(){return shaka.Player.getLanguageAndRolesFrom_(this.getTextTracks())};
shaka.Player.prototype.getAudioLanguages=function(){return Array.from(shaka.Player.getLanguagesFrom_(this.getVariantTracks()))};shaka.Player.prototype.getTextLanguages=function(){return Array.from(shaka.Player.getLanguagesFrom_(this.getTextTracks()))};
shaka.Player.prototype.selectAudioLanguage=function(a,b,c,d,e,f,g){var h=this;c=c===void 0?0:c;d=d===void 0?0:d;e=e===void 0?"":e;f=f===void 0?!1:f;g=g===void 0?"":g;var k=function(){var l=h.streamingEngine_.getCurrentVariant();h.currentAdaptationSetCriteria_=h.config_.adaptationSetCriteriaFactory();h.currentAdaptationSetCriteria_.configure({language:a,role:b||"",videoRole:l.video&&l.video.roles&&l.video.roles[0]||"",channelCount:c||0,hdrLevel:"",spatialAudio:f||!1,videoLayout:"",audioLabel:g||"",
videoLabel:"",codecSwitchingStrategy:h.config_.mediaSource.codecSwitchingStrategy,audioCodec:e||"",activeAudioCodec:l.audio&&l.audio.codecs?l.audio.codecs:"",activeAudioChannelCount:l.audio&&l.audio.channelsCount?l.audio.channelsCount:0,preferredAudioCodecs:h.config_.preferredAudioCodecs,preferredAudioChannelCount:h.config_.preferredAudioChannelCount});var m=function(r,t){return r.video||t.video?r.video&&t.video?Math.abs((r.video.height||0)-(t.video.height||0))+Math.abs((r.video.width||0)-(t.video.width||
0)):Infinity:0},n=h.currentAdaptationSetCriteria_.create(h.manifest_.variants),p=null;n=(0,$jscomp.makeIterator)(n.values());for(var q=n.next();!q.done;q=n.next())q=q.value,shaka.util.StreamUtils.isPlayable(q)&&(!p||m(p,l)>m(q,l))&&(p=q);p==l?shaka.log.debug("Audio already selected."):p?(l=shaka.util.StreamUtils.variantToTrack(p),h.selectVariantTrack(l,!0,d||0)):h.chooseVariantAndSwitch_()};if(this.manifest_&&this.playhead_&&(k(),!this.isRemotePlayback()))return;(function(){if(h.video_&&h.video_.audioTracks){var l=
shaka.util.StreamUtils.filterStreamsByLanguageAndRole(h.getVariantTracks(),a,b||"",!1)[0];l&&h.selectVariantTrack(l)}})()};
shaka.Player.prototype.selectTextLanguage=function(a,b,c){var d=this;c=c===void 0?!1:c;var e=function(){d.currentTextLanguage_=a;d.currentTextRole_=b||"";d.currentTextForced_=c||!1;var f=d.chooseTextStream_();f&&(f==d.streamingEngine_.getCurrentTextStream()?shaka.log.debug("Text track already selected."):(d.addTextStreamToSwitchHistory_(f,!1),d.shouldStreamText_()&&(d.streamingEngine_.switchTextStream(f),d.onTextChanged_(),d.setTextDisplayerLanguage_())))};if(this.manifest_&&this.playhead_&&(e(),
!this.isRemotePlayback()))return;(function(){var f=shaka.util.StreamUtils.filterStreamsByLanguageAndRole(d.getTextTracks(),a,b||"",c||!1)[0];f&&d.selectTextTrack(f)})()};
shaka.Player.prototype.selectVariantsByLabel=function(a,b,c){var d=this;b=b===void 0?!0:b;c=c===void 0?0:c;var e=function(){for(var f=null,g=(0,$jscomp.makeIterator)(d.manifest_.variants),h=g.next();!h.done;h=g.next())if(h=h.value,h.audio.label==a){f=h;break}f==null?shaka.log.warning("No variants were found with label: "+a+". Ignoring the request to switch."):(d.currentAdaptationSetCriteria_=d.config_.adaptationSetCriteriaFactory(),d.currentAdaptationSetCriteria_.configure({language:f.language,role:"",
videoRole:"",channelCount:0,hdrLevel:"",spatialAudio:!1,videoLayout:"",videoLabel:"",audioLabel:a,codecSwitchingStrategy:d.config_.mediaSource.codecSwitchingStrategy,audioCodec:"",activeAudioCodec:"",activeAudioChannelCount:0,preferredAudioCodecs:d.config_.preferredAudioCodecs,preferredAudioChannelCount:d.config_.preferredAudioChannelCount}),d.chooseVariantAndSwitch_(b,c))};if(this.manifest_&&this.playhead_&&(e(),!this.isRemotePlayback()))return;(function(){if(d.video_&&d.video_.audioTracks){var f=
Array.from(d.video_.audioTracks),g=null;f=(0,$jscomp.makeIterator)(f);for(var h=f.next();!h.done;h=f.next())h=h.value,h.label==a&&(g=h);g&&d.switchHtml5Track_(g)}})()};shaka.Player.prototype.isTextTrackVisible=function(){var a=this.isTextVisible_;if(this.textDisplayer_){var b=this.textDisplayer_.isTextVisible();goog.asserts.assert(b==a,"text visibility has fallen out of sync");return b}return a};shaka.Player.prototype.getChaptersTracks=function(){return this.externalChaptersStreams_.map(function(a){return shaka.util.StreamUtils.textStreamToTrack(a)})};
shaka.Player.prototype.getChapters=function(a){shaka.Deprecate.deprecateFeature(5,"getChapters","Please use an getChaptersAsync.");if(!this.externalChaptersStreams_.length)return[];var b=shaka.util.LanguageUtils,c=b.normalize(a);a=this.externalChaptersStreams_.filter(function(g){return b.normalize(g.language)==c});if(!a.length)return[];var d=[],e=new Set;a=(0,$jscomp.makeIterator)(a);for(var f=a.next();!f.done;f=a.next())f=f.value,f.segmentIndex&&f.segmentIndex.forEachTopLevelReference(function(g){var h=
g.getUris()[0],k=g.startTime+"-"+g.endTime+"-"+h;g={id:k,title:h,startTime:g.startTime,endTime:g.endTime};e.has(k)||(d.push(g),e.add(k))});return d};
shaka.Player.prototype.getChaptersAsync=function(a){var b=this,c,d,e,f,g,h,k,l;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(m){switch(m.getNextAddressJsc()){case 1:if(!b.externalChaptersStreams_.length)return m.return([]);c=shaka.util.LanguageUtils;d=c.normalize(a);e=b.externalChaptersStreams_.filter(function(n){return c.normalize(n.language)==d});if(!e.length)return m.return([]);f=[];g=new Set;h=(0,$jscomp.makeIterator)(e);k=h.next();case 2:if(k.done){m.jumpTo(4);break}l=k.value;
if(l.segmentIndex){m.jumpTo(5);break}return m.yield(l.createSegmentIndex(),5);case 5:l.segmentIndex.forEachTopLevelReference(function(n){var p=n.getUris()[0],q=n.startTime+"-"+n.endTime+"-"+p;n={id:q,title:p,startTime:n.startTime,endTime:n.endTime};g.has(q)||(f.push(n),g.add(q))});k=h.next();m.jumpTo(2);break;case 4:return m.return(f)}})};
shaka.Player.prototype.getFilteredTextTracks_=function(){goog.asserts.assert(this.video_.textTracks,"TextTracks should be valid.");return Array.from(this.video_.textTracks).filter(function(a){return a.kind!="metadata"&&a.kind!="chapters"&&a.label!=shaka.Player.TextTrackLabel})};shaka.Player.prototype.getGeneratedTextTrack_=function(){goog.asserts.assert(this.video_.textTracks,"TextTracks should be valid.");return Array.from(this.video_.textTracks).find(function(a){return a.label==shaka.Player.TextTrackLabel})};
shaka.Player.prototype.getMetadataTracks_=function(){goog.asserts.assert(this.video_.textTracks,"TextTracks should be valid.");return Array.from(this.video_.textTracks).filter(function(a){return a.kind=="metadata"})};
shaka.Player.prototype.setTextTrackVisibility=function(a){a=!!a;this.isTextVisible_!=a&&(this.isTextVisible_=a,this.loadMode_==shaka.Player.LoadMode.MEDIA_SOURCE?(this.textDisplayer_.setTextVisibility(a),this.config_.streaming.alwaysStreamText||(a?this.streamingEngine_.getCurrentTextStream()||(a=shaka.util.StreamUtils.filterStreamsByLanguageAndRole(this.manifest_.textStreams,this.currentTextLanguage_,this.currentTextRole_,this.currentTextForced_),a.length>0&&(this.streamingEngine_.switchTextStream(a[0]),
this.onTextChanged_(),this.setTextDisplayerLanguage_())):this.streamingEngine_.unloadTextStream())):this.video_&&this.video_.src&&this.video_.textTracks&&this.textDisplayer_.setTextVisibility(a),this.onTextTrackVisibility_())};
shaka.Player.prototype.getPlayheadTimeAsDate=function(){if(this.playhead_)var a=this.playhead_.getTime();else{if(this.startTime_==null)return new Date;if(this.startTime_ instanceof Date)return this.startTime_;a=this.startTime_}if(this.manifest_&&!this.isRemotePlayback()){var b=this.manifest_.presentationTimeline;b=b.getInitialProgramDateTime()||b.getPresentationStartTime();return new Date((b+a)*1E3)}if(this.video_&&this.video_.getStartDate)return b=this.video_.getStartDate(),b instanceof Date&&!isNaN(b.getTime())?
new Date(b.getTime()+a*1E3):(shaka.log.warning("EXT-X-PROGRAM-DATETIME required to get playhead time as Date!"),null);shaka.log.warning("No way to get playhead time as Date!");return null};
shaka.Player.prototype.getPresentationStartTimeAsDate=function(){if(this.manifest_&&!this.isRemotePlayback()){var a=this.manifest_.presentationTimeline;a=a.getInitialProgramDateTime()||a.getPresentationStartTime();return a===null?(shaka.log.info("Manifest appears to have no PDT or PST"),null):new Date(a*1E3)}if(this.video_&&this.video_.getStartDate)return a=this.video_.getStartDate(),a instanceof Date&&!isNaN(a.getTime())?a:(shaka.log.warning("EXT-X-PROGRAM-DATETIME required to get presentation start time as Date!"),
null);shaka.log.warning("No way to get presentation start time as Date!");return null};shaka.Player.prototype.getSegmentAvailabilityDuration=function(){if(!this.isLive())return shaka.log.warning("getSegmentAvailabilityDuration is for live streams!"),null;if(this.manifest_)return this.manifest_.presentationTimeline.getSegmentAvailabilityDuration();shaka.log.warning("No way to get segment segment availability duration!");return null};
shaka.Player.prototype.getBufferedInfo=function(){if(this.loadMode_==shaka.Player.LoadMode.MEDIA_SOURCE)return this.mediaSourceEngine_.getBufferedInfo();var a={total:[],audio:[],video:[],text:[]};this.loadMode_==shaka.Player.LoadMode.SRC_EQUALS&&(a.total=shaka.media.TimeRangesUtils.getBufferedInfo(this.video_.buffered));return a};
shaka.Player.prototype.getLiveLatency=function(){if(!this.video_||!this.video_.currentTime)return null;var a=this.getPresentationStartTimeAsDate();if(!a)return null;a=a.getTime()+this.video_.currentTime*1E3;return Math.floor(Date.now()-a)};shaka.Player.prototype.getBandwidthEstimate=function(){return this.abrManager_?this.abrManager_.getBandwidthEstimate():NaN};
shaka.Player.prototype.getStats=function(){if(this.loadMode_!=shaka.Player.LoadMode.MEDIA_SOURCE&&this.loadMode_!=shaka.Player.LoadMode.SRC_EQUALS)return shaka.util.Stats.getEmptyBlob();this.updateStateHistory_();goog.asserts.assert(this.video_,"If we have stats, we should have video_");var a=this.video_,b=a.currentTime/a.duration;isNaN(b)||this.isLive()||this.stats_.setCompletionPercent(Math.round(100*b));this.playhead_&&(this.stats_.setGapsJumped(this.playhead_.getGapsJumped()),this.stats_.setStallsDetected(this.playhead_.getStallsDetected()));
a.getVideoPlaybackQuality&&(b=a.getVideoPlaybackQuality(),this.stats_.setDroppedFrames(Number(b.droppedVideoFrames),Number(b.totalVideoFrames)),this.stats_.setCorruptedFrames(Number(b.corruptedVideoFrames)));b=this.drmEngine_?this.drmEngine_.getLicenseTime():NaN;this.stats_.setLicenseTime(b);this.stats_.setResolution(a.videoWidth||NaN,a.videoHeight||NaN);this.stats_.setCodecs("");this.isLive()&&(a=this.getLiveLatency(),a!=null&&this.stats_.setLiveLatency(a/1E3));b=this.getVariantTracks().find(function(e){return e.active});
a=this.getTextTracks().find(function(e){return e.active});if(b){if(b.bandwidth){var c=this.playRateController_?this.playRateController_.getRealRate():1,d=c*b.bandwidth;a&&a.bandwidth&&(d+=c*a.bandwidth);this.stats_.setCurrentStreamBandwidth(d)}b.width&&b.height&&this.stats_.setResolution(b.width||NaN,b.height||NaN);b=b.codecs;a&&(b+=","+(a.codecs||a.mimeType));b&&this.stats_.setCodecs(b)}this.loadMode_!=shaka.Player.LoadMode.MEDIA_SOURCE||this.isRemotePlayback()||(this.manifest_&&(this.stats_.setManifestPeriodCount(this.manifest_.periodCount),
this.stats_.setManifestGapCount(this.manifest_.gapCount),this.manifest_.presentationTimeline&&(a=this.manifest_.presentationTimeline.getMaxSegmentDuration(),this.stats_.setMaxSegmentDuration(a))),a=this.abrManager_.getBandwidthEstimate(),this.stats_.setBandwidthEstimate(a));this.loadMode_==shaka.Player.LoadMode.SRC_EQUALS&&this.stats_.addBytesDownloaded(NaN);return this.stats_.getBlob()};
shaka.Player.prototype.addTextTrackAsync=function(a,b,c,d,e,f,g){g=g===void 0?!1:g;var h=this,k,l,m,n,p,q,r,t,u,v,w,x;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(y){switch(y.getNextAddressJsc()){case 1:if(h.loadMode_!=shaka.Player.LoadMode.MEDIA_SOURCE&&h.loadMode_!=shaka.Player.LoadMode.SRC_EQUALS)throw shaka.log.error("Must call load() and wait for it to resolve before adding text tracks."),new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.PLAYER,
shaka.util.Error.Code.CONTENT_NOT_LOADED);c!="subtitles"&&c!="captions"&&shaka.log.alwaysWarn("Using a kind value different of `subtitles` or `captions` can cause unwanted issues.");if(d){y.jumpTo(2);break}return y.yield(h.getTextMimetype_(a),3);case 3:d=y.getYieldResultJsc();case 2:k=[];h.adManager_&&(k=h.adManager_.getCuePoints());if(h.loadMode_!=shaka.Player.LoadMode.SRC_EQUALS){y.jumpTo(4);break}l=shaka.device.DeviceFactory.getDevice();g&&l.getBrowserEngine()===shaka.device.IDevice.BrowserEngine.WEBKIT&&
(c="forced");return y.yield(h.addSrcTrackElement_(a,b,c,d,f||"",k),5);case 5:m=y.getYieldResultJsc();if(m.track)return h.onTracksChanged_(),h.onTextChanged_(),y.return(shaka.util.StreamUtils.html5TextTrackToTrack(m.track));shaka.log.error("Cannot add this text when loaded with src=");throw new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.CANNOT_ADD_EXTERNAL_TEXT_TO_SRC_EQUALS);case 4:n=shaka.util.ManifestParserUtils.ContentType;p=h.seekRange();
q=p.end-p.start;h.manifest_&&(q=h.manifest_.presentationTimeline.getDuration());if(q==Infinity)throw new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.CANNOT_ADD_EXTERNAL_TEXT_TO_LIVE_STREAM);if(!k.length){y.jumpTo(6);break}return y.yield(h.getTextData_(a),7);case 7:r=y.getYieldResultJsc(),t=h.convertToWebVTT_(r,d,k),u=new Blob([t],{type:"text/vtt"}),a=shaka.media.MediaSourceEngine.createObjectURL(u),d="text/vtt";case 6:v={id:h.nextExternalStreamId_++,
originalId:null,groupId:null,createSegmentIndex:function(){return Promise.resolve()},segmentIndex:shaka.media.SegmentIndex.forSingleSegment(0,q,[a]),mimeType:d||"",codecs:e||"",kind:c,encrypted:!1,drmInfos:[],keyIds:new Set,language:b,originalLanguage:b,label:f||null,type:n.TEXT,primary:!1,trickModeVideo:null,dependencyStream:null,emsgSchemeIdUris:null,roles:[],forced:!!g,channelsCount:null,audioSamplingRate:null,spatialAudio:!1,closedCaptions:null,accessibilityPurpose:null,external:!0,fastSwitching:!1,
fullMimeTypes:new Set([shaka.util.MimeUtils.getFullType(d||"",e||"")]),isAudioMuxedInVideo:!1,baseOriginalId:null};w=shaka.util.MimeUtils.getFullType(v.mimeType,v.codecs);x=shaka.text.TextEngine.isTypeSupported(w);if(!x)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.MISSING_TEXT_PLUGIN,d);h.manifest_.textStreams.push(v);h.onTracksChanged_();h.onTextChanged_();return y.return(shaka.util.StreamUtils.textStreamToTrack(v))}})};
shaka.Player.prototype.addThumbnailsTrack=function(a,b){var c=this,d,e,f,g,h,k,l,m,n,p,q,r,t,u,v,w,x,y;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(C){switch(C.getNextAddressJsc()){case 1:if(c.loadMode_!=shaka.Player.LoadMode.MEDIA_SOURCE&&c.loadMode_!=shaka.Player.LoadMode.SRC_EQUALS)throw shaka.log.error("Must call load() and wait for it to resolve before adding image tracks."),new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.PLAYER,shaka.util.Error.Code.CONTENT_NOT_LOADED);
if(b){C.jumpTo(2);break}return C.yield(c.getTextMimetype_(a),3);case 3:b=C.getYieldResultJsc();case 2:if(b!="text/vtt")throw new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.UNSUPPORTED_EXTERNAL_THUMBNAILS_URI,a);d=shaka.util.ManifestParserUtils.ContentType;e=c.seekRange();f=e.end-e.start;c.manifest_&&(f=c.manifest_.presentationTimeline.getDuration());if(f==Infinity)throw new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.MANIFEST,
shaka.util.Error.Code.CANNOT_ADD_EXTERNAL_THUMBNAILS_TO_LIVE_STREAM);return C.yield(c.getTextData_(a),4);case 4:g=C.getYieldResultJsc();h=shaka.text.TextEngine.findParser(b);if(!h)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.MISSING_TEXT_PLUGIN,b);k=h();l={periodStart:0,segmentStart:0,segmentEnd:f,vttOffset:0};m=shaka.util.BufferUtils.toUint8(g);n=k.parseMedia(m,l,a,[]);p=[];q=(0,$jscomp.makeIterator)(n);r=q.next();for(t={};!r.done;t=
{uris$jscomp$21:void 0,cue$jscomp$44:void 0},r=q.next())t.cue$jscomp$44=r.value,t.uris$jscomp$21=null,u=function(D){return function(){D.uris$jscomp$21==null&&(D.uris$jscomp$21=shaka.util.ManifestParserUtils.resolveUris([a],[D.cue$jscomp$44.payload]));return D.uris$jscomp$21||[]}}(t),v=new shaka.media.SegmentReference(t.cue$jscomp$44.startTime,t.cue$jscomp$44.endTime,u,0,null,null,0,0,Infinity),t.cue$jscomp$44.payload.includes("#xywh")&&(w=t.cue$jscomp$44.payload.split("#xywh=")[1].split(","),w.length===
4&&v.setThumbnailSprite({height:parseInt(w[3],10),positionX:parseInt(w[0],10),positionY:parseInt(w[1],10),width:parseInt(w[2],10)})),p.push(v);x=b;if(!p.length){C.jumpTo(5);break}return C.yield(c.getTextMimetype_(p[0].getUris()[0]),6);case 6:x=C.getYieldResultJsc();case 5:return y={id:c.nextExternalStreamId_++,originalId:null,groupId:null,createSegmentIndex:function(){return Promise.resolve()},segmentIndex:new shaka.media.SegmentIndex(p),mimeType:x||"",codecs:"",kind:"",encrypted:!1,drmInfos:[],keyIds:new Set,
language:"und",originalLanguage:null,label:null,type:d.IMAGE,primary:!1,trickModeVideo:null,dependencyStream:null,emsgSchemeIdUris:null,roles:[],forced:!1,channelsCount:null,audioSamplingRate:null,spatialAudio:!1,closedCaptions:null,tilesLayout:"1x1",accessibilityPurpose:null,external:!0,fastSwitching:!1,fullMimeTypes:new Set([shaka.util.MimeUtils.getFullType(x||"","")]),isAudioMuxedInVideo:!1,baseOriginalId:null},c.loadMode_==shaka.Player.LoadMode.SRC_EQUALS?c.externalSrcEqualsThumbnailsStreams_.push(y):
c.manifest_.imageStreams.push(y),c.onTracksChanged_(),C.return(shaka.util.StreamUtils.imageStreamToTrack(y))}})};
shaka.Player.prototype.addChaptersTrack=function(a,b,c){var d=this,e,f,g,h,k,l,m,n,p,q,r,t,u,v,w;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(x){switch(x.getNextAddressJsc()){case 1:if(d.loadMode_!=shaka.Player.LoadMode.MEDIA_SOURCE&&d.loadMode_!=shaka.Player.LoadMode.SRC_EQUALS)throw shaka.log.error("Must call load() and wait for it to resolve before adding chapters tracks."),new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.PLAYER,shaka.util.Error.Code.CONTENT_NOT_LOADED);
if(c){x.jumpTo(2);break}return x.yield(d.getTextMimetype_(a),3);case 3:c=x.getYieldResultJsc();case 2:e=shaka.util.ManifestParserUtils.ContentType;f=d.seekRange();g=f.end-f.start;d.manifest_&&(g=d.manifest_.presentationTimeline.getDuration());if(g==Infinity)throw new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.MANIFEST,shaka.util.Error.Code.CANNOT_ADD_EXTERNAL_CHAPTERS_TO_LIVE_STREAM);h=shaka.text.TextEngine.findParser(c);if(!h)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.TEXT,shaka.util.Error.Code.MISSING_TEXT_PLUGIN,c);return x.yield(d.getTextData_(a),4);case 4:k=x.getYieldResultJsc();l=h();m={periodStart:0,segmentStart:0,segmentEnd:g,vttOffset:0};n=shaka.util.BufferUtils.toUint8(k);p=l.parseMedia(n,m,a,[]);q=[];r=(0,$jscomp.makeIterator)(p);t=r.next();for(u={};!t.done;u={cue$jscomp$45:void 0},t=r.next())u.cue$jscomp$45=t.value,v=new shaka.media.SegmentReference(u.cue$jscomp$45.startTime,u.cue$jscomp$45.endTime,function(y){return function(){return[y.cue$jscomp$45.payload]}}(u),
0,null,null,0,0,Infinity),q.push(v);w={id:d.nextExternalStreamId_++,originalId:null,groupId:null,createSegmentIndex:function(){return Promise.resolve()},segmentIndex:new shaka.media.SegmentIndex(q),mimeType:"text/plain",codecs:"",kind:"",encrypted:!1,drmInfos:[],keyIds:new Set,language:b,originalLanguage:b,label:null,type:e.TEXT,primary:!1,trickModeVideo:null,dependencyStream:null,emsgSchemeIdUris:null,roles:[],forced:!1,channelsCount:null,audioSamplingRate:null,spatialAudio:!1,closedCaptions:null,
accessibilityPurpose:null,external:!0,fastSwitching:!1,fullMimeTypes:new Set([shaka.util.MimeUtils.getFullType("text/plain","")]),isAudioMuxedInVideo:!1,baseOriginalId:null};d.externalChaptersStreams_.push(w);d.onTracksChanged_();return x.return(shaka.util.StreamUtils.textStreamToTrack(w))}})};
shaka.Player.prototype.getTextMimetype_=function(a){var b=this,c;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(d){switch(d.getNextAddressJsc()){case 1:return d.setCatchFinallyBlocks(2),goog.asserts.assert(b.networkingEngine_,"Need networking engine."),d.yield(shaka.net.NetworkingUtils.getMimeType(a,b.networkingEngine_,b.config_.streaming.retryParameters),4);case 4:c=d.getYieldResultJsc();d.leaveTryBlock(3);break;case 2:d.enterCatchBlock();case 3:if(c)return d.return(c);shaka.log.error("The mimeType has not been provided and it could not be deduced from its uri.");
throw new shaka.util.Error(shaka.util.Error.Severity.RECOVERABLE,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.TEXT_COULD_NOT_GUESS_MIME_TYPE,a);}})};
shaka.Player.prototype.addSrcTrackElement_=function(a,b,c,d,e,f){var g=this,h,k,l,m;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(n){if(n.getNextAddressJsc()==1)return d!="text/vtt"||f.length?n.yield(g.getTextData_(a),3):n.jumpTo(2);n.getNextAddressJsc()!=2&&(h=n.getYieldResultJsc(),k=g.convertToWebVTT_(h,d,f),l=new Blob([k],{type:"text/vtt"}),a=shaka.media.MediaSourceEngine.createObjectURL(l),d="text/vtt");m=document.createElement("track");m.src=g.cmcdManager_.appendTextTrackData(a);
m.label=e;m.kind=c;m.srclang=b;g.video_.getAttribute("crossorigin")||g.video_.setAttribute("crossorigin","anonymous");g.video_.appendChild(m);g.externalSrcEqualsTextTracks_.push(m);return n.return(m)})};
shaka.Player.prototype.getTextData_=function(a){var b=this,c,d,e,f;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(g){if(g.getNextAddressJsc()==1)return goog.asserts.assert(b.networkingEngine_,"Need networking engine."),c=shaka.net.NetworkingEngine.RequestType.SEGMENT,d=b.config_.streaming.retryParameters,e=shaka.net.NetworkingEngine.makeRequest([a],d),e.method="GET",b.cmcdManager_.applyTextData(e),g.yield(b.networkingEngine_.request(c,e).promise,2);f=g.getYieldResultJsc();return g.return(f.data)})};
shaka.Player.prototype.convertToWebVTT_=function(a,b,c){var d=shaka.text.TextEngine.findParser(b);if(d)return b=d(),d={periodStart:0,segmentStart:0,segmentEnd:this.video_.duration,vttOffset:0},a=shaka.util.BufferUtils.toUint8(a),a=b.parseMedia(a,d,null,[]),shaka.text.WebVttGenerator.convert(a,c);throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.MISSING_TEXT_PLUGIN,b);};
shaka.Player.prototype.setMaxHardwareResolution=function(a,b){this.maxHwRes_.width=a;this.maxHwRes_.height=b};shaka.Player.prototype.retryStreaming=function(a){return this.loadMode_==shaka.Player.LoadMode.MEDIA_SOURCE?this.streamingEngine_.retry(a===void 0?.1:a):!1};
shaka.Player.prototype.getManifest=function(){shaka.log.alwaysWarn("Shaka Player's internal Manifest structure is NOT covered by semantic versioning compatibility guarantees.  It may change at any time!  Please consider filing a feature request for whatever you use getManifest() for.");return this.manifest_};shaka.Player.prototype.getManifestParserFactory=function(){return this.parserFactory_};
shaka.Player.prototype.getFetchedPlaybackInfo=function(){var a={video:null,audio:null,text:null};if(this.loadMode_!=shaka.Player.LoadMode.MEDIA_SOURCE)return a;var b=shaka.util.ManifestParserUtils.ContentType,c=this.streamingEngine_.getCurrentVariant(),d=this.streamingEngine_.getCurrentTextStream(),e=this.video_.currentTime;c=(0,$jscomp.makeIterator)([c.video,c.audio,d]);for(d=c.next();!d.done;d=c.next())if((d=d.value)&&d.segmentIndex){var f=d.segmentIndex.find(e);f=d.segmentIndex.get(f);f={codecs:f.codecs||
d.codecs,mimeType:f.mimeType||d.mimeType,bandwidth:f.bandwidth||d.bandwidth};d.type==b.VIDEO?(f.width=d.width,f.height=d.height,a.video=f):d.type==b.AUDIO?a.audio=f:d.type==b.TEXT&&(a.text=f)}return a};shaka.Player.prototype.addVariantToSwitchHistory_=function(a,b){this.stats_.getSwitchHistory().updateCurrentVariant(a,b)};shaka.Player.prototype.addTextStreamToSwitchHistory_=function(a,b){this.stats_.getSwitchHistory().updateCurrentText(a,b)};
shaka.Player.prototype.defaultConfig_=function(){var a=this,b=shaka.util.PlayerConfiguration.createDefault();b.streaming.failureCallback=function(c){a.defaultStreamingFailureCallback_(c)};b.textDisplayFactory=function(){if(a.videoContainer_){var c=a.video_;c=c.webkitDisplayingFullscreen||c.webkitPresentationMode&&c.webkitPresentationMode!="inline"?!1:!0}else c=!1;if(c)return new shaka.text.UITextDisplayer(a.video_,a.videoContainer_);if("track"in document.createElement("track"))return new shaka.text.NativeTextDisplayer(a);
shaka.log.warning("Text tracks are not supported by the browser, disabling.");return new shaka.text.StubTextDisplayer};return b};shaka.Player.prototype.setVideoContainer=function(a){this.videoContainer_=a};
shaka.Player.prototype.defaultStreamingFailureCallback_=function(a){if(this.isLive()){var b=null;a.code==shaka.util.Error.Code.BAD_HTTP_STATUS||a.code==shaka.util.Error.Code.HTTP_ERROR?(b=1,this.config_.streaming.lowLatencyMode&&(b=.1)):a.code==shaka.util.Error.Code.TIMEOUT&&(b=.1);b!=null&&(a.severity=shaka.util.Error.Severity.RECOVERABLE,shaka.log.warning("Live streaming error.  Retrying automatically..."),this.retryStreaming(b))}};
shaka.Player.prototype.makeTextStreamsForClosedCaptions_=function(a){for(var b=shaka.util.ManifestParserUtils.ContentType,c=shaka.util.ManifestParserUtils.TextStreamKind,d=shaka.util.MimeUtils.CEA608_CLOSED_CAPTION_MIMETYPE,e=shaka.util.MimeUtils.CEA708_CLOSED_CAPTION_MIMETYPE,f=new Set,g=(0,$jscomp.makeIterator)(a.textStreams),h=g.next();!h.done;h=g.next())h=h.value,h.mimeType!=d&&h.mimeType!=e||f.add(h.originalId);g=(0,$jscomp.makeIterator)(a.variants);for(h=g.next();!h.done;h=g.next())if((h=h.value.video)&&
h.closedCaptions)for(var k=(0,$jscomp.makeIterator)(h.closedCaptions.keys()),l=k.next();!l.done;l=k.next())if(l=l.value,!f.has(l)){var m=l.startsWith("CC")?d:e,n=new shaka.media.MetaSegmentIndex,p=h.closedCaptions.get(l);m={id:this.nextExternalStreamId_++,originalId:l,groupId:null,createSegmentIndex:function(){return Promise.resolve()},segmentIndex:n,mimeType:m,codecs:"",kind:c.CLOSED_CAPTION,encrypted:!1,drmInfos:[],keyIds:new Set,language:p,originalLanguage:p,label:null,type:b.TEXT,primary:!1,trickModeVideo:null,
dependencyStream:null,emsgSchemeIdUris:null,roles:h.roles,forced:!1,channelsCount:null,audioSamplingRate:null,spatialAudio:!1,closedCaptions:null,accessibilityPurpose:null,external:!1,fastSwitching:!1,fullMimeTypes:new Set([shaka.util.MimeUtils.getFullType(m,"")]),isAudioMuxedInVideo:!1,baseOriginalId:null};a.textStreams.push(m);f.add(l)}};
shaka.Player.prototype.adjustStartTime_=function(a,b){var c,d,e,f,g;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(h){if(h.getNextAddressJsc()==1)return c=a.audio,d=a.video,e=function(k,l){var m,n,p;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(q){if(q.getNextAddressJsc()==1)return k?k.segmentIndex?q.jumpTo(2):q.yield(k.createSegmentIndex(),2):q.return(null);n=(m=k.segmentIndex.getIteratorForTime(l))?m.next().value:null;if(!n)return q.return(null);p=n.startTime;goog.asserts.assert(p<=
l,"Segment should start before target time!");return q.return(p)})},h.yield(e(c,b),2);if(h.getNextAddressJsc()!=3)return f=h.getYieldResultJsc(),h.yield(e(d,b),3);g=h.getYieldResultJsc();return g!=null&&f!=null?h.return(Math.max(g,f)):g!=null?h.return(g):f!=null?h.return(f):h.return(b)})};
shaka.Player.prototype.updateBufferState_=function(){var a=this.isBuffering();shaka.log.v2("Player changing buffering state to",a);if(this.stats_&&this.bufferObserver_&&this.playhead_){this.config_.streaming.rebufferingGoal==0?this.playRateController_.setBuffering(!1):this.playRateController_.setBuffering(a);this.cmcdManager_&&this.cmcdManager_.setBuffering(a);this.updateStateHistory_();var b=this.config_.streaming.liveSync.dynamicTargetLatency.maxAttempts;if(this.config_.streaming.liveSync.dynamicTargetLatency.enabled&&
a&&this.rebufferingCount_<b){b=this.config_.streaming.liveSync.dynamicTargetLatency.maxLatency;var c=this.config_.streaming.liveSync.targetLatencyTolerance,d=this.config_.streaming.liveSync.dynamicTargetLatency.rebufferIncrement;this.currentTargetLatency_&&(this.currentTargetLatency_=Math.min(this.currentTargetLatency_+ ++this.rebufferingCount_*d,b-c))}}b=shaka.util.FakeEvent.EventName.Buffering;a=(new Map).set("buffering",a);this.dispatchEvent(shaka.Player.makeEvent_(b,a))};
shaka.Player.prototype.onRateChange_=function(){var a=this.video_.playbackRate;a==0?(a=this.getPlaybackRate(),a!==0&&a!==1&&(a=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.RateChange),this.dispatchEvent(a))):(this.playRateController_&&(this.playRateController_.set(a),this.loadMode_==shaka.Player.LoadMode.MEDIA_SOURCE&&this.abrManager_.playbackRateChanged(a),this.setupTrickPlayEventListeners_(a)),a=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.RateChange),this.dispatchEvent(a))};
shaka.Player.prototype.setupTrickPlayEventListeners_=function(a){var b=this;this.trickPlayEventManager_.removeAll();this.trickPlayEventManager_.listen(this.video_,"timeupdate",function(){var c=b.video_.currentTime,d=b.seekRange(),e=b.isLive(),f=e?b.config_.streaming.safeSeekOffset:0;a>0?e&&a>1&&Math.floor(c)>=Math.floor(d.end)&&b.cancelTrickPlay():Math.floor(c)<=Math.floor(d.start+f)&&b.cancelTrickPlay()})};
shaka.Player.prototype.updateStateHistory_=function(){if(this.stats_&&this.bufferObserver_){var a=shaka.media.BufferingObserver.State,b=this.stats_.getStateHistory(),c="playing";this.bufferObserver_.getState()==a.STARVING?c="buffering":this.isEnded()?c="ended":this.video_.paused&&(c="paused");b.update(c)&&(a=shaka.util.FakeEvent.EventName.StateChanged,c=(new Map).set("newstate",c),this.dispatchEvent(shaka.Player.makeEvent_(a,c)))}};
shaka.Player.prototype.onTimeUpdate_=function(){var a=this.video_.playbackRate,b=this.isLive();if(this.config_.streaming.vodDynamicPlaybackRate&&!b){var c=this.config_.streaming.vodDynamicPlaybackRateLowBufferRate,d=this.getBufferFullness(),e=this.config_.streaming.vodDynamicPlaybackRateBufferRatio;d<=e?a!=c&&(shaka.log.debug("Buffer fullness ratio ("+d+") is less than the vodDynamicPlaybackRateBufferRatio ("+e+"). Updating playbackRate to "+c),this.trickPlay(c,!1)):d==1&&a!==this.playRateController_.getDefaultRate()&&
(shaka.log.debug("Buffer is full. Cancel trick play."),this.cancelTrickPlay())}if(b&&(b=this.seekRange(),Number.isFinite(b.end)&&!(this.video_.currentTime<b.start||this.video_.paused))){c=this.config_.streaming.liveSync.targetLatencyTolerance;d=this.config_.streaming.liveSync.dynamicTargetLatency.enabled;e=this.config_.streaming.liveSync.dynamicTargetLatency.stabilityThreshold;if(this.config_.streaming.liveSync&&this.config_.streaming.liveSync.enabled){var f=this.config_.streaming.liveSync.targetLatency;
var g=f+c;var h=Math.max(0,f-c);var k=this.config_.streaming.liveSync.maxPlaybackRate;var l=this.config_.streaming.liveSync.minPlaybackRate}else this.manifest_&&this.manifest_.serviceDescription&&(f=this.manifest_.serviceDescription.targetLatency,this.manifest_.serviceDescription.targetLatency!=null?g=this.manifest_.serviceDescription.targetLatency+c:this.manifest_.serviceDescription.maxLatency!=null&&(g=this.manifest_.serviceDescription.maxLatency),this.manifest_.serviceDescription.targetLatency!=
null?h=Math.max(0,this.manifest_.serviceDescription.targetLatency-c):this.manifest_.serviceDescription.minLatency!=null&&(h=this.manifest_.serviceDescription.minLatency),k=this.manifest_.serviceDescription.maxPlaybackRate||this.config_.streaming.liveSync.maxPlaybackRate,l=this.manifest_.serviceDescription.minPlaybackRate||this.config_.streaming.liveSync.minPlaybackRate);this.currentTargetLatency_||typeof f!=="number"||(this.currentTargetLatency_=f);var m=this.config_.streaming.liveSync.dynamicTargetLatency.maxAttempts;
d&&this.targetLatencyReached_&&this.currentTargetLatency_!==null&&typeof f==="number"&&this.rebufferingCount_<m&&Date.now()-this.targetLatencyReached_>e*1E3&&(e=this.config_.streaming.liveSync.dynamicTargetLatency.minLatency,this.currentTargetLatency_=Math.max(this.currentTargetLatency_-(f-e)/2,e+c),this.targetLatencyReached_=Date.now());d&&this.currentTargetLatency_!==null&&(g=this.currentTargetLatency_+c,h=this.currentTargetLatency_-c);f=b.end-this.video_.currentTime;c=0;this.loadMode_==shaka.Player.LoadMode.SRC_EQUALS&&
(d=this.video_.buffered,d.length>0&&(c=d.end(d.length-1),c=Math.max(k,c-b.end)));b=this.config_.streaming.liveSync.panicMode;d=this.config_.streaming.liveSync.panicThreshold*1E3;e=Date.now()-this.bufferObserver_.getLastRebufferTime();b&&!l&&(l=this.config_.streaming.liveSync.minPlaybackRate);b&&l&&e<=d?a!=l&&(shaka.log.debug("Time since last rebuffer ("+e+"s) is less than the live sync panicThreshold ("+d+"s). Updating playbackRate to "+l),this.trickPlay(l,!1)):g!=void 0&&k&&f-c>g?(a!=k&&(shaka.log.debug("Latency ("+
f+"s) is greater than live sync maxLatency ("+g+"s). Updating playbackRate to "+k),this.trickPlay(k,!1)),this.targetLatencyReached_=null):h!=void 0&&l&&f-c<h?(a!=l&&(shaka.log.debug("Latency ("+f+"s) is smaller than live sync minLatency ("+h+"s). Updating playbackRate to "+l),this.trickPlay(l,!1)),this.targetLatencyReached_=null):a!==this.playRateController_.getDefaultRate()&&(this.cancelTrickPlay(),this.targetLatencyReached_=Date.now())}};
shaka.Player.prototype.isQuartile_=function(a,b){return(shaka.util.NumberUtils.isFloatEqual(a,b,.01)||b>a)&&this.completionPercent_<a?(this.completionPercent_=a,!0):!1};shaka.Player.prototype.checkEnded_=function(){this.config_&&this.config_.playRangeEnd!=Infinity&&this.isEnded()&&this.video_.pause()};
shaka.Player.prototype.onVideoProgress_=function(){if(this.video_){var a=this.seekRange();a=a.end-a.start;a=a>0?this.video_.currentTime/a:0;if(!isNaN(a)){a*=100;if(this.isQuartile_(0,a))var b=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.Started);else if(this.isQuartile_(25,a))b=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.FirstQuartile);else if(this.isQuartile_(50,a))b=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.Midpoint);else if(this.isQuartile_(75,a))b=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.ThirdQuartile);
else{if(this.isQuartile_(100,a)||a>100)b=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.Complete);this.checkEnded_()}b&&this.dispatchEvent(b)}}};shaka.Player.prototype.onSeek_=function(){this.playheadObservers_&&this.playheadObservers_.notifyOfSeek(!this.playhead_.getIsJumpingGap());this.streamingEngine_&&this.streamingEngine_.seeked();this.bufferObserver_&&this.pollBufferState_(shaka.util.MediaElementEvent.SEEKING)};
shaka.Player.prototype.updateAbrManagerVariants_=function(){try{goog.asserts.assert(this.manifest_,"Manifest should exist by now!"),this.manifestFilterer_.checkRestrictedVariants(this.manifest_)}catch(b){return this.onError_(b),!1}var a=shaka.util.StreamUtils.getPlayableVariants(this.manifest_.variants);a=this.currentAdaptationSetCriteria_.create(a);a=this.abrManager_.setVariants(Array.from(a.values()));return typeof a=="boolean"?a:!0};
shaka.Player.prototype.chooseVariant_=function(a){a=a===void 0?!1:a;if(this.updateAbrManagerVariants_()){if(!this.config_.abr.enabled){var b=this.currentAdaptationSetCriteria_;typeof b.getLastAdaptationSet!="function"&&(shaka.Deprecate.deprecateFeature(5,"AdaptationSetCriteria w/o getLastAdaptationSet","Please use an AdaptationSetCriteria with getLastAdaptationSet."),b.getLastAdaptationSet=function(){return null});if(b=b.getLastAdaptationSet())if(b=Array.from(b.values()),b.length){var c=this.streamingEngine_.getCurrentVariant();
if(c&&c.video&&(b=b.find(function(d){return d.video==c.video})))return b}}return this.abrManager_.chooseVariant(a)}return null};
shaka.Player.prototype.checkVariants_=function(){goog.asserts.assert(this.manifest_,"Should have manifest!");for(var a=Date.now()/1E3,b=!1,c=!0,d=(0,$jscomp.makeIterator)(this.manifest_.variants),e=d.next();!e.done;e=d.next()){e=e.value;if(e.disabledUntilTime>0&&e.disabledUntilTime<=a){e.disabledUntilTime=0;b=!0;var f=shaka.log,g=f.v2,h="";e.video&&(h+="video:"+e.video.id);e.audio&&(h=h+(h?"&":"")+("audio:"+e.audio.id));g.call(f,"Re-enabled variant with "+h)}e.disabledUntilTime>0&&(c=!1)}c&&this.checkVariantsTimer_.stop();
b&&this.chooseVariantAndSwitch_(!1,void 0,!1,!1)};shaka.Player.prototype.chooseTextStream_=function(){return shaka.util.StreamUtils.filterStreamsByLanguageAndRole(this.manifest_.textStreams,this.currentTextLanguage_,this.currentTextRole_,this.currentTextForced_)[0]||null};
shaka.Player.prototype.chooseVariantAndSwitch_=function(a,b,c,d){a=a===void 0?!0:a;b=b===void 0?0:b;c=c===void 0?!1:c;d=d===void 0?!0:d;goog.asserts.assert(this.config_,"Must not be destroyed");var e=this.chooseVariant_();e&&this.switchVariant_(e,d,a,b,c)};
shaka.Player.prototype.switchVariant_=function(a,b,c,d,e){e=e===void 0?!1:e;var f=this.streamingEngine_.getCurrentVariant();if(a==f)shaka.log.debug("Variant already selected."),c&&this.streamingEngine_.switchVariant(a,c,d,!0);else{this.addVariantToSwitchHistory_(a,b);this.streamingEngine_.switchVariant(a,c,d,e,b);c=null;f&&(c=shaka.util.StreamUtils.variantToTrack(f));f=shaka.util.StreamUtils.variantToTrack(a);f.active=!0;this.lcevcDec_&&this.lcevcDec_.updateVariant(a,this.getManifestType());if(b)this.onAdaptation_(c,
f);else this.onVariantChanged_(c,f);this.checkAudioTracksChanged_(c,f)}};
shaka.Player.prototype.switchHtml5Track_=function(a){var b=shaka.util.StreamUtils;goog.asserts.assert(this.video_&&this.video_.audioTracks,"Video and video.audioTracks should not be null!");var c=Array.from(this.video_.audioTracks).find(function(e){return e.enabled});a.enabled=!0;if(c){a.id!==c.id&&(c.enabled=!1);var d=this.getActiveHtml5VideoTrack_();c=b.html5TrackToShakaTrack(c,d);a=b.html5TrackToShakaTrack(a,d);this.onVariantChanged_(c,a);this.checkAudioTracksChanged_(c,a)}};
shaka.Player.prototype.getActiveHtml5VideoTrack_=function(){return this.video_&&this.video_.videoTracks?Array.from(this.video_.videoTracks).find(function(a){return a.selected}):null};
shaka.Player.prototype.setInitialTextState_=function(a,b){b?(goog.asserts.assert(this.config_,"Must not be destroyed"),shaka.util.StreamUtils.shouldInitiallyShowText(a.audio,b,this.config_)&&(this.isTextVisible_=!0),this.isTextVisible_&&(this.textDisplayer_.setTextVisibility(!0),goog.asserts.assert(this.shouldStreamText_(),"Should be streaming text"))):(this.isTextVisible_=!1,this.textDisplayer_.setTextVisibility(!1));this.onTextTrackVisibility_()};
shaka.Player.prototype.onManifestUpdate_=function(){this.parser_&&this.parser_.update&&this.parser_.update()};
shaka.Player.prototype.onSegmentAppended_=function(a,b,c,d,e){var f=shaka.util.NumberUtils;if(c!=shaka.util.ManifestParserUtils.ContentType.TEXT){if(this.playhead_){this.playhead_.notifyOfBufferingChange();var g=this.mediaSourceEngine_.bufferStart(c);!this.isLive()&&this.video_.paused&&!this.video_.seeking&&g!=null&&g>0&&this.playhead_.getTime()<g&&!f.isFloatEqual(this.playhead_.getTime(),g,.001)&&this.playhead_.setStartTime(g)}this.pollBufferState_()}a=(new Map).set("start",a).set("end",b).set("contentType",
c).set("isMuxed",d).set("isDependency",e);this.dispatchEvent(shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.SegmentAppended,a))};shaka.Player.prototype.switch_=function(a,b,c){b=b===void 0?!1:b;c=c===void 0?0:c;shaka.log.debug("switch_");goog.asserts.assert(this.config_.abr.enabled,"AbrManager should not call switch while disabled!");this.manifest_&&this.streamingEngine_&&a!=this.streamingEngine_.getCurrentVariant()&&this.switchVariant_(a,!0,b,c)};
shaka.Player.prototype.onAdaptation_=function(a,b){a=(new Map).set("oldTrack",a).set("newTrack",b);a=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.Adaptation,a);this.delayDispatchEvent_(a)};shaka.Player.prototype.onTracksChanged_=function(){var a=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.TracksChanged);this.delayDispatchEvent_(a);this.onAudioTracksChanged_()};
shaka.Player.prototype.onVariantChanged_=function(a,b){a=(new Map).set("oldTrack",a).set("newTrack",b);a=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.VariantChanged,a);this.delayDispatchEvent_(a)};shaka.Player.prototype.checkAudioTracksChanged_=function(a,b){var c=!1;a&&a.audioId==b.audioId&&a.audioGroupId==b.audioGroupId||(c=!0);if(c)this.onAudioTracksChanged_()};
shaka.Player.prototype.onAudioTracksChanged_=function(){var a=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.AudioTracksChanged);this.delayDispatchEvent_(a)};shaka.Player.prototype.onTextChanged_=function(){var a=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.TextChanged);this.delayDispatchEvent_(a)};shaka.Player.prototype.onTextTrackVisibility_=function(){var a=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.TextTrackVisibility);this.delayDispatchEvent_(a)};
shaka.Player.prototype.onAbrStatusChanged_=function(){this.config_.abr.enabled||this.restoreDisabledVariants_();var a=(new Map).set("newStatus",this.config_.abr.enabled);this.delayDispatchEvent_(shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.AbrStatusChanged,a))};shaka.Player.prototype.setTextDisplayerLanguage_=function(){var a=this.getTextTracks().find(function(b){return b.active});a&&this.textDisplayer_&&this.textDisplayer_.setTextLanguage&&this.textDisplayer_.setTextLanguage(a.language)};
shaka.Player.prototype.restoreDisabledVariants_=function(a){a=a===void 0?!0:a;if(this.loadMode_==shaka.Player.LoadMode.MEDIA_SOURCE){goog.asserts.assert(this.manifest_,"Should have manifest!");shaka.log.v2("Restoring all disabled streams...");this.checkVariantsTimer_.stop();for(var b=(0,$jscomp.makeIterator)(this.manifest_.variants),c=b.next();!c.done;c=b.next())c.value.disabledUntilTime=0;a&&this.updateAbrManagerVariants_()}};
shaka.Player.prototype.disableStream=function(a,b){if(!this.config_.abr.enabled||this.loadMode_===shaka.Player.LoadMode.DESTROYED||!navigator.onLine||b==0||!this.manifest_)return!1;if(this.manifest_.variants.some(function(h){var k=h[a.type];return k&&k.id!==a.id&&!h.disabledUntilTime?shaka.util.StreamUtils.isAudio(a)?a.language===k.language:!0:!1})){for(var c=!1,d=!1,e=(0,$jscomp.makeIterator)(this.manifest_.variants),f=e.next();!f.done;f=e.next()){f=f.value;var g=f[a.type];g&&(g.id===a.id?(f.disabledUntilTime=
Date.now()/1E3+b,c=!0,shaka.log.v2("Disabled stream "+a.type+":"+a.id+" for "+b+" seconds...")):g.trickModeVideo&&g.trickModeVideo.id==a.id&&(d=!0))}if(!c&&d)return!1;goog.asserts.assert(c,"Must have disabled stream");this.checkVariantsTimer_.tickEvery(1);b=this.getBufferedInfo().video.reduce(function(h,k){return h+k.end-k.start},0);this.chooseVariantAndSwitch_(!1,b,!0,!1);return!0}shaka.log.warning("No alternate stream found for active "+a.type+" stream. Will ignore request to disable stream...");
return!1};
shaka.Player.prototype.onError_=function(a){var b=this,c,d,e,f,g,h;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(k){switch(k.getNextAddressJsc()){case 1:goog.asserts.assert(a instanceof shaka.util.Error,"Wrong error type!");if(b.loadMode_==shaka.Player.LoadMode.DESTROYED)return k.return();a.severity===shaka.util.Error.Severity.RECOVERABLE&&b.stats_.addNonFatalError();c=!0;if(!(b.fullyLoaded_&&b.manifest_&&b.streamingEngine_)||a.code!=shaka.util.Error.Code.VIDEO_ERROR&&a.code!=shaka.util.Error.Code.MEDIA_SOURCE_OPERATION_FAILED&&
a.code!=shaka.util.Error.Code.MEDIA_SOURCE_OPERATION_THREW&&a.code!=shaka.util.Error.Code.STREAMING_NOT_ALLOWED&&a.code!=shaka.util.Error.Code.TRANSMUXING_FAILED){k.jumpTo(2);break}d=shaka.device.DeviceFactory.getDevice();if(d.getBrowserEngine()===shaka.device.IDevice.BrowserEngine.WEBKIT&&a.code==shaka.util.Error.Code.VIDEO_ERROR)return k.return();k.setCatchFinallyBlocks(3);return k.yield(b.streamingEngine_.resetMediaSource(),5);case 5:e=k.getYieldResultJsc();c=!e;e&&(f=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.MediaSourceRecovered),
b.dispatchEvent(f));k.leaveTryBlock(2);break;case 3:k.enterCatchBlock(),c=!0;case 2:if(!c)return k.return();a.severity===shaka.util.Error.Severity.CRITICAL&&b.restoreDisabledVariants_(!1);g=shaka.util.FakeEvent.EventName.Error;h=shaka.Player.makeEvent_(g,(new Map).set("detail",a));b.dispatchEvent(h);h.defaultPrevented&&(a.handled=!0);k.jumpToEnd()}})};shaka.Player.prototype.addFont=function(a,b){return shaka.util.Dom.addFont(a,b)};
shaka.Player.prototype.onRegionEvent_=function(a,b,c){c=c===void 0?this:c;b={schemeIdUri:b.schemeIdUri,value:b.value,startTime:b.startTime,endTime:b.endTime,id:b.id,timescale:b.timescale,eventElement:b.eventElement,eventNode:b.eventNode};b=(new Map).set("detail",b);c.dispatchEvent(shaka.Player.makeEvent_(a,b))};
shaka.Player.prototype.onMediaQualityChange_=function(a,b,c){c=c===void 0?!1:c;a={bandwidth:a.bandwidth,audioSamplingRate:a.audioSamplingRate,codecs:a.codecs,contentType:a.contentType,frameRate:a.frameRate,height:a.height,mimeType:a.mimeType,channelsCount:a.channelsCount,pixelAspectRatio:a.pixelAspectRatio,width:a.width,label:a.label,roles:a.roles,language:a.language};b=(new Map).set("mediaQuality",a).set("position",b);this.dispatchEvent(shaka.Player.makeEvent_(c?shaka.util.FakeEvent.EventName.AudioTrackChanged:
shaka.util.FakeEvent.EventName.MediaQualityChanged,b))};
shaka.Player.prototype.videoErrorToShakaError_=function(a){a=a===void 0?!0:a;goog.asserts.assert(this.video_.error,"Video error expected, but missing!");if(!this.video_.error)return a?new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,shaka.util.Error.Code.VIDEO_ERROR):null;var b=this.video_.error.code;if(!a&&b==1)return null;if(a=this.video_.error.msExtendedCode)a<0&&(a+=4294967296),a=a.toString(16);return new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.MEDIA,
shaka.util.Error.Code.VIDEO_ERROR,b,a,this.video_.error.message)};shaka.Player.prototype.onVideoError_=function(a){if(a=this.videoErrorToShakaError_(!1))this.onError_(a)};
shaka.Player.prototype.onKeyStatus_=function(a){var b=this;if(this.streamingEngine_){var c=shaka.Player.makeEvent_(shaka.util.FakeEvent.EventName.KeyStatusChanged);this.dispatchEvent(c);var d=Object.keys(a);d.length==0&&shaka.log.warning("Got a key status event without any key statuses, so we don't know the real key statuses. If we don't have all the keys, you'll need to set restrictions so we don't select those tracks.");d.length==1&&d[0]==""&&(d=["00"],a={"00":a[""]});var e=d.length==1&&d[0]=="00";
e&&shaka.log.warning("Got a synthetic key status event, so we don't know the real key statuses. If we don't have all the keys, you'll need to set restrictions so we don't select those tracks.");var f=shaka.media.ManifestFilterer.restrictedStatuses;c=!1;goog.asserts.assert(this.drmEngine_,"drmEngine should be non-null here.");if(d.length){d=this.keySystem();for(var g=shaka.util.MapUtils.asMap(this.config_.drm.clearKeys),h=function(t,u){t.allowedByKeySystem=!0;u=(0,$jscomp.makeIterator)(u);for(var v=
u.next();!v.done;v=u.next())if(v=v.value,(v=a[e?"00":v])||b.drmEngine_.hasManifestInitData())t.allowedByKeySystem=t.allowedByKeySystem&&!!v&&!f.includes(v)},k=(0,$jscomp.makeIterator)(this.manifest_.variants),l=k.next();!l.done;l=k.next()){l=l.value;var m=shaka.util.StreamUtils.getVariantStreams(l);m=(0,$jscomp.makeIterator)(m);for(var n=m.next();!n.done;n=m.next()){n=n.value;var p=l.allowedByKeySystem;if(n.keyIds.size)if(n.drmInfos.length&&!g.size&&this.manifest_.type==shaka.media.ManifestParser.HLS)for(var q=
(0,$jscomp.makeIterator)(n.drmInfos),r=q.next();!r.done;r=q.next())r=r.value,r.keySystem==d&&(r.keyIds.size?h(l,r.keyIds):h(l,n.keyIds));else h(l,n.keyIds);p!=l.allowedByKeySystem&&(c=!0)}}}c&&(this.onTracksChanged_(),(c=this.streamingEngine_.getCurrentVariant())&&!c.allowedByKeySystem?(shaka.log.debug("Choosing new streams after key status changed"),this.chooseVariantAndSwitch_()):this.updateAbrManagerVariants_())}};
shaka.Player.prototype.shouldStreamText_=function(){return this.config_.streaming.alwaysStreamText||this.isTextTrackVisible()};shaka.Player.applyPlayRange_=function(a,b,c){b>0&&(a.isLive()?shaka.log.warning("|playRangeStart| has been configured for live content. Ignoring the setting."):a.setUserSeekStart(b));b=a.getDuration();c<b&&(a.isLive()?shaka.log.warning("|playRangeEnd| has been configured for live content. Ignoring the setting."):a.setDuration(c))};
shaka.Player.prototype.delayDispatchEvent_=function(a){var b=this;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(c){if(c.getNextAddressJsc()==1)return c.yield(Promise.resolve(),2);b.loadMode_!=shaka.Player.LoadMode.DESTROYED&&b.dispatchEvent(a);c.jumpToEnd()})};shaka.Player.getLanguagesFrom_=function(a){var b=new Set;a=(0,$jscomp.makeIterator)(a);for(var c=a.next();!c.done;c=a.next())c=c.value,c.language?b.add(shaka.util.LanguageUtils.normalize(c.language)):b.add("und");return b};
shaka.Player.getLanguageAndRolesFrom_=function(a){for(var b=new Map,c=new Map,d=0;d<a.length;d++){var e=a[d],f="und",g=[];e.language&&(f=shaka.util.LanguageUtils.normalize(e.language));(g=e.type=="variant"?e.audioRoles:e.roles)&&g.length||(g=[""]);b.has(f)||b.set(f,new Set);g=(0,$jscomp.makeIterator)(g);for(var h=g.next();!h.done;h=g.next())h=h.value,b.get(f).add(h),e.label&&(c.has(f)||c.set(f,new Map),c.get(f).set(h,e.label))}var k=[];b.forEach(function(l,m){l=(0,$jscomp.makeIterator)(l);for(var n=
l.next();!n.done;n=l.next()){n=n.value;var p=null;c.has(m)&&c.get(m).has(n)&&(p=c.get(m).get(n));k.push({language:m,role:n,label:p})}});return k};shaka.Player.prototype.createAbortLoadError_=function(){return new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.PLAYER,shaka.util.Error.Code.LOAD_INTERRUPTED)};shaka.Player.prototype.isRemotePlayback=function(){return this.video_&&this.video_.remote?this.video_.remote.state!="disconnected":!1};
shaka.Player.prototype.isEnded=function(){return!this.video_||this.video_.ended?!0:this.fullyLoaded_&&!this.isLive()&&this.video_.currentTime>=this.seekRange().end};goog.exportSymbol("shaka.Player",shaka.Player);goog.exportProperty(shaka.Player.prototype,"isEnded",shaka.Player.prototype.isEnded);goog.exportProperty(shaka.Player.prototype,"isRemotePlayback",shaka.Player.prototype.isRemotePlayback);goog.exportProperty(shaka.Player.prototype,"addFont",shaka.Player.prototype.addFont);
goog.exportProperty(shaka.Player.prototype,"setVideoContainer",shaka.Player.prototype.setVideoContainer);goog.exportProperty(shaka.Player.prototype,"getFetchedPlaybackInfo",shaka.Player.prototype.getFetchedPlaybackInfo);goog.exportProperty(shaka.Player.prototype,"getManifestParserFactory",shaka.Player.prototype.getManifestParserFactory);goog.exportProperty(shaka.Player.prototype,"getManifest",shaka.Player.prototype.getManifest);goog.exportProperty(shaka.Player.prototype,"retryStreaming",shaka.Player.prototype.retryStreaming);
goog.exportProperty(shaka.Player.prototype,"setMaxHardwareResolution",shaka.Player.prototype.setMaxHardwareResolution);goog.exportProperty(shaka.Player.prototype,"addChaptersTrack",shaka.Player.prototype.addChaptersTrack);goog.exportProperty(shaka.Player.prototype,"addThumbnailsTrack",shaka.Player.prototype.addThumbnailsTrack);goog.exportProperty(shaka.Player.prototype,"addTextTrackAsync",shaka.Player.prototype.addTextTrackAsync);goog.exportProperty(shaka.Player.prototype,"getStats",shaka.Player.prototype.getStats);
goog.exportProperty(shaka.Player.prototype,"getBufferedInfo",shaka.Player.prototype.getBufferedInfo);goog.exportProperty(shaka.Player.prototype,"getSegmentAvailabilityDuration",shaka.Player.prototype.getSegmentAvailabilityDuration);goog.exportProperty(shaka.Player.prototype,"getPresentationStartTimeAsDate",shaka.Player.prototype.getPresentationStartTimeAsDate);goog.exportProperty(shaka.Player.prototype,"getPlayheadTimeAsDate",shaka.Player.prototype.getPlayheadTimeAsDate);
goog.exportProperty(shaka.Player.prototype,"setTextTrackVisibility",shaka.Player.prototype.setTextTrackVisibility);goog.exportProperty(shaka.Player.prototype,"getChaptersAsync",shaka.Player.prototype.getChaptersAsync);goog.exportProperty(shaka.Player.prototype,"getChapters",shaka.Player.prototype.getChapters);goog.exportProperty(shaka.Player.prototype,"getChaptersTracks",shaka.Player.prototype.getChaptersTracks);goog.exportProperty(shaka.Player.prototype,"isTextTrackVisible",shaka.Player.prototype.isTextTrackVisible);
goog.exportProperty(shaka.Player.prototype,"selectVariantsByLabel",shaka.Player.prototype.selectVariantsByLabel);goog.exportProperty(shaka.Player.prototype,"selectTextLanguage",shaka.Player.prototype.selectTextLanguage);goog.exportProperty(shaka.Player.prototype,"selectAudioLanguage",shaka.Player.prototype.selectAudioLanguage);goog.exportProperty(shaka.Player.prototype,"getTextLanguages",shaka.Player.prototype.getTextLanguages);goog.exportProperty(shaka.Player.prototype,"getAudioLanguages",shaka.Player.prototype.getAudioLanguages);
goog.exportProperty(shaka.Player.prototype,"getTextLanguagesAndRoles",shaka.Player.prototype.getTextLanguagesAndRoles);goog.exportProperty(shaka.Player.prototype,"getAudioLanguagesAndRoles",shaka.Player.prototype.getAudioLanguagesAndRoles);goog.exportProperty(shaka.Player.prototype,"getVideoTracks",shaka.Player.prototype.getVideoTracks);goog.exportProperty(shaka.Player.prototype,"selectVideoTrack",shaka.Player.prototype.selectVideoTrack);
goog.exportProperty(shaka.Player.prototype,"getAudioTracks",shaka.Player.prototype.getAudioTracks);goog.exportProperty(shaka.Player.prototype,"selectAudioTrack",shaka.Player.prototype.selectAudioTrack);goog.exportProperty(shaka.Player.prototype,"selectVariantTrack",shaka.Player.prototype.selectVariantTrack);goog.exportProperty(shaka.Player.prototype,"selectTextTrack",shaka.Player.prototype.selectTextTrack);goog.exportProperty(shaka.Player.prototype,"getThumbnails",shaka.Player.prototype.getThumbnails);
goog.exportProperty(shaka.Player.prototype,"getAllThumbnails",shaka.Player.prototype.getAllThumbnails);goog.exportProperty(shaka.Player.prototype,"getImageTracks",shaka.Player.prototype.getImageTracks);goog.exportProperty(shaka.Player.prototype,"getTextTracks",shaka.Player.prototype.getTextTracks);goog.exportProperty(shaka.Player.prototype,"getVariantTracks",shaka.Player.prototype.getVariantTracks);goog.exportProperty(shaka.Player.prototype,"cancelTrickPlay",shaka.Player.prototype.cancelTrickPlay);
goog.exportProperty(shaka.Player.prototype,"trickPlay",shaka.Player.prototype.trickPlay);goog.exportProperty(shaka.Player.prototype,"useTrickPlayTrackIfAvailable",shaka.Player.prototype.useTrickPlayTrackIfAvailable);goog.exportProperty(shaka.Player.prototype,"getPlaybackRate",shaka.Player.prototype.getPlaybackRate);goog.exportProperty(shaka.Player.prototype,"isBuffering",shaka.Player.prototype.isBuffering);goog.exportProperty(shaka.Player.prototype,"getKeyStatuses",shaka.Player.prototype.getKeyStatuses);
goog.exportProperty(shaka.Player.prototype,"getActiveSessionsMetadata",shaka.Player.prototype.getActiveSessionsMetadata);goog.exportProperty(shaka.Player.prototype,"getExpiration",shaka.Player.prototype.getExpiration);goog.exportProperty(shaka.Player.prototype,"drmInfo",shaka.Player.prototype.drmInfo);goog.exportProperty(shaka.Player.prototype,"keySystem",shaka.Player.prototype.keySystem);goog.exportProperty(shaka.Player.prototype,"isFullyLoaded",shaka.Player.prototype.isFullyLoaded);
goog.exportProperty(shaka.Player.prototype,"goToLive",shaka.Player.prototype.goToLive);goog.exportProperty(shaka.Player.prototype,"seekRange",shaka.Player.prototype.seekRange);goog.exportProperty(shaka.Player.prototype,"isVideoOnly",shaka.Player.prototype.isVideoOnly);goog.exportProperty(shaka.Player.prototype,"isAudioOnly",shaka.Player.prototype.isAudioOnly);goog.exportProperty(shaka.Player.prototype,"isInProgress",shaka.Player.prototype.isInProgress);
goog.exportProperty(shaka.Player.prototype,"isLive",shaka.Player.prototype.isLive);goog.exportProperty(shaka.Player.prototype,"getQueueManager",shaka.Player.prototype.getQueueManager);goog.exportProperty(shaka.Player.prototype,"getAdManager",shaka.Player.prototype.getAdManager);goog.exportProperty(shaka.Player.prototype,"getAssetUri",shaka.Player.prototype.getAssetUri);goog.exportProperty(shaka.Player.prototype,"getNetworkingEngine",shaka.Player.prototype.getNetworkingEngine);
goog.exportProperty(shaka.Player.prototype,"getMediaElement",shaka.Player.prototype.getMediaElement);goog.exportProperty(shaka.Player.prototype,"getManifestType",shaka.Player.prototype.getManifestType);goog.exportProperty(shaka.Player.prototype,"getLoadMode",shaka.Player.prototype.getLoadMode);goog.exportProperty(shaka.Player.prototype,"resetConfiguration",shaka.Player.prototype.resetConfiguration);goog.exportProperty(shaka.Player.prototype,"getBufferFullness",shaka.Player.prototype.getBufferFullness);
goog.exportProperty(shaka.Player.prototype,"getNonDefaultConfiguration",shaka.Player.prototype.getNonDefaultConfiguration);goog.exportProperty(shaka.Player.prototype,"getConfigurationForLowLatency",shaka.Player.prototype.getConfigurationForLowLatency);goog.exportProperty(shaka.Player.prototype,"getConfiguration",shaka.Player.prototype.getConfiguration);goog.exportProperty(shaka.Player.prototype,"configurationForLowLatency",shaka.Player.prototype.configurationForLowLatency);
goog.exportProperty(shaka.Player.prototype,"configure",shaka.Player.prototype.configure);goog.exportProperty(shaka.Player.prototype,"releaseAllMutexes",shaka.Player.prototype.releaseAllMutexes);goog.exportProperty(shaka.Player.prototype,"destroyAllPreloads",shaka.Player.prototype.destroyAllPreloads);goog.exportProperty(shaka.Player.prototype,"preload",shaka.Player.prototype.preload);goog.exportProperty(shaka.Player.prototype,"detachAndSavePreload",shaka.Player.prototype.detachAndSavePreload);
goog.exportProperty(shaka.Player.prototype,"unloadAndSavePreload",shaka.Player.prototype.unloadAndSavePreload);goog.exportProperty(shaka.Player.prototype,"load",shaka.Player.prototype.load);goog.exportProperty(shaka.Player.prototype,"updateStartTime",shaka.Player.prototype.updateStartTime);goog.exportProperty(shaka.Player.prototype,"unload",shaka.Player.prototype.unload);goog.exportProperty(shaka.Player.prototype,"detach",shaka.Player.prototype.detach);
goog.exportProperty(shaka.Player.prototype,"attachCanvas",shaka.Player.prototype.attachCanvas);goog.exportProperty(shaka.Player.prototype,"attach",shaka.Player.prototype.attach);goog.exportProperty(shaka.Player,"probeSupport",shaka.Player.probeSupport);goog.exportProperty(shaka.Player,"isBrowserSupported",shaka.Player.isBrowserSupported);goog.exportProperty(shaka.Player,"setQueueManagerFactory",shaka.Player.setQueueManagerFactory);goog.exportProperty(shaka.Player,"setAdManagerFactory",shaka.Player.setAdManagerFactory);
goog.exportProperty(shaka.Player,"registerSupportPlugin",shaka.Player.registerSupportPlugin);goog.exportProperty(shaka.Player.prototype,"destroy",shaka.Player.prototype.destroy);shaka.Player.LoadMode={DESTROYED:0,NOT_LOADED:1,MEDIA_SOURCE:2,SRC_EQUALS:3};goog.exportProperty(shaka.Player,"LoadMode",shaka.Player.LoadMode);shaka.Player.TYPICAL_BUFFERING_THRESHOLD_=.5;shaka.Player.version="v4.16.37-debug";goog.exportProperty(shaka.Player,"version",shaka.Player.version);shaka.Deprecate.init(shaka.Player.version);
shaka.Player.supportPlugins_=new Map;shaka.Player.adManagerFactory_=null;shaka.Player.queueManagerFactory_=null;shaka.Player.TextTrackLabel="Shaka Player TextTrack";shaka.polyfill=function(){};shaka.polyfill.installAll=function(){for(var a=(0,$jscomp.makeIterator)(shaka.polyfill.polyfills_),b=a.next();!b.done;b=a.next()){b=b.value;try{b.callback()}catch(c){shaka.log.alwaysWarn("Error installing polyfill!",c)}}};shaka.polyfill.register=function(a,b){a={priority:b||0,callback:a};for(b=0;b<shaka.polyfill.polyfills_.length;b++)if(shaka.polyfill.polyfills_[b].priority<a.priority){shaka.polyfill.polyfills_.splice(b,0,a);return}shaka.polyfill.polyfills_.push(a)};
goog.exportSymbol("shaka.polyfill",shaka.polyfill);goog.exportProperty(shaka.polyfill,"register",shaka.polyfill.register);goog.exportProperty(shaka.polyfill,"installAll",shaka.polyfill.installAll);shaka.polyfill.polyfills_=[];shaka.polyfill.EmeEncryptionSchemePolyfillMediaKeySystemAccess=function(a,b,c){this.mksa_=a;this.videoScheme_=b||null;this.audioScheme_=c||null;this.keySystem=a.keySystem};
shaka.polyfill.EmeEncryptionSchemePolyfillMediaKeySystemAccess.prototype.getConfiguration=function(){var a=this.mksa_.getConfiguration();if(a.videoCapabilities)for(var b=(0,$jscomp.makeIterator)(a.videoCapabilities),c=b.next();!c.done;c=b.next())c.value.encryptionScheme=this.videoScheme_;if(a.audioCapabilities)for(b=(0,$jscomp.makeIterator)(a.audioCapabilities),c=b.next();!c.done;c=b.next())c.value.encryptionScheme=this.audioScheme_;return a};
shaka.polyfill.EmeEncryptionSchemePolyfillMediaKeySystemAccess.prototype.createMediaKeys=function(){return this.mksa_.createMediaKeys()};shaka.polyfill.EncryptionSchemeUtils=function(){};shaka.polyfill.EncryptionSchemeUtils.guessSupportedScheme=function(a){var b=shaka.drm.DrmUtils;if(b.isFairPlayKeySystem(a))return"cbcs";if(b.isWidevineKeySystem(a)||b.isPlayReadyKeySystem(a)||b.isClearKeySystem(a)||b.isWisePlayKeySystem(a))return"cenc";shaka.log.alwaysWarn("EmeEncryptionSchemePolyfill: Unknown key system:",a,"Please contribute!");return null};
shaka.polyfill.EncryptionSchemeUtils.hasEncryptionScheme=function(a){if(!a)return!1;a=a.getConfiguration();var b=a.audioCapabilities&&a.audioCapabilities[0];return(a=a.videoCapabilities&&a.videoCapabilities[0]||b)&&a.encryptionScheme!==void 0?!0:!1};shaka.polyfill.EncryptionSchemeUtils.checkSupportedScheme=function(a,b){return!a||a==b||(a=="cbcs"||a=="cbcs-1-9")&&shaka.device.DeviceFactory.getDevice().supportsCbcsWithoutEncryptionSchemeSupport()?!0:!1};shaka.polyfill.EmeEncryptionScheme=function(){};
shaka.polyfill.EmeEncryptionScheme.install=function(){shaka.device.DeviceFactory.getDevice().supportsEncryptionSchemePolyfill()&&(shaka.polyfill.EmeEncryptionScheme.originalRMKSA_||navigator.emeEncryptionSchemePolyfilled?shaka.log.debug("EmeEncryptionSchemePolyfill:","Already installed."):navigator.requestMediaKeySystemAccess&&MediaKeySystemAccess.prototype.getConfiguration?(shaka.polyfill.EmeEncryptionScheme.originalRMKSA_=navigator.requestMediaKeySystemAccess,shaka.log.debug("EmeEncryptionSchemePolyfill:",
"Waiting to detect encryptionScheme support."),navigator.requestMediaKeySystemAccess=shaka.polyfill.EmeEncryptionScheme.probeRMKSA_,navigator.emeEncryptionSchemePolyfilled=!0):shaka.log.debug("EmeEncryptionSchemePolyfill:","EME not found"))};
shaka.polyfill.EmeEncryptionScheme.probeRMKSA_=function(a,b){var c=this,d,e,f;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(g){if(g.getNextAddressJsc()==1)return d="EmeEncryptionSchemePolyfill:",goog.asserts.assert(c==navigator,'bad "this" for requestMediaKeySystemAccess'),g.yield(shaka.polyfill.EmeEncryptionScheme.originalRMKSA_.call(c,a,b),2);e=g.getYieldResultJsc();if(f=shaka.polyfill.EncryptionSchemeUtils.hasEncryptionScheme(e))return shaka.log.debug(d,"Native encryptionScheme support found."),
navigator.requestMediaKeySystemAccess=shaka.polyfill.EmeEncryptionScheme.originalRMKSA_,g.return(e);shaka.log.debug(d,"No native encryptionScheme support found. Patching encryptionScheme support.");navigator.requestMediaKeySystemAccess=shaka.polyfill.EmeEncryptionScheme.polyfillRMKSA_;return g.return(shaka.polyfill.EmeEncryptionScheme.polyfillRMKSA_.call(c,a,b))})};
shaka.polyfill.EmeEncryptionScheme.polyfillRMKSA_=function(a,b){var c=this,d,e,f,g,h,k,l,m,n,p,q,r;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(t){if(t.getNextAddressJsc()==1){goog.asserts.assert(c==navigator,'bad "this" for requestMediaKeySystemAccess');d=shaka.polyfill.EncryptionSchemeUtils.guessSupportedScheme(a);e=[];f=(0,$jscomp.makeIterator)(b);for(g=f.next();!g.done;g=f.next())h=g.value,k=shaka.polyfill.EmeEncryptionScheme.filterCapabilities_(h.videoCapabilities,d),l=shaka.polyfill.EmeEncryptionScheme.filterCapabilities_(h.audioCapabilities,
d),h.videoCapabilities&&h.videoCapabilities.length&&!k.length||h.audioCapabilities&&h.audioCapabilities.length&&!l.length||(m=Object.assign({},h),m.videoCapabilities=k,m.audioCapabilities=l,e.push(m));if(!e.length)throw n=Error("Unsupported keySystem or supportedConfigurations."),n.name="NotSupportedError",n.code=DOMException.NOT_SUPPORTED_ERR,n;return t.yield(shaka.polyfill.EmeEncryptionScheme.originalRMKSA_.call(c,a,e),2)}p=t.getYieldResultJsc();r=q=null;e[0]&&(e[0].videoCapabilities&&(q=e[0].videoCapabilities[0].encryptionScheme),
e[0].audioCapabilities&&(r=e[0].audioCapabilities[0].encryptionScheme));return t.return(new shaka.polyfill.EmeEncryptionSchemePolyfillMediaKeySystemAccess(p,q,r))})};shaka.polyfill.EmeEncryptionScheme.filterCapabilities_=function(a,b){return a?a.filter(function(c){return shaka.polyfill.EncryptionSchemeUtils.checkSupportedScheme(c.encryptionScheme,b)}):a};goog.exportProperty(shaka.polyfill,"EmeEncryptionScheme",shaka.polyfill.EmeEncryptionScheme);
goog.exportProperty(shaka.polyfill.EmeEncryptionScheme,"install",shaka.polyfill.EmeEncryptionScheme.install);shaka.polyfill.register(shaka.polyfill.EmeEncryptionScheme.install);shaka.polyfill.MCapEncryptionScheme=function(){};
shaka.polyfill.MCapEncryptionScheme.install=function(){shaka.device.DeviceFactory.getDevice().supportsEncryptionSchemePolyfill()&&(shaka.polyfill.MCapEncryptionScheme.originalDecodingInfo_||navigator.mediaCapabilitiesEncryptionSchemePolyfilled?shaka.log.debug("McEncryptionSchemePolyfill:","Already installed."):navigator.mediaCapabilities?(shaka.polyfill.MCapEncryptionScheme.originalDecodingInfo_=navigator.mediaCapabilities.decodingInfo,shaka.log.debug("McEncryptionSchemePolyfill:","Waiting to detect encryptionScheme support."),
navigator.mediaCapabilities.decodingInfo=shaka.polyfill.MCapEncryptionScheme.probeDecodingInfo_,navigator.mediaCapabilitiesEncryptionSchemePolyfilled=!0):shaka.log.debug("McEncryptionSchemePolyfill:","MediaCapabilities not found"))};
shaka.polyfill.MCapEncryptionScheme.probeDecodingInfo_=function(a){var b=this,c,d,e,f;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(g){switch(g.getNextAddressJsc()){case 1:return c="McEncryptionSchemePolyfill:",goog.asserts.assert(b==navigator.mediaCapabilities,'bad "this" for decodingInfo'),g.yield(shaka.polyfill.MCapEncryptionScheme.originalDecodingInfo_.call(b,a),2);case 2:d=g.getYieldResultJsc();if(!d.supported||!a.keySystemConfiguration)return g.return(d);e=d.keySystemAccess;
if(f=shaka.polyfill.EncryptionSchemeUtils.hasEncryptionScheme(e))return shaka.log.debug(c,"Native encryptionScheme support found."),navigator.mediaCapabilities.decodingInfo=shaka.polyfill.MCapEncryptionScheme.originalDecodingInfo_,g.return(d);shaka.log.debug(c,"No native encryptionScheme support found. Patching encryptionScheme support.");navigator.mediaCapabilities.decodingInfo=shaka.polyfill.MCapEncryptionScheme.polyfillDecodingInfo_;if(e){g.jumpTo(3);break}return g.yield(shaka.polyfill.MCapEncryptionScheme.getMediaKeySystemAccess_(a),
4);case 4:return d.keySystemAccess=g.getYieldResultJsc(),g.return(d);case 3:return g.return(shaka.polyfill.MCapEncryptionScheme.polyfillDecodingInfo_.call(b,a))}})};
shaka.polyfill.MCapEncryptionScheme.polyfillDecodingInfo_=function(a){var b=this,c,d,e,f,g,h,k;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(l){switch(l.getNextAddressJsc()){case 1:return goog.asserts.assert(b==navigator.mediaCapabilities,'bad "this" for decodingInfo'),d=c=null,!a.keySystemConfiguration||(e=a.keySystemConfiguration,f=e.keySystem,d=e.audio&&e.audio.encryptionScheme,c=e.video&&e.video.encryptionScheme,g=shaka.polyfill.EncryptionSchemeUtils.guessSupportedScheme(f),h=
{powerEfficient:!1,smooth:!1,supported:!1,keySystemAccess:null,configuration:a},shaka.polyfill.EncryptionSchemeUtils.checkSupportedScheme(d,g)&&shaka.polyfill.EncryptionSchemeUtils.checkSupportedScheme(c,g))?l.yield(shaka.polyfill.MCapEncryptionScheme.originalDecodingInfo_.call(b,a),2):l.return(h);case 2:k=l.getYieldResultJsc();if(k.keySystemAccess){k.keySystemAccess=new shaka.polyfill.EmeEncryptionSchemePolyfillMediaKeySystemAccess(k.keySystemAccess,c,d);l.jumpTo(3);break}if(!a.keySystemConfiguration){l.jumpTo(3);
break}return l.yield(shaka.polyfill.MCapEncryptionScheme.getMediaKeySystemAccess_(a),5);case 5:k.keySystemAccess=l.getYieldResultJsc();case 3:return l.return(k)}})};
shaka.polyfill.MCapEncryptionScheme.getMediaKeySystemAccess_=function(a){var b,c;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(d){if(d.getNextAddressJsc()==1)return b=shaka.polyfill.MCapEncryptionScheme.convertToMediaKeySystemConfig_(a),d.yield(navigator.requestMediaKeySystemAccess(a.keySystemConfiguration.keySystem,[b]),2);c=d.getYieldResultJsc();return d.return(c)})};
shaka.polyfill.MCapEncryptionScheme.convertToMediaKeySystemConfig_=function(a){var b=a.keySystemConfiguration,c=[],d=[];b.audio&&c.push({robustness:b.audio.robustness||"",contentType:a.audio.contentType,encryptionScheme:b.audio.encryptionScheme});b.video&&d.push({robustness:b.video.robustness||"",contentType:a.video.contentType,encryptionScheme:b.video.encryptionScheme});a={initDataTypes:b.initDataType?[b.initDataType]:[],distinctiveIdentifier:b.distinctiveIdentifier,persistentState:b.persistentState,
sessionTypes:b.sessionTypes};c.length&&(a.audioCapabilities=c);d.length&&(a.videoCapabilities=d);return a};goog.exportProperty(shaka.polyfill,"MCapEncryptionScheme",shaka.polyfill.MCapEncryptionScheme);goog.exportProperty(shaka.polyfill.MCapEncryptionScheme,"install",shaka.polyfill.MCapEncryptionScheme.install);shaka.polyfill.register(shaka.polyfill.MCapEncryptionScheme.install,-2);shaka.polyfill.MediaCapabilities=function(){};shaka.polyfill.MediaCapabilities.install=function(){shaka.device.DeviceFactory.getDevice().supportsMediaCapabilities()?shaka.log.info("MediaCapabilities: Native mediaCapabilities support found."):(shaka.log.info("MediaCapabilities: install"),navigator.mediaCapabilities||(navigator.mediaCapabilities={}),shaka.polyfill.MediaCapabilities.originalMcap=navigator.mediaCapabilities,navigator.mediaCapabilities.decodingInfo=shaka.polyfill.MediaCapabilities.decodingInfo_)};
shaka.polyfill.MediaCapabilities.decodingInfo_=function(a){var b,c,d,e,f,g,h,k,l,m,n,p;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(q){switch(q.getNextAddressJsc()){case 1:b={supported:!1,powerEfficient:!0,smooth:!0,keySystemAccess:null,configuration:a};c=shaka.device.DeviceFactory.getDevice();d=a.video;e=a.audio;if(a.type!="media-source"){if(a.type=="file"){if(d&&(f=d.contentType,g=c.supportsMediaType(f),!g)||e&&(h=e.contentType,k=c.supportsMediaType(h),!k))return q.return(b)}else return q.return(b);
q.jumpTo(2);break}if(!c.supportsMediaSource())return q.return(b);if(!d){q.jumpTo(3);break}return q.yield(shaka.polyfill.MediaCapabilities.checkVideoSupport_(d),4);case 4:if(l=q.getYieldResultJsc(),!l)return q.return(b);case 3:if(!e){q.jumpTo(2);break}return q.yield(shaka.polyfill.MediaCapabilities.checkAudioSupport_(e),6);case 6:if(m=q.getYieldResultJsc(),!m)return q.return(b);case 2:if(!a.keySystemConfiguration)return b.supported=!0,q.return(b);n=a.keySystemConfiguration;return q.yield(shaka.polyfill.MediaCapabilities.checkDrmSupport_(d,
e,n),8);case 8:if(p=q.getYieldResultJsc())b.supported=!0,b.keySystemAccess=p;case 7:return q.return(b)}})};
shaka.polyfill.MediaCapabilities.checkVideoSupport_=function(a){var b,c,d;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(e){return e.getNextAddressJsc()==1?(b=shaka.device.DeviceFactory.getDevice(),c=b.getDeviceType(),c!==shaka.device.IDevice.DeviceType.CAST?e.jumpTo(2):e.yield(shaka.polyfill.MediaCapabilities.canCastDisplayType_(a),3)):e.getNextAddressJsc()!=2?(d=e.getYieldResultJsc(),e.return(d)):e.return(shaka.media.Capabilities.isTypeSupported(a.contentType))})};
shaka.polyfill.MediaCapabilities.checkAudioSupport_=function(a){var b,c,d,e,f;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(g){switch(g.getNextAddressJsc()){case 1:b=shaka.device.DeviceFactory.getDevice();c=b.getDeviceType();d=a.contentType;if(c!==shaka.device.IDevice.DeviceType.CAST||!a.spatialRendering){g.jumpTo(2);break}d+="; spatialRendering=true";if(!(window.cast&&cast.__platform__&&cast.__platform__.canDisplayType)){g.jumpTo(2);break}e=!1;f=shaka.polyfill.MediaCapabilities.memoizedCanDisplayTypeRequests_;
if(f.has(d)){e=f.get(d);g.jumpTo(4);break}return g.yield(cast.__platform__.canDisplayType(d),5);case 5:e=g.getYieldResultJsc(),f.set(d,e);case 4:return g.return(e);case 2:return g.return(shaka.media.Capabilities.isTypeSupported(d))}})};
shaka.polyfill.MediaCapabilities.checkDrmSupport_=function(a,b,c){var d,e,f,g,h,k,l,m,n,p,q,r,t;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(u){switch(u.getNextAddressJsc()){case 1:d=shaka.util.MimeUtils;e=[];f=[];g=[];c.audio&&(h={robustness:c.audio.robustness||"",contentType:b.contentType},shaka.device.DeviceFactory.getDevice().misreportAC3UsingDrm()&&b.contentType.includes('codecs="ac-3"')&&(h.contentType='audio/mp4; codecs="ec-3"'),c.audio.encryptionScheme&&(h.encryptionScheme=
c.audio.encryptionScheme,g.push(c.audio.encryptionScheme)),e.push(h));c.video&&(k={robustness:c.video.robustness||"",contentType:a.contentType},c.video.encryptionScheme&&(k.encryptionScheme=c.video.encryptionScheme,g.push(c.video.encryptionScheme)),f.push(k));l={initDataTypes:[c.initDataType],distinctiveIdentifier:c.distinctiveIdentifier,persistentState:c.persistentState,sessionTypes:c.sessionTypes};e.length&&(l.audioCapabilities=e);f.length&&(l.videoCapabilities=f);m=a?a.contentType:"";n=b?b.contentType:
"";p=d.getBasicType(m)+";"+d.getCodecBase(m);q=d.getBasicType(n)+";"+d.getCodecBase(n);r=c.keySystem;t=null;u.setCatchFinallyBlocks(2);if(shaka.drm.DrmUtils.hasMediaKeySystemAccess(p,q,r,g)){t=shaka.drm.DrmUtils.getMediaKeySystemAccess(p,q,r,g);u.jumpTo(4);break}return u.yield(navigator.requestMediaKeySystemAccess(c.keySystem,[l]),5);case 5:t=u.getYieldResultJsc(),shaka.drm.DrmUtils.setMediaKeySystemAccess(p,q,r,g,t);case 4:u.leaveTryBlock(3);break;case 2:u.enterCatchBlock(),shaka.log.info("navigator.requestMediaKeySystemAccess failed.");
case 3:return u.return(t)}})};
shaka.polyfill.MediaCapabilities.canCastDisplayType_=function(a){var b,c,d,e,f;return(0,$jscomp.asyncExecutePromiseGeneratorProgram)(function(g){if(g.getNextAddressJsc()==1){if(!(window.cast&&cast.__platform__&&cast.__platform__.canDisplayType))return shaka.log.warning("Expected cast APIs to be available! Falling back to shaka.media.Capabilities.isTypeSupported() for type support."),g.return(shaka.media.Capabilities.isTypeSupported(a.contentType));b=a.contentType;a.width&&a.height&&a.width>1280&&
a.height>720&&(b+="; width="+a.width+"; height="+a.height);a.framerate&&(c=Math.round(a.framerate),c<24||c>30)&&(b+="; framerate="+a.framerate);d=a.transferFunction||"";switch(d){case "":case "srgb":break;case "pq":b+="; eotf=smpte2084";break;case "hlg":b+="; eotf=arib-std-b67";break;default:return g.return(!1)}e=!1;f=shaka.polyfill.MediaCapabilities.memoizedCanDisplayTypeRequests_;return f.has(b)?(e=f.get(b),g.jumpTo(2)):g.yield(cast.__platform__.canDisplayType(b),3)}g.getNextAddressJsc()!=2&&(e=
g.getYieldResultJsc(),f.set(b,e));return g.return(e)})};goog.exportProperty(shaka.polyfill,"MediaCapabilities",shaka.polyfill.MediaCapabilities);goog.exportProperty(shaka.polyfill.MediaCapabilities,"install",shaka.polyfill.MediaCapabilities.install);shaka.polyfill.MediaCapabilities.originalMcap=null;goog.exportProperty(shaka.polyfill.MediaCapabilities,"originalMcap",shaka.polyfill.MediaCapabilities.originalMcap);shaka.polyfill.MediaCapabilities.memoizedCanDisplayTypeRequests_=new Map;
shaka.polyfill.register(shaka.polyfill.MediaCapabilities.install,-1);shaka.polyfill.MediaSource=function(){};
shaka.polyfill.MediaSource.install=function(){shaka.log.debug("MediaSource.install");var a=shaka.device.IDevice.BrowserEngine,b=shaka.device.DeviceFactory.getDevice();a=b.getBrowserEngine()===a.WEBKIT?b.getVersion():null;window.MediaSource||window.ManagedMediaSource?a&&window.MediaSource?a<=12?(shaka.log.info("Patching Safari 8-12 MSE bugs."),shaka.polyfill.MediaSource.stubAbort_(),shaka.polyfill.MediaSource.patchRemovalRange_()):a<=15&&(shaka.log.info("Patching Safari 13 & 14 & 15 MSE bugs."),shaka.polyfill.MediaSource.stubAbort_()):
shaka.log.info("Using native MSE as-is."):shaka.log.info("No MSE implementation available.");b=(0,$jscomp.makeIterator)(b.rejectCodecs());for(a=b.next();!a.done;a=b.next())a=a.value,shaka.log.info("Rejecting "+a+"."),shaka.polyfill.MediaSource.rejectCodec_(a);(window.MediaSource||window.ManagedMediaSource)&&shaka.polyfill.MediaSource.rejectContainer_("mp2t");window.MediaSource&&MediaSource.isTypeSupported('video/webm; codecs="vp9"')&&!MediaSource.isTypeSupported('video/webm; codecs="vp09.00.10.08"')&&
(shaka.log.info("Patching vp09 support queries."),shaka.polyfill.MediaSource.patchVp09_())};shaka.polyfill.MediaSource.stubAbort_=function(){var a=MediaSource.prototype.addSourceBuffer;MediaSource.prototype.addSourceBuffer=function(){var b=$jscomp.getRestArguments.apply(0,arguments);b=a.apply(this,b);b.abort=function(){};return b}};shaka.polyfill.MediaSource.patchRemovalRange_=function(){var a=SourceBuffer.prototype.remove;SourceBuffer.prototype.remove=function(b,c){return a.call(this,b,c-.001)}};
shaka.polyfill.MediaSource.rejectContainer_=function(a){if(window.MediaSource){var b=MediaSource.isTypeSupported.bind(MediaSource);MediaSource.isTypeSupported=function(d){return shaka.util.MimeUtils.getContainerType(d)!=a&&b(d)}}if(window.ManagedMediaSource){var c=ManagedMediaSource.isTypeSupported.bind(ManagedMediaSource);window.ManagedMediaSource.isTypeSupported=function(d){return shaka.util.MimeUtils.getContainerType(d)!=a&&c(d)}}};
shaka.polyfill.MediaSource.rejectCodec_=function(a){var b=MediaSource.isTypeSupported.bind(MediaSource);MediaSource.isTypeSupported=function(d){return shaka.util.MimeUtils.getCodecBase(d)!=a&&b(d)};if(window.ManagedMediaSource){var c=ManagedMediaSource.isTypeSupported.bind(ManagedMediaSource);window.ManagedMediaSource.isTypeSupported=function(d){return shaka.util.MimeUtils.getCodecBase(d)!=a&&c(d)}}};
shaka.polyfill.MediaSource.patchVp09_=function(){var a=MediaSource.isTypeSupported;shaka.device.DeviceFactory.getDevice().supportStandardVP9Checking()&&(MediaSource.isTypeSupported=function(b){var c=b.split(/ *; */),d=c.findIndex(function(g){return g.startsWith("codecs=")});if(d<0)return a(b);var e=c[d].replace("codecs=","").replace(/"/g,"").split(/\s*,\s*/),f=e.findIndex(function(g){return g.startsWith("vp09")});f>=0&&(e[f]="vp9",c[d]='codecs="'+e.join(",")+'"',b=c.join("; "));return a(b)})};
goog.exportProperty(shaka.polyfill,"MediaSource",shaka.polyfill.MediaSource);goog.exportProperty(shaka.polyfill.MediaSource,"install",shaka.polyfill.MediaSource.install);shaka.polyfill.register(shaka.polyfill.MediaSource.install);shaka.polyfill.PatchedMediaKeysApple=function(){};shaka.polyfill.PatchedMediaKeysApple.defaultInstall=function(){window.HTMLVideoElement&&window.WebKitMediaKeys&&(navigator.requestMediaKeySystemAccess&&MediaKeySystemAccess.prototype.getConfiguration||shaka.polyfill.PatchedMediaKeysApple.install())};
shaka.polyfill.PatchedMediaKeysApple.install=function(a){var b=shaka.polyfill.PatchedMediaKeysApple;if(window.HTMLVideoElement&&window.WebKitMediaKeys&&window.shakaMediaKeysPolyfill!=b.apiName_){if(a===void 0?0:a)b.enableUninstall=!0,b.originalHTMLMediaElementPrototypeMediaKeys=Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype,"mediaKeys"),b.originalHTMLMediaElementPrototypeSetMediaKeys=HTMLMediaElement.prototype.setMediaKeys,b.originalWindowMediaKeys=window.MediaKeys,b.originalWindowMediaKeySystemAccess=
window.MediaKeySystemAccess,b.originalNavigatorRequestMediaKeySystemAccess=navigator.requestMediaKeySystemAccess;shaka.log.info("Using Apple-prefixed EME");delete HTMLMediaElement.prototype.mediaKeys;HTMLMediaElement.prototype.mediaKeys=null;HTMLMediaElement.prototype.setMediaKeys=b.setMediaKeys;window.MediaKeys=b.MediaKeys;window.MediaKeySystemAccess=b.MediaKeySystemAccess;navigator.requestMediaKeySystemAccess=b.requestMediaKeySystemAccess;window.shakaMediaKeysPolyfill=b.apiName_;shaka.util.StreamUtils.clearDecodingConfigCache();
shaka.drm.DrmUtils.clearMediaKeySystemAccessMap()}};
shaka.polyfill.PatchedMediaKeysApple.uninstall=function(){var a=shaka.polyfill.PatchedMediaKeysApple;window.shakaMediaKeysPolyfill==a.apiName_&&a.enableUninstall&&(shaka.log.info("Un-installing Apple-prefixed EME"),a.enableUninstall=!1,Object.defineProperty(HTMLMediaElement.prototype,"mediaKeys",a.originalHTMLMediaElementPrototypeMediaKeys),HTMLMediaElement.prototype.setMediaKeys=a.originalHTMLMediaElementPrototypeSetMediaKeys,window.MediaKeys=a.originalWindowMediaKeys,window.MediaKeySystemAccess=
a.originalWindowMediaKeySystemAccess,navigator.requestMediaKeySystemAccess=a.originalNavigatorRequestMediaKeySystemAccess,a.originalWindowMediaKeys=null,a.originalWindowMediaKeySystemAccess=null,a.originalHTMLMediaElementPrototypeSetMediaKeys=null,a.originalNavigatorRequestMediaKeySystemAccess=null,a.originalHTMLMediaElementPrototypeMediaKeys=null,window.shakaMediaKeysPolyfill="",shaka.util.StreamUtils.clearDecodingConfigCache(),shaka.drm.DrmUtils.clearMediaKeySystemAccessMap())};
shaka.polyfill.PatchedMediaKeysApple.requestMediaKeySystemAccess=function(a,b){shaka.log.debug("PatchedMediaKeysApple.requestMediaKeySystemAccess");goog.asserts.assert(this==navigator,'bad "this" for requestMediaKeySystemAccess');var c=shaka.polyfill.PatchedMediaKeysApple;try{var d=new c.MediaKeySystemAccess(a,b);return Promise.resolve(d)}catch(e){return Promise.reject(e)}};
shaka.polyfill.PatchedMediaKeysApple.setMediaKeys=function(a){shaka.log.debug("PatchedMediaKeysApple.setMediaKeys");goog.asserts.assert(this instanceof HTMLMediaElement,'bad "this" for setMediaKeys');var b=shaka.polyfill.PatchedMediaKeysApple,c=this.mediaKeys;c&&c!=a&&(goog.asserts.assert(c instanceof b.MediaKeys,"non-polyfill instance of oldMediaKeys"),c.setMedia(null));delete this.mediaKeys;return(this.mediaKeys=a)?(goog.asserts.assert(a instanceof b.MediaKeys,"non-polyfill instance of newMediaKeys"),
a.setMedia(this)):Promise.resolve()};
shaka.polyfill.PatchedMediaKeysApple.onWebkitNeedKey_=function(a){shaka.log.debug("PatchedMediaKeysApple.onWebkitNeedKey_",a);goog.asserts.assert(this.mediaKeys instanceof shaka.polyfill.PatchedMediaKeysApple.MediaKeys,"non-polyfill instance of newMediaKeys");goog.asserts.assert(a.initData!=null,"missing init data!");a=shaka.util.BufferUtils.toUint8(a.initData);if(shaka.util.BufferUtils.toDataView(a).getUint32(0,!0)+4!=a.byteLength)throw new RangeError("Malformed FairPlay init data");a=shaka.util.StringUtils.fromUTF16(a.subarray(4),
!0);a=shaka.util.StringUtils.toUTF8(a);var b=new Event("encrypted");b.initDataType="skd";b.initData=shaka.util.BufferUtils.toArrayBuffer(a);this.dispatchEvent(b)};goog.exportProperty(shaka.polyfill,"PatchedMediaKeysApple",shaka.polyfill.PatchedMediaKeysApple);goog.exportProperty(shaka.polyfill.PatchedMediaKeysApple,"uninstall",shaka.polyfill.PatchedMediaKeysApple.uninstall);goog.exportProperty(shaka.polyfill.PatchedMediaKeysApple,"install",shaka.polyfill.PatchedMediaKeysApple.install);
shaka.polyfill.PatchedMediaKeysApple.MediaKeySystemAccess=function(a,b){shaka.log.debug("PatchedMediaKeysApple.MediaKeySystemAccess");this.keySystem=a;if(a.startsWith("com.apple.fps"))for(a=(0,$jscomp.makeIterator)(b),b=a.next();!b.done;b=a.next())if(b=this.checkConfig_(b.value)){this.configuration_=b;return}a=Error("Unsupported keySystem");a.name="NotSupportedError";a.code=DOMException.NOT_SUPPORTED_ERR;throw a;};
shaka.polyfill.PatchedMediaKeysApple.MediaKeySystemAccess.prototype.checkConfig_=function(a){if(a.persistentState=="required")return null;var b={audioCapabilities:[],videoCapabilities:[],persistentState:"optional",distinctiveIdentifier:"optional",initDataTypes:a.initDataTypes,sessionTypes:["temporary"],label:a.label},c=!1,d=!1;if(a.audioCapabilities)for(var e=(0,$jscomp.makeIterator)(a.audioCapabilities),f=e.next();!f.done;f=e.next())if(f=f.value,f.contentType){c=!0;var g=f.contentType.split(";")[0];
WebKitMediaKeys.isTypeSupported(this.keySystem,g)&&(b.audioCapabilities.push(f),d=!0)}if(a.videoCapabilities)for(a=(0,$jscomp.makeIterator)(a.videoCapabilities),e=a.next();!e.done;e=a.next())e=e.value,e.contentType&&(c=!0,f=e.contentType.split(";")[0],WebKitMediaKeys.isTypeSupported(this.keySystem,f)&&(b.videoCapabilities.push(e),d=!0));c||(d=WebKitMediaKeys.isTypeSupported(this.keySystem,"video/mp4"));return d?b:null};
shaka.polyfill.PatchedMediaKeysApple.MediaKeySystemAccess.prototype.createMediaKeys=function(){shaka.log.debug("PatchedMediaKeysApple.MediaKeySystemAccess.createMediaKeys");var a=new shaka.polyfill.PatchedMediaKeysApple.MediaKeys(this.keySystem);return Promise.resolve(a)};shaka.polyfill.PatchedMediaKeysApple.MediaKeySystemAccess.prototype.getConfiguration=function(){shaka.log.debug("PatchedMediaKeysApple.MediaKeySystemAccess.getConfiguration");return this.configuration_};
shaka.polyfill.PatchedMediaKeysApple.MediaKeys=function(a){shaka.log.debug("PatchedMediaKeysApple.MediaKeys");this.nativeMediaKeys_=new WebKitMediaKeys(a);this.eventManager_=new shaka.util.EventManager};
shaka.polyfill.PatchedMediaKeysApple.MediaKeys.prototype.createSession=function(a){shaka.log.debug("PatchedMediaKeysApple.MediaKeys.createSession");a=a||"temporary";if(a!="temporary")throw new TypeError("Session type "+a+" is unsupported on this platform.");return new shaka.polyfill.PatchedMediaKeysApple.MediaKeySession(this.nativeMediaKeys_,a)};
shaka.polyfill.PatchedMediaKeysApple.MediaKeys.prototype.setServerCertificate=function(a){shaka.log.debug("PatchedMediaKeysApple.MediaKeys.setServerCertificate");return Promise.resolve(!1)};
shaka.polyfill.PatchedMediaKeysApple.MediaKeys.prototype.setMedia=function(a){var b=this,c=shaka.polyfill.PatchedMediaKeysApple;this.eventManager_.removeAll();if(!a)return Promise.resolve();this.eventManager_.listen(a,"webkitneedkey",c.onWebkitNeedKey_);try{return shaka.util.MediaReadyState.waitForReadyState(a,HTMLMediaElement.HAVE_METADATA,this.eventManager_,function(){a.webkitSetMediaKeys(b.nativeMediaKeys_)}),Promise.resolve()}catch(d){return Promise.reject(d)}};
shaka.polyfill.PatchedMediaKeysApple.MediaKeys.prototype.getStatusForPolicy=function(a){return Promise.resolve("usable")};
shaka.polyfill.PatchedMediaKeysApple.MediaKeySession=function(a,b){shaka.log.debug("PatchedMediaKeysApple.MediaKeySession");shaka.util.FakeEventTarget.call(this);this.nativeMediaKeySession_=null;this.nativeMediaKeys_=a;this.updatePromise_=this.generateRequestPromise_=null;this.eventManager_=new shaka.util.EventManager;this.sessionId="";this.expiration=NaN;this.closed=new shaka.util.PublicPromise;this.keyStatuses=new shaka.polyfill.PatchedMediaKeysApple.MediaKeyStatusMap;this.onkeystatuseschange=null};
$jscomp.inherits(shaka.polyfill.PatchedMediaKeysApple.MediaKeySession,shaka.util.FakeEventTarget);
shaka.polyfill.PatchedMediaKeysApple.MediaKeySession.prototype.generateRequest=function(a,b){var c=this;shaka.log.debug("PatchedMediaKeysApple.MediaKeySession.generateRequest");this.generateRequestPromise_=new shaka.util.PublicPromise;try{var d=this.nativeMediaKeys_.createSession("video/mp4",shaka.util.BufferUtils.toUint8(b));this.nativeMediaKeySession_=d;this.sessionId=d.sessionId||"";this.eventManager_.listen(this.nativeMediaKeySession_,"webkitkeymessage",function(e){return c.onWebkitKeyMessage_(e)});
this.eventManager_.listen(d,"webkitkeyadded",function(e){return c.onWebkitKeyAdded_(e)});this.eventManager_.listen(d,"webkitkeyerror",function(e){return c.onWebkitKeyError_(e)});this.updateKeyStatus_("status-pending")}catch(e){this.generateRequestPromise_.reject(e)}return this.generateRequestPromise_};shaka.polyfill.PatchedMediaKeysApple.MediaKeySession.prototype.load=function(){shaka.log.debug("PatchedMediaKeysApple.MediaKeySession.load");return Promise.reject(Error("MediaKeySession.load not yet supported"))};
shaka.polyfill.PatchedMediaKeysApple.MediaKeySession.prototype.update=function(a){shaka.log.debug("PatchedMediaKeysApple.MediaKeySession.update");this.updatePromise_=new shaka.util.PublicPromise;try{this.nativeMediaKeySession_.update(shaka.util.BufferUtils.toUint8(a))}catch(b){this.updatePromise_.reject(b)}return this.updatePromise_};
shaka.polyfill.PatchedMediaKeysApple.MediaKeySession.prototype.close=function(){shaka.log.debug("PatchedMediaKeysApple.MediaKeySession.close");try{this.nativeMediaKeySession_.close(),this.closed.resolve(),this.eventManager_.removeAll()}catch(a){this.closed.reject(a)}return this.closed};shaka.polyfill.PatchedMediaKeysApple.MediaKeySession.prototype.remove=function(){shaka.log.debug("PatchedMediaKeysApple.MediaKeySession.remove");return Promise.reject(Error("MediaKeySession.remove is only applicable for persistent licenses, which are not supported on this platform"))};
shaka.polyfill.PatchedMediaKeysApple.MediaKeySession.prototype.onWebkitKeyMessage_=function(a){shaka.log.debug("PatchedMediaKeysApple.onWebkitKeyMessage_",a);goog.asserts.assert(this.generateRequestPromise_,"generateRequestPromise_ should be set before now!");this.generateRequestPromise_&&(this.generateRequestPromise_.resolve(),this.generateRequestPromise_=null);var b=this.keyStatuses.getStatus()==void 0;a=(new Map).set("messageType",b?"license-request":"license-renewal").set("message",shaka.util.BufferUtils.toArrayBuffer(a.message));
a=new shaka.util.FakeEvent("message",a);this.dispatchEvent(a)};shaka.polyfill.PatchedMediaKeysApple.MediaKeySession.prototype.onWebkitKeyAdded_=function(a){shaka.log.debug("PatchedMediaKeysApple.onWebkitKeyAdded_",a);goog.asserts.assert(!this.generateRequestPromise_,"Key added during generate!");goog.asserts.assert(this.updatePromise_,"updatePromise_ should be set before now!");this.updatePromise_&&(this.updateKeyStatus_("usable"),this.updatePromise_.resolve(),this.updatePromise_=null)};
shaka.polyfill.PatchedMediaKeysApple.MediaKeySession.prototype.onWebkitKeyError_=function(a){shaka.log.debug("PatchedMediaKeysApple.onWebkitKeyError_",a);a=Error("EME PatchedMediaKeysApple key error");a.errorCode=this.nativeMediaKeySession_.error;if(this.generateRequestPromise_!=null)this.generateRequestPromise_.reject(a),this.generateRequestPromise_=null;else if(this.updatePromise_!=null)this.updatePromise_.reject(a),this.updatePromise_=null;else switch(this.nativeMediaKeySession_.error.code){case WebKitMediaKeyError.MEDIA_KEYERR_OUTPUT:case WebKitMediaKeyError.MEDIA_KEYERR_HARDWARECHANGE:this.updateKeyStatus_("output-not-allowed");
break;default:this.updateKeyStatus_("internal-error")}};shaka.polyfill.PatchedMediaKeysApple.MediaKeySession.prototype.updateKeyStatus_=function(a){this.keyStatuses.setStatus(a);a=new shaka.util.FakeEvent("keystatuseschange");this.dispatchEvent(a);if(this.onkeystatuseschange)this.onkeystatuseschange(a)};shaka.polyfill.PatchedMediaKeysApple.MediaKeyStatusMap=function(){this.size=0;this.status_=void 0};
shaka.polyfill.PatchedMediaKeysApple.MediaKeyStatusMap.prototype.setStatus=function(a){this.size=a==void 0?0:1;this.status_=a};shaka.polyfill.PatchedMediaKeysApple.MediaKeyStatusMap.prototype.getStatus=function(){return this.status_};shaka.polyfill.PatchedMediaKeysApple.MediaKeyStatusMap.prototype.forEach=function(a){this.status_&&a(this.status_,shaka.drm.DrmUtils.DUMMY_KEY_ID.value())};shaka.polyfill.PatchedMediaKeysApple.MediaKeyStatusMap.prototype.get=function(a){if(this.has(a))return this.status_};
shaka.polyfill.PatchedMediaKeysApple.MediaKeyStatusMap.prototype.has=function(a){var b=shaka.drm.DrmUtils.DUMMY_KEY_ID.value();return this.status_&&shaka.util.BufferUtils.equal(a,b)?!0:!1};shaka.polyfill.PatchedMediaKeysApple.MediaKeyStatusMap.prototype.entries=function(){goog.asserts.assert(!1,"Not used!  Provided only for the compiler.")};shaka.polyfill.PatchedMediaKeysApple.MediaKeyStatusMap.prototype.keys=function(){goog.asserts.assert(!1,"Not used!  Provided only for the compiler.")};
shaka.polyfill.PatchedMediaKeysApple.MediaKeyStatusMap.prototype.values=function(){goog.asserts.assert(!1,"Not used!  Provided only for the compiler.")};shaka.polyfill.PatchedMediaKeysApple.apiName_="apple";shaka.polyfill.register(shaka.polyfill.PatchedMediaKeysApple.defaultInstall);shaka.polyfill.PatchedMediaKeysCert=function(){};shaka.polyfill.PatchedMediaKeysCert.install=function(){if(window.MediaKeys){var a=shaka.device.DeviceFactory.getDevice();MediaKeys.prototype.setServerCertificate&&a.supportsServerCertificate()||(shaka.log.info("Patching MediaKeys.setServerCertificate"),MediaKeys.prototype.setServerCertificate=shaka.polyfill.PatchedMediaKeysCert.setServerCertificate_)}};
shaka.polyfill.PatchedMediaKeysCert.setServerCertificate_=function(a){shaka.log.debug("PatchedMediaKeysCert.setServerCertificate");return Promise.resolve(!1)};goog.exportProperty(shaka.polyfill,"PatchedMediaKeysCert",shaka.polyfill.PatchedMediaKeysCert);goog.exportProperty(shaka.polyfill.PatchedMediaKeysCert,"install",shaka.polyfill.PatchedMediaKeysCert.install);shaka.polyfill.register(shaka.polyfill.PatchedMediaKeysCert.install);shaka.polyfill.PatchedMediaKeysWebkit=function(){};
shaka.polyfill.PatchedMediaKeysWebkit.install=function(){var a=shaka.polyfill.PatchedMediaKeysWebkit;if(!(!window.HTMLVideoElement||navigator.requestMediaKeySystemAccess&&MediaKeySystemAccess.prototype.getConfiguration)){if(HTMLMediaElement.prototype.webkitGenerateKeyRequest)shaka.log.info("Using webkit-prefixed EME v0.1b"),a.prefix_="webkit";else if(HTMLMediaElement.prototype.generateKeyRequest)shaka.log.info("Using nonprefixed EME v0.1b");else return;goog.asserts.assert(HTMLMediaElement.prototype[a.prefixApi_("generateKeyRequest")],
"PatchedMediaKeysWebkit APIs not available!");navigator.requestMediaKeySystemAccess=a.requestMediaKeySystemAccess;delete HTMLMediaElement.prototype.mediaKeys;HTMLMediaElement.prototype.mediaKeys=null;HTMLMediaElement.prototype.setMediaKeys=a.setMediaKeys;window.MediaKeys=a.MediaKeys;window.MediaKeySystemAccess=a.MediaKeySystemAccess;window.shakaMediaKeysPolyfill=a.apiName_}};
shaka.polyfill.PatchedMediaKeysWebkit.prefixApi_=function(a){var b=shaka.polyfill.PatchedMediaKeysWebkit.prefix_;return b?b+a.charAt(0).toUpperCase()+a.slice(1):a};shaka.polyfill.PatchedMediaKeysWebkit.requestMediaKeySystemAccess=function(a,b){shaka.log.debug("PatchedMediaKeysWebkit.requestMediaKeySystemAccess");goog.asserts.assert(this==navigator,'bad "this" for requestMediaKeySystemAccess');var c=shaka.polyfill.PatchedMediaKeysWebkit;try{var d=new c.MediaKeySystemAccess(a,b);return Promise.resolve(d)}catch(e){return Promise.reject(e)}};
shaka.polyfill.PatchedMediaKeysWebkit.setMediaKeys=function(a){shaka.log.debug("PatchedMediaKeysWebkit.setMediaKeys");goog.asserts.assert(this instanceof HTMLMediaElement,'bad "this" for setMediaKeys');var b=shaka.polyfill.PatchedMediaKeysWebkit,c=this.mediaKeys;c&&c!=a&&(goog.asserts.assert(c instanceof b.MediaKeys,"non-polyfill instance of oldMediaKeys"),c.setMedia(null));delete this.mediaKeys;if(this.mediaKeys=a)goog.asserts.assert(a instanceof b.MediaKeys,"non-polyfill instance of newMediaKeys"),
a.setMedia(this);return Promise.resolve()};shaka.polyfill.PatchedMediaKeysWebkit.getVideoElement_=function(){var a=document.getElementsByTagName("video");return a.length?a[0]:document.createElement("video")};goog.exportProperty(shaka.polyfill,"PatchedMediaKeysWebkit",shaka.polyfill.PatchedMediaKeysWebkit);goog.exportProperty(shaka.polyfill.PatchedMediaKeysWebkit,"install",shaka.polyfill.PatchedMediaKeysWebkit.install);
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeySystemAccess=function(a,b){shaka.log.debug("PatchedMediaKeysWebkit.MediaKeySystemAccess");this.internalKeySystem_=this.keySystem=a;var c=!1;a=="org.w3.clearkey"&&(this.internalKeySystem_="webkit-org.w3.clearkey",c=!1);var d=!1,e=shaka.polyfill.PatchedMediaKeysWebkit.getVideoElement_();b=(0,$jscomp.makeIterator)(b);for(var f=b.next();!f.done;f=b.next()){f=f.value;var g={audioCapabilities:[],videoCapabilities:[],persistentState:"optional",distinctiveIdentifier:"optional",
initDataTypes:f.initDataTypes,sessionTypes:["temporary"],label:f.label},h=!1;if(f.audioCapabilities)for(var k=(0,$jscomp.makeIterator)(f.audioCapabilities),l=k.next();!l.done;l=k.next())if(l=l.value,l.contentType){h=!0;var m=l.contentType.split(";")[0];e.canPlayType(m,this.internalKeySystem_)&&(g.audioCapabilities.push(l),d=!0)}if(f.videoCapabilities)for(k=(0,$jscomp.makeIterator)(f.videoCapabilities),l=k.next();!l.done;l=k.next())l=l.value,l.contentType&&(h=!0,e.canPlayType(l.contentType,this.internalKeySystem_)&&
(g.videoCapabilities.push(l),d=!0));h||(d=e.canPlayType("video/mp4",this.internalKeySystem_)||e.canPlayType("video/webm",this.internalKeySystem_));f.persistentState=="required"&&(c?(g.persistentState="required",g.sessionTypes=["persistent-license"]):d=!1);if(d){this.configuration_=g;return}}c="Unsupported keySystem";if(a=="org.w3.clearkey"||a=="com.widevine.alpha")c="None of the requested configurations were supported.";a=Error(c);a.name="NotSupportedError";a.code=DOMException.NOT_SUPPORTED_ERR;throw a;
};shaka.polyfill.PatchedMediaKeysWebkit.MediaKeySystemAccess.prototype.createMediaKeys=function(){shaka.log.debug("PatchedMediaKeysWebkit.MediaKeySystemAccess.createMediaKeys");var a=new shaka.polyfill.PatchedMediaKeysWebkit.MediaKeys(this.internalKeySystem_);return Promise.resolve(a)};shaka.polyfill.PatchedMediaKeysWebkit.MediaKeySystemAccess.prototype.getConfiguration=function(){shaka.log.debug("PatchedMediaKeysWebkit.MediaKeySystemAccess.getConfiguration");return this.configuration_};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeys=function(a){shaka.log.debug("PatchedMediaKeysWebkit.MediaKeys");this.keySystem_=a;this.media_=null;this.eventManager_=new shaka.util.EventManager;this.newSessions_=[];this.sessionMap_=new Map};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeys.prototype.setMedia=function(a){var b=this;this.media_=a;this.eventManager_.removeAll();var c=shaka.polyfill.PatchedMediaKeysWebkit.prefix_;a&&(this.eventManager_.listen(a,c+"needkey",function(d){return b.onWebkitNeedKey_(d)}),this.eventManager_.listen(a,c+"keymessage",function(d){return b.onWebkitKeyMessage_(d)}),this.eventManager_.listen(a,c+"keyadded",function(d){return b.onWebkitKeyAdded_(d)}),this.eventManager_.listen(a,c+"keyerror",function(d){return b.onWebkitKeyError_(d)}))};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeys.prototype.createSession=function(a){shaka.log.debug("PatchedMediaKeysWebkit.MediaKeys.createSession");a=a||"temporary";if(a!="temporary"&&a!="persistent-license")throw new TypeError("Session type "+a+" is unsupported on this platform.");var b=shaka.polyfill.PatchedMediaKeysWebkit,c=this.media_||document.createElement("video");c.src||(c.src="about:blank");a=new b.MediaKeySession(c,this.keySystem_,a);this.newSessions_.push(a);return a};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeys.prototype.setServerCertificate=function(a){shaka.log.debug("PatchedMediaKeysWebkit.MediaKeys.setServerCertificate");return Promise.resolve(!1)};shaka.polyfill.PatchedMediaKeysWebkit.MediaKeys.prototype.getStatusForPolicy=function(a){return Promise.resolve("usable")};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeys.prototype.onWebkitNeedKey_=function(a){shaka.log.debug("PatchedMediaKeysWebkit.onWebkitNeedKey_",a);goog.asserts.assert(this.media_,"media_ not set in onWebkitNeedKey_");var b=new CustomEvent("encrypted");b.initDataType="cenc";b.initData=shaka.util.BufferUtils.toArrayBuffer(a.initData);this.media_.dispatchEvent(b)};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeys.prototype.onWebkitKeyMessage_=function(a){shaka.log.debug("PatchedMediaKeysWebkit.onWebkitKeyMessage_",a);var b=this.findSession_(a.sessionId);if(b){var c=b.keyStatuses.getStatus()==void 0;a=(new Map).set("messageType",c?"licenserequest":"licenserenewal").set("message",a.message);a=new shaka.util.FakeEvent("message",a);b.generated();b.dispatchEvent(a)}else shaka.log.error("Session not found",a.sessionId)};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeys.prototype.onWebkitKeyAdded_=function(a){shaka.log.debug("PatchedMediaKeysWebkit.onWebkitKeyAdded_",a);a=this.findSession_(a.sessionId);goog.asserts.assert(a,"unable to find session in onWebkitKeyAdded_");a&&a.ready()};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeys.prototype.onWebkitKeyError_=function(a){shaka.log.debug("PatchedMediaKeysWebkit.onWebkitKeyError_",a);var b=this.findSession_(a.sessionId);goog.asserts.assert(b,"unable to find session in onWebkitKeyError_");b&&b.handleError(a)};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeys.prototype.findSession_=function(a){var b=this.sessionMap_.get(a);return b?(shaka.log.debug("PatchedMediaKeysWebkit.MediaKeys.findSession_",b),b):(b=this.newSessions_.shift())?(b.sessionId=a,this.sessionMap_.set(a,b),shaka.log.debug("PatchedMediaKeysWebkit.MediaKeys.findSession_",b),b):null};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeySession=function(a,b,c){shaka.log.debug("PatchedMediaKeysWebkit.MediaKeySession");shaka.util.FakeEventTarget.call(this);this.media_=a;this.initialized_=!1;this.updatePromise_=this.generatePromise_=null;this.keySystem_=b;this.type_=c;this.sessionId="";this.expiration=NaN;this.closed=new shaka.util.PublicPromise;this.keyStatuses=new shaka.polyfill.PatchedMediaKeysWebkit.MediaKeyStatusMap;this.onkeystatuseschange=null};
$jscomp.inherits(shaka.polyfill.PatchedMediaKeysWebkit.MediaKeySession,shaka.util.FakeEventTarget);shaka.polyfill.PatchedMediaKeysWebkit.MediaKeySession.prototype.generated=function(){shaka.log.debug("PatchedMediaKeysWebkit.MediaKeySession.generated");this.generatePromise_&&(this.generatePromise_.resolve(),this.generatePromise_=null)};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeySession.prototype.ready=function(){shaka.log.debug("PatchedMediaKeysWebkit.MediaKeySession.ready");this.updateKeyStatus_("usable");this.updatePromise_&&this.updatePromise_.resolve();this.updatePromise_=null};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeySession.prototype.handleError=function(a){shaka.log.debug("PatchedMediaKeysWebkit.MediaKeySession.handleError",a);var b=Error("EME v0.1b key error"),c=a.errorCode;c.systemCode=a.systemCode;b.errorCode=c;!a.sessionId&&this.generatePromise_?(a.systemCode==45&&(b.message="Unsupported session type."),this.generatePromise_.reject(b),this.generatePromise_=null):a.sessionId&&this.updatePromise_?(this.updatePromise_.reject(b),this.updatePromise_=null):(b=a.systemCode,
a.errorCode.code==MediaKeyError.MEDIA_KEYERR_OUTPUT?this.updateKeyStatus_("output-restricted"):b==1?this.updateKeyStatus_("expired"):this.updateKeyStatus_("internal-error"))};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeySession.prototype.generate_=function(a,b){var c=this,d=shaka.polyfill.PatchedMediaKeysWebkit;if(this.initialized_)return Promise.reject(Error("The session is already initialized."));this.initialized_=!0;try{if(this.type_=="persistent-license"){var e=shaka.util.StringUtils;if(b)var f=shaka.util.BufferUtils.toUint8(e.toUTF8("LOAD_SESSION|"+b));else{goog.asserts.assert(a,"expecting init data");var g=e.toUTF8("PERSISTENT|");f=shaka.util.Uint8ArrayUtils.concat(g,
a)}}else goog.asserts.assert(this.type_=="temporary","expected temporary session"),goog.asserts.assert(!b,"unexpected offline session ID"),goog.asserts.assert(a,"expecting init data"),f=shaka.util.BufferUtils.toUint8(a);goog.asserts.assert(f,"init data not set!")}catch(k){return Promise.reject(k)}goog.asserts.assert(this.generatePromise_==null,"generatePromise_ should be null");this.generatePromise_=new shaka.util.PublicPromise;var h=d.prefixApi_("generateKeyRequest");try{this.media_[h](this.keySystem_,
f)}catch(k){if(k.name!="InvalidStateError")return this.generatePromise_=null,Promise.reject(k);(new shaka.util.Timer(function(){try{c.media_[h](c.keySystem_,f)}catch(l){c.generatePromise_.reject(l),c.generatePromise_=null}})).tickAfter(.01)}return this.generatePromise_};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeySession.prototype.update_=function(a,b){var c=this,d=shaka.polyfill.PatchedMediaKeysWebkit;if(this.updatePromise_)this.updatePromise_.then(function(){return c.update_(a,b)}).catch(function(){return c.update_(a,b)});else{this.updatePromise_=a;if(this.keySystem_=="webkit-org.w3.clearkey"){var e=shaka.util.Uint8ArrayUtils;var f=shaka.util.StringUtils.fromUTF8(b);var g=JSON.parse(f);g.keys[0].kty!="oct"&&(this.updatePromise_.reject(Error("Response is not a valid JSON Web Key Set.")),
this.updatePromise_=null);f=e.fromBase64(g.keys[0].k);e=e.fromBase64(g.keys[0].kid)}else f=shaka.util.BufferUtils.toUint8(b),e=null;d=d.prefixApi_("addKey");try{this.media_[d](this.keySystem_,f,e,this.sessionId)}catch(h){this.updatePromise_.reject(h),this.updatePromise_=null}}};shaka.polyfill.PatchedMediaKeysWebkit.MediaKeySession.prototype.updateKeyStatus_=function(a){this.keyStatuses.setStatus(a);a=new shaka.util.FakeEvent("keystatuseschange");this.dispatchEvent(a);if(this.onkeystatuseschange)this.onkeystatuseschange(a)};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeySession.prototype.generateRequest=function(a,b){shaka.log.debug("PatchedMediaKeysWebkit.MediaKeySession.generateRequest");return this.generate_(b,null)};shaka.polyfill.PatchedMediaKeysWebkit.MediaKeySession.prototype.load=function(a){shaka.log.debug("PatchedMediaKeysWebkit.MediaKeySession.load");return this.type_=="persistent-license"?this.generate_(null,a):Promise.reject(Error("Not a persistent session."))};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeySession.prototype.update=function(a){shaka.log.debug("PatchedMediaKeysWebkit.MediaKeySession.update",a);goog.asserts.assert(this.sessionId,"update without session ID");var b=new shaka.util.PublicPromise;this.update_(b,a);return b};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeySession.prototype.close=function(){var a=shaka.polyfill.PatchedMediaKeysWebkit;shaka.log.debug("PatchedMediaKeysWebkit.MediaKeySession.close");if(this.type_!="persistent-license"){if(!this.sessionId)return this.closed.reject(Error("The session is not callable.")),this.closed;a=a.prefixApi_("cancelKeyRequest");try{this.media_[a](this.keySystem_,this.sessionId)}catch(b){shaka.log.debug(a+" exception",b)}}this.closed.resolve();return this.closed};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeySession.prototype.remove=function(){shaka.log.debug("PatchedMediaKeysWebkit.MediaKeySession.remove");return this.type_!="persistent-license"?Promise.reject(Error("Not a persistent session.")):this.close()};shaka.polyfill.PatchedMediaKeysWebkit.MediaKeyStatusMap=function(){this.size=0;this.status_=void 0};shaka.polyfill.PatchedMediaKeysWebkit.MediaKeyStatusMap.prototype.setStatus=function(a){this.size=a==void 0?0:1;this.status_=a};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeyStatusMap.prototype.getStatus=function(){return this.status_};shaka.polyfill.PatchedMediaKeysWebkit.MediaKeyStatusMap.prototype.forEach=function(a){this.status_&&a(this.status_,shaka.drm.DrmUtils.DUMMY_KEY_ID.value())};shaka.polyfill.PatchedMediaKeysWebkit.MediaKeyStatusMap.prototype.get=function(a){if(this.has(a))return this.status_};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeyStatusMap.prototype.has=function(a){var b=shaka.drm.DrmUtils.DUMMY_KEY_ID.value();return this.status_&&shaka.util.BufferUtils.equal(a,b)?!0:!1};shaka.polyfill.PatchedMediaKeysWebkit.MediaKeyStatusMap.prototype.entries=function(){goog.asserts.assert(!1,"Not used!  Provided only for compiler.")};shaka.polyfill.PatchedMediaKeysWebkit.MediaKeyStatusMap.prototype.keys=function(){goog.asserts.assert(!1,"Not used!  Provided only for compiler.")};
shaka.polyfill.PatchedMediaKeysWebkit.MediaKeyStatusMap.prototype.values=function(){goog.asserts.assert(!1,"Not used!  Provided only for compiler.")};shaka.polyfill.PatchedMediaKeysWebkit.prefix_="";shaka.polyfill.PatchedMediaKeysWebkit.apiName_="webkit";shaka.polyfill.register(shaka.polyfill.PatchedMediaKeysWebkit.install);shaka.polyfill.RandomUUID=function(){};shaka.polyfill.RandomUUID.install=function(){shaka.log.debug("randomUUID.install");window.crypto?"randomUUID"in window.crypto?shaka.log.debug("RandomUUID: Native window.crypto.randomUUID() support found."):window.crypto.randomUUID=shaka.polyfill.RandomUUID.randomUUID_:shaka.log.debug("window.crypto must be available to install randomUUID polyfill.")};
shaka.polyfill.RandomUUID.randomUUID_=function(){var a=URL.createObjectURL(new Blob),b=a.toString();URL.revokeObjectURL(a);return b.substr(b.lastIndexOf("/")+1)};goog.exportProperty(shaka.polyfill,"RandomUUID",shaka.polyfill.RandomUUID);goog.exportProperty(shaka.polyfill.RandomUUID,"install",shaka.polyfill.RandomUUID.install);shaka.polyfill.register(shaka.polyfill.RandomUUID.install);shaka.polyfill.Symbol=function(){};shaka.polyfill.Symbol.install=function(){shaka.log.debug("Symbol.install");var a=Symbol.prototype;"description"in a||Object.defineProperty(a,"description",{get:shaka.polyfill.Symbol.getSymbolDescription_})};shaka.polyfill.Symbol.getSymbolDescription_=function(){var a=/\((.*)\)/.exec(this.toString());return a?a[1]:void 0};goog.exportProperty(shaka.polyfill,"Symbol",shaka.polyfill.Symbol);goog.exportProperty(shaka.polyfill.Symbol,"install",shaka.polyfill.Symbol.install);
shaka.polyfill.register(shaka.polyfill.Symbol.install);shaka.polyfill.TypedArray=function(){};shaka.polyfill.TypedArray.install=function(){for(var a=(0,$jscomp.makeIterator)([Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array]),b=a.next();!b.done;b=a.next()){b=b.value;var c=void 0;(c=b.prototype).indexOf!=null||(c.indexOf=Array.prototype.indexOf);c=void 0;(c=b.prototype).lastIndexOf!=null||(c.lastIndexOf=Array.prototype.lastIndexOf);c=void 0;(c=b.prototype).includes!=null||(c.includes=Array.prototype.includes)}};
goog.exportProperty(shaka.polyfill,"TypedArray",shaka.polyfill.TypedArray);goog.exportProperty(shaka.polyfill.TypedArray,"install",shaka.polyfill.TypedArray.install);shaka.polyfill.register(shaka.polyfill.TypedArray.install);shaka.polyfill.VideoPlayPromise=function(){};shaka.polyfill.VideoPlayPromise.install=function(){shaka.log.debug("VideoPlayPromise.install");if(window.HTMLMediaElement){var a=HTMLMediaElement.prototype.play;HTMLMediaElement.prototype.play=function(){var b=a.apply(this);b&&b.catch(function(){});return b}}};goog.exportProperty(shaka.polyfill,"VideoPlayPromise",shaka.polyfill.VideoPlayPromise);goog.exportProperty(shaka.polyfill.VideoPlayPromise,"install",shaka.polyfill.VideoPlayPromise.install);shaka.polyfill.register(shaka.polyfill.VideoPlayPromise.install);shaka.polyfill.VideoPlaybackQuality=function(){};shaka.polyfill.VideoPlaybackQuality.install=function(){if(window.HTMLVideoElement){var a=HTMLVideoElement.prototype;!a.getVideoPlaybackQuality&&("webkitDroppedFrameCount"in a||typeof shaka.util.Dom.anyMediaElement().webkitDroppedFrameCount==="number")&&(a.getVideoPlaybackQuality=shaka.polyfill.VideoPlaybackQuality.webkit_)}};
shaka.polyfill.VideoPlaybackQuality.webkit_=function(){return{droppedVideoFrames:this.webkitDroppedFrameCount,totalVideoFrames:this.webkitDecodedFrameCount,corruptedVideoFrames:0,creationTime:NaN,totalFrameDelay:0}};goog.exportProperty(shaka.polyfill,"VideoPlaybackQuality",shaka.polyfill.VideoPlaybackQuality);goog.exportProperty(shaka.polyfill.VideoPlaybackQuality,"install",shaka.polyfill.VideoPlaybackQuality.install);shaka.polyfill.register(shaka.polyfill.VideoPlaybackQuality.install);shaka.polyfill.VTTCue=function(){};
shaka.polyfill.VTTCue.install=function(){if(window.VTTCue)shaka.log.info("Using native VTTCue.");else if(window.TextTrackCue){var a=null,b=TextTrackCue.length;b==3?(shaka.log.info("Using VTTCue polyfill from 3 argument TextTrackCue."),a=shaka.polyfill.VTTCue.from3ArgsTextTrackCue_):b==6?(shaka.log.info("Using VTTCue polyfill from 6 argument TextTrackCue."),a=shaka.polyfill.VTTCue.from6ArgsTextTrackCue_):shaka.polyfill.VTTCue.canUse3ArgsTextTrackCue_()&&(shaka.log.info("Using VTTCue polyfill from 3 argument TextTrackCue."),a=
shaka.polyfill.VTTCue.from3ArgsTextTrackCue_);a?window.VTTCue=function(c,d,e){return a(c,d,e)}:shaka.log.error("No recognized signature for TextTrackCue found!")}else shaka.log.error("VTTCue not available.")};shaka.polyfill.VTTCue.from3ArgsTextTrackCue_=function(a,b,c){return new window.TextTrackCue(a,b,c)};shaka.polyfill.VTTCue.from6ArgsTextTrackCue_=function(a,b,c){return new window.TextTrackCue(a+"-"+b+"-"+c,a,b,c)};
shaka.polyfill.VTTCue.canUse3ArgsTextTrackCue_=function(){try{return!!shaka.polyfill.VTTCue.from3ArgsTextTrackCue_(1,2,"")}catch(a){return!1}};goog.exportProperty(shaka.polyfill,"VTTCue",shaka.polyfill.VTTCue);goog.exportProperty(shaka.polyfill.VTTCue,"install",shaka.polyfill.VTTCue.install);shaka.polyfill.register(shaka.polyfill.VTTCue.install);shaka.text.TtmlTextParser=function(){this.manifestType_=shaka.media.ManifestParser.UNKNOWN};shaka.text.TtmlTextParser.prototype.parseInit=function(a){goog.asserts.assert(!1,"TTML does not have init segments")};shaka.text.TtmlTextParser.prototype.setSequenceMode=function(a){};shaka.text.TtmlTextParser.prototype.setManifestType=function(a){this.manifestType_=a};
shaka.text.TtmlTextParser.prototype.parseMedia=function(a,b,c,d){var e=shaka.text.TtmlTextParser,f=shaka.util.TXml,g=e.parameterNs_,h=e.styleNs_,k=shaka.util.StringUtils.fromUTF8(a);a=[];if(k=="")return a;var l=f.parseXmlString(k,"tt",!0);if(!l)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.INVALID_XML,"Failed to parse TTML.");k=f.getElementsByTagName(l,"body")[0];if(!k)return[];var m=f.getAttributeNSList(l,g,"frameRate"),n=f.getAttributeNSList(l,
g,"subFrameRate"),p=f.getAttributeNSList(l,g,"frameRateMultiplier"),q=f.getAttributeNSList(l,g,"tickRate"),r=f.getAttributeNSList(l,g,"cellResolution"),t=l.attributes["xml:space"]||"default";g=f.getAttributeNSList(l,h,"extent");if(t!="default"&&t!="preserve")throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.INVALID_XML,"Invalid xml:space value: "+t);h=t=="default";e=new e.RateInfo_(m,n,p,q);m=this.getCellResolution_(r);n=f.getElementsByTagName(l,
"metadata")[0];n=(n?n.children:[]).filter(function(u){return u!="\n"});p=f.getElementsByTagName(l,"style");l=f.getElementsByTagName(l,"region");q=[];r=(0,$jscomp.makeIterator)(l);for(t=r.next();!t.done;t=r.next())(t=this.parseCueRegion_(t.value,p,g))&&q.push(t);if(f.findChildren(k,"p").length)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.INVALID_TEXT_CUE,"<p> can only be inside <div> in TTML");g=(0,$jscomp.makeIterator)(f.findChildren(k,
"div"));for(r=g.next();!r.done;r=g.next())if(f.findChildren(r.value,"span").length)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.INVALID_TEXT_CUE,"<span> can only be inside <p> in TTML");if(b=this.parseCue_(k,b,e,n,p,l,q,h,m,null,!1,c,d))b.backgroundColor||(b.backgroundColor="transparent"),a.push(b);return a};
shaka.text.TtmlTextParser.prototype.parseCue_=function(a,b,c,d,e,f,g,h,k,l,m,n,p){var q=shaka.util.TXml,r=shaka.util.StringUtils,t=l;if(q.isText(a)){if(!m)return null;var u={tagName:"span",children:[q.getTextContents(a)],attributes:{},parent:null}}else u=a;goog.asserts.assert(u,"cueElement should be non-null!");for(var v=null,w=(0,$jscomp.makeIterator)(shaka.text.TtmlTextParser.smpteNsList_),x=w.next();!x.done&&!(v=this.getElementsFromCollection_(u,"backgroundImage",d,"#",x.value)[0]);x=w.next());
w=null;x=q.getAttributeNSList(u,shaka.text.TtmlTextParser.smpteNsList_,"backgroundImage");var y=/^(urn:)(mpeg:[a-z0-9][a-z0-9-]{0,31}:)(subs:)([0-9]+)$/;if(x&&y.test(x)){w=parseInt(x.split(":").pop(),10)-1;if(w>=p.length)return null;w=p[w]}else n&&x&&!x.startsWith("#")&&(y=new goog.Uri(n),x=new goog.Uri(x),(x=y.resolve(x).toString())&&(w=x));if(a.tagName=="p"||v||w)m=!0;a=m;x=(u.attributes["xml:space"]||(h?"default":"preserve"))=="default";y=u.children.every(q.isText);h=[];if(!y)for(var C=(0,$jscomp.makeIterator)(u.children),
D=C.next();!D.done;D=C.next())(D=this.parseCue_(D.value,b,c,d,e,f,g,x,k,u,m,n,p))&&h.push(D);d=l!=null;n=q.getTextContents(u);n=u.children.length&&n&&/\S/.test(n);C=u.attributes.begin||u.attributes.end||u.attributes.dur;if(!(C||n||u.tagName=="br"||h.length!=0||d&&!x))return null;p=this.parseTime_(u,c);n=p.start;for(p=p.end;t&&q.isNode(t)&&t.tagName!="tt";)p=this.resolveTime_(t,c,n,p),n=p.start,p=p.end,t=t.parent;n==null&&(n=0);n+=b.periodStart;p=p==null?Infinity:p+b.periodStart;this.manifestType_!==
shaka.media.ManifestParser.HLS&&(n=Math.max(n,b.segmentStart),p=Math.min(p,b.segmentEnd));if(!C&&h.length>0)for(n=Infinity,p=0,b=(0,$jscomp.makeIterator)(h),c=b.next();!c.done;c=b.next())c=c.value,n=Math.min(n,c.startTime),p=Math.max(p,c.endTime);if(u.tagName=="br")return e=new shaka.text.Cue(n,p,""),e.lineBreak=!0,e;b="";y&&(b=r.htmlUnescape(shaka.util.TXml.getTextContents(u)||""),x&&(b=b.replace(/\s+/g," ")));r=new shaka.text.Cue(n,p,b);r.nestedCues=h;m||(r.isContainer=!0);k&&(r.cellResolution=
k);k=this.getElementsFromCollection_(u,"region",f,"")[0];if(u.attributes.region&&k&&k.attributes["xml:id"]){var A=k.attributes["xml:id"];r.region=g.filter(function(z){return z.id==A})[0]}g=k;l&&d&&!u.attributes.region&&!u.attributes.style&&(g=this.getElementsFromCollection_(l,"region",f,"")[0]);this.addStyle_(r,u,g,v,w,e,a,h.length==0);return r};
shaka.text.TtmlTextParser.prototype.parseCueRegion_=function(a,b,c){var d=shaka.text.TtmlTextParser,e=new shaka.text.CueRegion,f=a.attributes["xml:id"];if(!f)return shaka.log.warning("TtmlTextParser parser encountered a region with no id. Region will be ignored."),null;e.id=f;f=null;c&&(f=d.percentValues_.exec(c)||d.pixelValues_.exec(c));c=f?Number(f[1]):null;f=f?Number(f[2]):null;var g,h=this.getStyleAttributeFromRegion_(a,b,"extent");if(h){var k=(g=d.percentValues_.exec(h))||d.pixelValues_.exec(h);
k!=null&&(e.width=Number(k[1]),e.height=Number(k[2]),g||(c!=null&&(e.width=e.width*100/c),f!=null&&(e.height=e.height*100/f)),e.widthUnits=g||c!=null?shaka.text.CueRegion.units.PERCENTAGE:shaka.text.CueRegion.units.PX,e.heightUnits=g||f!=null?shaka.text.CueRegion.units.PERCENTAGE:shaka.text.CueRegion.units.PX)}if(a=this.getStyleAttributeFromRegion_(a,b,"origin"))if(k=(g=d.percentValues_.exec(a))||d.pixelValues_.exec(a),k!=null)e.viewportAnchorX=Number(k[1]),e.viewportAnchorY=Number(k[2]),g?h||(e.width=
100-e.viewportAnchorX,e.widthUnits=shaka.text.CueRegion.units.PERCENTAGE,e.height=100-e.viewportAnchorY,e.heightUnits=shaka.text.CueRegion.units.PERCENTAGE):(f!=null&&(e.viewportAnchorY=e.viewportAnchorY*100/f),c!=null&&(e.viewportAnchorX=e.viewportAnchorX*100/c)),e.viewportAnchorUnits=g||c!=null?shaka.text.CueRegion.units.PERCENTAGE:shaka.text.CueRegion.units.PX;return e};
shaka.text.TtmlTextParser.prototype.convertTTMLrgbaToHTMLrgba_=function(a){var b=a.match(/rgba\(([^)]+)\)/);return b&&(b=b[1].split(","),b.length==4)?(b[3]=String(Number(b[3])/255),"rgba("+b.join(",")+")"):a};
shaka.text.TtmlTextParser.prototype.addStyle_=function(a,b,c,d,e,f,g,h){var k=shaka.text.TtmlTextParser,l=shaka.util.TXml,m=shaka.text.Cue;g=g||h;this.getStyleAttribute_(b,c,f,"direction",g)=="rtl"&&(a.direction=m.direction.HORIZONTAL_RIGHT_TO_LEFT);h=this.getStyleAttribute_(b,c,f,"writingMode",g);h=="tb"||h=="tblr"?a.writingMode=m.writingMode.VERTICAL_LEFT_TO_RIGHT:h=="tbrl"?a.writingMode=m.writingMode.VERTICAL_RIGHT_TO_LEFT:h=="rltb"||h=="rl"?a.direction=m.direction.HORIZONTAL_RIGHT_TO_LEFT:h&&
(a.direction=m.direction.HORIZONTAL_LEFT_TO_RIGHT);(h=this.getStyleAttribute_(b,c,f,"textAlign",!0))?(a.positionAlign=k.textAlignToPositionAlign_.get(h),a.lineAlign=k.textAlignToLineAlign_.get(h),goog.asserts.assert(h.toUpperCase()in m.textAlign,h.toUpperCase()+" Should be in Cue.textAlign values!"),a.textAlign=m.textAlign[h.toUpperCase()]):a.textAlign=m.textAlign.CENTER;if(h=this.getStyleAttribute_(b,c,f,"displayAlign",!0))goog.asserts.assert(h.toUpperCase()in m.displayAlign,h.toUpperCase()+" Should be in Cue.displayAlign values!"),
a.displayAlign=m.displayAlign[h.toUpperCase()];if(h=this.getStyleAttribute_(b,c,f,"color",g))a.color=this.convertTTMLrgbaToHTMLrgba_(h);if(h=this.getStyleAttribute_(b,c,f,"backgroundColor",g))a.backgroundColor=this.convertTTMLrgbaToHTMLrgba_(h);if(h=this.getStyleAttribute_(b,c,f,"border",g))a.border=h;if(h=this.getStyleAttribute_(b,c,f,"fontFamily",g))switch(h){case "monospaceSerif":a.fontFamily="Courier New,Liberation Mono,Courier,monospace";break;case "proportionalSansSerif":a.fontFamily="Arial,Helvetica,Liberation Sans,sans-serif";
break;case "sansSerif":a.fontFamily="sans-serif";break;case "monospaceSansSerif":a.fontFamily="Consolas,monospace";break;case "proportionalSerif":a.fontFamily="serif";break;default:a.fontFamily=h.split(",").filter(function(n){return n!="default"}).join(",")}(h=this.getStyleAttribute_(b,c,f,"fontWeight",g))&&h=="bold"&&(a.fontWeight=m.fontWeight.BOLD);h=this.getStyleAttribute_(b,c,f,"wrapOption",g);a.wrapLine=h&&h=="noWrap"?!1:!0;(h=this.getStyleAttribute_(b,c,f,"lineHeight",g))&&h.match(k.unitValues_)&&
(a.lineHeight=h);(h=this.getStyleAttribute_(b,c,f,"fontSize",g))&&(h.match(k.unitValues_)||h.match(k.percentValue_))&&(a.fontSize=h);if(h=this.getStyleAttribute_(b,c,f,"fontStyle",g))goog.asserts.assert(h.toUpperCase()in m.fontStyle,h.toUpperCase()+" Should be in Cue.fontStyle values!"),a.fontStyle=m.fontStyle[h.toUpperCase()];d?(e=d.attributes.imageType||d.attributes.imagetype,m=d.attributes.encoding,d=l.getTextContents(d).trim(),e=="PNG"&&m=="Base64"&&d&&(a.backgroundImage="data:image/png;base64,"+
d)):e&&(a.backgroundImage=e);if(d=this.getStyleAttribute_(b,c,f,"textOutline",g))d=d.split(" "),d[0].match(k.unitValues_)?a.textStrokeColor=a.color:(a.textStrokeColor=this.convertTTMLrgbaToHTMLrgba_(d[0]),d.shift()),d[0]&&d[0].match(k.unitValues_)?a.textStrokeWidth=d[0]:a.textStrokeColor="";(d=this.getStyleAttribute_(b,c,f,"letterSpacing",g))&&d.match(k.unitValues_)&&(a.letterSpacing=d);(d=this.getStyleAttribute_(b,c,f,"linePadding",g))&&d.match(k.unitValues_)&&(a.linePadding=d);if(k=this.getStyleAttribute_(b,
c,f,"opacity",g))a.opacity=parseFloat(k);(k=this.getStyleAttributeFromRegion_(c,f,"textDecoration"))&&this.addTextDecoration_(a,k);(k=this.getStyleAttributeFromElement_(b,f,"textDecoration"))&&this.addTextDecoration_(a,k);if(k=this.getStyleAttribute_(b,c,f,"textCombine",g))a.textCombineUpright=k;switch(this.getStyleAttribute_(b,c,f,"ruby",g)){case "container":a.rubyTag="ruby";break;case "text":a.rubyTag="rt"}};
shaka.text.TtmlTextParser.prototype.addTextDecoration_=function(a,b){var c=shaka.text.Cue;b=(0,$jscomp.makeIterator)(b.split(" "));for(var d=b.next();!d.done;d=b.next())switch(d.value){case "underline":a.textDecoration.includes(c.textDecoration.UNDERLINE)||a.textDecoration.push(c.textDecoration.UNDERLINE);break;case "noUnderline":a.textDecoration.includes(c.textDecoration.UNDERLINE)&&shaka.util.ArrayUtils.remove(a.textDecoration,c.textDecoration.UNDERLINE);break;case "lineThrough":a.textDecoration.includes(c.textDecoration.LINE_THROUGH)||
a.textDecoration.push(c.textDecoration.LINE_THROUGH);break;case "noLineThrough":a.textDecoration.includes(c.textDecoration.LINE_THROUGH)&&shaka.util.ArrayUtils.remove(a.textDecoration,c.textDecoration.LINE_THROUGH);break;case "overline":a.textDecoration.includes(c.textDecoration.OVERLINE)||a.textDecoration.push(c.textDecoration.OVERLINE);break;case "noOverline":a.textDecoration.includes(c.textDecoration.OVERLINE)&&shaka.util.ArrayUtils.remove(a.textDecoration,c.textDecoration.OVERLINE)}};
shaka.text.TtmlTextParser.prototype.getStyleAttribute_=function(a,b,c,d,e){e=e===void 0?!0:e;return(a=this.getStyleAttributeFromElement_(a,c,d))?a:e?this.getStyleAttributeFromRegion_(b,c,d):null};shaka.text.TtmlTextParser.prototype.getStyleAttributeFromRegion_=function(a,b,c){if(!a)return null;var d=shaka.util.TXml.getAttributeNSList(a,shaka.text.TtmlTextParser.styleNs_,c);return d?d:this.getInheritedStyleAttribute_(a,b,c)};
shaka.text.TtmlTextParser.prototype.getStyleAttributeFromElement_=function(a,b,c){var d=shaka.util.TXml.getAttributeNSList(a,shaka.text.TtmlTextParser.styleNs_,c);return d?d:this.getInheritedStyleAttribute_(a,b,c)};
shaka.text.TtmlTextParser.prototype.getInheritedStyleAttribute_=function(a,b,c){var d=shaka.util.TXml,e=shaka.text.TtmlTextParser.styleNs_,f=shaka.text.TtmlTextParser.styleEbuttsNs_;a=this.getElementsFromCollection_(a,"style",b,"");for(var g=null,h=0;h<a.length;h++){var k=d.getAttributeNS(a[h],f,c);k||(k=d.getAttributeNSList(a[h],e,c));k||(k=this.getStyleAttributeFromElement_(a[h],b,c));k&&(g=k)}return g};
shaka.text.TtmlTextParser.prototype.getElementsFromCollection_=function(a,b,c,d,e){var f=[];if(!a||c.length<1)return f;if(a=this.getInheritedAttribute_(a,b,e))for(a=a.split(" "),a=(0,$jscomp.makeIterator)(a),b=a.next();!b.done;b=a.next()){b=b.value;e=(0,$jscomp.makeIterator)(c);for(var g=e.next();!g.done;g=e.next())if(g=g.value,d+g.attributes["xml:id"]==b){f.push(g);break}}return f};
shaka.text.TtmlTextParser.prototype.getInheritedAttribute_=function(a,b,c){for(var d=null,e=shaka.util.TXml;!d&&!(d=c?e.getAttributeNS(a,c,b):a.attributes[b])&&(a=a.parent,a););return d};shaka.text.TtmlTextParser.prototype.resolveTime_=function(a,b,c,d){a=this.parseTime_(a,b);c==null?c=a.start:a.start!=null&&(c+=a.start);d==null?d=a.end:a.start!=null&&(d+=a.start);return{start:c,end:d}};
shaka.text.TtmlTextParser.prototype.parseTime_=function(a,b){var c=this.parseTimeAttribute_(a.attributes.begin,b),d=this.parseTimeAttribute_(a.attributes.end,b);a=this.parseTimeAttribute_(a.attributes.dur,b);d==null&&a!=null&&(d=c+a);return{start:c,end:d}};
shaka.text.TtmlTextParser.prototype.parseTimeAttribute_=function(a,b){var c=null,d=shaka.text.TtmlTextParser;if(d.timeColonFormatFrames_.test(a))c=this.parseColonTimeWithFrames_(b,a);else if(d.timeColonFormat_.test(a))c=this.parseTimeFromRegex_(d.timeColonFormat_,a);else if(d.timeColonFormatMilliseconds_.test(a))c=this.parseTimeFromRegex_(d.timeColonFormatMilliseconds_,a);else if(d.timeFramesFormat_.test(a))c=this.parseFramesTime_(b,a);else if(d.timeTickFormat_.test(a))c=this.parseTickTime_(b,a);
else if(d.timeHMSFormat_.test(a))c=this.parseTimeFromRegex_(d.timeHMSFormat_,a);else if(a)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.INVALID_TEXT_CUE,"Could not parse cue time range in TTML");return c};shaka.text.TtmlTextParser.prototype.parseFramesTime_=function(a,b){b=shaka.text.TtmlTextParser.timeFramesFormat_.exec(b);return Number(b[1])/a.frameRate};
shaka.text.TtmlTextParser.prototype.parseTickTime_=function(a,b){b=shaka.text.TtmlTextParser.timeTickFormat_.exec(b);return Number(b[1])/a.tickRate};shaka.text.TtmlTextParser.prototype.parseColonTimeWithFrames_=function(a,b){b=shaka.text.TtmlTextParser.timeColonFormatFrames_.exec(b);var c=Number(b[1]),d=Number(b[2]),e=Number(b[3]),f=Number(b[4]);f+=(Number(b[5])||0)/a.subFrameRate;e+=f/a.frameRate;return e+d*60+c*3600};
shaka.text.TtmlTextParser.prototype.parseTimeFromRegex_=function(a,b){a=a.exec(b);return a==null||a[0]==""?null:(Number(a[4])||0)/1E3+(Number(a[3])||0)+(Number(a[2])||0)*60+(Number(a[1])||0)*3600};shaka.text.TtmlTextParser.prototype.getCellResolution_=function(a){if(!a)return null;var b=/^(\d+) (\d+)$/.exec(a);if(!b)return null;a=parseInt(b[1],10);b=parseInt(b[2],10);return{columns:a,rows:b}};goog.exportSymbol("shaka.text.TtmlTextParser",shaka.text.TtmlTextParser);
goog.exportProperty(shaka.text.TtmlTextParser.prototype,"parseMedia",shaka.text.TtmlTextParser.prototype.parseMedia);goog.exportProperty(shaka.text.TtmlTextParser.prototype,"setManifestType",shaka.text.TtmlTextParser.prototype.setManifestType);goog.exportProperty(shaka.text.TtmlTextParser.prototype,"setSequenceMode",shaka.text.TtmlTextParser.prototype.setSequenceMode);goog.exportProperty(shaka.text.TtmlTextParser.prototype,"parseInit",shaka.text.TtmlTextParser.prototype.parseInit);
shaka.text.TtmlTextParser.RateInfo_=function(a,b,c,d){this.frameRate=Number(a)||30;this.subFrameRate=Number(b)||1;this.tickRate=Number(d);this.tickRate==0&&(this.tickRate=a?this.frameRate*this.subFrameRate:1);c&&(a=/^(\d+) (\d+)$/g.exec(c))&&(this.frameRate*=Number(a[1])/Number(a[2]))};shaka.text.TtmlTextParser.percentValues_=/^(\d{1,2}(?:\.\d+)?|100(?:\.0+)?)% (\d{1,2}(?:\.\d+)?|100(?:\.0+)?)%$/;shaka.text.TtmlTextParser.percentValue_=/^(\d{1,4}(?:\.\d+)?|100)%$/;
shaka.text.TtmlTextParser.unitValues_=/^(\d+px|\d+em|\d*\.?\d+c)$/;shaka.text.TtmlTextParser.pixelValues_=/^(\d+)px (\d+)px$/;shaka.text.TtmlTextParser.timeColonFormatFrames_=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/;shaka.text.TtmlTextParser.timeColonFormat_=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/;shaka.text.TtmlTextParser.timeColonFormatMilliseconds_=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d+)$/;shaka.text.TtmlTextParser.timeFramesFormat_=/^(\d*(?:\.\d*)?)f$/;shaka.text.TtmlTextParser.timeTickFormat_=/^(\d*(?:\.\d*)?)t$/;
shaka.text.TtmlTextParser.timeHMSFormat_=RegExp("^(?:(\\d*(?:\\.\\d*)?)h)?(?:(\\d*(?:\\.\\d*)?)m)?(?:(\\d*(?:\\.\\d*)?)s)?(?:(\\d*(?:\\.\\d*)?)ms)?$");shaka.text.TtmlTextParser.textAlignToLineAlign_=(new Map).set("left",shaka.text.Cue.lineAlign.START).set("center",shaka.text.Cue.lineAlign.CENTER).set("right",shaka.text.Cue.lineAlign.END).set("start",shaka.text.Cue.lineAlign.START).set("end",shaka.text.Cue.lineAlign.END);
shaka.text.TtmlTextParser.textAlignToPositionAlign_=(new Map).set("left",shaka.text.Cue.positionAlign.LEFT).set("center",shaka.text.Cue.positionAlign.CENTER).set("right",shaka.text.Cue.positionAlign.RIGHT).set("start",shaka.text.Cue.positionAlign.LEFT).set("end",shaka.text.Cue.positionAlign.RIGHT);shaka.text.TtmlTextParser.parameterNs_=["http://www.w3.org/ns/ttml#parameter","http://www.w3.org/2006/10/ttaf1#parameter"];shaka.text.TtmlTextParser.styleNs_=["http://www.w3.org/ns/ttml#styling","http://www.w3.org/2006/10/ttaf1#styling"];
shaka.text.TtmlTextParser.styleEbuttsNs_="urn:ebu:tt:style";shaka.text.TtmlTextParser.smpteNsList_=["http://www.smpte-ra.org/schemas/2052-1/2010/smpte-tt","http://www.smpte-ra.org/schemas/2052-1/2013/smpte-tt"];shaka.text.TextEngine.registerParser("application/ttml+xml",function(){return new shaka.text.TtmlTextParser});shaka.text.Mp4TtmlParser=function(){this.parser_=new shaka.text.TtmlTextParser};shaka.text.Mp4TtmlParser.prototype.parseInit=function(a){var b=shaka.util.Mp4Parser,c=!1;(new b).boxes(["moov","trak","mdia","minf","stbl"],b.children).fullBox("stsd",b.sampleDescription).box("stpp",function(d){c=!0;d.parser.stop()}).parse(a);if(!c)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.INVALID_MP4_TTML);};
shaka.text.Mp4TtmlParser.prototype.setSequenceMode=function(a){this.parser_.setSequenceMode(a)};shaka.text.Mp4TtmlParser.prototype.setManifestType=function(a){this.parser_.setManifestType(a)};
shaka.text.Mp4TtmlParser.prototype.parseMedia=function(a,b,c){var d=shaka.util.Mp4Parser,e=[],f=null,g=[],h=new Map,k=[];(new d).boxes(["moof","traf"],d.children).fullBox("tfhd",function(v){goog.asserts.assert(v.flags!=null,"A TFHD box should have a valid flags value");f=shaka.util.Mp4BoxParsers.parseTFHD(v.reader,v.flags).defaultSampleSize}).fullBox("trun",function(v){goog.asserts.assert(v.version!=null,"A TRUN box should have a valid version value");goog.asserts.assert(v.flags!=null,"A TRUN box should have a valid flags value");
v=shaka.util.Mp4BoxParsers.parseTRUN(v.reader,v.version,v.flags);v=(0,$jscomp.makeIterator)(v.sampleData);for(var w=v.next();!w.done;w=v.next())k.push(w.value.sampleSize||f||0)}).fullBox("subs",function(v){for(var w=v.reader,x=w.readUint32(),y=-1,C=0;C<x;C++){var D=w.readUint32();y+=D;D=w.readUint16();for(var A=[],z=0;z<D;z++)v.version==1?A.push(w.readUint32()):A.push(w.readUint16()),w.readUint8(),w.readUint8(),w.readUint32();h.set(y,A)}}).box("mdat",d.allData(function(v){g.push(v)},!1)).parse(a,
!1);if(g.length==0)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.INVALID_MP4_TTML);a=shaka.util.Uint8ArrayUtils.concat.apply(shaka.util.Uint8ArrayUtils,(0,$jscomp.arrayFromIterable)(g));for(var l=d=0;l<k.length;l++){var m=shaka.util.BufferUtils.toUint8(a,d,k[l]);d+=k[l];var n=h.get(l);if(n&&n.length){for(var p=shaka.util.BufferUtils.toUint8(m,0,n[0]),q=[],r=n[0],t=1;t<n.length;t++){var u=shaka.util.BufferUtils.toUint8(m,r,n[t]);
u=shaka.util.Uint8ArrayUtils.toStandardBase64(u);q.push("data:image/png;base64,"+u);r+=n[t]}e=e.concat(this.parser_.parseMedia(p,b,c,q))}else e=e.concat(this.parser_.parseMedia(m,b,c,[]))}return e};goog.exportSymbol("shaka.text.Mp4TtmlParser",shaka.text.Mp4TtmlParser);goog.exportProperty(shaka.text.Mp4TtmlParser.prototype,"parseMedia",shaka.text.Mp4TtmlParser.prototype.parseMedia);goog.exportProperty(shaka.text.Mp4TtmlParser.prototype,"setManifestType",shaka.text.Mp4TtmlParser.prototype.setManifestType);
goog.exportProperty(shaka.text.Mp4TtmlParser.prototype,"setSequenceMode",shaka.text.Mp4TtmlParser.prototype.setSequenceMode);goog.exportProperty(shaka.text.Mp4TtmlParser.prototype,"parseInit",shaka.text.Mp4TtmlParser.prototype.parseInit);shaka.text.TextEngine.registerParser('application/mp4; codecs="stpp"',function(){return new shaka.text.Mp4TtmlParser});shaka.text.TextEngine.registerParser('application/mp4; codecs="stpp.ttml"',function(){return new shaka.text.Mp4TtmlParser});
shaka.text.TextEngine.registerParser('application/mp4; codecs="stpp.ttml.im1i"',function(){return new shaka.text.Mp4TtmlParser});shaka.text.TextEngine.registerParser('application/mp4; codecs="stpp.ttml.im1t"',function(){return new shaka.text.Mp4TtmlParser});shaka.text.TextEngine.registerParser('application/mp4; codecs="stpp.ttml.im2i"',function(){return new shaka.text.Mp4TtmlParser});shaka.text.TextEngine.registerParser('application/mp4; codecs="stpp.ttml.im2t"',function(){return new shaka.text.Mp4TtmlParser});
shaka.text.TextEngine.registerParser('application/mp4; codecs="stpp.ttml.etd1"',function(){return new shaka.text.Mp4TtmlParser});shaka.text.TextEngine.registerParser('application/mp4; codecs="stpp.ttml.etd1|im1t"',function(){return new shaka.text.Mp4TtmlParser});shaka.text.TextEngine.registerParser('application/mp4; codecs="stpp.ttml.im1t|etd1"',function(){return new shaka.text.Mp4TtmlParser});shaka.text.TextEngine.registerParser('application/mp4; codecs="stpp.TTML.im1t"',function(){return new shaka.text.Mp4TtmlParser});shaka.text.VttTextParser=function(){this.sequenceMode_=!1;this.manifestType_=shaka.media.ManifestParser.UNKNOWN};shaka.text.VttTextParser.prototype.parseInit=function(a){goog.asserts.assert(!1,"VTT does not have init segments")};shaka.text.VttTextParser.prototype.setSequenceMode=function(a){this.sequenceMode_=a};shaka.text.VttTextParser.prototype.setManifestType=function(a){this.manifestType_=a};
shaka.text.VttTextParser.prototype.parseMedia=function(a,b){var c=shaka.text.VttTextParser;a=shaka.util.StringUtils.fromUTF8(a);a=a.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n");var d=a.split(/\n{2,}/m);if(!/^WEBVTT($|[ \t\n])/m.test(d[0]))throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.INVALID_TEXT_HEADER);a=b.vttOffset;this.manifestType_==shaka.media.ManifestParser.HLS&&d[0].includes("X-TIMESTAMP-MAP")&&(a=this.computeHlsOffset_(d[0],b));
b=[];for(var e=(0,$jscomp.makeIterator)(d[0].split("\n")),f=e.next();!f.done;f=e.next())f=f.value,/^Region:/.test(f)&&(f=c.parseRegion_(f),b.push(f));e=new Map;shaka.text.Cue.addDefaultTextColor(e);f=[];d=(0,$jscomp.makeIterator)(d.slice(1));for(var g=d.next();!g.done;g=d.next())g=g.value.split("\n"),c.parseStyle_(g,e),(g=c.parseCue_(g,a,b,e))&&f.push(g);return f};
shaka.text.VttTextParser.prototype.computeHlsOffset_=function(a,b){var c=a.match(/LOCAL:((?:(\d{1,}):)?(\d{2}):(\d{2})\.(\d{3}))/m);a=a.match(/MPEGTS:(\d+)/m);if(!c||!a)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.INVALID_TEXT_HEADER);c=shaka.util.TextParser.parseTime(c[1]);if(c==null)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.INVALID_TEXT_HEADER);a=Number(a[1]);
for(var d=shaka.text.VttTextParser.MPEG_TIMESCALE_,e=shaka.text.VttTextParser.TS_ROLLOVER_/d,f=b.segmentStart-b.periodStart;f>=e;)f-=e,a+=shaka.text.VttTextParser.TS_ROLLOVER_;return b.periodStart+a/d-c};
shaka.text.VttTextParser.parseRegion_=function(a){var b=shaka.text.VttTextParser;a=new shaka.util.TextParser(a);var c=new shaka.text.CueRegion;a.readWord();a.skipWhitespace();for(var d=a.readWord();d;)b.parseRegionSetting_(c,d)||shaka.log.warning("VTT parser encountered an invalid VTTRegion setting: ",d," The setting will be ignored."),a.skipWhitespace(),d=a.readWord();return c};
shaka.text.VttTextParser.parseStyle_=function(a,b){if((a.length!=1||a[0])&&!shaka.text.VttTextParser.REGEX_NOTE_.test(a[0])&&a[0]=="STYLE"){for(var c=[],d=-1,e=1;e<a.length;e++)a[e].includes("::cue")&&(c.push([]),d=c.length-1),d!=-1&&(c[d].push(a[e]),a[e].includes("}")&&(d=-1));a=(0,$jscomp.makeIterator)(c);for(c=a.next();!c.done;c=a.next()){e=c.value;c="global";(d=e[0].match(/\((.*)\)/))&&(c=d.pop());d=e.slice(1,-1);e[0].includes("}")&&(e=/\{(.*?)\}/.exec(e[0]))&&(d=e[1].split(";"));(e=b.get(c))||
(e=new shaka.text.Cue(0,0,""));for(var f=!1,g=0;g<d.length;g++){var h=/^\s*([^:]+):\s*(.*)/.exec(d[g]);if(h){var k=h[1].trim(),l=h[2].trim().replace(";","");switch(k){case "background-color":case "background":f=!0;e.backgroundColor=l;break;case "color":f=!0;e.color=l;break;case "font-family":f=!0;e.fontFamily=l;break;case "font-size":f=!0;e.fontSize=l;break;case "font-weight":if(parseInt(l,10)>=700||l=="bold")f=!0,e.fontWeight=shaka.text.Cue.fontWeight.BOLD;break;case "font-style":switch(l){case "normal":f=
!0;e.fontStyle=shaka.text.Cue.fontStyle.NORMAL;break;case "italic":f=!0;e.fontStyle=shaka.text.Cue.fontStyle.ITALIC;break;case "oblique":f=!0,e.fontStyle=shaka.text.Cue.fontStyle.OBLIQUE}break;case "opacity":f=!0;e.opacity=parseFloat(l);break;case "text-combine-upright":f=!0;e.textCombineUpright=l;break;case "text-shadow":f=!0;e.textShadow=l;break;case "white-space":f=!0;e.wrapLine=l!="noWrap";break;default:shaka.log.warning("VTT parser encountered an unsupported style: ",h)}}}f&&b.set(c,e)}}};
shaka.text.VttTextParser.parseCue_=function(a,b,c,d){var e=shaka.text.VttTextParser;if(a.length==1&&!a[0]||shaka.text.VttTextParser.REGEX_NOTE_.test(a[0])||a[0]=="STYLE"||a[0]=="REGION")return null;var f=null,g=0;a[0].includes("--\x3e")||(f=a[0],g=1);var h=new shaka.util.TextParser(a[g]),k=h.parseTime(),l=h.readRegex(/[ \t]+--\x3e[ \t]+/g),m=h.parseTime();if(k==null||l==null||m==null)return shaka.log.alwaysWarn("Failed to parse VTT time code. Cue skipped:",f,a),null;k+=b;m+=b;k<0&&(k=0);b="";for(l=
g+1;l<a.length;l++)l>g+1&&(b+="\n"),b+=a[l];b=b.trim();d.has("global")?(a=d.get("global").clone(),a.startTime=k,a.endTime=m,a.payload=b):a=new shaka.text.Cue(k,m,b);h.skipWhitespace();for(k=h.readWord();k;)e.parseCueSetting(a,k,c)||shaka.log.warning("VTT parser encountered an invalid VTT setting: ",k," The setting will be ignored."),h.skipWhitespace(),k=h.readWord();shaka.text.Cue.parseCuePayload(a,d);f!=null&&(a.id=f);return a};
shaka.text.VttTextParser.parseCueSetting=function(a,b,c){var d=shaka.text.VttTextParser,e;if(e=d.REGEX_ALIGN_.exec(b))d.setTextAlign_(a,e[1]);else if(e=d.REGEX_VERTICAL_.exec(b))d.setVerticalWritingMode_(a,e[1]);else if(e=d.REGEX_SIZE_.exec(b))a.size=Number(e[1]);else if(e=d.REGEX_POSITION_.exec(b))a.position=Number(e[1]),e[2]&&d.setPositionAlign_(a,e[2]);else if(e=d.REGEX_REGION_.exec(b)){if(b=d.getRegionById_(c,e[1]))a.region=b}else return d.parsedLineValueAndInterpretation_(a,b);return!0};
shaka.text.VttTextParser.getRegionById_=function(a,b){a=a.filter(function(c){return c.id==b});if(!a.length)return shaka.log.warning("VTT parser could not find a region with id: ",b," The region will be ignored."),null;goog.asserts.assert(a.length==1,"VTTRegion ids should be unique!");return a[0]};
shaka.text.VttTextParser.parseRegionSetting_=function(a,b){var c;if(c=/^id=(.*)$/.exec(b))a.id=c[1];else if(c=/^width=(\d{1,2}|100)%$/.exec(b))a.width=Number(c[1]);else if(c=/^lines=(\d+)$/.exec(b))a.height=Number(c[1]),a.heightUnits=shaka.text.CueRegion.units.LINES;else if(c=/^regionanchor=(\d{1,2}|100)%,(\d{1,2}|100)%$/.exec(b))a.regionAnchorX=Number(c[1]),a.regionAnchorY=Number(c[2]);else if(c=/^viewportanchor=(\d{1,2}|100)%,(\d{1,2}|100)%$/.exec(b))a.viewportAnchorX=Number(c[1]),a.viewportAnchorY=
Number(c[2]);else if(/^scroll=up$/.exec(b))a.scroll=shaka.text.CueRegion.scrollMode.UP;else return!1;return!0};shaka.text.VttTextParser.setTextAlign_=function(a,b){var c=shaka.text.Cue;b=="middle"?a.textAlign=c.textAlign.CENTER:(goog.asserts.assert(b.toUpperCase()in c.textAlign,b.toUpperCase()+" Should be in Cue.textAlign values!"),a.textAlign=c.textAlign[b.toUpperCase()])};
shaka.text.VttTextParser.setPositionAlign_=function(a,b){var c=shaka.text.Cue;a.positionAlign=b=="line-left"||b=="start"?c.positionAlign.LEFT:b=="line-right"||b=="end"?c.positionAlign.RIGHT:b=="center"||b=="middle"?c.positionAlign.CENTER:c.positionAlign.AUTO};shaka.text.VttTextParser.setVerticalWritingMode_=function(a,b){var c=shaka.text.Cue;a.writingMode=b=="lr"?c.writingMode.VERTICAL_LEFT_TO_RIGHT:c.writingMode.VERTICAL_RIGHT_TO_LEFT};
shaka.text.VttTextParser.parsedLineValueAndInterpretation_=function(a,b){var c=shaka.text.Cue,d;if(d=shaka.text.VttTextParser.REGEX_LINE_PCT_.exec(b))a.lineInterpretation=c.lineInterpretation.PERCENTAGE,a.line=Number(d[1]),d[2]&&(goog.asserts.assert(d[2].toUpperCase()in c.lineAlign,d[2].toUpperCase()+" Should be in Cue.lineAlign values!"),a.lineAlign=c.lineAlign[d[2].toUpperCase()]);else if(d=shaka.text.VttTextParser.REGEX_LINE_NUM_.exec(b))a.lineInterpretation=c.lineInterpretation.LINE_NUMBER,a.line=
Number(d[1]),d[2]&&(goog.asserts.assert(d[2].toUpperCase()in c.lineAlign,d[2].toUpperCase()+" Should be in Cue.lineAlign values!"),a.lineAlign=c.lineAlign[d[2].toUpperCase()]);else return!1;return!0};goog.exportSymbol("shaka.text.VttTextParser",shaka.text.VttTextParser);goog.exportProperty(shaka.text.VttTextParser.prototype,"parseMedia",shaka.text.VttTextParser.prototype.parseMedia);goog.exportProperty(shaka.text.VttTextParser.prototype,"setManifestType",shaka.text.VttTextParser.prototype.setManifestType);
goog.exportProperty(shaka.text.VttTextParser.prototype,"setSequenceMode",shaka.text.VttTextParser.prototype.setSequenceMode);goog.exportProperty(shaka.text.VttTextParser.prototype,"parseInit",shaka.text.VttTextParser.prototype.parseInit);shaka.text.VttTextParser.MPEG_TIMESCALE_=9E4;shaka.text.VttTextParser.TS_ROLLOVER_=8589934592;shaka.text.VttTextParser.REGEX_NOTE_=/^NOTE($|[ \t])/;shaka.text.VttTextParser.REGEX_ALIGN_=/^align:(start|middle|center|end|left|right)$/;
shaka.text.VttTextParser.REGEX_VERTICAL_=/^vertical:(lr|rl)$/;shaka.text.VttTextParser.REGEX_SIZE_=/^size:([\d.]+)%$/;shaka.text.VttTextParser.REGEX_POSITION_=/^position:([\d.]+)%(?:,(line-left|line-right|middle|center|start|end|auto))?$/;shaka.text.VttTextParser.REGEX_REGION_=/^region:(.*)$/;shaka.text.VttTextParser.REGEX_LINE_PCT_=/^line:([\d.]+)%(?:,(start|end|center))?$/;shaka.text.VttTextParser.REGEX_LINE_NUM_=/^line:(-?\d+)(?:,(start|end|center))?$/;
shaka.text.TextEngine.registerParser("text/vtt",function(){return new shaka.text.VttTextParser});shaka.text.TextEngine.registerParser('text/vtt; codecs="vtt"',function(){return new shaka.text.VttTextParser});shaka.text.TextEngine.registerParser('text/vtt; codecs="wvtt"',function(){return new shaka.text.VttTextParser});shaka.text.Mp4VttParser=function(){this.timescale_=null};
shaka.text.Mp4VttParser.prototype.parseInit=function(a){var b=this,c=shaka.util.Mp4Parser,d=!1;(new c).boxes(["moov","trak","mdia","minf","stbl"],c.children).fullBox("mdhd",function(e){goog.asserts.assert(e.version==0||e.version==1,"MDHD version can only be 0 or 1");e=shaka.util.Mp4BoxParsers.parseMDHD(e.reader,e.version);b.timescale_=e.timescale}).fullBox("stsd",c.sampleDescription).box("wvtt",function(e){d=!0}).parse(a);if(!this.timescale_)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,
shaka.util.Error.Code.INVALID_MP4_VTT);if(!d)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.INVALID_MP4_VTT);};shaka.text.Mp4VttParser.prototype.setSequenceMode=function(a){};shaka.text.Mp4VttParser.prototype.setManifestType=function(a){};
shaka.text.Mp4VttParser.prototype.parseMedia=function(a,b){if(!a.length)return[];if(!this.timescale_)throw shaka.log.error("No init segment for MP4+VTT!"),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.INVALID_MP4_VTT);var c=shaka.util.Mp4Parser,d=0,e=[],f,g=[],h=!1,k=!1,l=!1,m=null;(new c).boxes(["moof","traf"],c.children).fullBox("tfdt",function(x){h=!0;goog.asserts.assert(x.version==0||x.version==1,"TFDT version can only be 0 or 1");
d=shaka.util.Mp4BoxParsers.parseTFDTInaccurate(x.reader,x.version).baseMediaDecodeTime}).fullBox("tfhd",function(x){goog.asserts.assert(x.flags!=null,"A TFHD box should have a valid flags value");m=shaka.util.Mp4BoxParsers.parseTFHD(x.reader,x.flags).defaultSampleDuration}).fullBox("trun",function(x){k=!0;goog.asserts.assert(x.version!=null,"A TRUN box should have a valid version value");goog.asserts.assert(x.flags!=null,"A TRUN box should have a valid flags value");e=shaka.util.Mp4BoxParsers.parseTRUN(x.reader,
x.version,x.flags).sampleData}).box("mdat",c.allData(function(x){goog.asserts.assert(!l,"VTT cues in mp4 with multiple MDAT are not currently supported");l=!0;f=x},!1)).parse(a,!1);if(!l&&!h&&!k)throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.INVALID_MP4_VTT);a=d;c=new shaka.util.DataViewReader(f,shaka.util.DataViewReader.Endianness.BIG_ENDIAN);for(var n=(0,$jscomp.makeIterator)(e),p=n.next();!p.done;p=n.next()){p=p.value;var q=p.sampleDuration||
m,r=p.sampleCompositionTimeOffset?d+p.sampleCompositionTimeOffset:a;a=r+(q||0);var t=0;do{var u=c.readUint32();t+=u;var v=c.readUint32();v=shaka.util.Mp4Parser.typeToString(v);var w=null;v=="vttc"?u>8&&(w=c.readBytes(u-8,!1)):(v!="vtte"&&shaka.log.error("Unknown box "+v+"! Skipping!"),c.skip(u-8));q?w&&(goog.asserts.assert(this.timescale_!=null,"Timescale should not be null!"),u=shaka.text.Mp4VttParser.parseVTTC_(w,b.periodStart+r/this.timescale_,b.periodStart+a/this.timescale_),g.push(u)):shaka.log.error("WVTT sample duration unknown, and no default found!");
goog.asserts.assert(!p.sampleSize||t<=p.sampleSize,"The samples do not fit evenly into the sample sizes given in the TRUN box!")}while(p.sampleSize&&t<p.sampleSize)}goog.asserts.assert(!c.hasMoreData(),"MDAT which contain VTT cues and non-VTT data are not currently supported!");return g.filter(shaka.util.Functional.isNotNull)};
shaka.text.Mp4VttParser.parseVTTC_=function(a,b,c){var d,e,f;(new shaka.util.Mp4Parser).box("payl",shaka.util.Mp4Parser.allData(function(g){d=shaka.util.StringUtils.fromUTF8(g)},!1)).box("iden",shaka.util.Mp4Parser.allData(function(g){e=shaka.util.StringUtils.fromUTF8(g)},!1)).box("sttg",shaka.util.Mp4Parser.allData(function(g){f=shaka.util.StringUtils.fromUTF8(g)},!1)).parse(a);return d?shaka.text.Mp4VttParser.assembleCue_(d,e,f,b,c):null};
shaka.text.Mp4VttParser.assembleCue_=function(a,b,c,d,e){a=new shaka.text.Cue(d,e,a);shaka.text.Cue.parseCuePayload(a);b&&(a.id=b);if(c)for(b=new shaka.util.TextParser(c),c=b.readWord();c;)shaka.text.VttTextParser.parseCueSetting(a,c,[])||shaka.log.warning("VTT parser encountered an invalid VTT setting: ",c," The setting will be ignored."),b.skipWhitespace(),c=b.readWord();return a};goog.exportSymbol("shaka.text.Mp4VttParser",shaka.text.Mp4VttParser);
goog.exportProperty(shaka.text.Mp4VttParser.prototype,"parseMedia",shaka.text.Mp4VttParser.prototype.parseMedia);goog.exportProperty(shaka.text.Mp4VttParser.prototype,"setManifestType",shaka.text.Mp4VttParser.prototype.setManifestType);goog.exportProperty(shaka.text.Mp4VttParser.prototype,"setSequenceMode",shaka.text.Mp4VttParser.prototype.setSequenceMode);goog.exportProperty(shaka.text.Mp4VttParser.prototype,"parseInit",shaka.text.Mp4VttParser.prototype.parseInit);
shaka.text.TextEngine.registerParser('application/mp4; codecs="wvtt"',function(){return new shaka.text.Mp4VttParser});shaka.transmuxer.TransmuxerUtils=function(){};shaka.transmuxer.TransmuxerUtils.AUDIO_SAMPLE_FLAGS=Object.freeze({isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:2,isNonSync:0});shaka.transmuxer.TransmuxerUtils.VIDEO_KEYFRAME_FLAGS=Object.freeze({isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:2,isNonSync:0});shaka.transmuxer.TransmuxerUtils.VIDEO_NON_KEYFRAME_FLAGS=Object.freeze({isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1,isNonSync:1});shaka.util.FairPlayUtils=function(){shaka.drm.FairPlay.apply(this,arguments)};$jscomp.inherits(shaka.util.FairPlayUtils,shaka.drm.FairPlay);goog.exportSymbol("shaka.util.FairPlayUtils",shaka.util.FairPlayUtils);}).call(exportTo,innerGlobal,innerGlobal,undefined);if(typeof exports!="undefined")for(var k in exportTo.shaka)exports[k]=exportTo.shaka[k];else if(typeof define=="function"&&define.amd)define(function(){return exportTo.shaka});else innerGlobal.shaka=exportTo.shaka})();

//# sourceMappingURL=shaka-player.dash.debug.map