@playkit-js/playkit-js-dash
Version:
[](https://github.com/kaltura/playkit-js-dash/actions/workflows/run_canary_full_flow.yaml) [{"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@playkit-js/playkit-js"),require("shaka-player")):"function"==typeof define&&define.amd?define("playkit",["@playkit-js/playkit-js","shaka-player"],t):"object"==typeof exports?exports.playkit=t(require("@playkit-js/playkit-js"),require("shaka-player")):(e.playkit=e.playkit||{},e.playkit.dash=t(e.playkit.core,e.shaka))}(self,(function(e,t){return function(){var r={774:function(e,t,r){"use strict";var n=r(864),i=r.n(n),a=r(352),o=r.n(a)()(i());o.push([e.id,".shaka-text-container {\n position: absolute;\n left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n pointer-events: none;\n width: 100%;\n min-width: 48px;\n transition: bottom cubic-bezier(0.4, 0, 0.6, 1) 0.1s;\n transition-delay: 0s;\n font-size: 20px;\n line-height: 1.4;\n color: #fff;\n font-family: Roboto-Regular, Roboto, sans-serif, TengwarTelcontar;\n}\n.shaka-text-container span.shaka-text-wrapper {\n display: inline;\n background: 0 0;\n text-align: center;\n}\n\n:fullscreen .shaka-text-container {\n font-size: 4.4vmin;\n}\n\n:-webkit-full-screen .shaka-text-container {\n font-size: 4.4vmin;\n}\n\n:-moz-full-screen .shaka-text-container {\n font-size: 4.4vmin;\n}\n\n:-ms-fullscreen .shaka-text-container {\n font-size: 4.4vmin;\n}\n","",{version:3,sources:["webpack://./src/assets/style.css"],names:[],mappings:"AAAA;EACE,kBAAkB;EAClB,OAAO;EACP,QAAQ;EACR,MAAM;EACN,SAAS;EACT,oBAAoB;EACpB,WAAW;EACX,eAAe;EACf,oDAAoD;EACpD,oBAAoB;EACpB,eAAe;EACf,gBAAgB;EAChB,WAAW;EACX,iEAAiE;AACnE;AACA;EACE,eAAe;EACf,eAAe;EACf,kBAAkB;AACpB;;AAEA;EACE,kBAAkB;AACpB;;AAEA;EACE,kBAAkB;AACpB;;AAEA;EACE,kBAAkB;AACpB;;AAEA;EACE,kBAAkB;AACpB",sourcesContent:[".shaka-text-container {\n position: absolute;\n left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n pointer-events: none;\n width: 100%;\n min-width: 48px;\n transition: bottom cubic-bezier(0.4, 0, 0.6, 1) 0.1s;\n transition-delay: 0s;\n font-size: 20px;\n line-height: 1.4;\n color: #fff;\n font-family: Roboto-Regular, Roboto, sans-serif, TengwarTelcontar;\n}\n.shaka-text-container span.shaka-text-wrapper {\n display: inline;\n background: 0 0;\n text-align: center;\n}\n\n:fullscreen .shaka-text-container {\n font-size: 4.4vmin;\n}\n\n:-webkit-full-screen .shaka-text-container {\n font-size: 4.4vmin;\n}\n\n:-moz-full-screen .shaka-text-container {\n font-size: 4.4vmin;\n}\n\n:-ms-fullscreen .shaka-text-container {\n font-size: 4.4vmin;\n}\n"],sourceRoot:""}]),t.Z=o},352:function(e){"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var r="",n=void 0!==t[5];return t[4]&&(r+="@supports (".concat(t[4],") {")),t[2]&&(r+="@media ".concat(t[2]," {")),n&&(r+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),r+=e(t),n&&(r+="}"),t[2]&&(r+="}"),t[4]&&(r+="}"),r})).join("")},t.i=function(e,r,n,i,a){"string"==typeof e&&(e=[[null,e,void 0]]);var o={};if(n)for(var s=0;s<this.length;s++){var u=this[s][0];null!=u&&(o[u]=!0)}for(var c=0;c<e.length;c++){var l=[].concat(e[c]);n&&o[l[0]]||(void 0!==a&&(void 0===l[5]||(l[1]="@layer".concat(l[5].length>0?" ".concat(l[5]):""," {").concat(l[1],"}")),l[5]=a),r&&(l[2]?(l[1]="@media ".concat(l[2]," {").concat(l[1],"}"),l[2]=r):l[2]=r),i&&(l[4]?(l[1]="@supports (".concat(l[4],") {").concat(l[1],"}"),l[4]=i):l[4]="".concat(i)),t.push(l))}},t}},864:function(e){"use strict";e.exports=function(e){var t=e[1],r=e[3];if(!r)return t;if("function"==typeof btoa){var n=btoa(unescape(encodeURIComponent(JSON.stringify(r)))),i="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(n),a="/*# ".concat(i," */");return[t].concat([a]).join("\n")}return[t].join("\n")}},701:function(e){"use strict";var t=[];function r(e){for(var r=-1,n=0;n<t.length;n++)if(t[n].identifier===e){r=n;break}return r}function n(e,n){for(var a={},o=[],s=0;s<e.length;s++){var u=e[s],c=n.base?u[0]+n.base:u[0],l=a[c]||0,h="".concat(c," ").concat(l);a[c]=l+1;var f=r(h),d={css:u[1],media:u[2],sourceMap:u[3],supports:u[4],layer:u[5]};if(-1!==f)t[f].references++,t[f].updater(d);else{var p=i(d,n);n.byIndex=s,t.splice(s,0,{identifier:h,updater:p,references:1})}o.push(h)}return o}function i(e,t){var r=t.domAPI(t);return r.update(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap&&t.supports===e.supports&&t.layer===e.layer)return;r.update(e=t)}else r.remove()}}e.exports=function(e,i){var a=n(e=e||[],i=i||{});return function(e){e=e||[];for(var o=0;o<a.length;o++){var s=r(a[o]);t[s].references--}for(var u=n(e,i),c=0;c<a.length;c++){var l=r(a[c]);0===t[l].references&&(t[l].updater(),t.splice(l,1))}a=u}}},182:function(e){"use strict";e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},75:function(e){"use strict";e.exports=function(e,t){Object.keys(t).forEach((function(r){e.setAttribute(r,t[r])}))}},236:function(e){"use strict";e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=e.insertStyleElement(e);return{update:function(r){!function(e,t,r){var n="";r.supports&&(n+="@supports (".concat(r.supports,") {")),r.media&&(n+="@media ".concat(r.media," {"));var i=void 0!==r.layer;i&&(n+="@layer".concat(r.layer.length>0?" ".concat(r.layer):""," {")),n+=r.css,i&&(n+="}"),r.media&&(n+="}"),r.supports&&(n+="}");var a=r.sourceMap;a&&"undefined"!=typeof btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(a))))," */")),t.styleTagTransform(n,e,t.options)}(t,e,r)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}},213:function(e){"use strict";e.exports=function(e,t){if(t.styleSheet)t.styleSheet.cssText=e;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}}},230:function(t){"use strict";t.exports=e},475:function(e){"use strict";e.exports=t},333:function(e,t,r){var n=r(125).default;function i(){"use strict";e.exports=i=function(){return r},e.exports.__esModule=!0,e.exports.default=e.exports;var t,r={},a=Object.prototype,o=a.hasOwnProperty,s=Object.defineProperty||function(e,t,r){e[t]=r.value},u="function"==typeof Symbol?Symbol:{},c=u.iterator||"@@iterator",l=u.asyncIterator||"@@asyncIterator",h=u.toStringTag||"@@toStringTag";function f(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{f({},"")}catch(t){f=function(e,t,r){return e[t]=r}}function d(e,t,r,n){var i=t&&t.prototype instanceof k?t:k,a=Object.create(i.prototype),o=new C(n||[]);return s(a,"_invoke",{value:D(e,r,o)}),a}function p(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}r.wrap=d;var v="suspendedStart",g="suspendedYield",y="executing",m="completed",_={};function k(){}function T(){}function b(){}var E={};f(E,c,(function(){return this}));var A=Object.getPrototypeOf,S=A&&A(A(N([])));S&&S!==a&&o.call(S,c)&&(E=S);var w=b.prototype=k.prototype=Object.create(E);function x(e){["next","throw","return"].forEach((function(t){f(e,t,(function(e){return this._invoke(t,e)}))}))}function P(e,t){function r(i,a,s,u){var c=p(e[i],e,a);if("throw"!==c.type){var l=c.arg,h=l.value;return h&&"object"==n(h)&&o.call(h,"__await")?t.resolve(h.__await).then((function(e){r("next",e,s,u)}),(function(e){r("throw",e,s,u)})):t.resolve(h).then((function(e){l.value=e,s(l)}),(function(e){return r("throw",e,s,u)}))}u(c.arg)}var i;s(this,"_invoke",{value:function(e,n){function a(){return new t((function(t,i){r(e,n,t,i)}))}return i=i?i.then(a,a):a()}})}function D(e,r,n){var i=v;return function(a,o){if(i===y)throw new Error("Generator is already running");if(i===m){if("throw"===a)throw o;return{value:t,done:!0}}for(n.method=a,n.arg=o;;){var s=n.delegate;if(s){var u=I(s,n);if(u){if(u===_)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===v)throw i=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=y;var c=p(e,r,n);if("normal"===c.type){if(i=n.done?m:g,c.arg===_)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=m,n.method="throw",n.arg=c.arg)}}}function I(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,I(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),_;var a=p(i,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,_;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,_):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,_)}function R(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function C(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(R,this),this.reset(!0)}function N(e){if(e||""===e){var r=e[c];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function r(){for(;++i<e.length;)if(o.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(n(e)+" is not iterable")}return T.prototype=b,s(w,"constructor",{value:b,configurable:!0}),s(b,"constructor",{value:T,configurable:!0}),T.displayName=f(b,h,"GeneratorFunction"),r.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===T||"GeneratorFunction"===(t.displayName||t.name))},r.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,f(e,h,"GeneratorFunction")),e.prototype=Object.create(w),e},r.awrap=function(e){return{__await:e}},x(P.prototype),f(P.prototype,l,(function(){return this})),r.AsyncIterator=P,r.async=function(e,t,n,i,a){void 0===a&&(a=Promise);var o=new P(d(e,t,n,i),a);return r.isGeneratorFunction(t)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},x(w),f(w,h,"Generator"),f(w,c,(function(){return this})),f(w,"toString",(function(){return"[object Generator]"})),r.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},r.values=N,C.prototype={constructor:C,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(O),!e)for(var r in this)"t"===r.charAt(0)&&o.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(n,i){return s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],s=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var u=o.call(a,"catchLoc"),c=o.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,_):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),_},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),O(r),_}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;O(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:N(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),_}},r}e.exports=i,e.exports.__esModule=!0,e.exports.default=e.exports},125:function(e){function t(r){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},47:function(e,t,r){var n=r(333)();e.exports=n;try{regeneratorRuntime=n}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=n:Function("r","regeneratorRuntime = r")(n)}}},n={};function i(e){var t=n[e];if(void 0!==t)return t.exports;var a=n[e]={id:e,exports:{}};return r[e](a,a.exports,i),a.exports}i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,{a:t}),t},i.d=function(e,t){for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};return function(){"use strict";i.r(a),i.d(a,{NAME:function(){return ue},VERSION:function(){return se},default:function(){return ce}});var e=i(230);function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function r(e,r){if(e){if("string"==typeof e)return t(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(e,r):void 0}}function n(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||r(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t,r,n,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function s(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var a=e.apply(t,r);function s(e){o(a,n,i,s,u,"next",e)}function u(e){o(a,n,i,s,u,"throw",e)}s(void 0)}))}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c(e)}function l(e){var t=function(e,t){if("object"!=c(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=c(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==c(t)?t:String(t)}function h(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,l(n.key),n)}}function f(e,t,r){return t&&h(e.prototype,t),r&&h(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function d(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function p(e){return p=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},p(e)}function v(){return v="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=p(e)););return e}(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}},v.apply(this,arguments)}function g(e,t){return g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},g(e,t)}function y(e,t,r){return(t=l(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var m,_,k=i(47),T=i.n(k),b=i(475),E=i.n(b),A=(m=function(){function t(){u(this,t)}return f(t,null,[{key:"isConfigured",value:function(t,r){return e.DrmScheme.WIDEVINE===r.keySystem&&!!t.find((function(e){return e.scheme===r.keySystem}))}},{key:"canPlayDrm",value:function(r){return t._logger.debug("Can play DRM scheme of: "+e.DrmScheme.WIDEVINE),!!r.find((function(t){return t.scheme===e.DrmScheme.WIDEVINE}))}},{key:"setDrmPlayback",value:function(r,n){t._logger.debug("Sets drm playback");var i=e.Env.browser.name,a=n.find((function(t){return t.scheme===e.DrmScheme.WIDEVINE}));a&&(r.drm={servers:y({},e.DrmScheme.WIDEVINE,a.licenseUrl),advanced:{}},"Chrome"===i&&(r.drm.advanced=y({},e.DrmScheme.WIDEVINE,{videoRobustness:"SW_SECURE_CRYPTO",audioRobustness:"SW_SECURE_CRYPTO"})))}}]),t}(),y(m,"_logger",(0,e.getLogger)("Widevine")),m),S=(_=function(){function t(){u(this,t)}return f(t,null,[{key:"isConfigured",value:function(t,r){return e.DrmScheme.PLAYREADY===r.keySystem&&!!t.find((function(e){return e.scheme===r.keySystem}))}},{key:"canPlayDrm",value:function(r){return t._logger.debug("Can play DRM scheme of: "+e.DrmScheme.PLAYREADY),!!r.find((function(t){return t.scheme===e.DrmScheme.PLAYREADY}))}},{key:"setDrmPlayback",value:function(r,n){t._logger.debug("Sets drm playback");var i=n.find((function(t){return t.scheme===e.DrmScheme.PLAYREADY}));i&&(r.drm={servers:y({},e.DrmScheme.PLAYREADY,i.licenseUrl)})}}]),t}(),y(_,"_logger",(0,e.getLogger)("PlayReady")),_),w=JSON.parse('{"shakaConfig":{"streaming":{"ignoreTextStreamFailures":true,"bufferingGoal":60,"alwaysStreamText":true},"abr":{"enabled":true,"restrictions":{}}},"forceRedirectExternalStreams":false,"trackEmsgEvents":true,"switchDynamicToStatic":false,"stallDetectionThreshold":3}'),x=i(701),P=i.n(x),D=i(236),I=i.n(D),R=i(75),O=i.n(R),C=i(182),N=i.n(C),M=i(213),L=i.n(M),B=i(774),j={attributes:{id:"@playkit-js/playkit-js-dash"}};j.styleTagTransform=L(),j.setAttributes=O(),j.insert=function(e){window.kalturaGlobalConfig&&"string"==typeof window.kalturaGlobalConfig.stylesNonce&&e.setAttribute("nonce",window.kalturaGlobalConfig.stylesNonce),document.head.appendChild(e)},j.domAPI=I(),j.insertStyleElement=N(),P()(B.Z,j),B.Z&&B.Z.locals&&B.Z.locals;var U=function(){function e(t){u(this,e),this._media=G.parseAttr(t,F.AttributeTypes.MEDIA),this._startNumber=G.parseAttr(t,F.AttributeTypes.START_NUMBER,G.parseInt,1),this._duration=G.parseAttr(t,F.AttributeTypes.DURATION,G.parseFloat),this._timescale=G.parseAttr(t,F.AttributeTypes.TIMESCALE,G.parsePositiveInt,1),this._presentationTimeOffset=G.parseAttr(t,F.AttributeTypes.PRESENTATION_TIME_OFFSET,G.parseInt,0),this._endNumber=G.parseAttr(t,F.AttributeTypes.END_NUMBER,G.parsePositiveInt)}return f(e,[{key:"media",get:function(){return this._media}},{key:"startNumber",get:function(){return this._startNumber}},{key:"duration",get:function(){return this._duration}},{key:"timescale",get:function(){return this._timescale}},{key:"presentationTimeOffset",get:function(){return this._presentationTimeOffset}},{key:"endNumber",get:function(){return this._endNumber}}]),e}();y(U,"MediaTemplateType",{REPRESENTATION:"$RepresentationID$",NUMBER:"$Number$",BANDWIDTH:"$Bandwidth$",TIME:"$Time$"});var V=function(e,t){var r=t.id,n=t.index,i=t.bitrate,a=t.time,o=e.match(/\$([a-zA-Z]+)\$/g),s=function(e,t,r){return r?e.replace(t,r):e};return o&&o.forEach((function(t){switch(t){case U.MediaTemplateType.REPRESENTATION:e=s(e,t,r);break;case U.MediaTemplateType.NUMBER:e=s(e,t,n);break;case U.MediaTemplateType.BANDWIDTH:e=s(e,t,i);break;case U.MediaTemplateType.TIME:e=s(e,t,a)}})),e},F={TagTypes:{BASE_URL:"BaseURL",SEGMENT_TEMPLATE:"SegmentTemplate",REPRESENTATION:"Representation",ESSENTIAL_PROPERTY:"EssentialProperty",ADAPTATION_SET:"AdaptationSet"},AttributeTypes:{BASE_URL:"BaseURL",ID:"id",CONTENT_TYPE:"contentType",MIME_TYPE:"mimeType",MEDIA:"media",DURATION:"duration",START_NUMBER:"startNumber",TIMESCALE:"timescale",PRESENTATION_TIME_OFFSET:"presentationTimeOffset",END_NUMBER:"endNumber",BANDWIDTH:"bandwidth",WIDTH:"width",HEIGHT:"height",SCHEME_ID_URI:"schemeIdUri",VALUE:"value"}},G={parseXml:function(e){return(new DOMParser).parseFromString(e,"text/xml")},parseAttr:function(e,t,r,n){var i=null,a=e.getAttribute(t);return null!==a&&(i=r?r(a):a),null===i?n:i},findElements:function(e,t){return e.getElementsByTagName(t)},findChild:function(e,t){var r=this.findChildren(e,t);return 1!==r.length?null:r[0]},findChildren:function(e,t){return Array.from(e.childNodes).filter((function(e){return e instanceof Element&&e.tagName===t}))},parseInt:function(e){var t=Number(e);return t%1==0?t:null},parsePositiveInt:function(e){var t=Number(e);return t%1==0&&t>0?t:null},parseFloat:function(e){var t=Number(e);return isNaN(t)?null:t}},W=function(){function e(t){u(this,e),this._schemeIdUri=G.parseAttr(t,F.AttributeTypes.SCHEME_ID_URI),this._value=G.parseAttr(t,F.AttributeTypes.VALUE)}return f(e,[{key:"schemeIdUri",get:function(){return this._schemeIdUri}},{key:"value",get:function(){return this._value}}]),e}(),H=function(){function e(t){u(this,e),this._id=G.parseAttr(t,F.AttributeTypes.ID),this._bandwidth=G.parseAttr(t,F.AttributeTypes.BANDWIDTH,parseInt),this._width=G.parseAttr(t,F.AttributeTypes.WIDTH,parseInt),this._height=G.parseAttr(t,F.AttributeTypes.HEIGHT,parseInt);var r=G.findChild(t,F.TagTypes.ESSENTIAL_PROPERTY);r&&(this._essentialProperty=new W(r))}return f(e,[{key:"bandwidth",get:function(){return this._bandwidth}},{key:"id",get:function(){return this._id}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"essentialProperty",get:function(){return this._essentialProperty}}]),e}(),z=function(){function e(t){u(this,e),this._id=G.parseAttr(t,F.AttributeTypes.ID),this._mimeType=G.parseAttr(t,F.AttributeTypes.MIME_TYPE),this._contentType=G.parseAttr(t,F.AttributeTypes.CONTENT_TYPE),this._representations=Array.from(G.findChildren(t,F.TagTypes.REPRESENTATION)).map((function(e){return new H(e)}));var r=G.findChild(t,F.TagTypes.SEGMENT_TEMPLATE);r&&(this._segmentTemplate=new U(r));var n=G.findChild(t,F.TagTypes.ESSENTIAL_PROPERTY);n&&(this._essentialProperty=new W(n))}return f(e,[{key:"id",get:function(){return this._id}},{key:"mimeType",get:function(){return this._mimeType}},{key:"contentType",get:function(){return this._contentType}},{key:"segmentTemplate",get:function(){return this._segmentTemplate}},{key:"essentialProperty",get:function(){return this._essentialProperty}},{key:"representations",get:function(){return this._representations}}]),e}();y(z,"ContentType",{VIDEO:"video",AUDIO:"audio",TEXT:"text",IMAGE:"image"});var Y=function(){function t(r){var n,i,a=this;u(this,t),y(this,"_logger",(0,e.getLogger)("DashManifestParser")),y(this,"_parseAdaptionSets",(function(){var e=G.findElements(a._xmlDoc,F.TagTypes.BASE_URL);e&&e.length>0&&e[0].innerHTML&&(a._baseURL=e[0].textContent);var t=G.findElements(a._xmlDoc,F.TagTypes.ADAPTATION_SET),r=Array.from(t).filter((function(e){return G.parseAttr(e,F.AttributeTypes.CONTENT_TYPE)===z.ContentType.IMAGE}));r.length>0?(a._adaptationSets=r.map((function(e){return new z(e)})),a._logger.debug("Found image adaptation set",a._adaptationSets)):a._logger.debug("No image adaptations were found in manifest")})),this._logger.debug("Initialize manifest parser"),this._adaptationSets=[],(n=r instanceof ArrayBuffer?(i=r,TextDecoder?(new TextDecoder).decode(new Uint8Array(i)):null):r)&&(this._xmlDoc=G.parseXml(n))}return f(t,[{key:"parseManifest",value:function(){try{this._logger.debug("Start parsing dash manifest"),this._parseAdaptionSets(),this._logger.debug("Manifest parsing finished successfully")}catch(e){this._logger.warn("Manifest parsing failed",e)}}},{key:"getBaseUrl",value:function(){return this._baseURL||""}},{key:"getImageSet",value:function(){return this._adaptationSets.find((function(e){return e.contentType===z.ContentType.IMAGE}))}},{key:"hasImageSet",value:function(){return!!this.getImageSet()}},{key:"adaptationSets",get:function(){return this._adaptationSets}}],[{key:"isValid",value:function(){return!(!window.TextEncoder||!window.TextDecoder)}}]),t}();var q,$=function(){function t(n,i,a){var o=this;u(this,t),y(this,"_tracks",[]),y(this,"_parseTracks",(function(t,n,i){var a=t.representations,s=t.segmentTemplate,u=t.essentialProperty;a.forEach((function(t,a){var c,l,h=t.id,f=t.bandwidth,d=t.width,p=t.height,v=s,g=v.startNumber,y=v.duration,m=v.media,_=v.timescale,k=v.presentationTimeOffset,T=o._getEssentialValue(u,t),b=(c=o._getDimensions(T),l=2,function(e){if(Array.isArray(e))return e}(c)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,a,o,s=[],u=!0,c=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,i=e}finally{try{if(!u&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(c)throw i}}return s}}(c,l)||r(c,l)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),E=b[0],A=b[1];o._tracks.push(new e.ImageTrack({id:h,index:a,active:!1,width:d,height:p,duration:y,rows:E,cols:A,url:o._buildTemplateUrl(m,h,n,i),customData:{bitrate:f,startNumber:g,timescale:_,presentationTimeOffset:k}}))}))})),y(this,"_getDimensions",(function(e){var t=1,r=1;if(e.includes("x")){var n=e.split("x");r=parseInt(n[0]),t=parseInt(n[1])}return[t,r]})),y(this,"_getEssentialValue",(function(e,t){return e?e.value:t.essentialProperty?t.essentialProperty.value:""})),y(this,"_buildTemplateUrl",(function(e,t,r,n){var i=r.split("/").pop(),a=r.replace(i,"");(n=n.replace(/^\.\//,"")).length>0&&!n.endsWith("/")&&(n+="/");var o="".concat(a).concat(n).concat(e);return V(o,{id:t})})),y(this,"_buildUrlFromTemplate",(function(e,t){return V(e.url,{index:t,time:(t-1)*e.duration*e.customData.timescale,bitrate:e.customData.bitrate})})),this._parseTracks(n,i,a),this._tracks.length>0&&(this._tracks.sort((function(e,t){return e.customData.bitrate-t.customData.bitrate})),this.selectTrack(this._tracks[this._tracks.length-1]))}return f(t,[{key:"selectTrack",value:function(e){this._tracks.forEach((function(t){return t.index===e.index?t.active=!0:t.active=!1}))}},{key:"getTracks",value:function(){return this._tracks}},{key:"getActiveTrack",value:function(){return this._tracks.find((function(e){return e.active}))}},{key:"getThumbnail",value:function(t){var r=this.getActiveTrack(),n=r.duration,i=r.rows,a=r.cols,o=r.sliceWidth,s=r.sliceHeight,u=r.customData,c=Math.floor(t/n)+u.startNumber,l=t%n,h=Math.floor(l*i*a/n);return new e.ThumbnailInfo({width:Math.floor(o),height:Math.floor(s),x:Math.floor(h%a)*o,y:Math.floor(h/a)*s,url:this._buildUrlFromTemplate(r,c)})}}]),t}(),K=["startTime","endTime","id"];function X(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return Z(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Z(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function Z(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var J="error",Q="adaptation",ee="buffering",te="drmsessionupdate",re="emsg",ne="timelineregionadded",ie="timelineregionenter",ae="timelineregionexit",oe=function(t){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&g(e,t)}(m,t);var r,i,a,o,l,h=(o=m,l=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=p(o);if(l){var r=p(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"===c(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return d(e)}(this,e)});function m(t,r){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return u(this,m),y(d(n=h.call(this,t,r,i)),"_shakaLib",E()),y(d(n),"_adapterEventsBindings",y(y(y(y(y(y(y(y(y(y({},J,(function(e){return n._onError(e)})),Q,(function(){return n._onAdaptation()})),ee,(function(e){return n._onBuffering(e)})),te,(function(){return n._onDrmSessionUpdate()})),re,(function(e){return n._onEmsg(e)})),ne,(function(e){return n._onTimelineRegionAdded(e)})),ie,(function(e){return n._onTimelineRegionEnter(e)})),ae,(function(e){return n._onTimelineRegionExit(e)})),e.EventType.WAITING,(function(){return n._onWaiting()})),e.EventType.PLAYING,(function(){return n._onPlaying()}))),y(d(n),"_buffering",!1),y(d(n),"_waitingSent",!1),y(d(n),"_playingSent",!1),y(d(n),"_videoSizeUpdateTimer",null),y(d(n),"_stallInterval",null),y(d(n),"VIDEO_ERROR_CODE",3016),y(d(n),"_lastTimeDetach",NaN),y(d(n),"_requestFilterError",!1),y(d(n),"_responseFilterError",!1),y(d(n),"_isDestroyInProgress",!1),y(d(n),"_errorCounter",{}),y(d(n),"_isStartOver",!0),y(d(n),"_seekRangeStart",0),y(d(n),"_isLive",!1),y(d(n),"_isStaticLive",!1),y(d(n),"_selectedVideoTrack",null),m._logger.debug("Creating adapter. Shaka version: "+E().Player.version),n._config=e.Utils.Object.mergeDeep({},w,n._config),n._init(),n}return f(m,[{key:"applyTextTrackStyles",value:function(e,t,r){e.insertRule("#".concat(r," .").concat(m.textContainerClass," { align-items: ").concat({left:"flex-start",center:"center",right:"flex-end"}[t.textAlign],"!important; }"),0),e.insertRule("#".concat(r," .").concat(m.textContainerClass," > * { ").concat(t.toCSS()," }"),0)}},{key:"setMaxBitrate",value:function(e){this._hasLowerOrEqualBitrate(e)&&this._shaka.configure({abr:{restrictions:{maxBandwidth:e}}})}},{key:"_getSortedTracks",value:function(){return this._shaka.getVariantTracks().map((function(e){return{id:e.id,bandwidth:e.bandwidth,active:e.active}})).sort((function(e,t){return e.bandwidth-t.bandwidth}))}},{key:"_hasLowerOrEqualBitrate",value:function(e){return this._getSortedTracks()[0].bandwidth<=e}},{key:"_init",value:function(){E().polyfill.installAll(),this._shaka=new(E().Player),this._config.useShakaTextTrackDisplay&&this._shaka.setVideoContainer(e.Utils.Dom.getElementBySelector(".playkit-subtitles")),this._maybeSetFilters(),this._maybeSetDrmConfig(),this._maybeBreakStalls(),this._shaka.configure(this._config.shakaConfig),this._addBindings()}},{key:"_clearStallInterval",value:function(){this._stallInterval&&(clearInterval(this._stallInterval),this._stallInterval=null)}},{key:"_stallHandler",value:function(){var e=this;this._clearStallInterval();var t=function(){return Date.now()/1e3},r=t(),n=this._videoElement.currentTime;this._stallInterval=window.setInterval((function(){t()-r>e._config.stallDetectionThreshold&&!e._videoElement.paused&&(n===e._videoElement.currentTime&&(m._logger.debug("stall found, break the stall"),e._videoElement.currentTime=parseFloat(e._videoElement.currentTime.toFixed(1))+.1),e._clearStallInterval()),n=e._videoElement.currentTime}),500)}},{key:"_maybeBreakStalls",value:function(){var t=this;this._config.forceBreakStall&&this._eventManager.listen(this._videoElement,e.EventType.SEEKING,(function(){return t._stallHandler()}))}},{key:"_maybeGetRedirectedUrl",value:function(t){var r=this._config.forceRedirectExternalStreams,n=this._config.redirectExternalStreamsTimeout,i=this._config.redirectExternalStreamsHandler;return new Promise((function(a){if(!r)return a(t);e.Utils.Http.jsonp(t,i,{timeout:n}).then((function(e){a(e)})).catch((function(){return a(t)}))}))}},{key:"_maybeSetFilters",value:function(){var t,r,n=this;"function"==typeof e.Utils.Object.getPropertyPath(this._config,"network.requestFilter")&&(m._logger.debug("Register request filter"),null===(t=this._shaka.getNetworkingEngine())||void 0===t||t.registerRequestFilter((function(t,r){if(Object.values(e.RequestType).includes(t)){var i,a={url:r.uris[0],body:r.body,headers:r.headers};try{i=n._config.network.requestFilter(t,a)}catch(e){i=Promise.reject(e)}return(i=i||Promise.resolve(a)).then((function(e){r.uris=[e.url],r.headers=e.headers,"boolean"==typeof e.withCredentials&&(r.allowCrossSiteCredentials=e.withCredentials),"POST"===r.method?r.body=e.body:e.body&&m._logger.warn("Request with ".concat(r.method," method cannot have body"))})).catch((function(e){throw n._requestFilterError=!0,e}))}}))),"function"==typeof e.Utils.Object.getPropertyPath(this._config,"network.responseFilter")&&(m._logger.debug("Register response filter"),null===(r=this._shaka.getNetworkingEngine())||void 0===r||r.registerResponseFilter((function(t,r){if(Object.values(e.RequestType).includes(t)){var i,a=r.uri,o=r.data,s=r.headers,u={url:a,originalUrl:n._sourceObj.url,data:o,headers:s};try{i=n._config.network.responseFilter(t,u)}catch(e){i=Promise.reject(e)}return(i=i||Promise.resolve(u)).then((function(e){r.data=e.data})).catch((function(e){throw n._responseFilterError=!0,e}))}})))}},{key:"_maybeSetDrmConfig",value:function(){if(this._sourceObj&&this._sourceObj.drmData){var t,r={},n=X(m._availableDrmProtocol);try{for(n.s();!(t=n.n()).done;)t.value.setDrmPlayback(r,this._sourceObj.drmData),this._config.shakaConfig.drm&&e.Utils.Object.mergeDeep(r.drm,this._config.shakaConfig.drm),e.Utils.Object.mergeDeep(this._config.shakaConfig,r)}catch(e){n.e(e)}finally{n.f()}}}},{key:"_maybeCapLevelToPlayerSize",value:function(){var e=this;if(this._config.capLevelToPlayerSize){var t=function(){return{minHeight:0,maxHeight:e._videoHeight,minWidth:0,maxWidth:e._videoWidth,minBitrate:0,maxBitrate:1/0}};this._clearVideoUpdateTimer(),this._videoSizeUpdateTimer=window.setInterval((function(){return e._updateRestriction(t())}),1e3),this._updateRestriction(t())}}},{key:"_maybeApplyAbrRestrictions",value:function(){this._config.capLevelToPlayerSize||(this._clearVideoUpdateTimer(),e.Utils.Object.hasPropertyPath(this._config,"abr.restrictions")&&this._updateRestriction(this._config.abr.restrictions))}},{key:"_updateRestriction",value:function(e){var t=this._getRestrictionShakaConfig(e);this._shaka.configure({abr:{restrictions:t}})}},{key:"_getRestrictionShakaConfig",value:function(e){var t=this,r=function(e){var r=t._getVideoTracks();return Math.min.apply(null,r.map((function(t){return t[e]})))},n={};if(e){var i=e.maxHeight,a=e.maxWidth,o=e.maxBitrate,s=e.minHeight,u=e.minWidth,c=e.minBitrate,l=Math.max(s,0),h=Math.max(i,r("height"));h>=l?(n.minHeight=l,n.maxHeight=h):m._logger.warn("Invalid maxHeight restriction, maxHeight must be greater than minHeight",s,i);var f=Math.max(u,0),d=Math.max(a,r("width"));d>=f?(n.minWidth=f,n.maxWidth=d):m._logger.warn("Invalid maxWidth restriction, maxWidth must be greater than minWidth",u,a);var p=Math.max(c,0),v=Math.max(o,r("bandwidth"));v>=p?(n.minBandwidth=p,n.maxBandwidth=v):m._logger.warn("Invalid maxBitrate restriction, maxBitrate must be greater than minBitrate",c,o)}return n}},{key:"attachMediaSource",value:function(){this._shaka||(this._videoElement&&this._videoElement.src&&(e.Utils.Dom.setAttribute(this._videoElement,"src",""),e.Utils.Dom.removeAttribute(this._videoElement,"src")),this._init())}},{key:"detachMediaSource",value:function(){var e=this;return this._shaka?(0===Math.floor(this.duration-this.currentTime)?this._lastTimeDetach=0:this.currentTime>0&&(this._lastTimeDetach=this.currentTime),this._reset().then((function(){e._shaka=null,e._loadPromise=void 0}))):Promise.resolve()}},{key:"_clearVideoUpdateTimer",value:function(){this._videoSizeUpdateTimer&&(clearInterval(this._videoSizeUpdateTimer),this._videoSizeUpdateTimer=null)}},{key:"_videoWidth",get:function(){var e,t=this._videoElement;return t&&(e=t.width||t.clientWidth||t.offsetWidth,e*=this._contentScaleFactor),e}},{key:"_videoHeight",get:function(){var e,t=this._videoElement;return t&&(e=t.height||t.clientHeight||t.offsetHeight,e*=this._contentScaleFactor),e}},{key:"_contentScaleFactor",get:function(){var e=1;try{e=window.devicePixelRatio}catch(e){m._logger.debug("failed reading devicePixelRatio, assume 1")}return e}},{key:"_addBindings",value:function(){var t,r=this;this._eventManager.listen(this._shaka,Q,this._adapterEventsBindings.adaptation),this._eventManager.listen(this._shaka,J,this._adapterEventsBindings.error),this._eventManager.listen(this._shaka,te,this._adapterEventsBindings.drmsessionupdate),this._eventManager.listen(this._videoElement,e.EventType.WAITING,this._adapterEventsBindings.waiting),this._eventManager.listen(this._videoElement,e.EventType.PLAYING,this._adapterEventsBindings.playing),this._eventManager.listen(this._videoElement,e.EventType.LOADED_DATA,(function(){return r._onLoadedData()})),this._eventManager.listenOnce(this._videoElement,e.EventType.PLAYING,(function(){r._eventManager.listen(r._shaka,ee,r._adapterEventsBindings.buffering)})),this._config.trackEmsgEvents&&this._eventManager.listen(this._shaka,re,this._adapterEventsBindings.emsg),this._eventManager.listen(this._shaka,ne,this._adapterEventsBindings.timelineregionadded),this._eventManager.listen(this._shaka,ie,this._adapterEventsBindings.timelineregionenter),this._eventManager.listen(this._shaka,ae,this._adapterEventsBindings.timelineregionexit),null===(t=this._shaka.getNetworkingEngine())||void 0===t||t.registerResponseFilter((function(t,n){switch(t){case E().net.NetworkingEngine.RequestType.SEGMENT:r._trigger(e.EventType.FRAG_LOADED,{miliSeconds:n.timeMs,bytes:n.data.byteLength,url:n.uri}),r.isLive()&&r._dispatchNativeEvent(e.EventType.DURATION_CHANGE);break;case E().net.NetworkingEngine.RequestType.MANIFEST:r._parseManifest(n.data),r._playbackActualUri=n.uri,r._trigger(e.EventType.MANIFEST_LOADED,{miliSeconds:n.timeMs}),setTimeout((function(){var e,t;r._isLive=r._isLive||(null===(e=r._shaka)||void 0===e?void 0:e.isLive()),!r._isLive||null!==(t=r._shaka)&&void 0!==t&&t.isLive()||r._isStaticLive||!r._config.switchDynamicToStatic||(r._sourceObj.url=n.uri,r._switchFromDynamicToStatic())}))}}))}},{key:"_onLoadedData",value:function(){var e=this;this._setLowLatencyMode();var t=this.getSegmentDuration();this._seekRangeStart=this._shaka.seekRange().start,this._startOverTimeout=window.setTimeout((function(){e._shaka.seekRange().start-e._seekRangeStart>=t&&(e._isStartOver=!1)}),1e3*(t+1))}},{key:"_switchFromDynamicToStatic",value:(a=s(T().mark((function t(){var r,n,i;return T().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return m._logger.info("Switching from dynamic manifest to static"),this._dispatchNativeEvent(e.EventType.WAITING),r=this._videoElement.currentTime-this._seekRangeStart,n=this.isAdaptiveBitrateEnabled(),i=this._videoElement.paused,t.next=7,this.detachMediaSource();case 7:return this._isStaticLive=!0,this._isLive=!0,this.attachMediaSource(),t.next=12,this.load();case 12:this._videoElement.currentTime=r,i||this._videoElement.play(),n?this._onAdaptation():this._selectedVideoTrack&&this.selectVideoTrack(this._selectedVideoTrack);case 15:case"end":return t.stop()}}),t,this)}))),function(){return a.apply(this,arguments)})},{key:"_setLowLatencyMode",value:function(){this._shaka.configure({streaming:{lowLatencyMode:"boolean"==typeof this._config.lowLatencyMode?this._config.lowLatencyMode:this.isLive()}})}},{key:"_parseManifest",value:function(e){!this._manifestParser&&Y.isValid()&&(m._logger.debug("Creating parser for the first time"),this._manifestParser=new Y(e),this._manifestParser.parseManifest())}},{key:"load",value:(i=s(T().mark((function t(r){var n=this;return T().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._loadPromise){t.next=5;break}return t.next=3,this._removeMediaKeys();case 3:this._shaka.attach(this._videoElement),this._loadPromise=new Promise((function(t,i){if(n._sourceObj&&n._sourceObj.url){n._trigger(e.EventType.ABR_MODE_CHANGED,{mode:n.isAdaptiveBitrateEnabled()?"auto":"manual"});var a="number"==typeof r&&r>-1?r:void 0;a=isNaN(n._lastTimeDetach)?a:n._lastTimeDetach,n._lastTimeDetach=NaN,n._maybeGetRedirectedUrl(n._sourceObj.url).then((function(e){return n._shaka.load(e,a)})).then((function(){var e={tracks:n._getParsedTracks()};n._maybeCapLevelToPlayerSize(),m._logger.debug("The source has been loaded successfully"),t(e)})).catch((function(t){i(new e.Error(n._isDestroyInProgress?e.Error.Severity.RECOVERABLE:t.severity,t.category,t.code,t.data))}))}}));case 5:return t.abrupt("return",this._loadPromise);case 6:case"end":return t.stop()}}),t,this)}))),function(e){return i.apply(this,arguments)})},{key:"destroy",value:function(){var e=this;return this._isDestroyInProgress=!0,new Promise((function(t,r){v(p(m.prototype),"destroy",e).call(e).then((function(){m._logger.debug("destroy"),e._loadPromise=void 0,e._adapterEventsBindings={},e._reset().then((function(r){e._isDestroyInProgress=!1,t(r)})).catch((function(t){e._isDestroyInProgress=!1,r(t)}))}))}))}},{key:"getThumbnail",value:function(e){return this._thumbnailController?this._thumbnailController.getThumbnail(e):null}},{key:"_reset",value:function(){return this._buffering=!1,this._waitingSent=!1,this._playingSent=!1,this._isLive=!1,this._isStaticLive=!1,this._requestFilterError=!1,this._responseFilterError=!1,this._manifestParser=null,this._thumbnailController=null,this._errorCounter={},this._clearStallInterval(),this._clearVideoUpdateTimer(),clearTimeout(this._startOverTimeout),this._eventManager&&this._eventManager.removeAll(),this._shaka?this._shaka.destroy():Promise.resolve()}},{key:"_removeMediaKeys",value:(r=s(T().mark((function e(){return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._videoElement||!this._videoElement.mediaKeys){e.next=16;break}return e.prev=1,m._logger.debug("Removing mediaKeys from the video element"),e.next=5,this._videoElement.setMediaKeys(null);case 5:m._logger.debug("mediaKeys removed"),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),m._logger.warn("mediaKeys not cleared");case 11:return e.prev=11,e.abrupt("return",Promise.resolve());case 14:e.next=17;break;case 16:return e.abrupt("return",Promise.resolve());case 17:case"end":return e.stop()}}),e,this,[[1,8,11,14]])}))),function(){return r.apply(this,arguments)})},{key:"_getVideoTracks",value:function(){var e=this._shaka.getVariantTracks(),t=this._getActiveTrack();return e.filter((function(e){return e.audioId===t.audioId}))}},{key:"_getActiveTrack",value:function(){return this._shaka.getVariantTracks().find((function(e){return e.active}))}},{key:"_getAudioTracks",value:function(){var t=this._shaka.getVariantTracks(),r=this._shaka.getAudioLanguagesAndRoles();return r.forEach((function(r){var n=t.filter((function(e){return e.language===r.language&&(!r.role||!e.audioRoles||e.audioRoles.includes(r.role))})),i=n.map((function(e){return e.id})).join("_"),a=n.some((function(e){return e.active})),o=n.some((function(e){return e.accessibilityPurpose}));r.id=i,r.label=n[0].label,r.active=a,r.kind=o?e.AudioTrackKind.DESCRIPTION:e.AudioTrackKind.MAIN})),r}},{key:"_getParsedTracks",value:function(){if(this._shaka){var e=this._getParsedVideoTracks(),t=this._getParsedAudioTracks(),r=this._getParsedTextTracks(),i=this._getParsedImageTracks();return[].concat(n(e),n(t),n(r),n(i))}return[]}},{key:"_getParsedVideoTracks",value:function(){var t=this._getVideoTracks(),r=[];if(t)for(var n=0;n<t.length;n++){var i={id:t[n].id,bandwidth:t[n].videoBandwidth||t[n].bandwidth,width:t[n].width,height:t[n].height,active:t[n].active,index:n};r.push(new e.VideoTrack(i))}return r}},{key:"_getParsedAudioTracks",value:function(){var t=this._getAudioTracks(),r=[];if(t)for(var n=0;n<t.length;n++){var i={id:t[n].id,active:t[n].active,label:t[n].label,language:t[n].language,index:n,kind:t[n].kind};r.push(new e.AudioTrack(i))}return r}},{key:"_getParsedTextTracks",value:function(){var t,r=[],n=X(this._shaka.getTextTracks());try{for(n.s();!(t=n.n()).done;){var i=t.value,a=i.kind?i.kind+"s":"";a=""===a&&this._config.useShakaTextTrackDisplay?"captions":a;var o={id:i.id,kind:a,active:!1,default:i.primary,label:i.label,language:i.language};r.push(new e.TextTrack(o))}}catch(e){n.e(e)}finally{n.f()}return r}},{key:"_getParsedImageTracks",value:function(){var e,t,r=null===(e=this._manifestParser)||void 0===e?void 0:e.getImageSet(),n=(null===(t=this._manifestParser)||void 0===t?void 0:t.getBaseUrl())||"";return r?(this._thumbnailController=new $(r,this._playbackActualUri,n),this._thumbnailController.getTracks()):[]}},{key:"selectVideoTrack",value:function(t){if(this._shaka){var r=this._getVideoTracks();if(t instanceof e.VideoTrack&&r){var n=r[t.index];n&&(this.isAdaptiveBitrateEnabled()&&(this._shaka.configure({abr:{enabled:!1}}),this._trigger(e.EventType.ABR_MODE_CHANGED,{mode:"manual"})),n.active||(this._selectedVideoTrack=t,this._shaka.selectVariantTrack(r[t.index],!0),this._onTrackChanged(t)))}}}},{key:"selectAudioTrack",value:function(t){this._shaka&&t instanceof e.AudioTrack&&!t.active&&(this._shaka.selectAudioLanguage(t.language),this._onTrackChanged(t))}},{key:"selectTextTrack",value:function(t){this._shaka&&t instanceof e.TextTrack&&!t.active&&("subtitles"===t.kind||"captions"===t.kind)&&(this._shaka.setTextTrackVisibility(this._config.textTrackVisibile),this._shaka.selectTextLanguage(t.language),this._onTrackChanged(t))}},{key:"selectImageTrack",value:function(t){this._shaka&&this._thumbnailController&&t instanceof e.ImageTrack&&!t.active&&(this._thumbnailController.selectTrack(t),this._onTrackChanged(t))}},{key:"hideTextTrack",value:function(){this._shaka&&this._shaka.setTextTrackVisibility(!1)}},{key:"enableAdaptiveBitrate",value:function(){this._shaka&&!this.isAdaptiveBitrateEnabled()&&(this._trigger(e.EventType.ABR_MODE_CHANGED,{mode:"auto"}),this._shaka.configure({abr:{enabled:!0}}))}},{key:"isAdaptiveBitrateEnabled",value:function(){return!!this._shaka&&this._shaka.getConfiguration().abr.enabled}},{key:"applyABRRestriction",value:function(t){if(e.Utils.Object.createPropertyPath(this._config,"abr.restrictions",t),this._maybeApplyAbrRestrictions(),!this.isAdaptiveBitrateEnabled()){var r=this._getParsedVideoTracks(),n=(0,e.filterTracksByRestriction)(r,this._config.abr.restrictions);n.length&&(n.find((function(e){return e.active}))||this.selectVideoTrack(n[0]))}}},{key:"_getLiveEdge",value:function(){return this._shaka?this._shaka.seekRange().end:NaN}},{key:"seekToLiveEdge",value:function(){this._shaka&&this._videoElement.readyState>0&&(this._videoElement.currentTime=this._getLiveEdge())}},{key:"isLive",value:function(){var e;return(null===(e=this._shaka)||void 0===e?void 0:e.isLive())||this._isLive}},{key:"liveDuration",get:function(){return this._getLiveEdge()}},{key:"getSegmentDuration",value:function(){return this._shaka?this._shaka.getStats().maxSegmentDuration:0}},{key:"_onAdaptation",value:function(){var e=this._getParsedVideoTracks().find((function(e){return e.active}));this._onTrackChanged(e)}},{key:"_onError",value:function(t){if(t&&t.detail){var r=t.detail;if(r.code===this.VIDEO_ERROR_CODE)return;(this._requestFilterError||this._responseFilterError)&&r.data[0]instanceof E().util.Error&&(r=r.data[0],this._requestFilterError?this._requestFilterError=!1:this._responseFilterError=!1),r.severity=this._shouldErrorChangeSeverity(r.code)?e.Error.Severity.CRITICAL:r.severity,this._trigger(e.EventType.ERROR,new e.Error(r.severity,r.category,r.code,r.data)),m._logger.error(r),r.severity===e.Error.Severity.CRITICAL&&this.destroy()}}},{key:"_shouldErrorChangeSeverity",value:function(e){var t=function(){return Date.now()/1e3};return e in this._errorCounter?(this._errorCounter[e].count+=1,this._errorCounter[e].count>3?(delete this._errorCounter[e],!0):t()-this._errorCounter[e].timeStamp>30&&(this._errorCounter[e].timeStamp=t(),this._errorCounter[e].count=1,!1)):(this._errorCounter[e]={count:1,timeStamp:t()},!1)}},{key:"_onBuffering",value:function(t){t.buffering?this._waitingSent||(this._dispatchNativeEvent(e.EventType.WAITING),this._buffering=!0):(this._buffering=!1,this._videoElement.paused||this._playingSent||this._dispatchNativeEvent(e.EventType.PLAYING))}},{key:"_dispatchNativeEvent",value:function(e){var t;"function"==typeof window.Event?t=new Event(e):(t=document.createEvent("Event")).initEvent(e,!0,!0),this._videoElement.dispatchEvent(t)}},{key:"_onDrmSessionUpdate",value:function(){var t;this._trigger(