@vkontakte/videoplayer-core 2.0.42 → 2.0.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es2015.cjs.js +6 -0
- package/es2015.esm.js +6 -0
- package/es2018.cjs.js +4 -4
- package/es2018.esm.js +4 -4
- package/esnext.cjs.js +4 -4
- package/esnext.esm.js +4 -4
- package/package.json +2 -2
- package/player/Player.d.ts +4 -1
- package/player/types.d.ts +6 -1
- package/player/utils/watchCoverage.d.ts +5 -4
- package/providers/DashLiveProvider/utils/LiveDashPlayer.d.ts +2 -0
- package/providers/DashVKProvider/lib/types.d.ts +1 -0
- package/providers/ProviderContainer/index.d.ts +1 -0
- package/providers/types.d.ts +3 -0
- package/providers/utils/observableVideo.d.ts +1 -0
- package/utils/autoSelectVideoTrack.d.ts +3 -1
- package/utils/quality/types.d.ts +8 -0
- package/utils/quality/utils.d.ts +3 -1
- package/es5.cjs.js +0 -6
- package/es5.esm.js +0 -6
package/es5.esm.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @vkontakte/videoplayer-core v2.0.42
|
|
3
|
-
* Tue, 15 Mar 2022 22:20:55 GMT
|
|
4
|
-
* https://st.mycdn.me/static/playersdk/2-0-42/doc/
|
|
5
|
-
*/
|
|
6
|
-
import{ValueSubject as t,Subject as e,Subscription as r,isNonNullable as i,isNullable as n,fromEvent as a,assertNever as o,merge as s,tap as u,map as c,observableFrom as d,filterChanged as l,assertNonNullable as p,Observable as h,once as f,debounce as v,now as m,combine as S,filter as g,timeout as y,mapTo as b,throttle as T,Logger as E}from'@vkontakte/videoplayer-shared';export{Observable,Subject,Subscription,ValueSubject}from'@vkontakte/videoplayer-shared';import w from'lodash/debounce';var P,A,k,$,_,D;!function(t){t.STOPPED='stopped',t.PLAYING='playing',t.PAUSED='paused'}(P||(P={})),function(t){t.MPEG='MPEG',t.DASH='DASH',t.DASH_SEP='DASH_SEP',t.DASH_SEP_VK='DASH_SEP_VK',t.DASH_WEBM='DASH_WEBM',t.DASH_WEBM_VK='DASH_WEBM_VK',t.DASH_ONDEMAND='DASH_ONDEMAND',t.DASH_LIVE='DASH_LIVE',t.DASH_LIVE_WEBM='DASH_LIVE_WEBM',t.HLS='HLS',t.HLS_ONDEMAND='HLS_ONDEMAND',t.HLS_JS='HLS_JS',t.HLS_LIVE='HLS_LIVE'}(A||(A={})),function(t){t.SCREEN='SCREEN',t.CHROMECAST='CHROMECAST'}(k||(k={})),function(t){t.NOT_AVAILABLE='NOT_AVAILABLE',t.AVAILABLE='AVAILABLE',t.CONNECTING='CONNECTING',t.CONNECTED='CONNECTED'}($||($={})),function(t){t.SuccessWithSound='success_with_sound',t.SuccessWithoutSound='success_without_sound',t.Failed='failed'}(_||(_={})),function(t){t.HTTP1='http1',t.HTTP2='http2',t.QUIC='quic'}(D||(D={}));var R=function(){return(R=Object.assign||function(t){for(var e,r=1,i=arguments.length;r<i;r++)for(var n in e=arguments[r])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)};function I(t,e,r,i){return new(r||(r=Promise))((function(n,a){function o(t){try{u(i.next(t))}catch(t){a(t)}}function s(t){try{u(i.throw(t))}catch(t){a(t)}}function u(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,s)}u((i=i.apply(t,e||[])).next())}))}function x(t,e){var r,i,n,a,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},'function'==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(r)throw new TypeError('Generator is already executing.');for(;o;)try{if(r=1,i&&(n=2&a[0]?i.return:a[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,a[1])).done)return n;switch(i=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,i=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(n=o.trys,(n=n.length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){o.label=a[1];break}if(6===a[0]&&o.label<n[1]){o.label=n[1],n=a;break}if(n&&o.label<n[2]){o.label=n[2],o.ops.push(a);break}n[2]&&o.ops.pop(),o.trys.pop();continue}a=e.call(t,o)}catch(t){a=[6,t],i=0}finally{r=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}function L(t){var e='function'==typeof Symbol&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&'number'==typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?'Object is not iterable.':'Symbol.iterator is not defined.')}function O(t,e){var r='function'==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var i,n,a=r.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(i=a.next()).done;)o.push(i.value)}catch(t){n={error:t}}finally{try{i&&!i.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return o}function C(t,e,r){if(r||2===arguments.length)for(var i,n=0,a=e.length;n<a;n++)!i&&n in e||(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))}var N={throughputEstimator:{emaAlphaSlow:.2,emaAlphaFast:.7,changeThreshold:.2,useBrowserEstimation:!0,rttPenaltyRequestSize:1048576,streamMinSampleSize:10240,streamMinSampleTime:300},autoTrackSelection:{bitrateFactorAtEmptyBuffer:1.8,bitrateFactorAtFullBuffer:1.2,usePixelRatio:!0,limitByContainer:!0,containerSizeFactor:2,lazyQualitySwitch:!1},dash:{extraInitSize:1e3,forwardBufferTarget:3e4,segmentRequestSize:1048576,representationSwitchForwardBufferGap:3e3},enableTelemetryAtStart:!1,formatsToAvoid:[A.DASH_WEBM,A.DASH_SEP,A.DASH_SEP_VK],disableChromecast:!1,chromecastReceiverId:void 0,useWebmBigRequest:!0,bigRequestMinInitSize:51200,bigRequestMinDataSize:1048576,stripRangeHeader:!0,flushShortLoopedBuffers:!0,insufficientBufferRuleMargin:1e4,dashSeekInSegmentDurationThreshold:18e4,dashSeekInSegmentAlwaysSeekDelta:1e4,endGapTolerance:300,stallIgnoreThreshold:33},M=function(){function h(n){var a,o=this;this.connection$=new t(void 0),this.castState$=new t($.NOT_AVAILABLE),this.errorEvent$=new e,this.realCastState$=new t($.NOT_AVAILABLE),this.subscription=new r,this.params=n,this.log=this.params.dependencies.logger.createComponentLog('ChromecastInitializer');var s,u='chrome'in window;(this.log({message:'[constructor] receiverApplicationId: '.concat(this.params.receiverApplicationId,', isDisabled: ').concat(this.params.isDisabled,', isSupported: ').concat(u)}),!n.isDisabled&&u)&&(i(null===(a=window.chrome)||void 0===a?void 0:a.cast)?this.initializeCastApi():(window.__onGCastApiAvailable=function(t){t&&o.initializeCastApi()},(s='https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1',new Promise((function(t,e){var r=document.createElement('script');r.setAttribute('src',s),r.onload=function(){return t},r.onerror=function(){return e},document.body.appendChild(r)}))).catch((function(){return o.errorEvent$.next({id:'ChromecastLoading',message:'Script loading failed!'})}))))}return h.prototype.connect=function(){var t;null===(t=cast.framework.CastContext.getInstance())||void 0===t||t.requestSession()},h.prototype.disconnect=function(){var t,e;null===(e=null===(t=cast.framework.CastContext.getInstance())||void 0===t?void 0:t.getCurrentSession())||void 0===e||e.endSession(!0)},h.prototype.stopMedia=function(){return new Promise((function(t,e){var r,i,n;null===(n=null===(i=null===(r=cast.framework.CastContext.getInstance())||void 0===r?void 0:r.getCurrentSession())||void 0===i?void 0:i.getMediaSession())||void 0===n||n.stop(new chrome.cast.media.StopRequest,t,e)}))},h.prototype.toggleConnection=function(){i(this.connection$.getValue())?this.disconnect():this.connect()},h.prototype.setVolume=function(t){var e=this.connection$.getValue();n(e)||(e.remotePlayer.volumeLevel=t,e.remotePlayerController.setVolumeLevel())},h.prototype.setMuted=function(t){var e=this.connection$.getValue();n(e)||t!==e.remotePlayer.isMuted&&e.remotePlayerController.muteOrUnmute()},h.prototype.destroy=function(){this.subscription.unsubscribe()},h.prototype.initListeners=function(){var t=this,e=new cast.framework.RemotePlayer,r=new cast.framework.RemotePlayerController(e),h=cast.framework.CastContext.getInstance();this.subscription.add(a(h,cast.framework.CastContextEventType.SESSION_STATE_CHANGED).subscribe((function(e){var r,i;switch(e.sessionState){case cast.framework.SessionState.SESSION_STARTED:case cast.framework.SessionState.SESSION_STARTING:case cast.framework.SessionState.SESSION_RESUMED:t.contentId=null===(i=null===(r=h.getCurrentSession())||void 0===r?void 0:r.getMediaSession())||void 0===i?void 0:i.media.contentId;break;case cast.framework.SessionState.NO_SESSION:case cast.framework.SessionState.SESSION_ENDING:case cast.framework.SessionState.SESSION_ENDED:case cast.framework.SessionState.SESSION_START_FAILED:t.contentId=void 0;break;default:return o(e.sessionState)}}))).add(s(a(h,cast.framework.CastContextEventType.CAST_STATE_CHANGED).pipe(u((function(e){t.log({message:'[cast.framework.RemotePlayerEventType.CAST_STATE_CHANGED]: '.concat(JSON.stringify(e))})})),c((function(t){return t.castState}))),d([h.getCastState()])).pipe(l(),c(B),u((function(e){t.log({message:'realCastState$: '.concat(e)})}))).subscribe(this.realCastState$)).add(this.realCastState$.subscribe((function(a){var o,s=a===$.CONNECTED,u=i(t.connection$.getValue());if(s&&!u){var c=h.getCurrentSession();p(c);var d=c.getCastDevice(),l=null===(o=c.getMediaSession())||void 0===o?void 0:o.media.contentId;(n(l)||l===t.contentId)&&(t.log({message:'connection created'}),t.connection$.next({remotePlayer:e,remotePlayerController:r,session:c,castDevice:d}))}else!s&&u&&(t.log({message:'connection destroyed'}),t.connection$.next(void 0));t.castState$.next(a===$.CONNECTED?i(t.connection$.getValue())?$.CONNECTED:$.AVAILABLE:a)})))},h.prototype.initializeCastApi=function(){var t,e,r,i;try{e=cast.framework.CastContext.getInstance(),r=chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,i=chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}catch(t){return}try{e.setOptions({receiverApplicationId:null!==(t=this.params.receiverApplicationId)&&void 0!==t?t:r,autoJoinPolicy:i}),this.initListeners()}catch(t){this.errorEvent$.next({id:'ChromecastInitializer',message:'[initializeCastApi] failed',thrown:t})}},h}(),B=function(t){switch(t){case cast.framework.CastState.NO_DEVICES_AVAILABLE:return $.NOT_AVAILABLE;case cast.framework.CastState.NOT_CONNECTED:return $.AVAILABLE;case cast.framework.CastState.CONNECTING:return $.CONNECTING;case cast.framework.CastState.CONNECTED:return $.CONNECTED;default:return o(t)}},U='undefined'!=typeof globalThis?globalThis:'undefined'!=typeof window?window:'undefined'!=typeof global?global:'undefined'!=typeof self?self:{},V=function(t){return t&&t.Math==Math&&t},F=V('object'==typeof globalThis&&globalThis)||V('object'==typeof window&&window)||V('object'==typeof self&&self)||V('object'==typeof U&&U)||function(){return this}()||Function('return this')(),H=function(t){try{return!!t()}catch(t){return!0}},q=!H((function(){var t=function(){}.bind();return'function'!=typeof t||t.hasOwnProperty('prototype')})),G=q,Y=Function.prototype,j=Y.apply,z=Y.call,Q='object'==typeof Reflect&&Reflect.apply||(G?z.bind(j):function(){return z.apply(j,arguments)}),W=q,J=Function.prototype,K=J.bind,X=J.call,Z=W&&K.bind(X,X),tt=W?function(t){return t&&Z(t)}:function(t){return t&&function(){return X.apply(t,arguments)}},et=function(t){return'function'==typeof t},rt={},it=!H((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),nt=q,at=Function.prototype.call,ot=nt?at.bind(at):function(){return at.apply(at,arguments)},st={},ut={}.propertyIsEnumerable,ct=Object.getOwnPropertyDescriptor,dt=ct&&!ut.call({1:2},1);st.f=dt?function(t){var e=ct(this,t);return!!e&&e.enumerable}:ut;var lt,pt,ht=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},ft=tt,vt=ft({}.toString),mt=ft(''.slice),St=function(t){return mt(vt(t),8,-1)},gt=tt,yt=H,bt=St,Tt=F.Object,Et=gt(''.split),wt=yt((function(){return!Tt('z').propertyIsEnumerable(0)}))?function(t){return'String'==bt(t)?Et(t,''):Tt(t)}:Tt,Pt=F.TypeError,At=function(t){if(null==t)throw Pt('Can\'t call method on '+t);return t},kt=wt,$t=At,_t=function(t){return kt($t(t))},Dt=et,Rt=function(t){return'object'==typeof t?null!==t:Dt(t)},It={},xt=It,Lt=F,Ot=et,Ct=function(t){return Ot(t)?t:void 0},Nt=function(t,e){return arguments.length<2?Ct(xt[t])||Ct(Lt[t]):xt[t]&&xt[t][e]||Lt[t]&&Lt[t][e]},Mt=tt({}.isPrototypeOf),Bt=Nt('navigator','userAgent')||'',Ut=F,Vt=Bt,Ft=Ut.process,Ht=Ut.Deno,qt=Ft&&Ft.versions||Ht&&Ht.version,Gt=qt&&qt.v8;Gt&&(pt=(lt=Gt.split('.'))[0]>0&<[0]<4?1:+(lt[0]+lt[1])),!pt&&Vt&&(!(lt=Vt.match(/Edge\/(\d+)/))||lt[1]>=74)&&(lt=Vt.match(/Chrome\/(\d+)/))&&(pt=+lt[1]);var Yt=pt,jt=Yt,zt=H,Qt=!!Object.getOwnPropertySymbols&&!zt((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&jt&&jt<41})),Wt=Qt&&!Symbol.sham&&'symbol'==typeof Symbol.iterator,Jt=Nt,Kt=et,Xt=Mt,Zt=Wt,te=F.Object,ee=Zt?function(t){return'symbol'==typeof t}:function(t){var e=Jt('Symbol');return Kt(e)&&Xt(e.prototype,te(t))},re=F.String,ie=function(t){try{return re(t)}catch(t){return'Object'}},ne=et,ae=ie,oe=F.TypeError,se=function(t){if(ne(t))return t;throw oe(ae(t)+' is not a function')},ue=se,ce=function(t,e){var r=t[e];return null==r?void 0:ue(r)},de=ot,le=et,pe=Rt,he=F.TypeError,fe={exports:{}},ve=F,me=Object.defineProperty,Se=function(t,e){try{me(ve,t,{value:e,configurable:!0,writable:!0})}catch(r){ve[t]=e}return e},ge=F['__core-js_shared__']||Se('__core-js_shared__',{}),ye=ge;(fe.exports=function(t,e){return ye[t]||(ye[t]=void 0!==e?e:{})})('versions',[]).push({version:'3.21.1',mode:'pure',copyright:'© 2014-2022 Denis Pushkarev (zloirock.ru)',license:'https://github.com/zloirock/core-js/blob/v3.21.1/LICENSE',source:'https://github.com/zloirock/core-js'});var be=At,Te=F.Object,Ee=function(t){return Te(be(t))},we=Ee,Pe=tt({}.hasOwnProperty),Ae=Object.hasOwn||function(t,e){return Pe(we(t),e)},ke=tt,$e=0,_e=Math.random(),De=ke(1..toString),Re=function(t){return'Symbol('+(void 0===t?'':t)+')_'+De(++$e+_e,36)},Ie=F,xe=fe.exports,Le=Ae,Oe=Re,Ce=Qt,Ne=Wt,Me=xe('wks'),Be=Ie.Symbol,Ue=Be&&Be.for,Ve=Ne?Be:Be&&Be.withoutSetter||Oe,Fe=function(t){if(!Le(Me,t)||!Ce&&'string'!=typeof Me[t]){var e='Symbol.'+t;Ce&&Le(Be,t)?Me[t]=Be[t]:Me[t]=Ne&&Ue?Ue(e):Ve(e)}return Me[t]},He=ot,qe=Rt,Ge=ee,Ye=ce,je=function(t,e){var r,i;if('string'===e&&le(r=t.toString)&&!pe(i=de(r,t)))return i;if(le(r=t.valueOf)&&!pe(i=de(r,t)))return i;if('string'!==e&&le(r=t.toString)&&!pe(i=de(r,t)))return i;throw he('Can\'t convert object to primitive value')},ze=Fe,Qe=F.TypeError,We=ze('toPrimitive'),Je=function(t,e){if(!qe(t)||Ge(t))return t;var r,i=Ye(t,We);if(i){if(void 0===e&&(e='default'),r=He(i,t,e),!qe(r)||Ge(r))return r;throw Qe('Can\'t convert object to primitive value')}return void 0===e&&(e='number'),je(t,e)},Ke=ee,Xe=function(t){var e=Je(t,'string');return Ke(e)?e:e+''},Ze=Rt,tr=F.document,er=Ze(tr)&&Ze(tr.createElement),rr=function(t){return er?tr.createElement(t):{}},ir=rr,nr=!it&&!H((function(){return 7!=Object.defineProperty(ir('div'),'a',{get:function(){return 7}}).a})),ar=it,or=ot,sr=st,ur=ht,cr=_t,dr=Xe,lr=Ae,pr=nr,hr=Object.getOwnPropertyDescriptor;rt.f=ar?hr:function(t,e){if(t=cr(t),e=dr(e),pr)try{return hr(t,e)}catch(t){}if(lr(t,e))return ur(!or(sr.f,t,e),t[e])};var fr=H,vr=et,mr=/#|\.prototype\./,Sr=function(t,e){var r=yr[gr(t)];return r==Tr||r!=br&&(vr(e)?fr(e):!!e)},gr=Sr.normalize=function(t){return String(t).replace(mr,'.').toLowerCase()},yr=Sr.data={},br=Sr.NATIVE='N',Tr=Sr.POLYFILL='P',Er=Sr,wr=se,Pr=q,Ar=tt(tt.bind),kr=function(t,e){return wr(t),void 0===e?t:Pr?Ar(t,e):function(){return t.apply(e,arguments)}},$r={},_r=it&&H((function(){return 42!=Object.defineProperty((function(){}),'prototype',{value:42,writable:!1}).prototype})),Dr=F,Rr=Rt,Ir=Dr.String,xr=Dr.TypeError,Lr=function(t){if(Rr(t))return t;throw xr(Ir(t)+' is not an object')},Or=it,Cr=nr,Nr=_r,Mr=Lr,Br=Xe,Ur=F.TypeError,Vr=Object.defineProperty,Fr=Object.getOwnPropertyDescriptor;$r.f=Or?Nr?function(t,e,r){if(Mr(t),e=Br(e),Mr(r),'function'==typeof t&&'prototype'===e&&'value'in r&&'writable'in r&&!r.writable){var i=Fr(t,e);i&&i.writable&&(t[e]=r.value,r={configurable:'configurable'in r?r.configurable:i.configurable,enumerable:'enumerable'in r?r.enumerable:i.enumerable,writable:!1})}return Vr(t,e,r)}:Vr:function(t,e,r){if(Mr(t),e=Br(e),Mr(r),Cr)try{return Vr(t,e,r)}catch(t){}if('get'in r||'set'in r)throw Ur('Accessors not supported');return'value'in r&&(t[e]=r.value),t};var Hr=$r,qr=ht,Gr=it?function(t,e,r){return Hr.f(t,e,qr(1,r))}:function(t,e,r){return t[e]=r,t},Yr=F,jr=Q,zr=tt,Qr=et,Wr=rt.f,Jr=Er,Kr=It,Xr=kr,Zr=Gr,ti=Ae,ei=function(t){var e=function(r,i,n){if(this instanceof e){switch(arguments.length){case 0:return new t;case 1:return new t(r);case 2:return new t(r,i)}return new t(r,i,n)}return jr(t,this,arguments)};return e.prototype=t.prototype,e},ri=function(t,e){var r,i,n,a,o,s,u,c,d=t.target,l=t.global,p=t.stat,h=t.proto,f=l?Yr:p?Yr[d]:(Yr[d]||{}).prototype,v=l?Kr:Kr[d]||Zr(Kr,d,{})[d],m=v.prototype;for(n in e)r=!Jr(l?n:d+(p?'.':'#')+n,t.forced)&&f&&ti(f,n),o=v[n],r&&(s=t.noTargetGet?(c=Wr(f,n))&&c.value:f[n]),a=r&&s?s:e[n],r&&typeof o==typeof a||(u=t.bind&&r?Xr(a,Yr):t.wrap&&r?ei(a):h&&Qr(a)?zr(a):a,(t.sham||a&&a.sham||o&&o.sham)&&Zr(u,'sham',!0),Zr(v,n,u),h&&(ti(Kr,i=d+'Prototype')||Zr(Kr,i,{}),Zr(Kr[i],n,a),t.real&&m&&!m[n]&&Zr(m,n,a)))},ii=Math.ceil,ni=Math.floor,ai=function(t){var e=+t;return e!=e||0===e?0:(e>0?ni:ii)(e)},oi=ai,si=Math.min,ui=function(t){return t>0?si(oi(t),9007199254740991):0},ci=function(t){return ui(t.length)},di=Ee,li=ci,pi=ai;ri({target:'Array',proto:!0},{at:function(t){var e=di(this),r=li(e),i=pi(t),n=i>=0?i:r+i;return n<0||n>=r?void 0:e[n]}});var hi,fi,vi,mi,Si=Nt,gi=Si('Array','at');!function(t){t.VIDEO='video',t.AUDIO='audio',t.TEXT='text'}(hi||(hi={})),function(t){t.WEBM_AS_IN_SPEC='urn:mpeg:dash:profile:webm-on-demand:2012',t.WEBM_AS_IN_FFMPEG='urn:webm:dash:profile:webm-on-demand:2012'}(fi||(fi={})),function(t){t.NONE='none',t.DOWNLOADING='downloading',t.DOWNLOADED='downloaded',t.FED='fed'}(vi||(vi={})),function(t){t.MP4='mp4',t.WEBM='webm'}(mi||(mi={}));var yi,bi,Ti=function(t){return I(void 0,void 0,void 0,(function(){var e,r,i;return x(this,(function(n){switch(n.label){case 0:e=t.muted,n.label=1;case 1:return n.trys.push([1,3,,8]),[4,t.play()];case 2:return n.sent(),[3,8];case 3:if((r=n.sent())instanceof DOMException&&(20===r.code||'AbortError'===r.name))return[2,!1];if(e)return console.warn(r),[2,!1];t.muted=!0,n.label=4;case 4:return n.trys.push([4,6,,7]),[4,t.play()];case 5:return n.sent(),[3,7];case 6:return i=n.sent(),t.muted=!1,console.warn(i),[2,!1];case 7:return[3,8];case 8:return[2,!0]}}))}))},Ei=function(t,e,i,a){var o=void 0===a?{}:a,s=o.equal,u=void 0===s?function(t,e){return t===e}:s,c=o.changed$,d=o.onError,l=t.getState(),p=e(),h=n(c),f=new r;return c&&f.add(c.subscribe((function(e){var r=t.getState();u(e,r)&&t.setState(e)}),d)),u(p,l)||(i(l),h&&t.setState(l)),f.add(t.stateChangeStarted$.subscribe((function(e){i(e.to),h&&t.setState(e.to)}),d)),f},wi=function(t,e,r){return Ei(e,(function(){return t.loop}),(function(e){i(e)&&(t.loop=e)}),{onError:r})},Pi=function(t,e,r,n){return Ei(e,(function(){return{muted:t.muted,volume:t.volume}}),(function(e){i(e)&&(t.muted=e.muted,t.volume=e.volume)}),{equal:function(t,e){return t===e||(null==t?void 0:t.muted)===(null==e?void 0:e.muted)&&(null==t?void 0:t.volume)===(null==e?void 0:e.volume)},changed$:r,onError:n})},Ai=function(t,e){if(t.id===e)return!0;var r=O(e.split('|'),3);r[0];var i=r[1],n=r[2];return t.language===i&&t.label===n},ki=function(){function n(){this.available$=new e,this.current$=new t(void 0),this.error$=new e,this.subscription=new r,this.externalTracks=new Map}return n.prototype.connect=function(t,e,r){var n=this;this.video=t,this.cueSettings=e.textTrackCuesSettings,this.subscribe();var a=function(t){n.error$.next({id:'TextTracksManager',message:'Generic HtmlVideoTextTrackManager error',thrown:t})};this.subscription.add(this.available$.subscribe(r.availableTextTracks$)),this.subscription.add(this.current$.subscribe(r.currentTextTrack$)),this.subscription.add(this.error$.subscribe(r.error$)),this.subscription.add(Ei(e.externalTextTracks,(function(){return Object.values(n.externalTracks)}),(function(t){i(t)&&n.setExternal(t)}),{equal:function(t,e){return i(t)&&i(e)&&t.length===e.length&&t.every((function(t,r){return t.id===e[r].id}))},changed$:this.available$.pipe(c((function(t){return t.filter((function(t){return'external'===t.type}))}))),onError:a})),this.subscription.add(Ei(e.currentTextTrack,(function(){if(!n.video){var t=n.htmlTextTracksAsArray().find((function(t){return'showing'===t.mode}));return t&&n.htmlTextTrackToITextTrack(t).id}}),(function(t){return n.select(t)}),{changed$:this.current$,onError:a})),this.subscription.add(Ei(e.textTrackCuesSettings,(function(){return{}}),(function(){var t,e;if(n.video)try{for(var r=L(n.htmlTextTracksAsArray()),i=r.next();!i.done;i=r.next()){var a=i.value;n.applyCueSettings(a.cues),n.applyCueSettings(a.activeCues)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(t)throw t.error}}})))},n.prototype.subscribe=function(){var t=this;p(this.video);var e=this.video.textTracks;this.subscription.add(a(e,'addtrack').subscribe((function(){var e=t.current$.getValue();t.select(e)}))),this.subscription.add(s(a(e,'addtrack'),a(e,'removetrack'),d(['init'])).pipe(c((function(){return t.htmlTextTracksAsArray().map((function(e){return t.htmlTextTrackToITextTrack(e)}))})),l((function(t,e){return t.length===e.length&&t.every((function(t,r){return t.id===e[r].id}))}))).subscribe(this.available$)),this.subscription.add(s(a(e,'change'),d(['init'])).pipe(c((function(){return t.htmlTextTracksAsArray().find((function(t){return'showing'===t.mode}))})),c((function(e){return e&&t.htmlTextTrackToITextTrack(e).id})),l()).subscribe(this.current$));var r=function(e){var r,i;return t.applyCueSettings(null!==(i=null===(r=e.target)||void 0===r?void 0:r.activeCues)&&void 0!==i?i:null)};this.subscription.add(a(e,'addtrack').subscribe((function(e){var i,n;null===(i=e.track)||void 0===i||i.addEventListener('cuechange',r);var a=function(e){var r,i,n,o,s,u=null!==(i=null===(r=e.target)||void 0===r?void 0:r.cues)&&void 0!==i?i:null;u&&u.length&&(t.applyCueSettings(null!==(o=null===(n=e.target)||void 0===n?void 0:n.cues)&&void 0!==o?o:null),null===(s=e.target)||void 0===s||s.removeEventListener('cuechange',a))};null===(n=e.track)||void 0===n||n.addEventListener('cuechange',a)}))),this.subscription.add(a(e,'removetrack').subscribe((function(t){var e;null===(e=t.track)||void 0===e||e.removeEventListener('cuechange',r)})))},n.prototype.applyCueSettings=function(t){var e,r;if(t&&t.length){var n=this.cueSettings.getState();try{for(var a=L(Array.from(t)),o=a.next();!o.done;o=a.next()){var s=o.value;i(n.align)&&(s.align=n.align),i(n.position)&&(s.position=n.position),i(n.size)&&(s.size=n.size),i(n.line)&&(s.line=n.line)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}}},n.prototype.htmlTextTracksAsArray=function(t){void 0===t&&(t=!1),p(this.video);var e=C([],O(this.video.textTracks),!1);return t?e:e.filter(n.isHealthyTrack)},n.prototype.htmlTextTrackToITextTrack=function(t){var e=t.language,r=t.label,i=''!==t.id?t.id:function(t){return['__',t.language,t.label].join('|')}(t);return this.externalTracks.has(i)?{id:i,type:'external',language:e,label:r,url:this.externalTracks.get(i).url}:{id:i,type:'internal',language:e,label:r}},n.isHealthyTrack=function(t){return'metadata'!==t.kind&&(''!==t.id||''!==t.label||''!==t.language)},n.prototype.setExternal=function(t){var e=this;t.filter((function(t){var r=t.id;return!e.externalTracks.has(r)})).forEach((function(t){return e.attach(t)})),Array.from(this.externalTracks.keys()).filter((function(e){return!t.find((function(t){return t.id===e}))})).forEach((function(t){return e.detach(t)}))},n.prototype.select=function(t){var e,r;p(this.video);try{for(var n=L(this.htmlTextTracksAsArray(!0)),a=n.next();!a.done;a=n.next()){var o=a.value;i(t)&&Ai(o,t)?o.mode='showing':o.mode='disabled'}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}},n.prototype.destroy=function(){var t,e;if(this.subscription.unsubscribe(),this.video)try{for(var r=L(Array.from(this.video.getElementsByTagName('track'))),i=r.next();!i.done;i=r.next()){var n=i.value,a=n.getAttribute('id');a&&this.externalTracks.has(a)&&this.video.removeChild(n)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(t)throw t.error}}this.externalTracks.clear()},n.prototype.attach=function(t){p(this.video);var e=document.createElement('track');e.setAttribute('src',t.url),e.setAttribute('id',t.id),t.label&&e.setAttribute('label',t.label),t.language&&e.setAttribute('srclang',t.language),this.externalTracks.set(t.id,t),this.video.appendChild(e)},n.prototype.detach=function(t){p(this.video);var e=Array.prototype.find.call(this.video.getElementsByTagName('track'),(function(e){return e.getAttribute('id')===t}));e&&this.video.removeChild(e),this.externalTracks.delete(t)},n}(),$i=function(t){var e=document.createElement('video');return e.setAttribute('crossorigin','anonymous'),e.setAttribute('playsinline','playsinline'),t.appendChild(e),e},_i=function(t){return new h((function(e){var i=0;return(new r).add(a(t,'loadstart').subscribe((function(){i=Date.now()}))).add(a(t,'loadeddata').subscribe((function(){e.next(Date.now()-i)})))})).pipe(f())},Di=function(){function t(t){this._buffer=[],this._source=t}return t.prototype.fill=function(){this._buffer=[];for(var t=this._source.currentTime,e=0,r=this._source.buffered.length;e<r;e++){var i=this._source.buffered.start(e),n=this._source.buffered.end(e);i>t&&i-t<3&&(i=t),this._buffer.push({start:i,end:n,i:e})}return this._buffer.sort((function(t,e){return t.start-e.start})),this._buffer},t.prototype.getByTime=function(t){return this._buffer.find((function(e){return t>=e.start&&t<e.end}))},t.prototype.getNextWithGap=function(t,e){var r=this.getNext(t);if(r&&r.start-t.end<(e||3))return r},t.prototype.getNext=function(t){var e=this._buffer.indexOf(t);if(~e&&this._buffer.length-1>e)return this._buffer[++e]},t.prototype.smartRemove=function(t,e,r){this._buffer.forEach((function(i){var n=i.start,a=i.end,o=n>=t&&n<e,s=a>=t&&a<e;o&&s||(o?r(e,a):s?r(n,t):n<t&&a>e?(r(e,a),r(n,t)):r(n,a))}))},t.prototype.destroy=function(){this._buffer=[]},t}(),Ri=function(t,e,r){void 0===r&&(r=3);for(var i=0,n=0,a=0;a<t.length;a++){var o=t.start(a),s=t.end(a);if(o<=e&&e<=s){if(i=o,n=s,!r)return{start:i,end:n};for(var u=a-1;u>=0;u--)t.end(u)+r>=i&&(i=t.start(u));for(var c=a+1;c<t.length;c++)t.start(c)-r<=n&&(n=t.end(c))}}return{start:i,end:n}},Ii=function(t){return new h((function(e){var i=0;return(new r).add(a(t,'loadstart').subscribe((function(){i=Date.now()}))).add(a(t,'loadedmetadata').subscribe((function(){e.next(Date.now()-i)})))})).pipe(f())},xi=function(t){var e=function(e,r){return void 0===r&&(r=function(){}),a(t,e).pipe(c(r))},r=s.apply(void 0,C([],O(['waiting','pause','canplay','play','canplaythrough','playing','seeking','seeked','ended'].map((function(e){return a(t,e)}))),!1)).pipe(c((function(){return t.readyState<3})),l()),i=s(a(t,'progress'),a(t,'timeupdate')).pipe(c((function(){return Ri(t.buffered,t.currentTime)}))),n=a(t,'volumechange').pipe(v(0),c((function(){return{muted:t.muted,volume:t.volume}}))),o=a(t,'error').pipe(c((function(){var e=t.error;return{id:e?'MediaError#'.concat(e.code):'HtmlVideoError',message:e?e.message:'Error event from HTML video element'}})));return{playing$:e('playing'),pause$:e('pause'),canplay$:e('canplay'),ended$:e('ended'),error$:o,seeked$:e('seeked'),seeking$:e('seeking'),progress$:e('progress'),loadedMetadata$:e('loadedmetadata'),loadedData$:e('loadeddata'),timeUpdate$:e('timeupdate',(function(){return t.currentTime})),durationChange$:e('durationchange',(function(){return t.duration})),isBuffering$:r,currentBuffer$:i,volumeState$:n,firstBytes$:Ii(t),firstFrame$:_i(t)}},Li=function(t,e,r){void 0===r&&(r=!1);var i=t.getTransition();!r&&i&&i.to!==e||t.setState(e)};!function(t){t.INVARIANT='Invariant quality',t.Q_144P='144p',t.Q_240P='240p',t.Q_360P='360p',t.Q_480P='480p',t.Q_720P='720p',t.Q_1080P='1080p',t.Q_1440P='1440p',t.Q_2160P='2160p',t.Q_4320P='4320p'}(yi||(yi={}));var Oi=((bi={})[yi.Q_144P]=144,bi[yi.Q_240P]=240,bi[yi.Q_360P]=360,bi[yi.Q_480P]=480,bi[yi.Q_720P]=720,bi[yi.Q_1080P]=1080,bi[yi.Q_1440P]=1440,bi[yi.Q_2160P]=2160,bi[yi.Q_4320P]=4320,bi),Ci=function(t,e){return Oi[t]>Oi[e]},Ni=function(t,e){return Oi[t]<Oi[e]},Mi=Object.keys(Oi).sort((function(t,e){return Ni(t,e)?-1:1})),Bi=function(t,e){var r=t.width,i=t.height;return function(t,e){return void 0===e&&(e=.02),C([],O(Mi),!1).find((function(r){return Oi[r]*(1+e)>=t}))}(Math.min(r,i),e)},Ui=function(t){return t===yi.INVARIANT},Vi=!1,Fi={},Hi=function(t){t(Fi)},qi=function(t,e){var r;Vi&&(Fi.meta=null!==(r=Fi.meta)&&void 0!==r?r:{},Fi.meta[t]=e)},Gi=function(){function t(t){this.name=t}return t.prototype.next=function(t){var e,r;if(Vi){Fi.series=null!==(e=Fi.series)&&void 0!==e?e:{};var i=null!==(r=Fi.series[this.name])&&void 0!==r?r:[];i.push([Date.now(),t]),Fi.series[this.name]=i}},t}(),Yi=new Gi('best_bitrate'),ji=function(t,e){var r,n,a=e.container,o=e.throughput,s=e.tuning,u=e.forwardBufferHealth,c=e.currentRepresentation,d=s.usePixelRatio&&null!==(r=window.devicePixelRatio)&&void 0!==r?r:1,l=s.limitByContainer&&a&&a.width>0&&a.height>0&&{width:a.width*d*s.containerSizeFactor,height:a.height*d*s.containerSizeFactor},p=l&&Bi(l,0),h=t.filter((function(t){return!Ui(t.quality)})).sort((function(t,e){return Ci(t.quality,e.quality)?-1:1})),f=h.filter((function(t){var e,r,n,a,d=!p||Ni(t.quality,p),l=!(i(o)&&isFinite(o)&&i(t.bitrate))||o>=t.bitrate*(r=null!=u?u:.5,n=s.bitrateFactorAtEmptyBuffer,a=s.bitrateFactorAtFullBuffer,(n-a)*Math.pow(2,-10*r)+a),h=!s.lazyQualitySwitch||!c||(null!=u?u:.5)>=.5||((null===(e=t.size)||void 0===e?void 0:e.height)||0)<=((null==c?void 0:c.height)||0);return d&&l&&h}))[0];return f&&f.bitrate&&Yi.next(f.bitrate),null!==(n=null!=f?f:h[h.length-1])&&void 0!==n?n:t[0]},zi=function(t,e){for(var r=0,i=0;i<t.length;i++){var n=1e3*t.start(i),a=1e3*t.end(i);n<=e&&e<=a&&(r=a)}return Math.max(r-e,0)},Qi=function(t){return new URL(t).hostname},Wi=function(t,e){return void 0===e&&(e=300),new h((function(r){var n=t.getBoundingClientRect(),a=n.width,o=n.height;if(r.next({width:a,height:o}),window.ResizeObserver){var s=new ResizeObserver(w((function(t){var e,n,a=t[0];a&&(a.contentBoxSize&&a.contentBoxSize[0]?(n=a.contentBoxSize[0].blockSize,e=a.contentBoxSize[0].inlineSize):a.contentRect&&(e=a.contentRect.width,n=a.contentRect.height),i(e)&&i(n)&&r.next({width:e,height:n}))}),e));return s.observe(t),function(){return s.disconnect()}}}))},Ji=function(){function t(t){this.transitionStarted$=new e,this.transitionEnded$=new e,this.transitionUpdated$=new e,this.forceChanged$=new e,this.stateChangeStarted$=s(this.transitionStarted$,this.transitionUpdated$),this.stateChangeEnded$=s(this.transitionEnded$,this.forceChanged$),this.state=t}return t.prototype.setState=function(t){var e=this.transition,r=this.state;this.transition=void 0,this.state=t,e?e.to===t?this.transitionEnded$.next(e):this.forceChanged$.next({from:e.from,to:t,canceledTransition:e}):this.forceChanged$.next({from:r,to:t,canceledTransition:e})},t.prototype.startTransitionTo=function(t){var e=this.transition,r=this.state;r===t||i(e)&&e.to===t||(this.state=t,e?(this.transition={from:e.from,to:t,canceledTransition:e},this.transitionUpdated$.next(this.transition)):(this.transition={from:r,to:t},this.transitionStarted$.next(this.transition)))},t.prototype.getTransition=function(){return this.transition},t.prototype.getState=function(){return this.state},t}(),Ki={},Xi=et,Zi=ge,tn=tt(Function.toString);Xi(Zi.inspectSource)||(Zi.inspectSource=function(t){return tn(t)});var en,rn,nn,an=Zi.inspectSource,on=et,sn=an,un=F.WeakMap,cn=on(un)&&/native code/.test(sn(un)),dn=fe.exports,ln=Re,pn=dn('keys'),hn=function(t){return pn[t]||(pn[t]=ln(t))},fn={},vn=cn,mn=F,Sn=tt,gn=Rt,yn=Gr,bn=Ae,Tn=ge,En=hn,wn=fn,Pn=mn.TypeError,An=mn.WeakMap;if(vn||Tn.state){var kn=Tn.state||(Tn.state=new An),$n=Sn(kn.get),_n=Sn(kn.has),Dn=Sn(kn.set);en=function(t,e){if(_n(kn,t))throw new Pn('Object already initialized');return e.facade=t,Dn(kn,t,e),e},rn=function(t){return $n(kn,t)||{}},nn=function(t){return _n(kn,t)}}else{var Rn=En('state');wn[Rn]=!0,en=function(t,e){if(bn(t,Rn))throw new Pn('Object already initialized');return e.facade=t,yn(t,Rn,e),e},rn=function(t){return bn(t,Rn)?t[Rn]:{}},nn=function(t){return bn(t,Rn)}}var In={set:en,get:rn,has:nn,enforce:function(t){return nn(t)?rn(t):en(t,{})},getterFor:function(t){return function(e){var r;if(!gn(e)||(r=rn(e)).type!==t)throw Pn('Incompatible receiver, '+t+' required');return r}}},xn=it,Ln=Ae,On=Function.prototype,Cn=xn&&Object.getOwnPropertyDescriptor,Nn=Ln(On,'name'),Mn={EXISTS:Nn,PROPER:Nn&&'something'===function(){}.name,CONFIGURABLE:Nn&&(!xn||xn&&Cn(On,'name').configurable)},Bn={},Un=ai,Vn=Math.max,Fn=Math.min,Hn=_t,qn=function(t,e){var r=Un(t);return r<0?Vn(r+e,0):Fn(r,e)},Gn=ci,Yn=function(t){return function(e,r,i){var n,a=Hn(e),o=Gn(a),s=qn(i,o);if(t&&r!=r){for(;o>s;)if((n=a[s++])!=n)return!0}else for(;o>s;s++)if((t||s in a)&&a[s]===r)return t||s||0;return!t&&-1}},jn={includes:Yn(!0),indexOf:Yn(!1)},zn=Ae,Qn=_t,Wn=jn.indexOf,Jn=fn,Kn=tt([].push),Xn=['constructor','hasOwnProperty','isPrototypeOf','propertyIsEnumerable','toLocaleString','toString','valueOf'],Zn=function(t,e){var r,i=Qn(t),n=0,a=[];for(r in i)!zn(Jn,r)&&zn(i,r)&&Kn(a,r);for(;e.length>n;)zn(i,r=e[n++])&&(~Wn(a,r)||Kn(a,r));return a},ta=Xn,ea=Object.keys||function(t){return Zn(t,ta)},ra=it,ia=_r,na=$r,aa=Lr,oa=_t,sa=ea;Bn.f=ra&&!ia?Object.defineProperties:function(t,e){aa(t);for(var r,i=oa(e),n=sa(e),a=n.length,o=0;a>o;)na.f(t,r=n[o++],i[r]);return t};var ua,ca=Nt('document','documentElement'),da=Lr,la=Bn,pa=Xn,ha=fn,fa=ca,va=rr,ma=hn('IE_PROTO'),Sa=function(){},ga=function(t){return'<script>'+t+'<\/script>'},ya=function(t){t.write(ga('')),t.close();var e=t.parentWindow.Object;return t=null,e},ba=function(){try{ua=new ActiveXObject('htmlfile')}catch(t){}var t,e;ba='undefined'!=typeof document?document.domain&&ua?ya(ua):((e=va('iframe')).style.display='none',fa.appendChild(e),e.src=String('javascript:'),(t=e.contentWindow.document).open(),t.write(ga('document.F=Object')),t.close(),t.F):ya(ua);for(var r=pa.length;r--;)delete ba.prototype[pa[r]];return ba()};ha[ma]=!0;var Ta,Ea,wa,Pa=Object.create||function(t,e){var r;return null!==t?(Sa.prototype=da(t),r=new Sa,Sa.prototype=null,r[ma]=t):r=ba(),void 0===e?r:la.f(r,e)},Aa=!H((function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype})),ka=F,$a=Ae,_a=et,Da=Ee,Ra=Aa,Ia=hn('IE_PROTO'),xa=ka.Object,La=xa.prototype,Oa=Ra?xa.getPrototypeOf:function(t){var e=Da(t);if($a(e,Ia))return e[Ia];var r=e.constructor;return _a(r)&&e instanceof r?r.prototype:e instanceof xa?La:null},Ca=Gr,Na=function(t,e,r,i){i&&i.enumerable?t[e]=r:Ca(t,e,r)},Ma=H,Ba=et,Ua=Pa,Va=Oa,Fa=Na,Ha=Fe('iterator'),qa=!1;[].keys&&('next'in(wa=[].keys())?(Ea=Va(Va(wa)))!==Object.prototype&&(Ta=Ea):qa=!0);var Ga=null==Ta||Ma((function(){var t={};return Ta[Ha].call(t)!==t}));Ba((Ta=Ga?{}:Ua(Ta))[Ha])||Fa(Ta,Ha,(function(){return this}));var Ya={IteratorPrototype:Ta,BUGGY_SAFARI_ITERATORS:qa},ja={};ja[Fe('toStringTag')]='z';var za='[object z]'===String(ja),Qa=F,Wa=za,Ja=et,Ka=St,Xa=Fe('toStringTag'),Za=Qa.Object,to='Arguments'==Ka(function(){return arguments}()),eo=Wa?Ka:function(t){var e,r,i;return void 0===t?'Undefined':null===t?'Null':'string'==typeof(r=function(t,e){try{return t[e]}catch(t){}}(e=Za(t),Xa))?r:to?Ka(e):'Object'==(i=Ka(e))&&Ja(e.callee)?'Arguments':i},ro=eo,io=za?{}.toString:function(){return'[object '+ro(this)+']'},no=za,ao=$r.f,oo=Gr,so=Ae,uo=io,co=Fe('toStringTag'),lo=function(t,e,r,i){if(t){var n=r?t:t.prototype;so(n,co)||ao(n,co,{configurable:!0,value:e}),i&&!no&&oo(n,'toString',uo)}},po=Ya.IteratorPrototype,ho=Pa,fo=ht,vo=lo,mo=Ki,So=function(){return this},go=F,yo=(go.String,go.TypeError,tt);Object.setPrototypeOf||'__proto__'in{}&&function(){var t,e=!1,r={};try{(t=yo(Object.getOwnPropertyDescriptor(Object.prototype,'__proto__').set))(r,[]),e=r instanceof Array}catch(t){}}();var bo=ri,To=ot,Eo=function(t,e,r,i){var n=e+' Iterator';return t.prototype=ho(po,{next:fo(+!i,r)}),vo(t,n,!1,!0),mo[n]=So,t},wo=Oa,Po=lo,Ao=Na,ko=Ki,$o=Mn.PROPER,_o=Ya.BUGGY_SAFARI_ITERATORS,Do=Fe('iterator'),Ro=function(){return this},Io=_t,xo=Ki,Lo=In;$r.f;var Oo=function(t,e,r,i,n,a,o){Eo(r,e,i);var s,u,c,d=function(t){if(t===n&&v)return v;if(!_o&&t in h)return h[t];switch(t){case'keys':case'values':case'entries':return function(){return new r(this,t)}}return function(){return new r(this)}},l=e+' Iterator',p=!1,h=t.prototype,f=h[Do]||h['@@iterator']||n&&h[n],v=!_o&&f||d(n),m='Array'==e&&h.entries||f;if(m&&(s=wo(m.call(new t)))!==Object.prototype&&s.next&&(Po(s,l,!0,!0),ko[l]=Ro),$o&&'values'==n&&f&&'values'!==f.name&&(p=!0,v=function(){return To(f,this)}),n)if(u={values:d('values'),keys:a?v:d('keys'),entries:d('entries')},o)for(c in u)(_o||p||!(c in h))&&Ao(h,c,u[c]);else bo({target:e,proto:!0,forced:_o||p},u);return o&&h[Do]!==v&&Ao(h,Do,v,{name:n}),ko[e]=v,u},Co=Lo.set,No=Lo.getterFor('Array Iterator');Oo(Array,'Array',(function(t,e){Co(this,{type:'Array Iterator',target:Io(t),index:0,kind:e})}),(function(){var t=No(this),e=t.target,r=t.kind,i=t.index++;return!e||i>=e.length?(t.target=void 0,{value:void 0,done:!0}):'keys'==r?{value:i,done:!1}:'values'==r?{value:e[i],done:!1}:{value:[i,e[i]],done:!1}}),'values'),xo.Arguments=xo.Array;var Mo=Ki,Bo=Fe('iterator'),Uo=Array.prototype,Vo=eo,Fo=ce,Ho=Ki,qo=Fe('iterator'),Go=function(t){if(null!=t)return Fo(t,qo)||Fo(t,'@@iterator')||Ho[Vo(t)]},Yo=ot,jo=se,zo=Lr,Qo=ie,Wo=Go,Jo=F.TypeError,Ko=ot,Xo=Lr,Zo=ce,ts=kr,es=ot,rs=Lr,is=ie,ns=function(t){return void 0!==t&&(Mo.Array===t||Uo[Bo]===t)},as=ci,os=Mt,ss=function(t,e){var r=arguments.length<2?Wo(t):e;if(jo(r))return zo(Yo(r,t));throw Jo(Qo(t)+' is not iterable')},us=Go,cs=function(t,e,r){var i,n;Xo(t);try{if(!(i=Zo(t,'return'))){if('throw'===e)throw r;return r}i=Ko(i,t)}catch(t){n=!0,i=t}if('throw'===e)throw r;if(n)throw i;return Xo(i),r},ds=F.TypeError,ls=function(t,e){this.stopped=t,this.result=e},ps=ls.prototype,hs=function(t,e,r){var i,n,a,o,s,u,c,d=r&&r.that,l=!(!r||!r.AS_ENTRIES),p=!(!r||!r.IS_ITERATOR),h=!(!r||!r.INTERRUPTED),f=ts(e,d),v=function(t){return i&&cs(i,'normal',t),new ls(!0,t)},m=function(t){return l?(rs(t),h?f(t[0],t[1],v):f(t[0],t[1])):h?f(t,v):f(t)};if(p)i=t;else{if(!(n=us(t)))throw ds(is(t)+' is not iterable');if(ns(n)){for(a=0,o=as(t);o>a;a++)if((s=m(t[a]))&&os(ps,s))return s;return new ls(!1)}i=ss(t,n)}for(u=i.next;!(c=es(u,i)).done;){try{s=m(c.value)}catch(t){cs(i,'throw',t)}if('object'==typeof s&&s&&os(ps,s))return s}return new ls(!1)},fs=Xe,vs=$r,ms=ht,Ss=hs,gs=function(t,e,r){var i=fs(e);i in t?vs.f(t,i,ms(0,r)):t[i]=r};ri({target:'Object',stat:!0},{fromEntries:function(t){var e={};return Ss(t,(function(t,r){gs(e,t,r)}),{AS_ENTRIES:!0}),e}});var ys=It.Object.fromEntries,bs={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},Ts=F,Es=eo,ws=Gr,Ps=Ki,As=Fe('toStringTag');for(var ks in bs){var $s=Ts[ks],_s=$s&&$s.prototype;_s&&Es(_s)!==As&&ws(_s,As,ks),Ps[ks]=Ps.Array}var Ds=ys,Rs={};function Is(t,e){if(!(t instanceof e))throw new TypeError('Cannot call a class as a function')}function xs(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,'value'in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function Ls(t,e,r){return e&&xs(t.prototype,e),r&&xs(t,r),t}function Os(t){return(Os=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function Cs(t,e){return(Cs=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Ns(t){if(void 0===t)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return t}function Ms(t,e){return!e||'object'!=typeof e&&'function'!=typeof e?Ns(t):e}function Bs(t){var e=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(t){return!1}}();return function(){var r,i=Os(t);if(e){var n=Os(this).constructor;r=Reflect.construct(i,arguments,n)}else r=i.apply(this,arguments);return Ms(this,r)}}function Us(t,e,r){return(Us='undefined'!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Os(t)););return t}(t,e);if(i){var n=Object.getOwnPropertyDescriptor(i,e);return n.get?n.get.call(r):n.value}})(t,e,r||t)}Object.defineProperty(Rs,'__esModule',{value:!0});var Vs=function(){function t(){Is(this,t),Object.defineProperty(this,'listeners',{value:{},writable:!0,configurable:!0})}return Ls(t,[{key:'addEventListener',value:function(t,e,r){t in this.listeners||(this.listeners[t]=[]),this.listeners[t].push({callback:e,options:r})}},{key:'removeEventListener',value:function(t,e){if(t in this.listeners)for(var r=this.listeners[t],i=0,n=r.length;i<n;i++)if(r[i].callback===e)return void r.splice(i,1)}},{key:'dispatchEvent',value:function(t){if(t.type in this.listeners){for(var e=this.listeners[t.type].slice(),r=0,i=e.length;r<i;r++){var n=e[r];try{n.callback.call(this,t)}catch(t){Promise.resolve().then((function(){throw t}))}n.options&&n.options.once&&this.removeEventListener(t.type,n.callback)}return!t.defaultPrevented}}}]),t}(),Fs=function(t){!function(t,e){if('function'!=typeof e&&null!==e)throw new TypeError('Super expression must either be null or a function');t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Cs(t,e)}(r,Vs);var e=Bs(r);function r(){var t;return Is(this,r),(t=e.call(this)).listeners||Vs.call(Ns(t)),Object.defineProperty(Ns(t),'aborted',{value:!1,writable:!0,configurable:!0}),Object.defineProperty(Ns(t),'onabort',{value:null,writable:!0,configurable:!0}),t}return Ls(r,[{key:'toString',value:function(){return'[object AbortSignal]'}},{key:'dispatchEvent',value:function(t){'abort'===t.type&&(this.aborted=!0,'function'==typeof this.onabort&&this.onabort.call(this,t)),Us(Os(r.prototype),'dispatchEvent',this).call(this,t)}}]),r}(),Hs=function(){function t(){Is(this,t),Object.defineProperty(this,'signal',{value:new Fs,writable:!0,configurable:!0})}return Ls(t,[{key:'abort',value:function(){var t;try{t=new Event('abort')}catch(e){'undefined'!=typeof document?document.createEvent?(t=document.createEvent('Event')).initEvent('abort',!1,!1):(t=document.createEventObject()).type='abort':t={type:'abort',bubbles:!1,cancelable:!1}}this.signal.dispatchEvent(t)}},{key:'toString',value:function(){return'[object AbortController]'}}]),t}();'undefined'!=typeof Symbol&&Symbol.toStringTag&&(Hs.prototype[Symbol.toStringTag]='AbortController',Fs.prototype[Symbol.toStringTag]='AbortSignal');var qs=Rs.AbortController=Hs;Rs.AbortSignal=Fs;var Gs=Rs.abortableFetch=function(t){'function'==typeof t&&(t={fetch:t});var e=t,r=e.fetch,i=e.Request,n=void 0===i?r.Request:i,a=e.AbortController,o=e.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL,s=void 0!==o&&o;if(!function(t){return t.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log('__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill'),!0):'function'==typeof t.Request&&!t.Request.prototype.hasOwnProperty('signal')||!t.AbortController}({fetch:r,Request:n,AbortController:a,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:s}))return{fetch:r,Request:u};var u=n;(u&&!u.prototype.hasOwnProperty('signal')||s)&&((u=function(t,e){var r;e&&e.signal&&(r=e.signal,delete e.signal);var i=new n(t,e);return r&&Object.defineProperty(i,'signal',{writable:!1,enumerable:!1,configurable:!0,value:r}),i}).prototype=n.prototype);var c=r;return{fetch:function(t,e){var r=u&&u.prototype.isPrototypeOf(t)?t.signal:e?e.signal:void 0;if(r){var i;try{i=new DOMException('Aborted','AbortError')}catch(t){(i=new Error('Aborted')).name='AbortError'}if(r.aborted)return Promise.reject(i);var n=new Promise((function(t,e){r.addEventListener('abort',(function(){return e(i)}),{once:!0})}));return e&&e.signal&&delete e.signal,Promise.race([n,c(t,e)])}return c(t,e)},Request:u}},Ys=F.Promise,js=Na,zs=Nt,Qs=$r,Ws=it,Js=Fe('species'),Ks=Mt,Xs=F.TypeError,Zs=Fe('iterator'),tu=!1;try{var eu=0,ru={next:function(){return{done:!!eu++}},return:function(){tu=!0}};ru[Zs]=function(){return this},Array.from(ru,(function(){throw 2}))}catch(t){}var iu=tt,nu=H,au=et,ou=eo,su=an,uu=function(){},cu=[],du=Nt('Reflect','construct'),lu=/^\s*(?:class|function)\b/,pu=iu(lu.exec),hu=!lu.exec(uu),fu=function(t){if(!au(t))return!1;try{return du(uu,cu,t),!0}catch(t){return!1}},vu=function(t){if(!au(t))return!1;switch(ou(t)){case'AsyncFunction':case'GeneratorFunction':case'AsyncGeneratorFunction':return!1}try{return hu||!!pu(lu,su(t))}catch(t){return!0}};vu.sham=!0;var mu,Su,gu,yu,bu=!du||nu((function(){var t;return fu(fu.call)||!fu(Object)||!fu((function(){t=!0}))||t}))?vu:fu,Tu=ie,Eu=F.TypeError,wu=Lr,Pu=function(t){if(bu(t))return t;throw Eu(Tu(t)+' is not a constructor')},Au=Fe('species'),ku=function(t,e){var r,i=wu(t).constructor;return void 0===i||null==(r=wu(i)[Au])?e:Pu(r)},$u=tt([].slice),_u=F.TypeError,Du=/(?:ipad|iphone|ipod).*applewebkit/i.test(Bt),Ru='process'==St(F.process),Iu=F,xu=Q,Lu=kr,Ou=et,Cu=Ae,Nu=H,Mu=ca,Bu=$u,Uu=rr,Vu=function(t,e){if(t<e)throw _u('Not enough arguments');return t},Fu=Du,Hu=Ru,qu=Iu.setImmediate,Gu=Iu.clearImmediate,Yu=Iu.process,ju=Iu.Dispatch,zu=Iu.Function,Qu=Iu.MessageChannel,Wu=Iu.String,Ju=0,Ku={};try{mu=Iu.location}catch(t){}var Xu=function(t){if(Cu(Ku,t)){var e=Ku[t];delete Ku[t],e()}},Zu=function(t){return function(){Xu(t)}},tc=function(t){Xu(t.data)},ec=function(t){Iu.postMessage(Wu(t),mu.protocol+'//'+mu.host)};qu&&Gu||(qu=function(t){Vu(arguments.length,1);var e=Ou(t)?t:zu(t),r=Bu(arguments,1);return Ku[++Ju]=function(){xu(e,void 0,r)},Su(Ju),Ju},Gu=function(t){delete Ku[t]},Hu?Su=function(t){Yu.nextTick(Zu(t))}:ju&&ju.now?Su=function(t){ju.now(Zu(t))}:Qu&&!Fu?(yu=(gu=new Qu).port2,gu.port1.onmessage=tc,Su=Lu(yu.postMessage,yu)):Iu.addEventListener&&Ou(Iu.postMessage)&&!Iu.importScripts&&mu&&'file:'!==mu.protocol&&!Nu(ec)?(Su=ec,Iu.addEventListener('message',tc,!1)):Su='onreadystatechange'in Uu('script')?function(t){Mu.appendChild(Uu('script')).onreadystatechange=function(){Mu.removeChild(this),Xu(t)}}:function(t){setTimeout(Zu(t),0)});var rc,ic,nc,ac,oc,sc,uc,cc,dc={set:qu,clear:Gu},lc=F,pc=/ipad|iphone|ipod/i.test(Bt)&&void 0!==lc.Pebble,hc=/web0s(?!.*chrome)/i.test(Bt),fc=F,vc=kr,mc=rt.f,Sc=dc.set,gc=Du,yc=pc,bc=hc,Tc=Ru,Ec=fc.MutationObserver||fc.WebKitMutationObserver,wc=fc.document,Pc=fc.process,Ac=fc.Promise,kc=mc(fc,'queueMicrotask'),$c=kc&&kc.value;$c||(rc=function(){var t,e;for(Tc&&(t=Pc.domain)&&t.exit();ic;){e=ic.fn,ic=ic.next;try{e()}catch(t){throw ic?ac():nc=void 0,t}}nc=void 0,t&&t.enter()},gc||Tc||bc||!Ec||!wc?!yc&&Ac&&Ac.resolve?((uc=Ac.resolve(void 0)).constructor=Ac,cc=vc(uc.then,uc),ac=function(){cc(rc)}):Tc?ac=function(){Pc.nextTick(rc)}:(Sc=vc(Sc,fc),ac=function(){Sc(rc)}):(oc=!0,sc=wc.createTextNode(''),new Ec(rc).observe(sc,{characterData:!0}),ac=function(){sc.data=oc=!oc}));var _c=$c||function(t){var e={fn:t,next:void 0};nc&&(nc.next=e),ic||(ic=e,ac()),nc=e},Dc={},Rc=se,Ic=function(t){var e,r;this.promise=new t((function(t,i){if(void 0!==e||void 0!==r)throw TypeError('Bad Promise constructor');e=t,r=i})),this.resolve=Rc(e),this.reject=Rc(r)};Dc.f=function(t){return new Ic(t)};var xc=Lr,Lc=Rt,Oc=Dc,Cc=function(t,e){if(xc(t),Lc(e)&&e.constructor===t)return e;var r=Oc.f(t);return(0,r.resolve)(e),r.promise},Nc=F,Mc=function(){this.head=null,this.tail=null};Mc.prototype={add:function(t){var e={item:t,next:null};this.head?this.tail.next=e:this.head=e,this.tail=e},get:function(){var t=this.head;if(t)return this.head=t.next,this.tail===t&&(this.tail=null),t.item}};var Bc,Uc,Vc,Fc='object'==typeof window,Hc=ri,qc=F,Gc=Nt,Yc=ot,jc=Ys,zc=function(t,e,r){for(var i in e)r&&r.unsafe&&t[i]?t[i]=e[i]:js(t,i,e[i],r);return t},Qc=lo,Wc=function(t){var e=zs(t),r=Qs.f;Ws&&e&&!e[Js]&&r(e,Js,{configurable:!0,get:function(){return this}})},Jc=se,Kc=et,Xc=Rt,Zc=function(t,e){if(Ks(e,t))return t;throw Xs('Incorrect invocation')},td=an,ed=hs,rd=function(t,e){if(!e&&!tu)return!1;var r=!1;try{var i={};i[Zs]=function(){return{next:function(){return{done:r=!0}}}},t(i)}catch(t){}return r},id=ku,nd=dc.set,ad=_c,od=Cc,sd=function(t,e){var r=Nc.console;r&&r.error&&(1==arguments.length?r.error(t):r.error(t,e))},ud=Dc,cd=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}},dd=Mc,ld=In,pd=Er,hd=Fc,fd=Ru,vd=Yt,md=Fe('species'),Sd='Promise',gd=ld.getterFor(Sd),yd=ld.set,bd=ld.getterFor(Sd),Td=jc&&jc.prototype,Ed=jc,wd=Td,Pd=qc.TypeError,Ad=qc.document,kd=qc.process,$d=ud.f,_d=$d,Dd=!!(Ad&&Ad.createEvent&&qc.dispatchEvent),Rd=Kc(qc.PromiseRejectionEvent),Id=pd(Sd,(function(){var t=td(Ed),e=t!==String(Ed);if(!e&&66===vd)return!0;if(!wd.finally)return!0;if(vd>=51&&/native code/.test(t))return!1;var r=new Ed((function(t){t(1)})),i=function(t){t((function(){}),(function(){}))};return(r.constructor={})[md]=i,!(r.then((function(){}))instanceof i)||!e&&hd&&!Rd})),xd=Id||!rd((function(t){Ed.all(t).catch((function(){}))})),Ld=function(t){var e;return!(!Xc(t)||!Kc(e=t.then))&&e},Od=function(t,e){var r,i,n,a=e.value,o=1==e.state,s=o?t.ok:t.fail,u=t.resolve,c=t.reject,d=t.domain;try{s?(o||(2===e.rejection&&Ud(e),e.rejection=1),!0===s?r=a:(d&&d.enter(),r=s(a),d&&(d.exit(),n=!0)),r===t.promise?c(Pd('Promise-chain cycle')):(i=Ld(r))?Yc(i,r,u,c):u(r)):c(a)}catch(t){d&&!n&&d.exit(),c(t)}},Cd=function(t,e){t.notified||(t.notified=!0,ad((function(){for(var r,i=t.reactions;r=i.get();)Od(r,t);t.notified=!1,e&&!t.rejection&&Md(t)})))},Nd=function(t,e,r){var i,n;Dd?((i=Ad.createEvent('Event')).promise=e,i.reason=r,i.initEvent(t,!1,!0),qc.dispatchEvent(i)):i={promise:e,reason:r},!Rd&&(n=qc['on'+t])?n(i):'unhandledrejection'===t&&sd('Unhandled promise rejection',r)},Md=function(t){Yc(nd,qc,(function(){var e,r=t.facade,i=t.value;if(Bd(t)&&(e=cd((function(){fd?kd.emit('unhandledRejection',i,r):Nd('unhandledrejection',r,i)})),t.rejection=fd||Bd(t)?2:1,e.error))throw e.value}))},Bd=function(t){return 1!==t.rejection&&!t.parent},Ud=function(t){Yc(nd,qc,(function(){var e=t.facade;fd?kd.emit('rejectionHandled',e):Nd('rejectionhandled',e,t.value)}))},Vd=function(t,e,r){return function(i){t(e,i,r)}},Fd=function(t,e,r){t.done||(t.done=!0,r&&(t=r),t.value=e,t.state=2,Cd(t,!0))},Hd=function(t,e,r){if(!t.done){t.done=!0,r&&(t=r);try{if(t.facade===e)throw Pd('Promise can\'t be resolved itself');var i=Ld(e);i?ad((function(){var r={done:!1};try{Yc(i,e,Vd(Hd,r,t),Vd(Fd,r,t))}catch(e){Fd(r,e,t)}})):(t.value=e,t.state=1,Cd(t,!1))}catch(e){Fd({done:!1},e,t)}}};Id&&(wd=(Ed=function(t){Zc(this,wd),Jc(t),Yc(Bc,this);var e=gd(this);try{t(Vd(Hd,e),Vd(Fd,e))}catch(t){Fd(e,t)}}).prototype,(Bc=function(t){yd(this,{type:Sd,done:!1,notified:!1,parent:!1,reactions:new dd,rejection:!1,state:0,value:void 0})}).prototype=zc(wd,{then:function(t,e){var r=bd(this),i=$d(id(this,Ed));return r.parent=!0,i.ok=!Kc(t)||t,i.fail=Kc(e)&&e,i.domain=fd?kd.domain:void 0,0==r.state?r.reactions.add(i):ad((function(){Od(i,r)})),i.promise},catch:function(t){return this.then(void 0,t)}}),Uc=function(){var t=new Bc,e=gd(t);this.promise=t,this.resolve=Vd(Hd,e),this.reject=Vd(Fd,e)},ud.f=$d=function(t){return t===Ed||t===Vc?new Uc(t):_d(t)}),Hc({global:!0,wrap:!0,forced:Id},{Promise:Ed}),Qc(Ed,Sd,!1,!0),Wc(Sd),Vc=Gc(Sd),Hc({target:Sd,stat:!0,forced:Id},{reject:function(t){var e=$d(this);return Yc(e.reject,void 0,t),e.promise}}),Hc({target:Sd,stat:!0,forced:true},{resolve:function(t){return od(this===Vc?Ed:this,t)}}),Hc({target:Sd,stat:!0,forced:xd},{all:function(t){var e=this,r=$d(e),i=r.resolve,n=r.reject,a=cd((function(){var r=Jc(e.resolve),a=[],o=0,s=1;ed(t,(function(t){var u=o++,c=!1;s++,Yc(r,e,t).then((function(t){c||(c=!0,a[u]=t,--s||i(a))}),n)})),--s||i(a)}));return a.error&&n(a.value),r.promise},race:function(t){var e=this,r=$d(e),i=r.reject,n=cd((function(){var n=Jc(e.resolve);ed(t,(function(t){Yc(n,e,t).then(r.resolve,i)}))}));return n.error&&i(n.value),r.promise}});var qd=Ys,Gd=Nt,Yd=et,jd=ku,zd=Cc;ri({target:'Promise',proto:!0,real:!0,forced:!!qd&&H((function(){qd.prototype.finally.call({then:function(){}},(function(){}))}))},{finally:function(t){var e=jd(this,Gd('Promise')),r=Yd(t);return this.then(r?function(r){return zd(e,t()).then((function(){return r}))}:t,r?function(r){return zd(e,t()).then((function(){throw r}))}:t)}});var Qd,Wd=Si('Promise','finally'),Jd=function(t){var e,r,i=t.get('X-Delivery-Type'),n=t.get('X-Reused');return{type:null===i?D.HTTP1:null!==(e=i)&&void 0!==e?e:void 0,reused:null===n?void 0:null!==(r={1:!0,0:!1}[n])&&void 0!==r?r:void 0}};!function(t){t[t.HEADER=0]='HEADER',t[t.PARAM=1]='PARAM'}(Qd||(Qd={}));var Kd,Xd,Zd,tl=function(){function e(e){var i=(void 0===e?{}:e).throughputEstimator,n=this;this.lastConnectionType$=new t(void 0),this.lastConnectionReused$=new t(void 0),this.lastRequestFirstBytes$=new t(void 0),this.abortAllController=new qs,this.subscription=new r,this.fetchRepresentation=function(t,e,r){return void 0===r&&(r=0),I(n,void 0,void 0,(function(){var i,n,a,o,s,u,c,d,l,p,h,f,v,m,S;return x(this,(function(g){switch(g.label){case 0:return i=t.initRange,n=i.from,a=i.to,o=n,s=a,u=!1,t.indexRange&&(c=t.indexRange.from,d=t.indexRange.to,(u=a+1===c)&&(o=Math.min(c,n),s=Math.max(d,a))),o=Math.min(o,0),s+=r,[4,this.fetchRange(t.url,o,s,{method:Qd.PARAM})];case 1:if(!(l=g.sent()))return[2,null];if(p=new DataView(l,n-o,a-o),!e.validateData(p))throw new Error('Invalid media file');return h=e.parseInit(p),u&&void 0!==c&&void 0!==d?(f=new DataView(l,c-o,d-c),[3,4]):[3,2];case 2:return(v=e.getIndexRange(h))?[4,this.fetchRange(t.url,v.from,v.to,{method:Qd.PARAM})]:[3,4];case 3:if(!(m=g.sent()))return[2,null];f=new DataView(m),g.label=4;case 4:if(!f)throw new ReferenceError('No way to load representation index');return S=e.parseSegments(f,h),[2,{dataView:new DataView(l),segments:S}]}}))}))},this.throughputEstimator=i}return e.prototype.onHeadersReceived=function(t){var e=Jd(t),r=e.type,i=e.reused;this.lastConnectionType$.next(r),this.lastConnectionReused$.next(i)},e.prototype.fetchManifest=function(t){return I(this,void 0,void 0,(function(){var e;return x(this,(function(r){switch(r.label){case 0:return[4,Gs(fetch).fetch(t,{signal:this.abortAllController.signal}).catch(el)];case 1:return(e=r.sent())?(this.onHeadersReceived(e.headers),[2,e.text()]):[2,null]}}))}))},e.prototype.fetchRange=function(t,e,r,i){var n,u,c,d=void 0===i?{}:i,l=d.method,p=void 0===l?Qd.HEADER:l,h=d.onProgress,f=d.signal;return I(this,void 0,void 0,(function(){var i,d,l,v,S,g,y,b,T,E,w,P,A,k,$,_,D,R,L,C=this;return x(this,(function(N){switch(N.label){case 0:switch(i=t,d=new Headers,p){case Qd.HEADER:d.append('Range',''.concat(e,'-').concat(r));break;case Qd.PARAM:(l=new URL(i,location.href)).searchParams.append('bytes',''.concat(e,'-').concat(r)),i=l.toString();break;default:o(p)}return v=this.abortAllController.signal,f&&(S=new qs,this.subscription.add(s(a(this.abortAllController.signal,'abort'),a(f,'abort')).subscribe((function(){S.abort()}))),(this.abortAllController.signal.aborted||f.aborted)&&S.abort(),v=S.signal),g=m(),[4,Gs(fetch).fetch(i,{headers:d,signal:v}).catch(el)];case 1:return y=N.sent(),null===(n=this.throughputEstimator)||void 0===n||n.addRawRtt(m()-g),y?y.ok&&y.body?(this.onHeadersReceived(y.headers),b=O(y.body.tee(),2),T=b[0],E=b[1],w=T.getReader(),null===(u=this.throughputEstimator)||void 0===u||u.trackStream(E),P=parseInt(null!==(c=y.headers.get('Content-Length'))&&void 0!==c?c:'',10),A=0,k=new ArrayBuffer(P),$=new Uint8Array(k),_=new DataView(k),D=!1,R=function(t){D=!0,el(t)},L=function(t){var e=t.done,r=t.value;return I(C,void 0,void 0,(function(){return x(this,(function(t){switch(t.label){case 0:return 0===A&&this.lastRequestFirstBytes$.next(m()-g),e?(null==h||h(_,A),[3,3]):[3,1];case 1:return r?($.set(r,A),A+=r.byteLength,null==h||h(_,A),[4,null==w?void 0:w.read().then(L,R)]):[3,3];case 2:t.sent(),t.label=3;case 3:return[2]}}))}))},[4,null==w?void 0:w.read().then(L,R)]):[2,Promise.reject(new Error('Fetch error '.concat(y.status,': ').concat(y.statusText)))]:[2,null];case 2:return N.sent(),[2,D?null:k]}}))}))},e.prototype.destroy=function(){this.abortAllController.abort(),this.subscription.unsubscribe()},e}(),el=function(t){if(!(t instanceof DOMException)||'AbortError'!==t.name&&20!==t.code)throw t};!function(t){t[t.EBML=440786851]='EBML',t[t.EBMLVersion=17030]='EBMLVersion',t[t.EBMLReadVersion=17143]='EBMLReadVersion',t[t.EBMLMaxIDLength=17138]='EBMLMaxIDLength',t[t.EBMLMaxSizeLength=17139]='EBMLMaxSizeLength',t[t.DocType=17026]='DocType',t[t.DocTypeVersion=17031]='DocTypeVersion',t[t.DocTypeReadVersion=17029]='DocTypeReadVersion',t[t.Void=236]='Void',t[t.Segment=408125543]='Segment',t[t.SeekHead=290298740]='SeekHead',t[t.Seek=19899]='Seek',t[t.SeekID=21419]='SeekID',t[t.SeekPosition=21420]='SeekPosition',t[t.Info=357149030]='Info',t[t.TimestampScale=2807729]='TimestampScale',t[t.Duration=17545]='Duration',t[t.Tracks=374648427]='Tracks',t[t.Chapters=272869232]='Chapters',t[t.Cluster=524531317]='Cluster',t[t.Attachments=423732329]='Attachments',t[t.Tags=307544935]='Tags',t[t.Cues=475249515]='Cues',t[t.CuePoint=187]='CuePoint',t[t.CueTime=179]='CueTime',t[t.CueTrackPositions=183]='CueTrackPositions',t[t.CueTrack=247]='CueTrack',t[t.CueClusterPosition=241]='CueClusterPosition',t[t.CueRelativePosition=240]='CueRelativePosition',t[t.CueDuration=178]='CueDuration',t[t.CueBlockNumber=21368]='CueBlockNumber',t[t.CueCodecState=234]='CueCodecState',t[t.CueReference=219]='CueReference',t[t.CueRefTime=150]='CueRefTime'}(Xd||(Xd={})),function(t){t.SignedInteger='int',t.UnsignedInteger='uint',t.Float='float',t.String='string',t.UTF8='utf8',t.Date='date',t.Master='master',t.Binary='binary'}(Zd||(Zd={}));var rl,il=((Kd={})[Xd.EBML]={type:Zd.Master},Kd[Xd.EBMLVersion]={type:Zd.UnsignedInteger},Kd[Xd.EBMLReadVersion]={type:Zd.UnsignedInteger},Kd[Xd.EBMLMaxIDLength]={type:Zd.UnsignedInteger},Kd[Xd.EBMLMaxSizeLength]={type:Zd.UnsignedInteger},Kd[Xd.DocType]={type:Zd.String},Kd[Xd.DocTypeVersion]={type:Zd.UnsignedInteger},Kd[Xd.DocTypeReadVersion]={type:Zd.UnsignedInteger},Kd[Xd.Void]={type:Zd.Binary},Kd[Xd.Segment]={type:Zd.Master},Kd[Xd.SeekHead]={type:Zd.Master},Kd[Xd.Seek]={type:Zd.Master},Kd[Xd.SeekID]={type:Zd.Binary},Kd[Xd.SeekPosition]={type:Zd.UnsignedInteger},Kd[Xd.Info]={type:Zd.Master},Kd[Xd.TimestampScale]={type:Zd.UnsignedInteger},Kd[Xd.Duration]={type:Zd.Float},Kd[Xd.Tracks]={type:Zd.Master},Kd[Xd.Chapters]={type:Zd.Master},Kd[Xd.Cluster]={type:Zd.Master},Kd[Xd.Attachments]={type:Zd.Master},Kd[Xd.Tags]={type:Zd.Master},Kd[Xd.Cues]={type:Zd.Master},Kd[Xd.CuePoint]={type:Zd.Master},Kd[Xd.CueTime]={type:Zd.UnsignedInteger},Kd[Xd.CueTrackPositions]={type:Zd.Master},Kd[Xd.CueTrack]={type:Zd.UnsignedInteger},Kd[Xd.CueClusterPosition]={type:Zd.UnsignedInteger},Kd[Xd.CueRelativePosition]={type:Zd.UnsignedInteger},Kd[Xd.CueDuration]={type:Zd.UnsignedInteger},Kd[Xd.CueBlockNumber]={type:Zd.UnsignedInteger},Kd[Xd.CueCodecState]={type:Zd.UnsignedInteger},Kd[Xd.CueReference]={type:Zd.Master},Kd[Xd.CueRefTime]={type:Zd.UnsignedInteger},Kd),nl=function(t){var e=t.getUint8(0),r=0;128&e?r=1:64&e?r=2:32&e?r=3:16&e&&(r=4);var i=al(t,r),n=i in il,a=n?il[i].type:Zd.Binary,o=t.getUint8(r),s=0;128&o?s=1:64&o?s=2:32&o?s=3:16&o?s=4:8&o?s=5:4&o?s=6:2&o?s=7:1&o&&(s=8);var u,c=new DataView(t.buffer,t.byteOffset+r+1,s-1),d=((o&255>>s)<<8*(s-1))+al(c),l=r+s;return u=l+d>t.byteLength?new DataView(t.buffer,t.byteOffset+l):new DataView(t.buffer,t.byteOffset+l,d),{tag:n?i:'0x'+i.toString(16).toUpperCase(),type:a,value:u,valueSize:d}},al=function(t,e){switch(void 0===e&&(e=t.byteLength),e){case 1:return t.getUint8(0);case 2:return t.getUint16(0);case 3:return t.getUint16(0)<<8|t.getUint8(2);case 4:return t.getUint32(0);case 5:return t.getUint32(0)<<8|t.getUint8(4);case 6:return t.getUint32(0)<<16|t.getUint16(4);case 7:return t.getUint32(0)<<32|t.getUint16(4)<<8|t.getUint8(6);case 8:return t.getUint32(0)<<32|t.getUint32(4)}return 0},ol=function(t,e){switch(e){case Zd.SignedInteger:return t.getInt8(0);case Zd.UnsignedInteger:return al(t);case Zd.Float:return 4===t.byteLength?t.getFloat32(0):t.getFloat64(0);case Zd.String:return new TextDecoder('ascii').decode(t);case Zd.UTF8:return new TextDecoder('utf-8').decode(t);case Zd.Date:return new Date(Date.UTC(2001,0)+t.getInt8(0)).getTime();case Zd.Master:case Zd.Binary:return t;default:o(e)}},sl=function(t,e){for(var r=0;r<t.byteLength;){var i=new DataView(t.buffer,t.byteOffset+r),n=nl(i);if(!e(n))return;n.type===Zd.Master&&sl(n.value,e),r=n.value.byteOffset-t.byteOffset+n.valueSize}},ul=[Xd.Info,Xd.SeekHead,Xd.Tracks,Xd.Chapters,Xd.Cluster,Xd.Cues,Xd.Attachments,Xd.Tags],cl={validateData:function(t){if(t.getUint32(0)!==Xd.EBML)return!1;var e=void 0,r=void 0,i=void 0,n=nl(t);return sl(n.value,(function(t){var n=t.tag,a=t.type,o=t.value;return n===Xd.EBMLReadVersion?e=ol(o,a):n===Xd.DocType?r=ol(o,a):n===Xd.DocTypeReadVersion&&(i=ol(o,a)),!0})),(void 0===e||e<=1)&&void 0!==r&&'webm'===r&&(void 0===i||i<=2)},parseInit:function(t){var e=void 0,r=void 0,i=void 0,n=void 0,a=!1,o=!1,s=!1,u=void 0,c=void 0;return sl(t,(function(t){var d=t.tag,l=t.type,p=t.value,h=t.valueSize;if(d===Xd.SeekID){var f=ol(p,l);c=al(f)}else d!==Xd.SeekPosition&&(c=void 0);return d===Xd.Segment?(e=p.byteOffset,r=p.byteOffset+h):d===Xd.Info?a=!0:d===Xd.SeekHead?o=!0:d===Xd.TimestampScale?i=ol(p,l):d===Xd.Duration?n=ol(p,l):d===Xd.SeekPosition&&c===Xd.Cues?u=ol(p,l):a&&o&&ul.includes(d)&&(s=!0),!s})),p(e,'Failed to parse webm Segment start'),p(r,'Failed to parse webm Segment end'),p(n,'Failed to parse webm Segment duration'),i=null!=i?i:1e6,{segmentStart:Math.round(e/1e9*i*1e3),segmentEnd:Math.round(r/1e9*i*1e3),timeScale:i,segmentDuration:Math.round(n/1e9*i*1e3),cuesSeekPosition:u}},getIndexRange:function(t){if(!n(t.cuesSeekPosition)){var e=t.segmentStart+t.cuesSeekPosition;return{from:e,to:e+1048576}}},parseSegments:function(t,e){var r,n=!1,a=!1,o=function(t){return i(t.time)&&i(t.position)},s=[];return sl(t,(function(t){var e=t.tag,i=t.type,u=t.value;switch(e){case Xd.Cues:n=!0;break;case Xd.CuePoint:r&&o(r)&&s.push(r),r={};break;case Xd.CueTime:r&&(r.time=ol(u,i));break;case Xd.CueTrackPositions:break;case Xd.CueClusterPosition:r&&(r.position=ol(u,i));break;default:n&&ul.includes(e)&&(a=!0)}return!(n&&a)})),r&&o(r)&&s.push(r),s.map((function(t,r){var i=t.time,n=t.position,a=s[r+1];return{status:vi.NONE,time:{from:i,to:a?a.time:e.segmentDuration},byte:{from:e.segmentStart+n,to:a?e.segmentStart+a.position-1:e.segmentEnd-1}}}))}},dl=new TextDecoder('ascii'),ll={validateData:function(t){return'ftyp'===dl.decode(new DataView(t.buffer,t.byteOffset+4,4))},parseInit:function(){return null},getIndexRange:function(){},parseSegments:function(t){var e=function(t){var e=0,r=t.getUint32(e);e+=4;var i=new DataView(t.buffer,t.byteOffset+e,4),n=dl.decode(i);e+=4,0===r?r=1/0:1===r&&(e+=8,r=1/0);var a=Math.min(r,t.byteLength)-e+1;return{id:n,size:r,contents:new DataView(t.buffer,t.byteOffset+e,a)}}(t),r=[],i=0,n=function(){var t=e.contents.getUint32(i);return i+=4,t};if(0!==(4278190080&n()))throw new SyntaxError('Unsupported sidx version');n();for(var a=n(),o=n(),s=n(),u=255&n(),c=o/a*1e3,d=t.byteOffset+t.byteLength+s+1,l=0;l<u;l++){var p=n(),h=p>>>31,f=p<<1>>>1,v=n();if(n(),0!==h)throw new Error('Unsupported multilevel sidx');var m=v/a*1e3;r.push({status:vi.NONE,time:{from:c,to:c+m},byte:{from:d,to:d+f-1}}),c+=m,d+=f}return r}},pl=function(){function s(i,n,a,s,u){var c=u.fetcher,d=u.tuning;switch(this.ended$=new t(!1),this.playingRepresentation$=new t(void 0),this.error$=new e,this.subscription=new r,this.abortController=new qs,this.allInitsLoaded=!1,this.fetcher=c,this.tuning=d,this.container=a,a){case mi.MP4:this.containerParser=ll;break;case mi.WEBM:this.containerParser=cl;break;default:o(a)}this.initData=new Map,this.segments=new Map,this.representations=new Map(s.map((function(t){return[t.id,t]}))),this.kind=i,this.mediaSource=n,this.sourceBuffer=null,this.segmentDownloadPromise=Promise.resolve()}return s.prototype.startWith=function(t){return I(this,void 0,void 0,(function(){var e,r,i,n,o,s,u,c,d,l=this;return x(this,(function(h){switch(h.label){case 0:return e=this.representations.get(t),p(e,'Cannot find representation '.concat(t)),r=Math.ceil(1e3*e.bitrate/8*(this.tuning.extraInitSize/1e3)*1.1),this.playingRepresentationId=t,this.downloadingRepresentationId=t,this.sourceBuffer=this.mediaSource.addSourceBuffer(''.concat(e.mime,'; codecs="').concat(e.codecs,'"')),this.subscription.add(a(this.sourceBuffer,'updateEnd').subscribe((function(){return l.checkEjectedSegments()}),(function(t){return l.error$.next({id:'SegmentEjection',message:'Error when trying to clear segments ejecte by browser',thrown:t})}))),this.subscription.add(a(this.sourceBuffer,'error').subscribe((function(t){return l.error$.next({id:'SourceBuffer',message:'SourceBuffer Error event fired',thrown:t})}))),[4,this.fetcher.fetchRepresentation(e,this.containerParser,r).catch((function(t){return l.error$.next({id:'LoadInit',message:'Failed to init Representation',thrown:t})}))];case 1:return(i=h.sent())?(n=i.dataView,o=i.segments,s=n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength-r),this.initData.set(t,s),u=o.filter((function(t){return t.byte.from>=n.byteOffset&&t.byte.to<n.byteOffset+n.byteLength})),c=gi(u,-1),d=new DataView(n.buffer,n.byteOffset,u.length&&c?Math.min(c.byte.to-n.byteOffset+1,n.byteLength):n.byteLength-r),[4,this.appendDataToBuffer(d)]):[2,!1];case 2:return h.sent(),this.segments.set(t,o.map((function(t){return R(R({},t),{status:t.byte.from>=n.byteOffset&&t.byte.to<n.byteOffset+n.byteLength?vi.FED:vi.NONE})}))),this.maintain(0),[2,!0]}}))}))},s.prototype.switchTo=function(t){var e;return I(this,void 0,void 0,(function(){var r,n,a,o,s,u,c=this;return x(this,(function(d){switch(d.label){case 0:return t===this.downloadingRepresentationId||t===this.switchingToRepresentationId?[2]:(this.switchingToRepresentationId=t,this.initData.has(t)?[3,4]:this.loadAllInitsPromise?[4,this.loadAllInitsPromise]:[3,2]);case 1:return d.sent(),[3,4];case 2:return r=this.representations.get(t),p(r),[4,this.fetcher.fetchRepresentation(r,this.containerParser,0).catch((function(t){return c.error$.next({id:'LoadInit',message:'Failed to init Representation',thrown:t})}))];case 3:if(!(n=d.sent()))return[2];a=n.dataView,o=n.segments,s=a.buffer.slice(a.byteOffset,a.byteOffset+a.byteLength),this.initData.set(t,s),this.segments.set(t,o),d.label=4;case 4:return u=this.initData.get(t),p(u,'No init buffer for '.concat(t)),p(this.sourceBuffer),this.switchingToRepresentationId=void 0,this.downloadingRepresentationId=t,this.abortController.abort(),this.abortController=new qs,this.abortBuffer(),[4,this.appendDataToBuffer(u,this.abortController.signal)];case 5:return d.sent(),i(this.playingRepresentationId)&&(null===(e=this.segments.get(this.playingRepresentationId))||void 0===e||e.forEach((function(t){t.status===vi.FED&&(t.status=vi.NONE)}))),[2]}}))}))},s.prototype.maintain=function(t){return I(this,void 0,void 0,(function(){var e,r,i,a,o,s,u,c=this;return x(this,(function(d){switch(d.label){case 0:return n(this.downloadingRepresentationId)||n(this.playingRepresentationId)||n(this.sourceBuffer)||this.ended$.getValue()?[2]:(e=this.representations.get(this.downloadingRepresentationId),r=this.segments.get(this.downloadingRepresentationId),p(e),p(r),i=r.find((function(e){return t>=e.time.from&&t<e.time.to})),a=t,this.playingRepresentationId!==this.downloadingRepresentationId&&(o=zi(this.sourceBuffer.buffered,t),a=t+Math.min(o,this.tuning.representationSwitchForwardBufferGap)),(s=this.selectForwardBufferSegments(r,a)).length?[4,this.loadSegments(s,e)]:[3,2]);case 1:d.sent(),d.label=2;case 2:return!this.allInitsLoaded&&!this.loadAllInitsPromise&&i&&i.status===vi.FED&&!s.length&&zi(this.sourceBuffer.buffered,t)>3e3&&this.loadAllInits().catch((function(t){return c.error$.next({id:'InitDownload',message:'Error when trying to load all inits',thrown:t})})),(u=gi(r,-1))&&i===u&&u.status===vi.FED&&this.ended$.next(!0),[2]}}))}))},s.prototype.destroy=function(){this.initData.clear(),this.segments.clear(),this.representations.clear(),this.subscription.unsubscribe(),this.sourceBuffer&&'open'===this.mediaSource.readyState&&(this.abortBuffer(),this.mediaSource.removeSourceBuffer(this.sourceBuffer)),this.abortController.abort()},s.prototype.selectForwardBufferSegments=function(t,e){var r=this,i=t.findIndex((function(t){var i=t.status,n=t.time,a=n.from,o=n.to;return i===vi.NONE&&(a>e||a<=e&&o>=e)&&o<=e+r.tuning.forwardBufferTarget}));if(-1===i)return[];for(var n=0,a=[],o=i;o<t.length&&n<=this.tuning.segmentRequestSize;o++){var s=t[o];if(n+=s.byte.to+1-s.byte.from,s.status===vi.NONE)a.push(s);else if([vi.DOWNLOADING,vi.DOWNLOADED,vi.FED].includes(s.status))break}return a},s.prototype.loadSegments=function(t,e){return I(this,void 0,void 0,(function(){var r,i,n,a,o,s,u,c,d,l=this;return x(this,(function(p){if(!t.length)return[2];r=gi(t,0).byte.from,i=gi(t,-1).byte.to;try{for(n=L(t),a=n.next();!a.done;a=n.next())a.value.status=vi.DOWNLOADING}catch(t){c={error:t}}finally{try{a&&!a.done&&(d=n.return)&&d.call(n)}finally{if(c)throw c.error}}return o=this.abortController.signal,s=function(t,r){t.status=vi.DOWNLOADED,l.appendDataToBuffer(r,o).then((function(r){!r||o.aborted?t.status=vi.NONE:(l.playingRepresentationId=e.id,l.playingRepresentation$.next(l.playingRepresentationId),t.status=vi.FED)}))},u=function(e,i){var n,a;try{for(var o=L(t),u=o.next();!u.done;u=o.next()){var c=u.value;c.status===vi.DOWNLOADING&&c.byte.from-r>=0&&c.byte.to+1-r<=i&&s(c,new DataView(e.buffer,e.byteOffset+c.byte.from-r,c.byte.to+1-c.byte.from))}}catch(t){n={error:t}}finally{try{u&&!u.done&&(a=o.return)&&a.call(o)}finally{if(n)throw n.error}}},this.segmentDownloadPromise=this.segmentDownloadPromise.then((function(){return I(l,void 0,void 0,(function(){var n,a,c,d,l,p,h,f,v,m,S,g;return x(this,(function(y){switch(y.label){case 0:if(o.aborted){try{for(n=L(t),a=n.next();!a.done;a=n.next())(f=a.value).status===vi.DOWNLOADING&&(f.status=vi.NONE)}catch(t){v={error:t}}finally{try{a&&!a.done&&(m=n.return)&&m.call(n)}finally{if(v)throw v.error}}return[2]}return[4,this.fetcher.fetchRange(e.url,r,i,{method:Qd.PARAM,onProgress:u,signal:o})];case 1:if(c=y.sent(),d=gi(t,-1),l=gi(this.segments.get(e.id),-1),!c)try{for(p=L(t),h=p.next();!h.done;h=p.next())(f=h.value).status===vi.DOWNLOADING&&(f.status=vi.NONE)}catch(t){S={error:t}}finally{try{h&&!h.done&&(g=p.return)&&g.call(p)}finally{if(S)throw S.error}}return c&&!o.aborted&&d&&l&&d.status===vi.DOWNLOADING&&d===l&&s(d,new DataView(c,d.byte.from-r)),[2]}}))}))})).catch((function(t){return l.error$.next({id:'SegmentDownload',message:'Error when fetching segments',thrown:t})})),[2,this.segmentDownloadPromise]}))}))},s.prototype.loadAllInits=function(){return I(this,void 0,void 0,(function(){var t=this;return x(this,(function(e){return this.loadAllInitsPromise||(this.loadAllInitsPromise=Wd(Promise.all(Array.from(this.representations.entries()).map((function(e){var r=O(e,2),i=r[0],n=r[1];return t.initData.has(i)?Promise.resolve():t.fetcher.fetchRepresentation(n,t.containerParser).then((function(e){if(e){var r=e.dataView,n=e.segments,a=r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength);t.initData.set(i,a),t.segments.set(i,n)}}))}))).then((function(){t.allInitsLoaded=!0})),(function(){t.loadAllInitsPromise=null}))),[2,this.loadAllInitsPromise]}))}))},s.prototype.appendDataToBuffer=function(t,e){return I(this,void 0,void 0,(function(){return x(this,(function(r){switch(r.label){case 0:if(p(this.sourceBuffer),e&&e.aborted)return[2,!1];if(this.sourceBuffer.updating)return[3,2];try{this.sourceBuffer.appendBuffer(t)}catch(t){return this.error$.next({id:'AppendBuffer',message:'Error appending data to buffer',thrown:t}),[2,!1]}return[4,s.waitForBufferUpdate(this.sourceBuffer)];case 1:return r.sent(),[3,4];case 2:return[4,s.waitForBufferUpdate(this.sourceBuffer)];case 3:return r.sent(),[2,this.appendDataToBuffer(t,e)];case 4:return[2,!0]}}))}))},s.prototype.abortBuffer=function(){if(this.sourceBuffer&&'open'===this.mediaSource.readyState)try{this.sourceBuffer.abort()}catch(t){this.error$.next({id:'SourceBufferAbort',message:'SourceBuffer.abort() threw',thrown:t})}},s.prototype.checkEjectedSegments=function(){var t,e;if(!n(this.sourceBuffer)&&!n(this.playingRepresentationId)){var r=this.segments.get(this.playingRepresentationId);p(r);for(var i=[],a=0;a<this.sourceBuffer.buffered.length;a++){var o=1e3*this.sourceBuffer.buffered.start(a),s=this.sourceBuffer.buffered.end(a),u=1e3*(s%1>.9?Math.round(s):s);i.push({from:o,to:u})}var c=function(t){var e=i.some((function(e){return e.from<=t.time.from&&e.to>=t.time.to}));t.status!==vi.FED||e||(t.status=vi.NONE)};try{for(var d=L(r),l=d.next();!l.done;l=d.next()){c(l.value)}}catch(e){t={error:e}}finally{try{l&&!l.done&&(e=d.return)&&e.call(d)}finally{if(t)throw t.error}}}},s.waitForBufferUpdate=function(t){return I(this,void 0,void 0,(function(){return x(this,(function(e){return[2,new Promise((function(e){return t?t.addEventListener('update',(function(){return e()})):e()}))]}))}))},s}(),hl=function(t){if(t.includes('/')){var e=t.split('/');return parseInt(e[0])/parseInt(e[1])}return parseFloat(t)},fl=['timeupdate','progress','play','seeked','stalled'];!function(t){t.NONE='none',t.MANIFEST_LOADED='manifest_loaded',t.REPRESENTATION_SELECTED='representation_selected'}(rl||(rl={}));var vl,ml=function(){function i(i){var n=this;this.element=null,this.source=null,this.manifest=null,this.subscription=new r,this.state$=new Ji(rl.NONE),this.currentVideoRepresentation$=new t(void 0),this.error$=new e,this.lastConnectionType$=new t(void 0),this.lastConnectionReused$=new t(void 0),this.lastRequestFirstBytes$=new t(void 0),this.forceEnded$=new e,this.tick=function(){var t,e;if(n.element){var r=1e3*n.element.currentTime;null===(t=n.videoBufferManager)||void 0===t||t.maintain(r),null===(e=n.audioBufferManager)||void 0===e||e.maintain(r)}},this.throughputEstimator=i.throughputEstimator,this.tuning=i.tuning,this.fetcher=new tl({throughputEstimator:this.throughputEstimator})}return i.prototype.initManifest=function(t,e){return I(this,void 0,void 0,(function(){var r,i,n,o=this;return x(this,(function(s){switch(s.label){case 0:return this.element=t,this.subscription.add(a(t,'waiting').subscribe((function(){t.duration-t.currentTime<o.tuning.endGapTolerance/1e3&&o.forceEnded$.next()}),(function(t){return o.error$.next({id:'ForceEnd',message:'Error when forcing stream end',thrown:t})}))),this.state$.startTransitionTo(rl.MANIFEST_LOADED),[4,this.fetcher.fetchManifest(e)];case 1:r=s.sent();try{i=function(t,e){var r,i,n,a,o,s,u,c,d,l,p,h,f,v,m,S,g,y,b,T,E,w,P,A,k,$,_,D={video:[],audio:[],text:[]},R=(new DOMParser).parseFromString(t,'application/xml').children[0],I=R.getElementsByTagName('Period')[0].children,x=0,N=null!==(s=null===(o=R.getAttribute('profiles'))||void 0===o?void 0:o.split(','))&&void 0!==s?s:[],M=N.includes(fi.WEBM_AS_IN_FFMPEG)||N.includes(fi.WEBM_AS_IN_SPEC)?mi.WEBM:mi.MP4;try{for(var B=L(I),U=B.next();!U.done;U=B.next()){var V=U.value,F=V.getAttribute('mimeType'),H=V.getAttribute('codecs'),q=null!==(u=V.getAttribute('contentType'))&&void 0!==u?u:null==F?void 0:F.split('/')[0],G=null!==(d=null===(c=V.getAttribute('profiles'))||void 0===c?void 0:c.split(','))&&void 0!==d?d:[],Y=V.querySelectorAll('Representation');try{for(var j=(n=void 0,L(Y)),z=j.next();!z.done;z=j.next()){var Q=z.value,W=null!==(l=Q.getAttribute('mimeType'))&&void 0!==l?l:F,J=null!==(h=null!==(p=Q.getAttribute('codecs'))&&void 0!==p?p:H)&&void 0!==h?h:'',K=null!==(v=null!==(f=Q.getAttribute('contentType'))&&void 0!==f?f:null==W?void 0:W.split('/')[0])&&void 0!==v?v:q,X=null!==(S=null===(m=V.getAttribute('profiles'))||void 0===m?void 0:m.split(','))&&void 0!==S?S:[],Z=parseInt(null!==(g=Q.getAttribute('width'))&&void 0!==g?g:'',10),tt=parseInt(null!==(y=Q.getAttribute('height'))&&void 0!==y?y:'',10),et=parseInt(null!==(b=Q.getAttribute('bandwidth'))&&void 0!==b?b:'',10)/1e3,rt=null!==(T=Q.getAttribute('frameRate'))&&void 0!==T?T:'',it=rt?hl(rt):void 0,nt=null!==(E=Q.getAttribute('id'))&&void 0!==E?E:(x++).toString(10),at='video'===K?''.concat(tt,'p'):'audio'===K?''.concat(et,'Kbps'):J,ot=''.concat(nt,'@').concat(at),st=null!==(A=null===(P=null===(w=Q.querySelector('BaseURL'))||void 0===w?void 0:w.textContent)||void 0===P?void 0:P.trim())&&void 0!==A?A:'',ut=new URL(st,e).toString(),ct=C(C(C([],O(N),!1),O(G),!1),O(X),!1),dt=O((null!==($=null===(k=Q.querySelector('SegmentBase Initialization'))||void 0===k?void 0:k.getAttribute('range'))&&void 0!==$?$:'').split('-').map((function(t){return parseInt(t,10)})),2),lt={from:dt[0],to:dt[1]},pt=null===(_=Q.querySelector('SegmentBase'))||void 0===_?void 0:_.getAttribute('indexRange'),ht=O(pt?pt.split('-').map((function(t){return parseInt(t,10)})):[],2),ft=ht[0],vt=ht[1],mt=pt?{from:ft,to:vt}:void 0;if(K&&W){var St={video:hi.VIDEO,audio:hi.AUDIO,text:hi.TEXT}[K];St&&D[St].push({id:ot,kind:St,profiles:ct,initRange:lt,indexRange:mt,bitrate:et,mime:W,codecs:J,width:Z,height:tt,fps:it,url:ut})}}}catch(t){n={error:t}}finally{try{z&&!z.done&&(a=j.return)&&a.call(j)}finally{if(n)throw n.error}}}}catch(t){r={error:t}}finally{try{U&&!U.done&&(i=B.return)&&i.call(B)}finally{if(r)throw r.error}}return{container:M,representations:D}}(null!=r?r:'',e)}catch(t){this.error$.next({id:'ManifestParsing',message:'Failed to parse MPD manifest',thrown:t})}return p(i),n=function(e){var r,i,n,a=e.mime,o=e.codecs;return Boolean((null===(r=t.canPlayType)||void 0===r?void 0:r.call(t,a))&&(null===(n=null===(i=window.MediaSource)||void 0===i?void 0:i.isTypeSupported)||void 0===n?void 0:n.call(i,''.concat(a,'; codecs="').concat(o,'"'))))},this.manifest=R(R({},i),{representations:Ds(Object.entries(i.representations).map((function(t){var e=O(t,2);return[e[0],e[1].filter(n)]})))}),this.manifest.representations.video.length?this.state$.setState(rl.MANIFEST_LOADED):this.error$.next({id:'NoRepresentations',message:'No playable video representations'}),[2,this.manifest]}}))}))},i.prototype.initRepresentations=function(t,e){return I(this,void 0,void 0,(function(){var r,i=this;return x(this,(function(n){switch(n.label){case 0:return p(this.manifest),p(this.element),this.state$.startTransitionTo(rl.REPRESENTATION_SELECTED),this.source=new MediaSource,this.element.src=URL.createObjectURL(this.source),r={fetcher:this.fetcher,tuning:this.tuning.dash},this.videoBufferManager=new pl(hi.VIDEO,this.source,this.manifest.container,this.manifest.representations.video,r),this.audioBufferManager=new pl(hi.AUDIO,this.source,this.manifest.container,this.manifest.representations.audio,r),this.subscription.add(this.fetcher.lastConnectionType$.subscribe(this.lastConnectionType$)),this.subscription.add(this.fetcher.lastConnectionReused$.subscribe(this.lastConnectionReused$)),this.subscription.add(this.fetcher.lastRequestFirstBytes$.subscribe(this.lastRequestFirstBytes$)),this.subscription.add(s(this.forceEnded$,S({video:this.videoBufferManager.ended$,audio:this.audioBufferManager.ended$}).pipe(g((function(t){return Object.values(t).every((function(t){return!0===t}))})))).subscribe((function(){var t,e;if('open'===(null===(t=i.source)||void 0===t?void 0:t.readyState))try{null===(e=i.source)||void 0===e||e.endOfStream()}catch(t){i.error$.next({id:'EndOfStream',message:'Failed to end MediaSource stream',thrown:t})}}))),this.subscription.add(s(this.videoBufferManager.error$,this.audioBufferManager.error$).subscribe(this.error$)),this.subscription.add(this.videoBufferManager.playingRepresentation$.subscribe(this.currentVideoRepresentation$)),'open'===this.source.readyState?[3,2]:[4,new Promise((function(t){var e;return null===(e=i.source)||void 0===e?void 0:e.addEventListener('sourceopen',t)}))];case 1:n.sent(),n.label=2;case 2:return[4,Promise.all([this.videoBufferManager.startWith(t),this.audioBufferManager.startWith(e)])];case 3:return n.sent().some((function(t){return!t}))||(this.state$.setState(rl.REPRESENTATION_SELECTED),p(this.element),this.subscription.add(s.apply(void 0,C(C([],O(fl.map((function(t){return a(i.element,t)}))),!1),[a(window,'online')],!1)).subscribe(this.tick,(function(t){i.error$.next({id:'DashVKPlayer',message:'Internal logic error',thrown:t})}))),this.subscription.add(a(this.element,'progress').subscribe((function(){i.element&&2===i.element.readyState&&!i.element.seeking&&(i.element.currentTime=i.element.currentTime)}))),this.tick()),[2]}}))}))},i.prototype.switchRepresentation=function(t,e){return I(this,void 0,void 0,(function(){var r,i;return x(this,(function(n){return r=(i={},i[hi.VIDEO]=this.videoBufferManager,i[hi.AUDIO]=this.audioBufferManager,i[hi.TEXT]=null,i)[t],p(r),[2,r.switchTo(e)]}))}))},i.prototype.seek=function(t){p(this.element),p(this.videoBufferManager),p(this.audioBufferManager),this.videoBufferManager.maintain(t),this.audioBufferManager.maintain(t),this.element.currentTime=t/1e3},i.prototype.stop=function(){var t,e;this.element=null,this.source=null,this.manifest=null,this.currentVideoRepresentation$.next(void 0),null===(t=this.videoBufferManager)||void 0===t||t.destroy(),this.videoBufferManager=null,null===(e=this.audioBufferManager)||void 0===e||e.destroy(),this.audioBufferManager=null,this.state$.setState(rl.NONE)},i.prototype.destroy=function(){this.subscription.unsubscribe(),this.fetcher.destroy(),this.stop(),this.source=null},i}();!function(t){t.STOPPED='stopped',t.READY='ready',t.PLAYING='playing',t.PAUSED='paused'}(vl||(vl={}));var Sl,gl=function(t){var e=t.id,r=t.width,i=t.height,n=t.bitrate,a=t.fps,o=Bi({width:r,height:i});return o&&{id:e,quality:o,bitrate:n,size:{width:r,height:i},fps:a}},yl=function(t,e,r){var i,n=Array.from(e).sort((function(t,e){return e.bitrate-t.bitrate})).indexOf(r);return null!==(i=gi(t,Math.round(t.length*n/e.length)))&&void 0!==i?i:gi(t,-1)},bl=function(){function e(e){var n=this;this.subscription=new r,this.videoState=new Ji(vl.STOPPED),this.elementSize$=new t(void 0),this.textTracksManager=new ki,this.videoTracks=[],this.syncPlayback=function(){var t=n.videoState.getState(),e=n.params.desiredState.playbackState.getState(),r=n.params.desiredState.playbackState.getTransition(),a=n.params.desiredState.seekPosition.getTransition();if(!n.videoState.getTransition()){var s=null==a?void 0:a.to;if((null==r?void 0:r.to)!==P.PAUSED&&i(s)&&t!==vl.STOPPED&&e!==P.STOPPED&&n.seek(s),e!==P.STOPPED){if(t===vl.STOPPED)return n.videoState.startTransitionTo(vl.READY),void n.prepare();switch(t){case vl.READY:return void(e===P.PAUSED?(n.videoState.setState(vl.PAUSED),Li(n.params.desiredState.playbackState,P.PAUSED)):e===P.PLAYING&&(n.videoState.startTransitionTo(vl.PLAYING),n.playIfAllowed()));case vl.PLAYING:return void(e===P.PAUSED?(n.videoState.startTransitionTo(vl.PAUSED),n.video.pause()):(null==r?void 0:r.to)===P.PLAYING&&Li(n.params.desiredState.playbackState,P.PLAYING));case vl.PAUSED:return void(e===P.PLAYING?(n.videoState.startTransitionTo(vl.PLAYING),n.playIfAllowed()):(null==r?void 0:r.to)===P.PAUSED&&Li(n.params.desiredState.playbackState,P.PAUSED));default:return o(t)}}else t!==vl.STOPPED&&(n.videoState.startTransitionTo(vl.STOPPED),n.player.stop(),n.video.setAttribute('src',''),n.video.load(),n.params.output.position$.next(0),n.params.output.duration$.next(1/0),n.params.output.currentBuffer$.next(void 0),n.params.output.hostname$.next(void 0),n.videoState.setState(vl.STOPPED),Li(n.params.desiredState.playbackState,P.STOPPED,!0))}},this.params=e,this.video=$i(this.params.container),this.params.output.element$.next(this.video),this.params.output.availableVideoTracks$.next([]),this.params.output.hostname$.next(Qi(this.params.source.url)),this.params.output.isLive$.next(!1),this.player=new ml({throughputEstimator:this.params.dependencies.throughputEstimator,tuning:this.params.tuning}),this.subscribe()}return e.prototype.subscribe=function(){var t=this,e=this.params,r=e.output,n=e.desiredState,o=xi(this.video),u=function(t){r.error$.next({id:'DashVKProvider',message:'DashVKProvider internal logic error',thrown:t})},h=function(e,r){return t.subscription.add(e.subscribe(r,u))};h(o.timeUpdate$,r.position$),h(o.durationChange$,r.duration$),h(o.ended$,r.endedEvent$),h(o.error$,r.error$),h(o.isBuffering$,r.isBuffering$),h(o.currentBuffer$,r.currentBuffer$),h(o.firstFrame$,r.firstFrameEvent$),h(this.player.error$,r.error$),h(this.player.lastConnectionType$,r.httpConnectionType$),h(this.player.lastConnectionReused$,r.httpConnectionReused$),h(this.player.lastRequestFirstBytes$.pipe(g(i),f()),r.firstBytesEvent$),this.subscription.add(o.seeked$.subscribe(r.seekedEvent$,u)),this.subscription.add(wi(this.video,n.isLooped,u)),this.subscription.add(Pi(this.video,n.volume,o.volumeState$,u)),this.subscription.add(o.volumeState$.subscribe(this.params.output.volume$,u)),h(Wi(this.video),this.elementSize$),this.subscription.add(o.playing$.subscribe((function(){t.videoState.setState(vl.PLAYING),Li(n.playbackState,P.PLAYING)}),u)).add(o.pause$.subscribe((function(){t.videoState.setState(vl.PAUSED),Li(n.playbackState,P.PAUSED)}),u)).add(o.canplay$.subscribe((function(){t.videoState.getState()===vl.PLAYING&&t.playIfAllowed()}),u)),this.subscription.add(this.player.state$.stateChangeEnded$.pipe(g((function(t){return t.to===rl.REPRESENTATION_SELECTED}))).subscribe((function(){t.videoState.setState(vl.READY)}))),this.subscription.add(s(this.player.state$.stateChangeEnded$,n.videoTrack.stateChangeStarted$,n.autoVideoTrackSwitching.transitionStarted$,this.params.dependencies.throughputEstimator.rttAdjustedThroughput$,this.elementSize$,a(this.video,'progress')).subscribe((function(){var e,r,i,a=t.player.state$.getState(),o=t.player.state$.getTransition();if(a!==rl.NONE&&t.videoTracks.length){var s=a===rl.MANIFEST_LOADED&&!o,u=n.autoVideoTrackSwitching.getState(),c=n.videoTrack.getState(),d=null===(e=t.videoTracks.find((function(t){return t.track.id===c})))||void 0===e?void 0:e.track;n.autoVideoTrackSwitching.getTransition()&&n.autoVideoTrackSwitching.setState(u);var l=zi(t.video.buffered,1e3*t.video.currentTime),h=Math.min(l/Math.min(t.params.tuning.dash.forwardBufferTarget,(1e3*t.video.duration||1/0)-1e3*t.video.currentTime),1),f=ji(t.videoTracks.map((function(t){return t.track})),{container:t.elementSize$.getValue(),throughput:t.params.dependencies.throughputEstimator.rttAdjustedThroughput$.getValue(),tuning:t.params.tuning.autoTrackSelection,forwardBufferHealth:h}),v=u?null!=f?f:d:null!=d?d:f;if(s){var m=v&&(null===(r=t.videoTracks.find((function(t){return t.track===v})))||void 0===r?void 0:r.representation);p(m);var S=yl(t.audioRepresentations,t.videoTracks.map((function(t){return t.representation})),m);p(S),t.player.initRepresentations(m.id,S.id)}else{if(m=v&&(null===(i=t.videoTracks.find((function(t){return t.track===v})))||void 0===i?void 0:i.representation)){S=yl(t.audioRepresentations,t.videoTracks.map((function(t){return t.representation})),m);t.player.switchRepresentation(hi.VIDEO,m.id),S&&t.player.switchRepresentation(hi.AUDIO,S.id)}}}}))),this.subscription.add(this.player.currentVideoRepresentation$.pipe(l(),c((function(e){var r;return e&&(null===(r=t.videoTracks.find((function(t){return t.representation.id===e})))||void 0===r?void 0:r.track)}))).subscribe(r.currentVideoTrack$)),this.textTracksManager.connect(this.video,n,r);var m=s(n.playbackState.stateChangeStarted$,n.videoTrack.stateChangeStarted$,n.seekPosition.stateChangeStarted$,this.videoState.stateChangeEnded$,d(['init'])).pipe(v(0));this.subscription.add(m.subscribe(this.syncPlayback,u))},e.prototype.prepare=function(){return I(this,void 0,void 0,(function(){var t,e,r,i,n,a,o;return x(this,(function(s){switch(s.label){case 0:return[4,this.player.initManifest(this.video,this.params.source.url)];case 1:t=s.sent(),this.videoTracks=[];try{for(e=L(t.representations.video),r=e.next();!r.done;r=e.next())i=r.value,(n=gl(i))&&this.videoTracks.push({track:n,representation:i})}catch(t){a={error:t}}finally{try{r&&!r.done&&(o=e.return)&&o.call(e)}finally{if(a)throw a.error}}return this.audioRepresentations=Array.from(t.representations.audio).sort((function(t,e){return e.bitrate-t.bitrate})),this.params.output.availableVideoTracks$.next(this.videoTracks.map((function(t){return t.track}))),[2]}}))}))},e.prototype.seek=function(t){this.params.output.willSeekEvent$.next(),this.player.seek(1e3*t)},e.prototype.destroy=function(){this.subscription.unsubscribe(),this.textTracksManager.destroy(),this.video.remove(),this.params.output.element$.next(void 0),this.player.destroy()},e.prototype.playIfAllowed=function(){var t=this;Ti(this.video).then((function(e){e||(t.videoState.setState(vl.PAUSED),Li(t.params.desiredState.playbackState,P.PAUSED,!0))}))},e}();!function(t){t[t.OFFSET_P=0]='OFFSET_P',t[t.PLAYBACK_SHIFT=1]='PLAYBACK_SHIFT'}(Sl||(Sl={}));var Tl,El=function(t,e,r){switch(void 0===e&&(e=0),void 0===r&&(r=Sl.OFFSET_P),r){case Sl.OFFSET_P:return t.replace('_offset_p',0===e?'':'_'+e.toFixed(0));case Sl.PLAYBACK_SHIFT:if(0===e)return t;var i=new URL(t);return i.searchParams.append('playback_shift',e.toFixed(0)),i.toString();default:o(r)}return t};!function(t){t.STOPPED='stopped',t.READY='ready',t.PLAYING='playing',t.PAUSED='paused'}(Tl||(Tl={}));var wl,Pl=function(){function t(t){var e=this;this.subscription=new r,this.loadMediaTimeoutSubscription=new r,this.videoState=new Ji(Tl.STOPPED),this.syncPlayback=function(){var t=e.videoState.getState(),r=e.videoState.getTransition(),n=e.params.desiredState.playbackState.getState(),a=e.params.desiredState.playbackState.getTransition(),s=e.params.desiredState.seekPosition.getTransition();if(e.log({message:'[syncPlayback] videoState: '.concat(t,'; videoTransition: ').concat(JSON.stringify(r),'; desiredPlaybackState: ').concat(n,'; desiredPlaybackStateTransition: ').concat(e.params.desiredState.playbackState.getTransition(),'; seekPositionTransition: ').concat(JSON.stringify(s),';')}),n!==P.STOPPED){if(!r){var u=null==s?void 0:s.to;if((null==a?void 0:a.to)!==P.PAUSED&&i(u)&&t!==Tl.STOPPED)e.seek(u);else switch(n){case P.PLAYING:switch(t){case Tl.PLAYING:break;case Tl.PAUSED:case Tl.READY:e.videoState.startTransitionTo(Tl.PLAYING),e.params.connection.remotePlayerController.playOrPause();break;case Tl.STOPPED:e.videoState.startTransitionTo(Tl.READY),e.prepare();break;default:o(t)}break;case P.PAUSED:switch(t){case Tl.PLAYING:e.videoState.startTransitionTo(Tl.PAUSED),e.params.connection.remotePlayerController.playOrPause();break;case Tl.PAUSED:break;case Tl.READY:e.videoState.startTransitionTo(Tl.PAUSED),e.videoState.setState(Tl.PAUSED);break;case Tl.STOPPED:e.videoState.startTransitionTo(Tl.READY),e.prepare();break;default:o(t)}break;default:o(n)}}}else t!==Tl.STOPPED&&(e.videoState.startTransitionTo(Tl.STOPPED),e.stop())},this.params=t,this.log=this.params.dependencies.logger.createComponentLog('ChromecastProvider'),this.log({message:'constructor, format: '.concat(t.format)}),this.params.output.isLive$.next(function(t){switch(t){case A.MPEG:case A.DASH:case A.DASH_SEP:case A.DASH_SEP_VK:case A.DASH_ONDEMAND:case A.DASH_WEBM:case A.DASH_WEBM_VK:case A.HLS:case A.HLS_JS:case A.HLS_ONDEMAND:return!1;case A.HLS_LIVE:case A.DASH_LIVE:case A.DASH_LIVE_WEBM:return!0;default:return o(t)}}(t.format)),this.handleRemoteVolumeChange({volume:this.params.connection.remotePlayer.volumeLevel,muted:this.params.connection.remotePlayer.isMuted});var n=this.params.connection.session.getMediaSession();n&&this.restoreSession(n),this.subscribe()}return t.prototype.destroy=function(){this.log({message:'[destroy]'}),this.subscription.unsubscribe()},t.prototype.subscribe=function(){var t=this;this.subscription.add(this.loadMediaTimeoutSubscription);var u=new r;this.subscription.add(u),this.subscription.add(s(this.videoState.stateChangeStarted$.pipe(c((function(t){return'stateChangeStarted$ '.concat(JSON.stringify(t))}))),this.videoState.stateChangeEnded$.pipe(c((function(t){return'stateChangeEnded$ '.concat(JSON.stringify(t))})))).subscribe((function(e){return t.log({message:'[videoState] '.concat(e)})})));var l=function(e,r){return t.subscription.add(e.subscribe(r))};if(this.params.output.isLive$.getValue())this.params.output.position$.next(0),this.params.output.duration$.next(0);else{var p=new e;u.add(p.pipe(v(500)).subscribe((function(){t.params.output.seekedEvent$.next()})));var h=NaN;u.add(a(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED).subscribe((function(e){t.logRemoteEvent(e);var r=e.value;t.params.output.position$.next(r);var a=t.params.desiredState.seekPosition.getTransition();(i(a)&&n(a.to)||Math.abs(r-h)>5)&&p.next(r),h=r}))),u.add(a(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.DURATION_CHANGED).subscribe((function(e){t.logRemoteEvent(e),t.params.output.duration$.next(e.value)})))}l(a(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED),(function(e){t.logRemoteEvent(e),e.value?t.handleRemoteReady():(t.handleRemoteStop(),u.unsubscribe())})),l(a(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED),(function(e){t.logRemoteEvent(e),e.value?t.handleRemotePause():t.handleRemotePlay()})),l(a(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED),(function(e){t.logRemoteEvent(e);var r=t.params.connection.remotePlayer,i=e.value,n=t.params.output.isBuffering$.getValue(),a=i===chrome.cast.media.PlayerState.BUFFERING;switch(n!==a&&t.params.output.isBuffering$.next(a),i){case chrome.cast.media.PlayerState.IDLE:!t.params.output.isLive$.getValue()&&r.duration-r.currentTime<5&&t.params.output.endedEvent$.next(),t.handleRemoteStop(),Li(t.params.desiredState.playbackState,P.STOPPED);break;case chrome.cast.media.PlayerState.PAUSED:t.handleRemotePause();break;case chrome.cast.media.PlayerState.PLAYING:t.handleRemotePlay();break;case chrome.cast.media.PlayerState.BUFFERING:break;default:o(i)}})),l(a(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED),(function(e){t.logRemoteEvent(e),t.handleRemoteVolumeChange({volume:e.value})})),l(a(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED),(function(e){t.logRemoteEvent(e),t.handleRemoteVolumeChange({muted:e.value})})),l(s(this.params.desiredState.playbackState.stateChangeStarted$,this.params.desiredState.seekPosition.stateChangeStarted$,this.videoState.stateChangeEnded$,d(['init'])).pipe(v(0)),this.syncPlayback)},t.prototype.restoreSession=function(t){this.log({message:'restoreSession'});var e=this.params.connection.remotePlayer;if(t.playerState!==chrome.cast.media.PlayerState.IDLE){e.isPaused?(this.videoState.setState(Tl.PAUSED),Li(this.params.desiredState.playbackState,P.PAUSED)):(this.videoState.setState(Tl.PLAYING),Li(this.params.desiredState.playbackState,P.PLAYING));var r=this.params.output.isLive$.getValue();this.params.output.duration$.next(r?0:e.duration),this.params.output.position$.next(r?0:e.currentTime),this.params.desiredState.seekPosition.setState(void 0)}},t.prototype.prepare=function(){var t=this.params.format;this.log({message:'[prepare] format: '.concat(t)});var e=this.createMediaInfo(t),r=this.createLoadRequest(e);this.loadMedia(r)},t.prototype.handleRemotePause=function(){var t=this.videoState.getState(),e=this.videoState.getTransition();(null==e?void 0:e.to)!==Tl.PAUSED&&t!==Tl.PLAYING||(this.videoState.setState(Tl.PAUSED),Li(this.params.desiredState.playbackState,P.PAUSED))},t.prototype.handleRemotePlay=function(){var t=this.videoState.getState(),e=this.videoState.getTransition();(null==e?void 0:e.to)!==Tl.PLAYING&&t!==Tl.PAUSED||(this.videoState.setState(Tl.PLAYING),Li(this.params.desiredState.playbackState,P.PLAYING))},t.prototype.handleRemoteReady=function(){var t=this.videoState.getTransition();(null==t?void 0:t.to)===Tl.READY&&this.videoState.setState(Tl.READY)},t.prototype.handleRemoteStop=function(){this.videoState.getState()!==Tl.STOPPED&&this.videoState.setState(Tl.STOPPED)},t.prototype.handleRemoteVolumeChange=function(t){var e,r,i=this.params.output.volume$.getValue(),n={volume:null!==(e=t.volume)&&void 0!==e?e:i.volume,muted:null!==(r=t.muted)&&void 0!==r?r:i.muted};n.volume===i.volume&&n.muted==n.muted||this.params.output.volume$.next(n)},t.prototype.seek=function(t){this.params.output.willSeekEvent$.next();var e=this.params.connection,r=e.remotePlayer,i=e.remotePlayerController;r.currentTime=t,i.seek()},t.prototype.stop=function(){this.params.connection.remotePlayerController.stop()},t.prototype.createMediaInfo=function(t){var e,r,n,a,s=this.params.source;switch(t){case A.MPEG:var u=s[t];p(u);var c=Object.keys(u).sort((function(t,e){return t===e?0:t===yi.INVARIANT?1:e===yi.INVARIANT?-1:Ni(t,e)?1:-1}))[0];p(c);var d=u[c];p(d),r=d,n='video/mp4',a=chrome.cast.media.StreamType.BUFFERED;break;case A.HLS:case A.HLS_ONDEMAND:var l=s[t];p(l),r=l.url,n='application/x-mpegurl',a=chrome.cast.media.StreamType.BUFFERED;break;case A.DASH_SEP:case A.DASH_SEP_VK:case A.DASH_ONDEMAND:case A.DASH_WEBM_VK:case A.DASH_WEBM:var h=s[t];p(h),r=h.url,n='application/dash+xml',a=chrome.cast.media.StreamType.BUFFERED;break;case A.HLS_LIVE:l=s[t];p(l),r=El(l.url),n='application/x-mpegurl',a=chrome.cast.media.StreamType.LIVE;break;case A.DASH_LIVE_WEBM:h=s[t];p(h),r=h.url,n='application/dash+xml',a=chrome.cast.media.StreamType.LIVE;break;case A.HLS_JS:case A.DASH:case A.DASH_LIVE:var f='Unsupported format for Chromecast',v=new Error(f);throw this.params.output.error$.next({id:'ChromecastProvider.createMediaInfo()',message:f,thrown:v}),v;default:return o(t)}var m=new chrome.cast.media.MediaInfo(null!==(e=this.params.meta.videoId)&&void 0!==e?e:r,n);m.contentUrl=r,m.streamType=a,m.metadata=new chrome.cast.media.GenericMediaMetadata;var S=this.params.meta,g=S.title,y=S.subtitle;return i(g)&&(m.metadata.title=g),i(y)&&(m.metadata.subtitle=y),m},t.prototype.createLoadRequest=function(t){var e,r=new chrome.cast.media.LoadRequest(t);r.autoplay=!1;var i=this.params.desiredState.seekPosition.getTransition();return r.currentTime=i?this.params.output.isLive$.getValue()?0:null!==(e=i.to)&&void 0!==e?e:0:0,r},t.prototype.loadMedia=function(t){var e=this,r=this.params.connection.session.loadMedia(t),i=new Promise((function(t,r){e.loadMediaTimeoutSubscription.add(y(7e3).subscribe((function(){return r('timeout('.concat(7e3,')'))})))}));Wd(Promise.race([r,i]).then((function(){e.log({message:'[loadMedia] completed, format: '.concat(e.params.format)});var t=e.params.desiredState.seekPosition;t.getTransition()&&t.setState(void 0),e.handleRemoteReady()}),(function(t){var r='[prepare] loadMedia failed, format: '.concat(e.params.format,', reason: ').concat(t);e.log({message:r}),e.params.output.error$.next({id:'ChromecastProvider.loadMedia',message:r,thrown:t})})),(function(){e.loadMediaTimeoutSubscription.unsubscribe()}))},t.prototype.logRemoteEvent=function(t){this.log({message:'[remoteEvent] '.concat(JSON.stringify(t))})},t}();!function(t){t.STOPPED='stopped',t.READY='ready',t.PLAYING='playing',t.PAUSED='paused'}(wl||(wl={}));var Al,kl=function(){function t(t){var e=this;this.subscription=new r,this.videoState=new Ji(wl.STOPPED),this.trackUrls={},this.textTracksManager=new ki,this.syncPlayback=function(){var t=e.videoState.getState(),r=e.params.desiredState.playbackState.getState(),n=e.params.desiredState.playbackState.getTransition();if(r!==P.STOPPED){if(!e.videoState.getTransition()){var a=e.params.desiredState.videoTrack.getTransition(),s=e.params.desiredState.seekPosition.getTransition();if(t===wl.STOPPED)return e.videoState.startTransitionTo(wl.READY),void e.prepare();if(a){var u=e.video.currentTime;return e.prepare(),void(s||e.params.desiredState.seekPosition.startTransitionTo(u))}var c=null==s?void 0:s.to;switch((null==n?void 0:n.to)!==P.PAUSED&&i(c)&&e.seek(c),t){case wl.READY:return void(r===P.PAUSED?(e.videoState.setState(wl.PAUSED),Li(e.params.desiredState.playbackState,P.PAUSED)):r===P.PLAYING&&(e.videoState.startTransitionTo(wl.PLAYING),e.playIfAllowed()));case wl.PLAYING:return void(r===P.PAUSED?(e.videoState.startTransitionTo(wl.PAUSED),e.video.pause()):(null==n?void 0:n.to)===P.PLAYING&&Li(e.params.desiredState.playbackState,P.PLAYING));case wl.PAUSED:return void(r===P.PLAYING?(e.videoState.startTransitionTo(wl.PLAYING),e.playIfAllowed()):(null==n?void 0:n.to)===P.PAUSED&&Li(e.params.desiredState.playbackState,P.PAUSED));default:return o(t)}}}else t!==wl.STOPPED&&(e.videoState.startTransitionTo(wl.STOPPED),e.video.setAttribute('src',''),e.video.load(),e.params.output.position$.next(0),e.params.output.duration$.next(1/0),e.params.output.currentBuffer$.next(void 0),e.params.output.hostname$.next(void 0),e.videoState.setState(wl.STOPPED),Li(e.params.desiredState.playbackState,P.STOPPED,!0))},this.params=t,this.video=$i(t.container),this.params.output.element$.next(this.video),Object.entries(this.params.source).forEach((function(t,r){var i=O(t,2),n=i[0],a=i[1],o=r.toString(10);e.trackUrls[o]={track:{quality:n,id:o},url:a}})),this.params.output.availableVideoTracks$.next(Object.values(this.trackUrls).map((function(t){return t.track}))),this.params.output.isLive$.next(!1),this.subscribe()}return t.prototype.subscribe=function(){var t=this,e=this.params,r=e.output,n=e.desiredState,a=function(t){r.error$.next({id:'MpegProvider',message:'MpegProvider internal logic error',thrown:t})},o=xi(this.video),u=function(e,r){return t.subscription.add(e.subscribe(r,a))};u(o.timeUpdate$,r.position$),u(o.durationChange$,r.duration$),u(o.ended$,r.endedEvent$),u(o.error$,r.error$),u(o.isBuffering$,r.isBuffering$),u(o.currentBuffer$,r.currentBuffer$),u(o.firstBytes$,r.firstBytesEvent$),u(o.firstFrame$,r.firstFrameEvent$),u(o.seeked$,r.seekedEvent$),this.subscription.add(wi(this.video,n.isLooped,a)),this.subscription.add(Pi(this.video,n.volume,o.volumeState$,a)),this.subscription.add(o.volumeState$.subscribe(this.params.output.volume$,a)),this.subscription.add(o.playing$.subscribe((function(){t.videoState.setState(wl.PLAYING),Li(n.playbackState,P.PLAYING)}),a)).add(o.pause$.subscribe((function(){t.videoState.setState(wl.PAUSED),Li(n.playbackState,P.PAUSED)}),a)).add(o.canplay$.subscribe((function(){var e;(null===(e=t.videoState.getTransition())||void 0===e?void 0:e.to)===wl.READY&&t.videoState.setState(wl.READY);var r=t.params.desiredState.videoTrack.getTransition();r&&i(r.to)&&(t.params.desiredState.videoTrack.setState(r.to),t.params.output.currentVideoTrack$.next(t.trackUrls[r.to].track)),t.videoState.getState()===wl.PLAYING&&t.playIfAllowed()}),a)),this.subscription.add(n.autoVideoTrackSwitching.stateChangeStarted$.subscribe((function(){return n.autoVideoTrackSwitching.setState(!1)}),a)),this.textTracksManager.connect(this.video,n,r);var c=s(n.playbackState.stateChangeStarted$,n.videoTrack.stateChangeStarted$,n.seekPosition.stateChangeStarted$,this.videoState.stateChangeEnded$,d(['init'])).pipe(v(0));this.subscription.add(c.subscribe(this.syncPlayback,a))},t.prototype.destroy=function(){this.subscription.unsubscribe(),this.textTracksManager.destroy(),this.trackUrls={},this.video.remove(),this.params.output.element$.next(void 0)},t.prototype.prepare=function(){var t,e,r=null!==(e=null===(t=this.params.desiredState.videoTrack.getTransition())||void 0===t?void 0:t.to)&&void 0!==e?e:this.params.desiredState.videoTrack.getState();p(r,'MpegProvider: track is not selected');var i=this.trackUrls[r].url;p(i,'MpegProvider: No url for '.concat(r)),this.video.setAttribute('src',i),this.video.load(),this.params.output.hostname$.next(Qi(i))},t.prototype.playIfAllowed=function(){var t=this;Ti(this.video).then((function(e){e||(t.videoState.setState(wl.PAUSED),Li(t.params.desiredState.playbackState,P.PAUSED,!0))}))},t.prototype.seek=function(t){this.params.output.willSeekEvent$.next(),this.video.currentTime=t},t}(),$l=function(){function t(t,e,r,i,n,a){void 0===e&&(e=[]),this._failoverIndex=0,this._failoverCount=0,this._xhr=null,this._retryTimeout=0,this._url=t,this._failoverHosts=e,this._completeCb=r,this._progressCb=i,this._headersCb=n,this._errorCb=a,this._request()}return t.prototype._request=function(){var t=this;this._xhr=new XMLHttpRequest,this._xhr.open('GET',this._url,!0),this._xhr.overrideMimeType('text/plain; charset=x-user-defined');var e=!1;this._xhr.onreadystatechange=function(){var r,i,n,a,o,s,u,c;if(p(t._xhr),(null===(r=t._xhr)||void 0===r?void 0:r.status)>=400)return null===(i=t._errorCb)||void 0===i||i.call(t,'Http'.concat(null===(n=t._xhr)||void 0===n?void 0:n.status),'XHR response code '.concat(null===(a=t._xhr)||void 0===a?void 0:a.status)),void t.abort();if(4!==t._xhr.readyState||0!==t._xhr.status)try{if(t._xhr.readyState>=2&&!e){e=!0;var d=Ds(t._xhr.getAllResponseHeaders().trim().split(/[\n\r]+/).map((function(t){return t.split(':').map((function(t){return t.trim()}))})));null===(o=t._headersCb)||void 0===o||o.call(t,new Headers(d))}else 4===t._xhr.readyState?null===(s=t._completeCb)||void 0===s||s.call(t,t._xhr.response):3===t._xhr.readyState&&(null===(u=t._progressCb)||void 0===u||u.call(t,t._xhr.response))}catch(e){throw null===(c=t._errorCb)||void 0===c||c.call(t,'XHR2CallbackError','xhr2 callback threw '.concat(String(e)),e),e}},this._xhr.onerror=function(){var e;null===(e=t._xhr)||void 0===e||e.abort(),t._retryTimeout=window.setTimeout((function(){var e;if(t._xhr)if(++t._failoverCount>=30)t._xhr=null,null===(e=t._errorCb)||void 0===e||e.call(t,'XHR2Failover','XHR failed, retrying failover host');else{var r=void 0;t._failoverIndex>=t._failoverHosts.length?(r=t._url,t._failoverIndex=0):(r=t._url.replace(function(t){var e=document.createElement('a');return e.href=t,e.host}(t._url),t._failoverHosts[t._failoverIndex]),t._failoverIndex++),t._xhr.open('GET',r,!0),t._xhr.send(null)}}),500)},this._xhr.send(null)},t.prototype.abort=function(){window.clearTimeout(this._retryTimeout),this._completeCb=this._progressCb=this._errorCb=void 0,this._xhr&&(this._xhr.abort(),this._xhr=null)},t}(),_l=function(){function t(t){this._maxBufferDuration=Number.POSITIVE_INFINITY,this._isFull=!1,this._params=t,this._mediaSource=t.mediaSource,this._sourceBuffer=t.sourceBuffer,this._onDashCallback=t.onDashCallback}return t.prototype._appendBuffer=function(t,e){try{this._isFull=!1,(this._sourceBuffer.appendBuffer||this._sourceBuffer.append).bind(this._sourceBuffer)(t),null==e||e()}catch(t){if('QuotaExceededError'!==t.name)throw this._params.onError('AppendBuffer','Unknown Buffer error',t),t;this._isFull=!0;for(var r=this._sourceBuffer.buffered,i=0,n=0,a=r.length;n<a;n++)i+=r.end(n)-r.start(n);i&&(this._maxBufferDuration=Math.round(i))}},t.prototype.getMaxBufferDuration=function(){return this._maxBufferDuration},t.prototype.isFull=function(){return this._isFull},t.prototype.load=function(e,r,i,n,a,o,s){var u=this;this.abort((function(){var c=0,d=Date.now(),l=0,p=0,h=0,f=function(e){n(t._str2ua(e.substr(c))),c=e.length};u._lastXhr=new $l(e.baseURL+'&bytes='+r+'-'+i,e.failoverHosts,(function(t){u._lastXhr=void 0,f(t);var e=Date.now()-d;u._params.onBandwidthChange({size:t.length,duration:e,speed:8*t.length/(e/1e3)}),u._onDashCallback('loading',{size:t.length,done:!0}),null==a||a()}),(function(t){if(t.length-c>s&&f(t),0!==p){h=t.length-l;var e=Date.now()-p;h>=102400&&e>=1e3&&(u._params.onBandwidthChange({size:h,duration:e,speed:8*h/(e/1e3)}),h=0,l=t.length,p=Date.now()),u._onDashCallback('loading',{size:t.length,done:!1})}else p=Date.now()}),o,(function(t,e,r){return u._params.onError(t,e,r)}))}))},t.prototype.abort=function(t){var e,r=this;null===(e=this._lastXhr)||void 0===e||e.abort(),this._lastXhr=void 0,this._sbUpdatingStop(this._lastStreamUpdatingCallback),this._lastStreamUpdatingCallback=this._sbUpdatingWatch((function(){r._appendPromiseUint8Array&&(r._appendBuffer(r._appendPromiseUint8Array),r._appendPromiseUint8Array=void 0),r._lastStreamUpdatingCallback=r._sbUpdatingWatch((function(){'open'===r._mediaSource.readyState&&r._sourceBuffer.abort(),null==t||t()}))}))},t.prototype._sbUpdatingWatch=function(t){var e=this;if(this._sourceBuffer.updating){var r=function(){try{e._sbUpdatingStop(r),e._sbUpdatingWatch(t)}catch(t){throw e._params.onError('SourceBuffer','Source Buffer update error',t),t}};return this._sourceBuffer.addEventListener('updateend',r,!1),r}t()},t.prototype._sbUpdatingStop=function(t){t&&this._sourceBuffer.removeEventListener('updateend',t,!1)},t.prototype.append=function(e,r){var i=this;this._appendPromiseUint8Array?this._appendPromiseUint8Array=t._concatUint8(this._appendPromiseUint8Array,e):(this._appendPromiseUint8Array=e,this._lastStreamUpdatingCallback=this._sbUpdatingWatch((function(){i._appendPromiseUint8Array&&i._appendBuffer(i._appendPromiseUint8Array,(function(){i._appendPromiseUint8Array=void 0,r&&i._sbUpdatingWatch(r)}))})))},t.prototype.endOfStream=function(){var t=this;'open'===this._mediaSource.readyState&&this._sbUpdatingWatch((function(){return t._mediaSource.endOfStream()}))},t._concatUint8=function(t,e){var r=new Uint8Array(t.byteLength+e.byteLength);return r.set(t,0),r.set(e,t.byteLength),r},t._str2ua=function(t){for(var e=new Uint8Array(t.length),r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e},t.prototype.remove=function(t,e){var r=this;this._sbUpdatingWatch((function(){!r._sourceBuffer.updating&&r._sourceBuffer.remove&&r._sourceBuffer.remove(t,e),r._maxBufferDuration=Number.POSITIVE_INFINITY}))},t.prototype.destroy=function(){var t;null===(t=this._lastXhr)||void 0===t||t.abort(),this._sbUpdatingStop(this._lastStreamUpdatingCallback),'open'===this._mediaSource.readyState&&this._sourceBuffer.abort()},t}(),Dl=function(){function t(t){var e;this._representations=[],this._appendVector={},this._cachingPaused=!1,this._duration=0,this.STREAM_END_THRESHOLD=1,this._params=t,this._video=t.video,this._buffer=t.buffer,this._onDashCallback=null!==(e=t.onDashCallback)&&void 0!==e?e:function(){},this._config=t.config}return t.prototype._parseDurationFromISO8601=function(t){var e=function(t,e){var r=t?parseFloat(t.replace(',','.')):NaN;return(isNaN(r)?0:r)*e},r=/^(-)?P(?:(-?[0-9,.]*)Y)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)W)?(?:(-?[0-9,.]*)D)?(?:T(?:(-?[0-9,.]*)H)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)S)?)?$/.exec(t),i='-'===(null==r?void 0:r[1])?-1:1;e(null==r?void 0:r[2],i),e(null==r?void 0:r[3],i),e(null==r?void 0:r[4],i),e(null==r?void 0:r[5],i);return 3600*e(null==r?void 0:r[6],i)+60*e(null==r?void 0:r[7],i)+e(null==r?void 0:r[8],i)},t.prototype.getRepresentations=function(){return this._representations},t.prototype.attachSource=function(t,e){var r=this;new $l(t,e,(function(i){r.attachManifest(i,e,function(t){var e=document.createElement('a');return e.href=t,e.origin}(t))}),void 0,(function(t){r._params.onResponseHeaders(t)}),(function(t,e,i){return r._params.onError(t,e,i)}))},t.prototype.attachManifest=function(t,e,r){var i=this,n=(new DOMParser).parseFromString(t,'text/xml').documentElement,a=function(t,e){var r=t.attributes.getNamedItem(e);return r?r.value:null};this._duration=this._parseDurationFromISO8601(String(a(n,'mediaPresentationDuration')));var o=[],s=[];Array.prototype.forEach.call(n.getElementsByTagName('Representation'),(function(t){var i,n,u,c,d,l,p,h,f,v,m,S,g,y,b,T,E,w,P,A=t.getElementsByTagName('SegmentBase')[0],k=A&&a(A,'indexRange').split('-'),$=A&&A.getElementsByTagName('Initialization')[0],_=$&&a($,'range').split('-');if(_&&k){var D,R=Number(null===(p=t.attributes.getNamedItem('bandwidth'))||void 0===p?void 0:p.value),I=(r?r+'/':'')+t.getElementsByTagName('BaseURL')[0].childNodes[0].data,x=null!==(f=null===(h=t.attributes.getNamedItem('frameRate'))||void 0===h?void 0:h.value)&&void 0!==f?f:void 0;D=x?hl(x):void 0,o.push({width:Number(null===(v=t.attributes.getNamedItem('width'))||void 0===v?void 0:v.value),height:Number(null===(m=t.attributes.getNamedItem('height'))||void 0===m?void 0:m.value),bandwidth:R,baseURL:I,failoverHosts:e,indexFrom:Number(k[0]),indexTo:Number(k[1]),initFrom:Number(_[0]),initTo:Number(_[1]),codecs:null!==(g=null===(S=t.attributes.getNamedItem('codecs'))||void 0===S?void 0:S.value)&&void 0!==g?g:void 0,mimeType:null!==(b=null===(y=t.attributes.getNamedItem('mimeType'))||void 0===y?void 0:y.value)&&void 0!==b?b:void 0,fps:D,bufferSize:.1*R/8,bufferLength:.1,name:null!==(E=null===(T=t.attributes.getNamedItem('okQuality'))||void 0===T?void 0:T.value)&&void 0!==E?E:void 0,id:null!==(P=null===(w=t.attributes.getNamedItem('id'))||void 0===w?void 0:w.value)&&void 0!==P?P:void 0})}else{var L=t.parentElement;if('text'===(null==L?void 0:L.getAttribute('contentType'))){var O=null!==(i=t.getAttribute('id'))&&void 0!==i?i:void 0,C=(r?r+'/':'')+(null===(d=null===(c=null===(u=null===(n=t.getElementsByTagName('BaseURL'))||void 0===n?void 0:n[0])||void 0===u?void 0:u.childNodes)||void 0===c?void 0:c[0])||void 0===d?void 0:d.data),N=null!==(l=L.getAttribute('lang'))&&void 0!==l?l:void 0;C&&s.push({id:O,url:C,language:N})}}})),o.length?(this._representations=o,s.forEach((function(t){var e=t.id,r=t.language,n=t.url,a=document.createElement('track');a.setAttribute('src',n),e&&a.setAttribute('id',e),r&&a.setAttribute('srclang',r),i._video.appendChild(a)})),this._representations.sort((function(t,e){return e.bandwidth-t.bandwidth})),this._params.onManifestReady(this._representations)):this._onDashCallback('error')},t.prototype._loadInitAndSidx=function(t,e){var r=this;if(t!==this._currentRepresentation)if(t.refs)this._stream.abort((function(){r._stream.append(t.initMessage,e)}));else{var i=Date.now();this._stream.load(t,t.initFrom,t.indexTo,(function(i){var n=t.initTo-t.initFrom+1;if(i.byteLength){t.initMessage=new Uint8Array(i.buffer,0,n);var a=new DataView(i.buffer);n+=12;var o=a.getUint32(n+4,!1);n+=8;var s=a.getUint32(n,!1),u=a.getUint32(n+4,!1)+(t.indexTo+1);n+=8;var c=a.getUint16(n+2,!1);n+=4,t.refs=[];for(var d=0;d<c;d+=1){var l=u+(2147483647&a.getUint32(n,!1)),p=s+a.getUint32(n+4,!1);n+=12,t.refs.push({fromTime:s/o,toTime:p/o,fromOffset:u,toOffset:l-1}),u=l,s=p}var h=t.refs[t.refs.length-1];h.toTime-h.fromTime<.3&&t.refs.pop(),r._stream.append(t.initMessage,e)}else r._params.onError('EmptyResponse','Empty response')}),void 0,(function(t){r._params.onResponseHeaders(t),r._params.onIdxRequestPing(Date.now()-i)}),t.indexTo-t.initFrom+1)}else e&&e()},t.prototype.startPlay=function(t){var e=this,r=window.MediaSource||window.WebKitMediaSource;if(r){var i=new r,n=void 0,a=void 0,o=function(){e._loopTimeout=window.setTimeout((function(){try{!function(){var r=e._findRef(e._video.currentTime);if(r&&!e._video.paused){if(!e._cachingPaused&&void 0!==e._lastLoadOffset&&e._lastLoadOffset-e._video.currentTime<e._config.FRONT_CACHE_DURATION&&e._lastLoadOffset-e._video.currentTime<e._stream.getMaxBufferDuration()){var i=e._stream.isFull()?e._findBufferRangeEnd(e._video.currentTime):e._lastLoadOffset;e._loadRef(e._params.selectRepresentation(e._representations),i)}var o,s=e._appendVector[String(r.fromTime)];if(s!==n&&(n=s,e._params.onRepresentationPlay(s)),e._findRef(r.toTime)){var u=e._buffer.getByTime(e._video.currentTime);if(!u)return void e._onDashCallback('buffering');(o=u.end-e._video.currentTime)<t.bufferLength&&(e._onDashCallback('buffering'),a!==u.end&&(a=u.end,window.setTimeout((function(){try{var t=e._buffer.getNextWithGap(u);t&&(e._video.currentTime=t.start)}catch(t){throw e._params.onError('GapSyncError','Seek Error '.concat(String(t)),t),t}}),1e3*o)))}}}()}catch(t){throw e._params.onError('LoopError','Dash Loop exception '.concat(String(t)),t),t}o()}),250)},s=function(){if(!e._stream)try{var r=i.addSourceBuffer(''.concat(t.mimeType,'; codecs="').concat(t.codecs,'"'));e._stream=new _l({mediaSource:i,sourceBuffer:r,onBandwidthChange:e._params.onBandwidthChange,onError:e._params.onError,onDashCallback:e._onDashCallback})}catch(t){throw e._params.onError('DashSourceOpen','Source open exception '.concat(String(t)),t),t}e._loadInitAndSidx(t),i.duration||(i.duration=e._duration),e._loopTimeout||o(),i.removeEventListener('sourceopen',s),i.removeEventListener('webkitsourceopen',s)};i.addEventListener('sourceopen',s,!1),i.addEventListener('webkitsourceopen',s,!1),this._video&&(this._video.src=window.URL.createObjectURL(i),this._video.addEventListener('waiting',(function(){var t=e._video&&e._video.played.length;t&&!e._video.currentTime&&e._video.loop?e._video.duration-e._video.played.end(t-1)<e.STREAM_END_THRESHOLD&&e.seek(0):e._video.duration-e._video.currentTime<e.STREAM_END_THRESHOLD&&e._stream.endOfStream()})))}else this._params.onError('MediaSourceNotSupported','MediaSource is not supported')},t.prototype._loadRef=function(t,e,r){var i=this;void 0===r&&(r=!1),this._lastLoadOffset=void 0,this._loadInitAndSidx(t,(function(){i._currentRepresentation=t;var n=i._findRef(e);if(n){if(r){i._isLastRef(n)&&e>=n.toTime&&(e=n.fromTime);var a=i._findRef(i._video.currentTime),o=Math.abs(i._video.currentTime-e),s=i._video.duration<i._config.SEEK_IN_SEGMENT_THRESHOLD/1e3||n===a||o<=i._config.SEEK_IN_SEGMENT_DELTA/1e3;i._video.currentTime=s?e:n.fromTime}i._appendVector[String(n.fromTime)]=t,i._stream.load(t,n.fromOffset,n.toOffset,(function(t,e){return i._stream.append(t,e)}),(function(){i._lastLoadOffset=n.toTime,i._video.duration-i._lastLoadOffset<i.STREAM_END_THRESHOLD&&i._stream.endOfStream()}),(function(t){return i._params.onResponseHeaders(t)}),t.bufferSize)}}))},t.prototype.setQualityByRepresentation=function(t,e){var r=this;void 0===e&&(e=!1);var i=this._buffer.getByTime(this._video.currentTime),n=this._findRef(this._video.currentTime);if(i&&n){var a=.1;if(n.toTime<i.end+a){var o=this._findRef(n.toTime);o&&o.toTime<i.end+a?(this._buffer.smartRemove(n.fromTime-a,o.toTime+a,(function(t,e){return r._stream.remove(t,e)})),this._loadRef(t,o.toTime)):(this._buffer.smartRemove(n.fromTime-a,n.toTime+a,(function(t,e){return r._stream.remove(t,e)})),this._loadRef(t,n.toTime))}}else this._video.currentTime&&e&&this._loadRef(t,this._video.currentTime)},t.prototype.setQuality=function(t){return this.setQualityByRepresentation(this._representations[t])},t.prototype.pauseCaching=function(){this._cachingPaused=!0},t.prototype.resumeCaching=function(){this._cachingPaused=!1},t.prototype.seek=function(t,e){void 0===e&&(e=!1),this._stream&&this._buffer.getByTime(t)&&!e?this._video.currentTime=t:this._loadRef(this._params.selectRepresentation(this._representations),t,!0)},t.prototype.updateRefsForCurrentTime=function(){var t=this._video.currentTime;this._stream&&!n(this._buffer.getByTime(t))||this._loadRef(this._params.selectRepresentation(this._representations),t,!1)},t.prototype._findRef=function(t){var e,r=null===(e=this._currentRepresentation)||void 0===e?void 0:e.refs;if(r){if(!Array.isArray(r)||0!==r.length){for(var i=void 0,n=0;n<r.length;n++){var a=r[n];if(a.fromTime<=t&&a.toTime>t)return a;a.fromTime>t&&(!i||a.fromTime<i.fromTime)&&(i=a)}if(!i){var o=r[r.length-1];if(t>o.toTime)return o}return i}this._params.onError('emptyrefs','Empty refs')}},t.prototype._isLastRef=function(t){var e,r=null===(e=this._currentRepresentation)||void 0===e?void 0:e.refs;if(!r)return!1;var i=r[r.length-1];return t.fromTime===i.fromTime},t.prototype._findBufferRangeEnd=function(t){for(var e=this._video.buffered.length;e-- >0;){var r=this._video.buffered.start(e),i=this._video.buffered.end(e);if(t>r&&t<i)return Math.round(10*i)/10}return t},t.prototype.destroy=function(){this._stream&&this._stream.destroy(),clearTimeout(this._loopTimeout),this._loopTimeout=void 0},t}();!function(t){t.STOPPED='stopped',t.MANIFEST_LOADED='manifest-loaded',t.INITIAL_REPRESENTATION_SELECTED='initial-representation-selected',t.METADATA_LOADED='metadata-loaded',t.READY='ready',t.PLAYING='playing',t.PAUSED='paused'}(Al||(Al={}));var Rl,Il=[Al.PAUSED,Al.PLAYING],xl=function(){function u(n){var a=this;this.videoState=new Ji(Al.STOPPED),this.subscription=new r,this.representations$=new t([]),this.currentRepresentation$=new t(void 0),this.textTracksManager=new ki,this.elementSize$=new t(void 0),this.dashLiteEvents={idxRequestPing$:new e,responseHeaders$:new e,manifestReady$:new e,representationPlay$:new e,error$:new e},this.handleManifestReady=function(t){var e,r,i,n,o=[];try{for(var s=L(t),u=s.next();!u.done;u=s.next()){var c=u.value,d=null!==(n=null!==(i=c.name)&&void 0!==i?i:c.id)&&void 0!==n?n:c.height.toString(10),l=Bi(c),p=c.bandwidth/1e3,h={width:c.width,height:c.height},f=c.fps;if(l){var v={id:d,quality:l,bitrate:p,size:h,fps:f};o.push({track:v,representation:c})}}}catch(t){e={error:t}}finally{try{u&&!u.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}a.representations$.next(o),a.params.output.availableVideoTracks$.next(o.map((function(t){return t.track}))),a.videoState.setState(Al.MANIFEST_LOADED)},this.handleRepresentationPlay=function(t){var e,r=null===(e=a.representations$.getValue().find((function(e){return e.representation===t})))||void 0===e?void 0:e.track;r&&(a.params.output.currentVideoTrack$.next(r),a.params.desiredState.videoTrack.getTransition()&&a.params.desiredState.videoTrack.setState(r.id))},this.selectRepresentation=function(){var t=a.currentRepresentation$.getValue();return p(t,'Can\'t select representation. something went wrong'),t},this.syncPlayback=function(){var t=a.videoState.getState(),e=a.videoState.getTransition(),r=a.params.desiredState.playbackState.getState(),n=a.params.desiredState.playbackState.getTransition(),s=a.params.desiredState.seekPosition.getTransition();if(a.log({message:'[syncPlayback] videoState: '.concat(t,'; videoTransition: ').concat(JSON.stringify(e),'; desiredPlaybackState: ').concat(r,'; seekPositionTransition: ').concat(JSON.stringify(s),';')}),r!==P.STOPPED){if(!e){var u=null==s?void 0:s.to;switch((null==n?void 0:n.to)!==P.PAUSED&&i(u)&&Il.includes(t)&&a.seek(u),t){case Al.STOPPED:return a.videoState.startTransitionTo(Al.MANIFEST_LOADED),void a.prepare();case Al.MANIFEST_LOADED:return void a.videoState.startTransitionTo(Al.INITIAL_REPRESENTATION_SELECTED);case Al.INITIAL_REPRESENTATION_SELECTED:return a.videoState.startTransitionTo(Al.METADATA_LOADED),void a.dash.startPlay(a.selectRepresentation());case Al.METADATA_LOADED:return a.videoState.startTransitionTo(Al.READY),void a.dash.seek(null!=u?u:0);case Al.READY:return void(r===P.PAUSED?(a.videoState.setState(Al.PAUSED),Li(a.params.desiredState.playbackState,P.PAUSED)):r===P.PLAYING&&(a.videoState.startTransitionTo(Al.PLAYING),a.playIfAllowed()));case Al.PLAYING:return void(r===P.PAUSED?(a.videoState.startTransitionTo(Al.PAUSED),a.video.pause()):(null==n?void 0:n.to)===P.PLAYING&&Li(a.params.desiredState.playbackState,P.PLAYING));case Al.PAUSED:return void(r===P.PLAYING?(a.videoState.startTransitionTo(Al.PLAYING),a.playIfAllowed()):(null==n?void 0:n.to)===P.PAUSED&&Li(a.params.desiredState.playbackState,P.PAUSED));default:return o(t)}}}else t!==Al.STOPPED&&(a.videoState.startTransitionTo(Al.STOPPED),a.dash.destroy(),a.video.setAttribute('src',''),a.video.load(),a.params.output.position$.next(0),a.params.output.duration$.next(1/0),a.params.output.currentBuffer$.next(void 0),a.params.output.hostname$.next(void 0),a.videoState.setState(Al.STOPPED),Li(a.params.desiredState.playbackState,P.STOPPED,!0))},this.params=n,this.log=this.params.dependencies.logger.createComponentLog('DashProvider'),s(this.videoState.stateChangeStarted$.pipe(c((function(t){return{transition:t,type:'start'}}))),this.videoState.stateChangeEnded$.pipe(c((function(t){return{transition:t,type:'end'}})))).subscribe((function(t){var e=t.transition,r=t.type;a.log({message:'[videoState change] '.concat(r,': ').concat(JSON.stringify(e))})})),this.video=$i(n.container),this.params.output.element$.next(this.video),this.params.output.isLive$.next(!1),'url'===this.params.source.type&&this.params.output.hostname$.next(Qi(this.params.source.url)),this.buffer=new Di(this.video),this.dash=new Dl({video:this.video,buffer:this.buffer,selectRepresentation:this.selectRepresentation,onIdxRequestPing:function(t){return a.dashLiteEvents.idxRequestPing$.next(t)},onResponseHeaders:function(t){return a.dashLiteEvents.responseHeaders$.next(t)},onManifestReady:function(t){return a.dashLiteEvents.manifestReady$.next(t)},onRepresentationPlay:function(t){return a.dashLiteEvents.representationPlay$.next(t)},onBandwidthChange:function(t){return a.params.dependencies.throughputEstimator.addRawSpeed(t.size,t.duration)},onError:function(t,e,r){a.log({message:'[DashLite error], '.concat(t)}),a.dashLiteEvents.error$.next({id:t,message:e,thrown:r})},config:{SEEK_IN_SEGMENT_THRESHOLD:this.params.tuning.dashSeekInSegmentDurationThreshold,SEEK_IN_SEGMENT_DELTA:this.params.tuning.dashSeekInSegmentAlwaysSeekDelta,FRONT_CACHE_DURATION:this.params.config.cacheDuration/1e3}}),this.subscribe()}return u.prototype.subscribe=function(){var t=this,e=this.params,r=e.output,o=e.desiredState,u=function(t){r.error$.next({id:'DashProvider',message:'DashProvider internal logic error',thrown:t})},p=function(){var e=t.params.desiredState.autoVideoTrackSwitching.getState(),r=t.params.desiredState.autoVideoTrackSwitching.getTransition();return r?r.to:e},h=xi(this.video),m=function(e,r){return t.subscription.add(e.subscribe(r,u))};m(h.timeUpdate$,r.position$),m(h.durationChange$,r.duration$),m(h.ended$,r.endedEvent$),m(h.error$,r.error$),m(h.isBuffering$,r.isBuffering$),m(h.firstFrame$,r.firstFrameEvent$),this.subscription.add(h.seeking$.subscribe((function(){n(t.params.desiredState.seekPosition.getTransition())&&(t.videoState.getState()===Al.PLAYING||t.videoState.getState()===Al.PAUSED)&&t.dash.updateRefsForCurrentTime()}))),this.subscription.add(h.seeked$.subscribe(r.seekedEvent$,u)),this.subscription.add(wi(this.video,o.isLooped,u)),this.subscription.add(Pi(this.video,o.volume,h.volumeState$,u)),this.subscription.add(h.volumeState$.subscribe(this.params.output.volume$)),this.textTracksManager.connect(this.video,o,r),m(Wi(this.video),this.elementSize$),this.subscription.add(h.canplay$.subscribe((function(){var e;(null===(e=t.videoState.getTransition())||void 0===e?void 0:e.to)===Al.READY&&t.videoState.setState(Al.READY)}),u)).add(h.pause$.subscribe((function(){t.videoState.setState(Al.PAUSED),Li(t.params.desiredState.playbackState,P.PAUSED)}))).add(h.playing$.subscribe((function(){t.videoState.setState(Al.PLAYING),Li(t.params.desiredState.playbackState,P.PLAYING)}),u)).add(h.loadedMetadata$.subscribe((function(){t.videoState.setState(Al.METADATA_LOADED)}),u)).add(h.currentBuffer$.subscribe((function(e){t.buffer.fill(),r.currentBuffer$.next(e)}),u)).add(this.dashLiteEvents.error$.pipe(c((function(t){var e=t.id,r=t.message,i=t.thrown;return{id:'DashLite_'.concat(e),message:r,thrown:i}}))).subscribe(this.params.output.error$)).add(s(this.params.desiredState.videoTrack.transitionStarted$,this.params.desiredState.autoVideoTrackSwitching.transitionStarted$,this.representations$,this.params.dependencies.throughputEstimator.rttAdjustedThroughput$,this.params.output.element$,this.elementSize$,a(this.video,'progress')).pipe(c((function(){var e,r,n,a=t.currentRepresentation$.getValue(),o=t.representations$.getValue(),s=t.params.desiredState.autoVideoTrackSwitching.getTransition(),u=t.params.desiredState.videoTrack.getState(),c=t.params.dependencies.throughputEstimator.rttAdjustedThroughput$.getValue(),d=t.elementSize$.getValue(),l=p();if(s&&t.params.desiredState.autoVideoTrackSwitching.setState(s.to),!l&&i(u))n=u;else{var h=zi(t.video.buffered,1e3*t.video.currentTime),f=Math.min(h/t.params.tuning.dash.forwardBufferTarget,1);n=null===(e=ji(o.map((function(t){return t.track})),{container:d,throughput:c,tuning:t.params.tuning.autoTrackSelection,forwardBufferHealth:f,currentRepresentation:a}))||void 0===e?void 0:e.id}return i(n)?null===(r=o.find((function(t){return t.track.id===n})))||void 0===r?void 0:r.representation:void 0})),l()).subscribe(this.currentRepresentation$,u)).add(S({needToSelectRepresentation:this.videoState.stateChangeStarted$.pipe(g((function(t){return t.to===Al.INITIAL_REPRESENTATION_SELECTED}))),currentRepresentationSelected:this.currentRepresentation$.pipe(g(i))}).pipe(f()).subscribe((function(){return t.videoState.setState(Al.INITIAL_REPRESENTATION_SELECTED)}),u)).add(this.currentRepresentation$.pipe(g(i),l((function(e,r){return t.params.tuning.autoTrackSelection.lazyQualitySwitch&&p()?e.height<=r.height:e===r}))).subscribe((function(e){var r=zi(t.video.buffered,1e3*t.video.currentTime),i=Math.min(r/t.params.tuning.dash.forwardBufferTarget,1);(!t.params.tuning.autoTrackSelection.lazyQualitySwitch||i<=.5||!p())&&(t.dash.setQualityByRepresentation(e,!0),t.params.output.hostname$.next(Qi(e.baseURL)))}),u)).add(this.dashLiteEvents.responseHeaders$.subscribe((function(e){var r=Jd(e),i=r.type,n=r.reused;t.params.output.httpConnectionType$.next(i),t.params.output.httpConnectionReused$.next(n)}))).add(this.dashLiteEvents.idxRequestPing$.pipe(f()).subscribe(this.params.output.firstBytesEvent$)).add(this.dashLiteEvents.idxRequestPing$.subscribe((function(e){return t.params.dependencies.throughputEstimator.addRawRtt(e)}))).add(this.dashLiteEvents.manifestReady$.subscribe(this.handleManifestReady,u)).add(this.dashLiteEvents.representationPlay$.pipe(g(i)).subscribe(this.handleRepresentationPlay,u)).add(s(o.playbackState.stateChangeStarted$,o.seekPosition.stateChangeStarted$,this.videoState.stateChangeEnded$,d(['init'])).pipe(v(0)).subscribe(this.syncPlayback,u))},u.prototype.destroy=function(){this.subscription.unsubscribe(),this.textTracksManager.destroy(),this.video.remove(),this.params.output.element$.next(void 0),this.buffer.destroy(),this.dash.destroy()},u.prototype.prepare=function(){var t=this.params.source;switch(t.type){case'url':this.dash.attachSource(t.url);break;case'raw':this.dash.attachManifest(t.raw);break;default:return o(t)}},u.prototype.seek=function(t){this.log({message:'[seek] position: '.concat(t)}),this.params.output.willSeekEvent$.next(),this.dash.seek(t)},u.prototype.playIfAllowed=function(){var t=this;Ti(this.video).then((function(e){e||(t.videoState.setState(Al.PAUSED),Li(t.params.desiredState.playbackState,P.PAUSED,!0))}))},u}(),Ll=function(t){return t.range?t.range.split('-').map((function(t){return parseInt(t,10)})):[NaN,NaN]},Ol=function(){function t(t){this.params=t,this.dashJsRequestQueue=new Map,this.activeRequests=new Map}return t.prototype.setMetrics=function(t){this.dashMetrics=t},t.prototype.queueDashJSRequest=function(t){var e,r=t.request.url,i=null!==(e=this.dashJsRequestQueue.get(r))&&void 0!==e?e:[];i.push(t),this.dashJsRequestQueue.set(r,i)},t.prototype.executeNextRequests=function(){return I(this,void 0,void 0,(function(){var t,e,r,i,n,a,o,s,u,c,d,l,p;return x(this,(function(h){try{for(t=L(this.dashJsRequestQueue.entries()),e=t.next();!e.done;e=t.next()){if(r=O(e.value,2),i=r[0],n=r[1],a=this.activeRequests.get(i)){if(n.length&&this.onBigRequestProgress(a),!(o=n[0])||!o.request.range)continue;if(s=O(Ll(o.request),2),u=s[0],c=s[1],u>=a.from&&c<=a.to)continue;this.activeRequests.delete(i)}n.length&&(d=this.sendBigRequest(i,n.map((function(t){return t.request}))),this.activeRequests.set(i,d))}}catch(t){l={error:t}}finally{try{e&&!e.done&&(p=t.return)&&p.call(t)}finally{if(l)throw l.error}}return[2]}))}))},t.prototype.abort=function(t){var e,r,i;if(t){var n=t.request,a=(null!==(i=this.dashJsRequestQueue.get(n.url))&&void 0!==i?i:[]).includes(t),o=this.activeRequests.get(n.url);a&&o&&o.abortController.abort()}else try{for(var s=L(this.activeRequests.values()),u=s.next();!u.done;u=s.next()){u.value.abortController.abort()}}catch(t){e={error:t}}finally{try{u&&!u.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}},t.prototype.destroy=function(){this.abort(),this.dashMetrics=void 0,this.dashJsRequestQueue.clear(),this.activeRequests.clear()},t.prototype.sendBigRequest=function(e,r){for(var i=this,n=r.map(Ll),a=n[0][0],o=n[0][1],s=1;s<n.length&&o<this.params.minDataSize;s++){var u=n[s][1];u-a<=2*this.params.minDataSize&&(o=Math.max(o,u))}o=0===a?Math.max(o,a+this.params.minInitSize):Math.max(o,a+this.params.minDataSize);var c=new URL(e,location.href);c.searchParams.append('bytes',''.concat(a,'-').concat(o));var d=c.toString(),l=new qs,p=l.signal,h={url:e,from:a,to:o,loaded:0,data:null,abortController:l};p.addEventListener('abort',(function(){return i.onBigRequestAbort(h)}));var f=function(t){var e,r;throw null===(r=(e=i.params).onError)||void 0===r||r.call(e,{id:'BigRequestParsing',message:'Error parsing response data',thrown:t}),t};return Gs(fetch).fetch(d,{signal:p}).then((function(e){var r,n,a;if(e.ok&&e.body){var o=O(e.body.tee(),2),s=o[0],u=o[1];null===(n=(r=i.params).onDownloadStream)||void 0===n||n.call(r,u);var c=s.getReader(),d=parseInt(null!==(a=e.headers.get('Content-Length'))&&void 0!==a?a:'',10);h.data=new ArrayBuffer(d);var l=new Uint8Array(h.data),p=function(e){var r=e.done,n=e.value;return I(i,void 0,void 0,(function(){return x(this,(function(e){switch(e.label){case 0:return r?(this.onBigRequestProgress(h),[3,3]):[3,1];case 1:return n?(l.set(n,h.loaded),h.loaded+=n.byteLength,this.onBigRequestProgress(h),[4,null==c?void 0:c.read().then(p,t.suppressStreamErrors).catch(f)]):[3,3];case 2:e.sent(),e.label=3;case 3:return[2]}}))}))};null==c||c.read().then(p,t.suppressStreamErrors).catch(f)}else i.onBigRequestError(h)}),t.suppressAbort).catch((function(t){return i.onBigRequestError(h,t)})),h},t.prototype.onBigRequestProgress=function(t){var e,r,i,n,a,o,s,u,c,d=t.url,l=t.from,p=t.to,h=t.loaded,f=t.data;if(this.activeRequests.has(d)&&f){var v=null!==(i=this.dashJsRequestQueue.get(d))&&void 0!==i?i:[],m=function(t){var e=t.request,r=O(Ll(e),2),i=r[0],v=r[1],m=i>=l&&v<=l+h,g=l>=i&&l+h<v,y=f.slice(i-l,Math.min(v-l+1,h));(m||g)&&(e.requestStartDate=null!==(n=e.requestStartDate)&&void 0!==n?n:new Date,e.firstByteDate=null!==(a=e.firstByteDate)&&void 0!==a?a:new Date,e.bytesLoaded=y.byteLength,e.bytesTotal=p-l),m?(e.requestEndDate=new Date,S.dashJsRequestQueue.set(d,(null!==(o=S.dashJsRequestQueue.get(d))&&void 0!==o?o:[]).filter((function(e){return e!==t}))),null===(s=t.success)||void 0===s||s.call(t,y,'',d),null===(u=S.dashMetrics)||void 0===u||u.addHttpRequest(e,d,200,{},[])):g&&(null===(c=t.progress)||void 0===c||c.call(t,{loaded:h,total:p-l,lengthComputable:!0,stream:!0}))},S=this;try{for(var g=L(v),y=g.next();!y.done;y=g.next()){m(y.value)}}catch(t){e={error:t}}finally{try{y&&!y.done&&(r=g.return)&&r.call(g)}finally{if(e)throw e.error}}}},t.prototype.onBigRequestError=function(t,e){var r,i,n,a,o,s,u=t.url,c=t.from,d=t.to;if(null===(a=(n=this.params).onError)||void 0===a||a.call(n,{id:'BigRequest',message:'Download error',thrown:e}),this.activeRequests.has(u)){var l=null!==(o=this.dashJsRequestQueue.get(u))&&void 0!==o?o:[];try{for(var p=L(l),h=p.next();!h.done;h=p.next()){var f=h.value,v=O(Ll(f.request),2),m=v[0],S=v[1];(m>=c&&m<d||S>c&&S<=d)&&(null===(s=null==f?void 0:f.error)||void 0===s||s.call(f,f.request,String(e)))}}catch(t){r={error:t}}finally{try{h&&!h.done&&(i=p.return)&&i.call(p)}finally{if(r)throw r.error}}if(this.activeRequests.delete(u),e)throw e}},t.prototype.onBigRequestAbort=function(t){var e,r,i,n,a=t.url,o=t.from,s=t.to;if(this.activeRequests.has(a)){var u=null!==(i=this.dashJsRequestQueue.get(a))&&void 0!==i?i:[];try{for(var c=L(u),d=c.next();!d.done;d=c.next()){var l=d.value,p=O(Ll(l.request),2),h=p[0],f=p[1];(h>=o&&h<s||f>o&&f<=s)&&(null===(n=null==l?void 0:l.abort)||void 0===n||n.call(l,l.request))}}catch(t){e={error:t}}finally{try{d&&!d.done&&(r=c.return)&&r.call(c)}finally{if(e)throw e.error}}this.activeRequests.delete(a)}},t.suppressAbort=function(t){if(!(t instanceof DOMException)||'AbortError'!==t.name&&20!==t.code)throw t},t.suppressStreamErrors=function(){},t}(),Cl=function(){function t(t,e,r){this.baseLoader=t,this.config=r,this.bigRequest=e,e.setMetrics(r.dashMetrics)}return t.shouldDelegateToBase=function(t){return'download'!==t.action||'text'===t.mediaType||!t.range||'arraybuffer'!==t.responseType},t.prototype.load=function(e){var r=e.request;if(t.shouldDelegateToBase(r))return this.baseLoader.load(e);this.bigRequest.queueDashJSRequest(e),this.bigRequest.executeNextRequests()},t.prototype.abort=function(e){if(!e)return this.baseLoader.abort(),void this.bigRequest.abort();var r=e.request;t.shouldDelegateToBase(r)?this.baseLoader.abort(e):this.bigRequest.abort(e)},t}(),Nl=function(t,e){var r=new Ol(e);return t.extend('SchemeLoaderFactory',(function(){var t=this.parent.getLoader;return{getLoader:function(e){return function(t,e){return function(r){return{create:function(i){var n=t(r).create(i);return new Cl(n,e,i)}}}}(t(e),r)}}}),!0),function(){return r.destroy()}},Ml=function(r){var n=new t(1/0),a=new e,o=NaN,s=!1,u=function(t){var e,r,a;if(t.getAllResponseHeaders().includes('x-playback-duration')){var o=parseInt(null!==(e=t.getResponseHeader('X-Playback-Duration'))&&void 0!==e?e:'',10),s=parseInt(null!==(r=t.getResponseHeader('X-Playback-Duration-Millis'))&&void 0!==r?r:'',10),u=null!==(a=null!=s?s:1e3*o)&&void 0!==a?a:NaN;i(u)&&!isNaN(u)&&n.next(u)}},c=function(t){t.readyState>=2&&!s&&(s=!0,a.next(Date.now()-o))};return r.extend('XHRLoader',(function(){var t=this.parent,e=t.load.bind(t);return{load:function(t){if('MPD'===t.request.type){var r=t.onload,i=t.progress;t.onload=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return u(this),r.apply(void 0,C([],O(t),!1))},t.progress=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return c(this),i.apply(void 0,C([],O(t),!1))},o=Date.now(),s=!1}return e(t)}}}),!0),{playbackDuration$:n,ping$:a}},Bl=function(){function t(){this.pausedTime=0,this.streamOffset=0,this.pauseTimestamp=0}return t.prototype.getTotalPausedTime=function(){return this.pausedTime+this.getCurrentPausedTime()},t.prototype.getCurrentPausedTime=function(){return this.pauseTimestamp>0?Date.now()-this.pauseTimestamp:0},t.prototype.getStreamOffset=function(){return this.streamOffset},t.prototype.getTotalOffset=function(){return this.getTotalPausedTime()+this.streamOffset},t.prototype.pause=function(){0===this.pauseTimestamp&&(this.pauseTimestamp=Date.now())},t.prototype.resume=function(){this.pauseTimestamp>0&&(this.pausedTime+=this.getCurrentPausedTime(),this.pauseTimestamp=0)},t.prototype.resetTo=function(t){this.streamOffset=t,this.pauseTimestamp=0,this.pausedTime=0},t}(),Ul={};!function(t){t.DOWNLOADING_LIB='downloading_lib',t.STOPPED='stopped',t.STREAM_INITIALIZED='stream_initialized',t.READY='ready',t.PLAYING='playing',t.PAUSED='paused'}(Rl||(Rl={}));var Vl=function(t,e){return new h((function(r){var i=function(t){return r.next(t)};return t.on(e,i),function(){return t.off(e,i)}}))},Fl=function(){function e(e){var n=this;this.subscription=new r,this.videoState=new Ji(Rl.DOWNLOADING_LIB),this.textTracksManager=new ki,this.videoTracks=[],this.frameRatesByFrameHeight={},this.isLive$=new t(void 0),this.maxSeekBackTime$=new t(1/0),this.availableFrom$=new t(void 0),this.elementSize$=new t(void 0),this.liveOffset=new Bl,this.syncPlayback=function(){var t=n.videoState.getState(),e=n.params.desiredState.playbackState.getState(),r=n.params.desiredState.playbackState.getTransition(),a=n.params.desiredState.seekPosition.getTransition(),s=n.isLive$.getValue();if(!n.videoState.getTransition()&&t!==Rl.DOWNLOADING_LIB&&t!==Rl.STREAM_INITIALIZED){var u=null==a?void 0:a.to;switch((null==r?void 0:r.to)!==P.PAUSED&&i(u)&&t!==Rl.STOPPED&&e!==P.STOPPED&&(s?n.seek(u+Hl(n.liveOffset.getTotalPausedTime())):n.seek(u)),e){case P.STOPPED:switch(t){case Rl.STOPPED:break;case Rl.PLAYING:case Rl.PAUSED:case Rl.READY:n.stop();break;default:o(t)}break;case P.PLAYING:switch(t){case Rl.PLAYING:break;case Rl.PAUSED:s&&(n.liveOffset.getTotalPausedTime()<n.params.config.maxPausedTime&&n.liveOffset.getTotalOffset()<n.maxSeekBackTime$.getValue()?(n.liveOffset.resume(),n.params.output.position$.next(Hl(n.liveOffset.getTotalOffset()))):n.seek(Hl(n.liveOffset.getTotalOffset()))),n.play();break;case Rl.READY:n.play();break;case Rl.STOPPED:n.prepare();break;default:o(t)}break;case P.PAUSED:switch(t){case Rl.PLAYING:n.pause(),n.liveOffset.pause();break;case Rl.PAUSED:break;case Rl.READY:n.videoState.setState(Rl.PAUSED),Li(n.params.desiredState.playbackState,P.PAUSED);break;case Rl.STOPPED:n.prepare();break;default:o(t)}break;default:o(e)}}},this.video=$i(e.container),this.params=e,this.params.output.element$.next(this.video),this.params.output.availableVideoTracks$.next([]),this.params.output.hostname$.next(Qi(this.params.source.url)),this.loadDashJs()}return e.prototype.loadDashJs=function(){var t=this,e=!1,r=function(r){var i;e||t.params.output.error$.next({id:'timeout'===r?'DashJSTimedOut':'DashJSLoadingError',message:'Dash.js failed to load: '.concat(null===(i=null==r?void 0:r.toString)||void 0===i?void 0:i.call(r)),thrown:r}),e=!0},i=window.setTimeout((function(){return r('timeout')}),5e3);Wd(import('dashjs/dist/dash.mediaplayer.min.js').then((function(r){e||(Ul.MediaPlayer=r.MediaPlayer,Ul.Debug=r.Debug,t.init())}),r),(function(){window.clearTimeout(i),e=!0}))},e.prototype.init=function(){var t=this;p(Ul.MediaPlayer,'dashjs not loaded'),p(Ul.Debug,'dashjs not loaded'),this.player=Ul.MediaPlayer().create(),this.player.updateSettings({debug:{logLevel:3},streaming:{buffer:{fastSwitchEnabled:!0},abr:{limitBitrateByPortal:this.params.tuning.autoTrackSelection.limitByContainer,usePixelRatioInLimitBitrateByPortal:this.params.tuning.autoTrackSelection.usePixelRatio,additionalAbrRules:{insufficientBufferRule:!1}},utcSynchronization:{useManifestDateHeaderTimeSource:!0}}}),this.player.registerCustomCapabilitiesFilter((function(e){return e.height&&(t.frameRatesByFrameHeight[e.height]=e.frameRate?hl(e.frameRate+''):void 0),!0})),(this.params.format===A.DASH_WEBM||this.params.format===A.DASH_LIVE_WEBM)&&this.params.tuning.useWebmBigRequest?this.destroyBigRequest=Nl(this.player,{minInitSize:this.params.tuning.bigRequestMinInitSize,minDataSize:this.params.tuning.bigRequestMinDataSize,onError:function(e){return t.params.output.error$.next(e)},onDownloadStream:function(e){return t.params.dependencies.throughputEstimator.trackStream(e)}}):this.params.tuning.stripRangeHeader&&this.player.extend('HTTPLoader',(function(){var t=this.parent.load;return{load:function(e){if(e.request&&e.request.range){var r=O(e.request.range.split('-').map((function(t){return parseInt(t,10)})),2),i=r[0],n=r[1],a=new URL(e.request.url,location.href);a.searchParams.append('bytes',''.concat(i,'-').concat(n)),e.request.url=a.toString(),e.request.range=void 0}t(e)}}}),!0),function(t){var e,r=!1,i=!1;t.on('playbackTimeUpdated',(function(t){var n=t.timeToEnd;i=n<=3,r&&i&&(null==e||e())})),t.extend('MediaSourceController',(function(){var t=this.parent.signalEndOfStream;return{signalEndOfStream:function(n){e=function(){return t(n)},(r=!0)&&i&&(null==e||e())}}}),!0)}(this.player),this.player.clearDefaultUTCTimingSources(),this.subscribe(),this.videoState.setState(Rl.STOPPED)},e.prototype.subscribe=function(){var t=this,e=this.params,r=e.output,a=e.desiredState,o=function(t){r.error$.next({id:'DashIFProvider',message:'DashIFProvider internal logic error',thrown:t})},u=function(e,r){return t.subscription.add(e.subscribe(r,o))};u(Wi(this.video),this.elementSize$),u(Vl(this.player,'error').pipe(c((function(t){var e='object'==typeof t.error?t.error.code:t.error,r='object'==typeof t.error?t.error.message:void 0;return{id:'DashJS#'.concat(e),message:r}}))),r.error$),u(Vl(this.player,'playbackError').pipe(c((function(t){return{id:'DashJSPlayback',message:t.error}}))),r.error$);var l=Vl(this.player,'qualityChangeRendered').pipe(g((function(t){return'video'===t.mediaType})),c((function(e){var r,i=e.newQuality;return null===(r=t.videoTracks.find((function(t){return t.bitrateInfo.qualityIndex===i})))||void 0===r?void 0:r.track})));l.pipe(g(i)).subscribe(r.currentVideoTrack$),this.subscription.add(this.videoState.transitionEnded$.pipe(g((function(t){return t.to===Rl.STREAM_INITIALIZED})),f()).subscribe((function(){t.subscription.add(Ei(a.videoTrack,(function(){var e,r,i=t.player.getQualityFor('video');return null===(r=null===(e=t.videoTracks.find((function(t){return t.bitrateInfo.qualityIndex===i})))||void 0===e?void 0:e.track)||void 0===r?void 0:r.id}),(function(e){var r;if(!n(e)){var i=null===(r=t.videoTracks.find((function(t){return t.track.id===e})))||void 0===r?void 0:r.bitrateInfo;i&&t.player.setQualityFor('video',i.qualityIndex)}}),{changed$:l.pipe(c((function(t){return null==t?void 0:t.id}))),onError:o}))}),o)),this.subscription.add(Ei(a.autoVideoTrackSwitching,(function(){var e,r,i;return null===(i=null===(r=null===(e=t.player.getSettings().streaming)||void 0===e?void 0:e.abr)||void 0===r?void 0:r.autoSwitchBitrate)||void 0===i?void 0:i.video}),(function(e){return t.player.updateSettings({streaming:{abr:{autoSwitchBitrate:{video:e}}}})}),{onError:o})),u(Vl(this.player,'bufferStateChanged').pipe(g((function(t){return'video'===t.mediaType})),c((function(t){return'bufferStalled'===t.state}))),r.isBuffering$),u(Vl(this.player,'fragmentLoadingStarted').pipe(c((function(t){return Qi(t.request.url)}))),r.hostname$),u(Vl(this.player,'streamInitialized'),(function(e){var i,n,a=e.streamInfo,o=a.duration,s=a.manifestInfo,u=s.isDynamic,c=s.availableFrom;t.isLive$.next(u),t.availableFrom$.next(c.getTime()),u||r.duration$.next(o),t.videoTracks=[];var d,l=t.player.getQualityFor('video');try{for(var p=L(t.player.getBitrateInfoListFor('video')),h=p.next();!h.done;h=p.next()){var f=h.value,v=f.qualityIndex.toString(10),m=Bi(f),S=f.bitrate/1e3,g={width:f.width,height:f.height},y=t.frameRatesByFrameHeight[f.height];if(m){var b={id:v,quality:m,bitrate:S,size:g,fps:y};t.videoTracks.push({track:b,bitrateInfo:f}),f.qualityIndex===l&&(d=b)}}}catch(t){i={error:t}}finally{try{h&&!h.done&&(n=p.return)&&n.call(p)}finally{if(i)throw i.error}}r.availableVideoTracks$.next(t.videoTracks.map((function(t){return t.track}))),d&&r.currentVideoTrack$.next(d),t.videoState.setState(Rl.STREAM_INITIALIZED),t.videoState.startTransitionTo(Rl.READY)})),u(Vl(this.player,'fragmentLoadingCompleted'),(function(e){var r=e.request;if(r.requestEndDate&&r.firstByteDate&&r.bytesLoaded){var i=r.requestEndDate.getTime()-r.firstByteDate.getTime(),n=r.bytesLoaded;t.params.dependencies.throughputEstimator.addRawSpeed(n,i)}})),u(s(this.params.dependencies.throughputEstimator.throughput$,this.elementSize$),(function(){if(t.params.desiredState.autoVideoTrackSwitching.getState()&&t.videoTracks.length){var e=t.params.dependencies.throughputEstimator.throughput$.getValue(),r=ji(t.videoTracks.map((function(t){return t.track})),{container:t.elementSize$.getValue(),throughput:e,tuning:t.params.tuning.autoTrackSelection}),i=t.videoTracks.find((function(t){return t.track===r}));(null==i?void 0:i.bitrateInfo)&&t.player.setQualityFor('video',null==i?void 0:i.bitrateInfo.qualityIndex,!1)}})),u(S({maxSeekBackTime:this.maxSeekBackTime$,isLive:this.isLive$.pipe(g(i))}).pipe(g((function(t){return t.isLive})),c((function(t){var e=t.maxSeekBackTime;return Hl(e)}))),this.params.output.duration$);var p=Vl(this.player,'playbackTimeUpdated').pipe(c((function(t){var e=t.time;return null!=e?e:0})));u(S({availableFrom:this.availableFrom$.pipe(g(i)),currentTime:p}),(function(e){var r=e.availableFrom,i=e.currentTime;return t.params.output.liveTime$.next(r+1e3*i)})),u(p.pipe(g((function(){return!1===t.isLive$.getValue()}))),r.position$),u(Vl(this.player,'playbackSeeked'),(function(){return r.seekedEvent$.next()})),u(Vl(this.player,'playbackEnded'),r.endedEvent$),u(Vl(this.player,'playbackProgress').pipe(c((function(){return Ri(t.video.buffered,t.video.currentTime)}))),r.currentBuffer$),u(Vl(this.player,'playbackPlaying'),(function(){t.videoState.setState(Rl.PLAYING),Li(a.playbackState,P.PLAYING)})),u(Vl(this.player,'playbackNotAllowed'),(function(){t.player.isMuted()?(t.player.setMute(!1),t.videoState.setState(Rl.PAUSED),Li(t.params.desiredState.playbackState,P.PAUSED,!0)):(t.player.setMute(!0),t.player.play())})),u(Vl(this.player,'playbackPaused'),(function(){t.videoState.setState(Rl.PAUSED),Li(a.playbackState,P.PAUSED)})),u(Vl(this.player,'canPlay'),(function(){var e;(null===(e=t.videoState.getTransition())||void 0===e?void 0:e.to)===Rl.READY&&t.videoState.setState(Rl.READY)})),u(this.isLive$,r.isLive$),u(Wi(this.video),(function(){t.player.isReady()&&t.player.updatePortalSize()})),u(s(a.playbackState.stateChangeStarted$,a.seekPosition.stateChangeStarted$,this.videoState.stateChangeEnded$,d(['init'])).pipe(v(0)),this.syncPlayback);var h=Ml(this.player),m=h.playbackDuration$,y=h.ping$;u(m,this.maxSeekBackTime$),u(y.pipe(f()),r.firstBytesEvent$),this.params.tuning.flushShortLoopedBuffers&&u(S({isLive:this.isLive$,isShort:r.duration$.pipe(c((function(t){return t<60})))}),(function(e){var r=e.isLive,i=e.isShort,n=!r&&i;t.player.updateSettings({streaming:{buffer:{flushBufferAtTrackSwitch:n}}})})),u(p.pipe(g((function(e){return e>t.params.tuning.insufficientBufferRuleMargin})),f()),(function(){return t.player.updateSettings({streaming:{abr:{additionalAbrRules:{insufficientBufferRule:!0}}}})})),this.textTracksManager.connect(this.video,a,r),this.subscription.add(Vl(this.player,'manifestLoaded').pipe(f()).subscribe((function(){var e=Date.now();t.subscription.add(Vl(t.player,'playbackPlaying').pipe(f()).subscribe((function(){return r.firstFrameEvent$.next(Date.now()-e)}),o))}),o)),this.subscription.add(wi(this.video,a.isLooped,o));var b=xi(this.video).volumeState$;this.subscription.add(Pi(this.video,a.volume,b,o)),this.subscription.add(b.subscribe(r.volume$,o))},e.prototype.stop=function(){this.params.output.position$.next(0),this.params.output.duration$.next(1/0),this.params.output.currentBuffer$.next(void 0),this.params.output.hostname$.next(void 0),this.player.attachSource(null),this.player.attachView(null),this.player.initialize(),this.player.clearDefaultUTCTimingSources(),this.videoState.setState(Rl.STOPPED),Li(this.params.desiredState.playbackState,P.STOPPED,!0)},e.prototype.prepare=function(){this.videoState.startTransitionTo(Rl.STREAM_INITIALIZED),this.player.initialize(),this.player.clearDefaultUTCTimingSources(),this.player.attachView(this.video),this.player.attachSource(this.params.source.url)},e.prototype.seek=function(t){if(this.params.output.willSeekEvent$.next(),this.isLive$.getValue()){var e=-Math.round(1e3*t),r=e<this.maxSeekBackTime$.getValue()?e:0;this.liveOffset.resetTo(r),this.params.output.position$.next(Hl(r));var i=El(this.params.source.url,this.liveOffset.getTotalOffset()/1e3,Sl.PLAYBACK_SHIFT);this.player.attachSource(i)}else this.player.seek(t)},e.prototype.play=function(){this.videoState.startTransitionTo(Rl.PLAYING),this.player.play()},e.prototype.pause=function(){this.videoState.startTransitionTo(Rl.PAUSED),this.video.pause()},e.prototype.destroy=function(){var t,e;this.subscription.unsubscribe(),this.textTracksManager.destroy();try{null===(t=this.player)||void 0===t||t.destroy()}catch(t){}this.video.remove(),this.params.output.element$.next(void 0),null===(e=this.destroyBigRequest)||void 0===e||e.call(this)},e}(),Hl=function(t){return-t/1e3};function ql(){return m()}function Gl(t){return ql()-t}function Yl(t){var e=t.split('/'),r=e.slice(0,e.length-1).join('/'),i=/^([a-z]+:)?\/\//i;return{resolve:function(t,e,n){void 0===n&&(n=!1),function(t){return i.test(t)}(t)||(t.startsWith('/')||(t='/'+t),t=r+t);var a=t.indexOf('?')>-1?'&':'?';return n&&(t+=a+'lowLat=1',a='&'),e&&(t+=a+'_rnd='+Math.floor(999999999*Math.random())),t}}}function jl(t,e,r,n){var a,o,s,u,c,d=window.XMLHttpRequest,l=!1,h=0,f=!1,v='arraybuffer',m=7e3,S=2e3,g=function(){if(!l){p(u);var t=Gl(u);t<S?setTimeout(g,S-t):((S*=2)>m&&(S=m),o&&o.abort(),o=new d,b())}},y=function(){if(!l){if(--h>=0)return g(),void(n&&n());l=!0,c&&c(),r&&r()}},b=function(){u=ql(),(o=new d).open('get',t);var r,i=0,n=0,h=function(){return p(u),Math.max(u,Math.max(r||0,n||0))};if(a&&o.addEventListener('progress',(function(t){var e=ql();a.updateChunk&&t.loaded>i&&(a.updateChunk(h(),t.loaded-i),i=t.loaded,r=e)})),s&&(o.timeout=s,o.addEventListener('timeout',(function(){return y()}))),o.addEventListener('load',(function(){if(!l){p(o);var t=o.status;if(t>=200&&t<300){if(o.response.byteLength&&a){var r=o.response.byteLength-i;r&&a.updateChunk&&a.updateChunk(h(),r)}c&&c(),o&&e(o.response)}else y()}})),o.addEventListener('error',(function(){y()})),f){var m=function(){p(o),o.readyState===XMLHttpRequest.HEADERS_RECEIVED&&(n=ql(),o.removeEventListener('readystatechange',m))};o.addEventListener('readystatechange',m)}return o.responseType=v,o.send(),T},T={withBitrateReporting:function(t){return a=t,T},withParallel:function(t){return f=t,T},withJSONResponse:function(){return v='json',T},withRetryCount:function(t){return h=t,T},withRetryInterval:function(t,e){return i(t)&&(S=t),i(e)&&(m=e),T},withTimeout:function(t){return s=t,T},withFinally:function(t){return c=t,T},send:b,abort:function(){o&&(o.abort(),o=void 0),l=!0,c&&c()}};return T}var zl,Ql=function(){function t(t){this.intervals=[],this.currentRate=0,this.logger=t}return t.prototype._updateRate=function(t){var e=.2;this.currentRate&&(t<.1*this.currentRate?e=.8:t<.5*this.currentRate?e=.5:t<.7*this.currentRate&&(e=.3)),t=Math.max(1,Math.min(t,104857600)),this.currentRate=this.currentRate?this.currentRate*(1-e)+t*e:t},t.prototype._createInterval=function(t,e,r){return{start:t,end:e,bytes:r}},t.prototype._doMergeIntervals=function(t,e){t.start=Math.min(e.start,t.start),t.end=Math.max(e.end,t.end),t.bytes+=e.bytes},t.prototype._mergeIntervals=function(t,e){return t.start<=e.end&&e.start<=t.end&&(this._doMergeIntervals(t,e),!0)},t.prototype._flushIntervals=function(){if(!this.intervals.length)return!1;var t=this.intervals[0].start,e=this.intervals[this.intervals.length-1].end-500;if(e-t>2e3){for(var r=0,i=0;this.intervals.length>0;){var n=this.intervals[0];if(n.end<=e)r+=n.end-n.start,i+=n.bytes,this.intervals.splice(0,1);else{if(n.start>=e)break;var a=e-n.start,o=n.end-n.start;r+=a;var s=n.bytes*a/o;i+=s,n.start=e,n.bytes-=s}}if(i>0&&r>0){var u=8*i/(r/1e3);return this._updateRate(u),this.logger('rate updated, new='.concat(Math.round(u/1024),'K; average=').concat(Math.round(this.currentRate/1024),'K bytes/ms=').concat(Math.round(i),'/').concat(Math.round(r),' interval=').concat(Math.round(e-t))),!0}}return!1},t.prototype._joinIntervals=function(){var t;do{t=!1;for(var e=0;e<this.intervals.length-1;++e)this._mergeIntervals(this.intervals[e],this.intervals[e+1])&&(this.intervals.splice(e+1,1),t=!0)}while(t)},t.prototype.addInterval=function(t,e,r){return this.intervals.push(this._createInterval(t,e,r)),this._joinIntervals(),this.intervals.length>100&&(this.logger('too many intervals ('.concat(this.intervals.length,'); will merge'),{type:'warn'}),this._doMergeIntervals(this.intervals[1],this.intervals[0]),this.intervals.splice(0,1)),this._flushIntervals()},t.prototype.getBitRate=function(){return this.currentRate},t}(),Wl=function(){function t(t,e,r,i,n){this.pendingQueue=[],this.activeRequests={},this.completeRequests={},this.averageSegmentDuration=2e3,this.lastPrefetchStart=0,this.throttleTimeout=null,this.RETRY_COUNT=t,this.TIMEOUT=e,this.BITRATE_ESTIMATOR=r,this.MAX_PARALLEL_REQUESTS=i,this.logger=n}return t.prototype.limitCompleteCount=function(){for(var t;(t=Object.keys(this.completeRequests)).length>this._getParallelRequestCount()+2;){var e=t[Math.floor(Math.random()*t.length)];this.logger('Dropping completed request for url '.concat(e),{type:'warn'}),delete this.completeRequests[e]}},t.prototype._sendRequest=function(t,e){var r=this,i=ql();t._request=jl(e,(function(n){t._complete=1,t._responseData=n,t._downloadTime=ql()-i,delete r.activeRequests[e],r._sendPending(),t._cb?t._cb(n,t._downloadTime):(r.limitCompleteCount(),r.completeRequests[e]=t)}),(function(){return i='error',delete r.activeRequests[e],r.limitCompleteCount(),r.completeRequests[e]=t,r._sendPending(),t._error=1,t._errorMsg=i,void(t._errorCB?t._errorCB(i):(r.limitCompleteCount(),r.completeRequests[e]=t));var i}),(function(){t._retry=1,t._retryCB&&t._retryCB()})),t._request.withRetryCount(this.RETRY_COUNT).withTimeout(this.TIMEOUT).withBitrateReporting(this.BITRATE_ESTIMATOR).withParallel(this._getParallelRequestCount()>1).withFinally((function(){t._finallyCB&&t._finallyCB()})),this.activeRequests[e]=t,t._request.send(),this.lastPrefetchStart=ql()},t.prototype._getParallelRequestCount=function(){return Math.min(this.MAX_PARALLEL_REQUESTS,this.averageSegmentDuration<3e3?3:2)},t.prototype._getPrefetchDelay=function(){return Math.max(100,Math.min(5e3,this.averageSegmentDuration/3))},t.prototype._canSendPending=function(){var t=this,e=this._getParallelRequestCount(),r=ql();if(Object.keys(this.activeRequests).length>=e)return!1;var i=this._getPrefetchDelay()-(r-this.lastPrefetchStart);return this.throttleTimeout&&clearTimeout(this.throttleTimeout),!(i>0)||(this.throttleTimeout=window.setTimeout((function(){return t._sendPending()}),i),!1)},t.prototype._sendPending=function(){for(;this._canSendPending();){var t=this.pendingQueue.pop();if(!t)return;this.activeRequests[t]||this.completeRequests[t]||(this.logger('Submitting pending request url='.concat(t)),this._sendRequest({},t))}},t.prototype._removeFromActive=function(t){delete this.completeRequests[t],delete this.activeRequests[t]},t.prototype.abortAll=function(){Object.values(this.activeRequests).forEach((function(t){t&&t._request&&t._request.abort()})),this.activeRequests={},this.pendingQueue=[],this.completeRequests={}},t.prototype.requestData=function(t,e,r,i){var n=this,a={send:function(){var o=n.activeRequests[t]||n.completeRequests[t];if(o)o._cb=e,o._errorCB=r,o._retryCB=i,o._finallyCB=a._finallyCB,o._error||o._complete?(n._removeFromActive(t),setTimeout((function(){o._complete?(n.logger('Requested url already prefetched, url='.concat(t)),e(o._responseData,o._downloadTime)):(n.logger('Requested url already prefetched with error, url='.concat(t)),r(o._errorMsg)),a._finallyCB&&a._finallyCB()}),0)):n.logger('Attached to active request, url='.concat(t));else{var s=n.pendingQueue.indexOf(t);-1!==s&&n.pendingQueue.splice(s,1),n.logger('Request not prefetched, starting new request, url='.concat(t).concat(-1===s?'':'; removed pending')),n._sendRequest(a,t)}}};return a._cb=e,a._errorCB=r,a._retryCB=i,a.abort=function(){a.request&&a.request.abort()},a.withFinally=function(t){return a._finallyCB=t,a},a},t.prototype.prefetch=function(t){this.activeRequests[t]||this.completeRequests[t]?this.logger('Request already active for url='.concat(t)):(this.logger('Added to pending queue; url='.concat(t)),this.pendingQueue.unshift(t),this._sendPending())},t.prototype.optimizeForSegDuration=function(t){this.averageSegmentDuration=t},t}(),Jl=function(){function t(t){this.paused=!1,this.autoQuality=!0,this.buffering=!0,this.destroyed=!1,this.videoPlayStarted=!1,this.lowLatency=!1,this.bitrate=0,this.manifest=[],this.sourceBuffer=0,this.bufferStates=[],this.sourceJitter=-1,this.params=t,this.chunkRateEstimator=new Ql(this.params.logger),this._initVideo()}return t.prototype.attachSource=function(t){this.manifestUrl=t,this.urlResolver=Yl(t),this.bitrateSwitcher=this._initBitrateSwitcher(),this._initManifest()},t.prototype.setAutoQualityEnabled=function(t){this.autoQuality=t},t.prototype.switchByName=function(t){for(var e,r=0;r<this.manifest.length;++r)if((e=this.manifest[r]).name===t)return void this._switchToQuality(e)},t.prototype.catchUp=function(){this.rep&&this.rep.stop(),this.currentManifestEntry&&(this.paused=!1,this._initPlayerWith(this.currentManifestEntry),this._notifyBuffering(!0))},t.prototype.stop=function(){this.params.videoElement.pause(),this.rep&&(this.rep.stop(),this.rep=null)},t.prototype.pause=function(){this.paused=!0,this.params.videoElement.pause(),this.videoPlayStarted=!1,this._notifyBuffering(!1)},t.prototype.play=function(t){this.paused=!1;var e=this.lowLatency&&this._getBufferSizeSec()>this.sourceJitter+5;this.rep&&!e?(this.bufferStates=[],this.videoPlayStarted=!1,this.shouldPlay()?this._playVideoElement(t):this._notifyBuffering(!0)):this.catchUp()},t.prototype.startPlay=function(t,e){this.autoQuality=e,this._initPlayerWith(t)},t.prototype.destroy=function(){this.destroyed=!0,this.rep&&(this.rep.stop(),this.rep=null),this.manifestRequest&&this.manifestRequest.abort(),this.manifestRefetchTimer&&(clearTimeout(this.manifestRefetchTimer),this.manifestRefetchTimer=void 0)},t.prototype.reinit=function(t){this.manifestUrl=t,this.urlResolver=Yl(t),this.catchUp()},t.prototype._handleNetworkError=function(){this.params.logger('Fatal network error'),this.params.playerCallback({name:'error',type:'network'})},t.prototype._retryCallback=function(){this.params.playerCallback({name:'retry'})},t.prototype._getBufferSizeSec=function(){var t=this.params.videoElement,e=0,r=t.buffered.length;return 0!==r&&(e=t.buffered.end(r-1)-Math.max(t.currentTime,t.buffered.start(0))),e},t.prototype._notifyBuffering=function(t){this.destroyed||(this.params.logger('buffering: '.concat(t)),this.params.playerCallback({name:'buffering',isBuffering:t}),this.buffering=t)},t.prototype._initVideo=function(){var t=this,e=this.params,r=e.videoElement,i=e.logger;r.addEventListener('error',(function(e){var n;t.destroyed||(i('Video element error: '.concat(null===(n=r.error)||void 0===n?void 0:n.code)),t.params.playerCallback({name:'error',type:'media'}))})),r.addEventListener('timeupdate',(function(){var e=t._getBufferSizeSec();!t.paused&&e<.3?t.buffering||(t.buffering=!0,window.setTimeout((function(){!t.paused&&t.buffering&&t._notifyBuffering(!0),r.pause(),t.videoPlayStarted=!1}),1e3*(e+.1))):t.buffering&&t.videoPlayStarted&&t._notifyBuffering(!1)})),r.addEventListener('playing',(function(){i('playing')})),r.addEventListener('stalled',(function(){return t._fixupStall()})),r.addEventListener('waiting',(function(){return t._fixupStall()}))},t.prototype._fixupStall=function(){var t,e=this.params,r=e.logger,i=e.videoElement,n=i.buffered.length;0!==n&&(t=i.buffered.start(n-1),i.currentTime<t&&(r('Fixup stall'),i.currentTime=t))},t.prototype._selectQuality=function(t){for(var e,r,i,n=this.params.videoElement,a=n&&1.62*(window.devicePixelRatio||1)*n.offsetHeight||520,o=0;o<this.manifest.length;++o)(i=this.manifest[o]).bitrate<t&&a>Math.min(i.video.height,i.video.width)?(!r||i.bitrate>r.bitrate)&&(r=i):(!e||e.bitrate>i.bitrate)&&(e=i);return r||e},t.prototype.shouldPlay=function(){if(this.paused)return!1;var t=this._getBufferSizeSec()-Math.max(1,this.sourceJitter);return t>3||i(this.downloadRate)&&(this.downloadRate>1.5&&t>2||this.downloadRate>2&&t>1)},t.prototype._setVideoSrc=function(t,e){var r=this,i=this.params,n=i.logger,a=i.videoElement,o=i.playerCallback;this.mediaSource=new window.MediaSource,n('setting video src'),a.src=URL.createObjectURL(this.mediaSource),this.mediaSource.addEventListener('sourceopen',(function(){p(r.mediaSource),r.sourceBuffer=r.mediaSource.addSourceBuffer(t.codecs),r.bufferStates=[],e()})),this.videoPlayStarted=!1,a.addEventListener('canplay',(function(){r.shouldPlay()&&(r.videoPlayStarted=!0,r._playVideoElement())}));var s=function(){!function(t,e,r){var i=function(){for(var n=[],a=0;a<arguments.length;a++)n[a]=arguments[a];r.apply(null,n),t.removeEventListener(e,i)};t.addEventListener(e,i)}(a,'progress',(function(){a.buffered.length?(a.currentTime=a.buffered.start(0),o({name:'playing'})):s()}))};s()},t.prototype._initPlayerWith=function(t){var e=this;this.bitrate=0,this.rep=0,this.sourceBuffer=0,this.bufferStates=[],this.filesFetcher&&this.filesFetcher.abortAll(),this.filesFetcher=new Wl(3,1e4,this.bitrateSwitcher,this.params.config.MAX_PARALLEL_REQUESTS,this.params.logger),this._setVideoSrc(t,(function(){return e._switchToQuality(t)}))},t.prototype._representation=function(t){var e=this,r=this.params,a=r.logger,o=r.videoElement,s=r.playerCallback,u=!1,c=null,d=null,l=null,h=null,f=!1,v=function(){var t=u&&(!f||f===e.rep);return t||a('Not running!'),t},m=function(t){var e=o.playbackRate;o.playbackRate!==t&&(a('Playback rate switch: '.concat(e,'=>').concat(t)),o.playbackRate=t)},S=function(){if(e.lowLatency){var t=e._getBufferSizeSec();if(e.bufferStates.length<5)return void m(1);for(var r=ql()-6e4,i=0,n=0;n<e.bufferStates.length;n++){var o=e.bufferStates[n];t=Math.min(t,o.buf),o.ts<r&&i++}e.bufferStates.splice(0,i),a('update playback rate; minBuffer='.concat(t,' drop=').concat(i,' jitter=').concat(e.sourceJitter));var s=t-1;e.sourceJitter>=0?s-=e.sourceJitter/2:e.sourceJitter-=1,m(s>3?1.15:s>1?1.1:s>.3?1.01:1)}else m(1)},g=function(t){var r,n=function(){return r&&r.start?r.start.length:0},o=function(t){return r.start[t]/1e3},u=function(t){return r.dur[t]/1e3},c=function(t){return r.fragIndex+t},d=function(t,e){return{chunkIdx:c(t),startTS:o(t),dur:u(t),discontinuity:e}},l=function(){var t=0;if(r&&r.dur){var i=Math.max(e.sourceJitter,1);for(e.lowLatency||(i+=2),t=r.dur.length-1;t>=0&&!((i-=r.dur[t]/1e3)<=0);--t);}return d(t,!0)};return{seek:function(u,c){!function(t,r,i){h&&h.abort(),h=jl(e.urlResolver.resolve(t,!0,e.lowLatency),r,i,(function(){return e._retryCallback()})).withTimeout(1e4).withRetryCount(3).withFinally((function(){h=null})).withJSONResponse().send()}(t,(function(t){if(v()){r=t;var h,f=Boolean(r.lowLatency);f!==e.lowLatency&&(h=f,e.lowLatency=h,a('lowLatency changed to '.concat(h)),S());for(var m=0,g=0;g<r.dur.length;++g)m+=r.dur[g];m>0&&(p(e.filesFetcher),e.filesFetcher.optimizeForSegDuration(m/r.dur.length)),s({name:'index',zeroTime:r.zeroTime,shiftDuration:r.shiftDuration}),e.sourceJitter=r.hasOwnProperty('jitter')?Math.min(10,Math.max(.01,r.jitter/1e3)):1,u(function(t){var e=n();if(!(e<=0)){if(i(t))for(var r=0;r<e;r++)if(o(r)>t)return d(r);return l()}}(c))}}),(function(){return e._handleNetworkError()}))},nextChunk:function(t){var e=n(),i=t?t.chunkIdx+1:0,o=i-r.fragIndex;if(!(e<=0)){if(!t||o<0||o-e>10)return a('Resync: offset='.concat(o,' bChunks=').concat(e,' chunk=')+JSON.stringify(t)),l();if(!(o>=e))return d(i-r.fragIndex,!1)}}}},y=function(){u=!1,d&&d.abort(),l&&l.abort(),h&&h.abort(),p(e.filesFetcher),e.filesFetcher.abortAll()};return f={start:function(r){var i,a,o,s,f,m,b,T,E,w,P=e.params,A=P.videoElement,k=P.logger,$=g(t.jidxUrl),_=0,D=function(){f&&(clearTimeout(f),f=void 0);var t=Math.max(500,1e3*(e._getBufferSizeSec()-e.sourceJitter-5)),r=_+t,i=ql(),n=Math.min(1e4,r-i);_=i;var a=function(){h||v()&&$.seek((function(){v()&&(_=ql(),R(),D())}))};n>0?f=window.setTimeout((function(){e.paused?D():a()}),n):a()},R=function(){for(var r;r=$.nextChunk(s);)s=r,C(r);var i=$.nextChunk(o);if(i){if(o&&i.discontinuity)return k('Detected discontinuity; restarting playback'),void(e.paused?D():(y(),e._initPlayerWith(t)));O(i)}else D()},I=function(t,r){if(v()&&e.sourceBuffer){var i,n,a=function(e){window.setTimeout((function(){v()&&I(t,r)}),e)};if(e.sourceBuffer.updating)k('Source buffer is updating; delaying appendBuffer'),a(100);else{var o=ql(),s=A.currentTime;!e.paused&&A.buffered.length>1&&m===s&&o-b>500&&(k('Stall suspected; trying to fix'),e._fixupStall()),m!==s&&(m=s,b=o);var u=e._getBufferSizeSec();if(u>30)k('Buffered '.concat(u,' seconds; delaying appendBuffer')),a(2e3);else try{e.sourceBuffer.appendBuffer(t),e.videoPlayStarted?(e.bufferStates.push({ts:o,buf:u}),S(),e.bufferStates.length>200&&e.bufferStates.shift()):e.shouldPlay()&&(e.videoPlayStarted=!0,e._playVideoElement()),r&&r()}catch(t){if('QuotaExceededError'!==t.name)throw t;k('QuotaExceededError; delaying appendBuffer'),0!==e.sourceBuffer.buffered.length&&(n=s)-(i=e.sourceBuffer.buffered.start(0))>4&&e.sourceBuffer.remove(i,n-3),a(1e3)}}}},x=function(){a&&i&&(k(['Appending chunk, sz='.concat(a.byteLength,':'),JSON.stringify(o)]),I(a,(function(){a=null,R()})))},L=function(e){return t.fragUrlTemplate.replace('%%id%%',e.chunkIdx)},O=function(t){var r,i,n;v()&&(r=L(t),i=function(r,i){if(v()){if(i/=1e3,a=r,o=t,c=t.startTS,i){var n=Math.min(10,t.dur/i);e.downloadRate=e.downloadRate?.7*e.downloadRate+.3*n:n}x()}},n=function(){return e._handleNetworkError()},p(e.filesFetcher),null==d||d.abort(),d=e.filesFetcher.requestData(e.urlResolver.resolve(r,!1),i,n,(function(){return e._retryCallback()})).withFinally((function(){d=null})).send())},C=function(t){v()&&(p(e.filesFetcher),e.filesFetcher.prefetch(e.urlResolver.resolve(L(t),!1)))},N=function(e){v()&&(t.cachedHeader=e,I(e,(function(){i=!0,x()})))};u=!0,$.seek((function(t){v()&&(_=ql(),t?(s=t,!n(r)||t.startTS>r?O(t):(o=t,R())):D())}),r),t.cachedHeader?N(t.cachedHeader):(T=t.headerUrl,E=N,w=function(){return e._handleNetworkError()},l&&l.abort(),l=jl(e.urlResolver.resolve(T,!1),E,w,(function(){return e._retryCallback()})).withTimeout(1e4).withBitrateReporting(e.bitrateSwitcher).withRetryCount(3).withFinally((function(){l=null})).send())},stop:y,getTimestampSec:function(){return c}}},t.prototype._switchToQuality=function(t){var e,r=this.params,n=r.logger,a=r.playerCallback;t.bitrate!==this.bitrate&&(this.rep&&(e=this.rep.getTimestampSec(),i(e)&&(e+=.1),this.rep.stop()),this.currentManifestEntry=t,this.rep=this._representation(t),n('switch to quality: codecs='.concat(t.codecs,'; headerUrl=').concat(t.headerUrl,'; bitrate=').concat(t.bitrate)),this.bitrate=t.bitrate,p(this.bitrateSwitcher),this.bitrateSwitcher.notifySwitch(this.bitrate),this.rep.start(e),a({name:'qualitySwitch',quality:t}))},t.prototype._qualityAvailable=function(t){return i(this.manifest.find((function(e){return e.name===t})))},t.prototype._initBitrateSwitcher=function(){var t,e=this,r=this.params,i=r.logger,n=r.playerCallback,a={updateChunk:function(t,r){var i=ql();if(e.chunkRateEstimator.addInterval(t,i,r)){var a=e.chunkRateEstimator.getBitRate();return n({name:'bandwidth',size:r,duration:i-t,speed:a}),!0}},get:function(){var t=e.chunkRateEstimator.getBitRate();return t?.85*t:0}},o=-1/0,s=!0,u=function(){var r=a.get();if(r&&t&&e.autoQuality){if(s&&r>t&&Gl(o)<3e4)return;!function(t){var r,n,a;e.autoQuality&&(e.currentManifestEntry&&e._qualityAvailable(e.currentManifestEntry.name)&&t<e.bitrate&&(n=e._getBufferSizeSec(),a=t/e.bitrate,n>10&&a>.8||n>15&&a>.5||n>20&&a>.3)?i('Not switching: buffer='.concat(Math.floor(n),'; bitrate=').concat(e.bitrate,'; newRate=').concat(Math.floor(t))):(r=e._selectQuality(t))?e._switchToQuality(r):i('Could not find quality by bitrate '.concat(t)))}(r)}s=e.autoQuality};return{updateChunk:function(t,e){var r=a.updateChunk(t,e);return r&&u(),r},notifySwitch:function(e){var r=ql();e<t&&(o=r),t=e}}},t.prototype._fetchManifest=function(t,e,r){var i=this;this.manifestRequest=jl(this.urlResolver.resolve(t,!0),e,r,(function(){return i._retryCallback()})).withJSONResponse().withTimeout(1e4).withRetryCount(3).withRetryInterval(300,2e3).send().withFinally((function(){i.manifestRequest=void 0}))},t.prototype._playVideoElement=function(t){var e=this.params.videoElement;Ti(e).then((function(e){e||null==t||t()}))},t.prototype._handleManifestUpdate=function(t){var e=this,r=this.params,i=r.logger,n=r.playerCallback,a=r.videoElement;this.manifest=function(t){var r=[];return(null==t?void 0:t.length)?(t.forEach((function(t,e){t.video&&a.canPlayType(t.codecs).replace(/no/,'')&&window.MediaSource.isTypeSupported(t.codecs)&&(t.index=e,r.push(t))})),r.sort((function(t,e){return t.video&&e.video?e.video.height-t.video.height:e.bitrate-t.bitrate})),r):(e.params.playerCallback({name:'error',type:'partial_metadata'}),[])}(t),i('Valid manifest entries: '.concat(this.manifest.length,'/').concat(t.length)),n({name:'manifest',manifest:this.manifest})},t.prototype._refetchManifest=function(t){var e=this;this.destroyed||(this.manifestRefetchTimer&&clearTimeout(this.manifestRefetchTimer),this.manifestRefetchTimer=window.setTimeout((function(){e._fetchManifest(t,(function(r){e.destroyed||(e._handleManifestUpdate(r),e._refetchManifest(t))}),(function(){return e._refetchManifest(t)}))}),6e4))},t.prototype._initManifest=function(){var t=this;this._fetchManifest(this.manifestUrl,(function(e){t.destroyed||(t._handleManifestUpdate(e),t._refetchManifest(t.manifestUrl))}),(function(){return t._handleNetworkError()}))},t}();!function(t){t.STOPPED='stopped',t.MANIFEST_READY='manifest_ready',t.READY='ready',t.PLAYING='playing',t.PAUSED='paused'}(zl||(zl={}));var Kl,Xl=[zl.PAUSED,zl.PLAYING,zl.READY],Zl=[zl.PAUSED,zl.PLAYING,zl.READY],tp=function(){function e(e){var n=this;this.subscription=new r,this.videoState=new Ji(zl.STOPPED),this.representations$=new t([]),this.textTracksManager=new ki,this.maxSeekBackTime$=new t(1/0),this.zeroTime$=new t(void 0),this.liveOffset=new Bl,this._dashCb=function(t){var e,r,a,o,s;switch(t.name){case'buffering':var u=t.isBuffering;n.params.output.isBuffering$.next(u);break;case'error':n.params.output.error$.next({id:'DashLiveProviderInternal:'.concat(t.type),message:'LiveDashPlayer reported error'});break;case'manifest':var c=t.manifest,d=[];try{for(var l=L(c),p=l.next();!p.done;p=l.next()){var h=p.value,f=null!==(a=h.name)&&void 0!==a?a:h.index.toString(10),v=Bi(h.video),m=h.bitrate/1e3,S=R({},h.video);if(v){var g={id:f,quality:v,bitrate:m,size:S};d.push({track:g,representation:h})}}}catch(t){e={error:t}}finally{try{p&&!p.done&&(r=l.return)&&r.call(l)}finally{if(e)throw e.error}}n.representations$.next(d),n.params.output.availableVideoTracks$.next(d.map((function(t){return t.track}))),(null===(o=n.videoState.getTransition())||void 0===o?void 0:o.to)===zl.MANIFEST_READY&&n.videoState.setState(zl.MANIFEST_READY);break;case'qualitySwitch':var y=t.quality;g=null===(s=n.representations$.getValue().find((function(t){return t.representation===y})))||void 0===s?void 0:s.track;n.params.output.hostname$.next(new URL(y.headerUrl,n.params.source.url).hostname),i(g)&&n.params.output.currentVideoTrack$.next(g);break;case'bandwidth':S=t.size;var b=t.duration;n.params.dependencies.throughputEstimator.addRawSpeed(S,b);break;case'index':n.maxSeekBackTime$.next(t.shiftDuration),n.zeroTime$.next(t.zeroTime)}},this.syncPlayback=function(){var t,e=n.videoState.getState(),r=n.videoState.getTransition(),a=n.params.desiredState.playbackState.getState(),s=n.params.desiredState.playbackState.getTransition(),u=n.params.desiredState.seekPosition.getTransition();if(n.log({message:'[syncPlayback] videoState: '.concat(e,'; videoTransition: ').concat(JSON.stringify(r),'; desiredPlaybackState: ').concat(a,'; seekPositionTransition: ').concat(JSON.stringify(u),';')}),a!==P.STOPPED){if(!r){if(Zl.includes(e)){var c=null===(t=n.params.desiredState.videoTrack.getTransition())||void 0===t?void 0:t.to;i(c)&&n.setVideoTrack(c);var d=n.params.desiredState.autoVideoTrackSwitching.getTransition();d&&n.setAutoQuality(d.to)}var l=null==u?void 0:u.to;if((null==s?void 0:s.to)!==P.PAUSED&&i(l)&&Xl.includes(e))n.seek(l+ep(n.liveOffset.getTotalPausedTime()));else switch(e){case zl.STOPPED:return n.videoState.startTransitionTo(zl.MANIFEST_READY),void n.dash.attachSource(El(n.params.source.url));case zl.MANIFEST_READY:n.videoState.startTransitionTo(zl.READY),n.prepare();break;case zl.READY:return void(a===P.PAUSED?n.videoState.setState(zl.PAUSED):a===P.PLAYING&&(n.videoState.startTransitionTo(zl.PLAYING),n.dash.play((function(){n.liveOffset.pause(),n.videoState.setState(zl.PAUSED)}))));case zl.PLAYING:return void(a===P.PAUSED&&(n.videoState.startTransitionTo(zl.PAUSED),n.liveOffset.pause(),n.dash.pause()));case zl.PAUSED:return void(a===P.PLAYING&&(n.videoState.startTransitionTo(zl.PLAYING),n.liveOffset.getTotalPausedTime()<n.params.config.maxPausedTime&&n.liveOffset.getTotalOffset()<n.maxSeekBackTime$.getValue()?(n.liveOffset.resume(),n.dash.play((function(){n.liveOffset.pause(),n.videoState.setState(zl.PAUSED)})),n.params.output.position$.next(ep(n.liveOffset.getTotalOffset()))):n.seek(ep(n.liveOffset.getTotalOffset()))));default:return o(e)}}}else e!==zl.STOPPED&&(n.videoState.startTransitionTo(zl.STOPPED),n.dash.destroy(),n.video.setAttribute('src',''),n.video.load(),n.videoState.setState(zl.STOPPED))},this.params=e,this.log=this.params.dependencies.logger.createComponentLog('DashLiveProvider');var a=function(t){e.output.error$.next({id:'DashLiveProvider',message:'DashLiveProvider internal logic error',thrown:t})};s(this.videoState.stateChangeStarted$.pipe(c((function(t){return{transition:t,type:'start'}}))),this.videoState.stateChangeEnded$.pipe(c((function(t){return{transition:t,type:'end'}})))).subscribe((function(t){var e=t.transition,r=t.type;n.log({message:'[videoState change] '.concat(r,': ').concat(JSON.stringify(e))})})),this.video=$i(e.container),this.params.output.element$.next(this.video),this.dash=this.createLiveDashPlayer(),this.params.output.duration$.next(1/0),this.params.output.position$.next(0),this.params.output.isLive$.next(!0),this.params.output.hostname$.next(Qi(this.params.source.url)),this.textTracksManager.connect(this.video,this.params.desiredState,this.params.output);var u=xi(this.video);this.subscription.add(u.canplay$.subscribe((function(){var t;(null===(t=n.videoState.getTransition())||void 0===t?void 0:t.to)===zl.READY&&n.videoState.setState(zl.READY)}),a)).add(u.pause$.subscribe((function(){n.videoState.setState(zl.PAUSED)}),a)).add(u.playing$.subscribe((function(){n.videoState.setState(zl.PLAYING)}),a)).add(u.error$.subscribe(this.params.output.error$)).add(this.maxSeekBackTime$.pipe(l(),c(ep)).subscribe(this.params.output.duration$)).add(S({zeroTime:this.zeroTime$.pipe(g(i)),position:u.timeUpdate$}).subscribe((function(t){var e=t.zeroTime,r=t.position;return n.params.output.liveTime$.next(e+1e3*r)}),a)).add(wi(this.video,this.params.desiredState.isLooped,a)).add(Pi(this.video,this.params.desiredState.volume,u.volumeState$,a)).add(u.volumeState$.subscribe(this.params.output.volume$,a)).add(Ii(this.video).subscribe(this.params.output.firstBytesEvent$)).add(_i(this.video).subscribe(this.params.output.firstFrameEvent$)).add(this.videoState.stateChangeEnded$.subscribe((function(t){switch(t.to){case zl.STOPPED:n.params.output.position$.next(0),n.params.output.duration$.next(1/0),n.params.desiredState.playbackState.setState(P.STOPPED);break;case zl.MANIFEST_READY:case zl.READY:break;case zl.PAUSED:n.params.desiredState.playbackState.setState(P.PAUSED);break;case zl.PLAYING:n.params.desiredState.playbackState.setState(P.PLAYING);break;default:return o(t.to)}}),a)).add(s(e.desiredState.playbackState.stateChangeStarted$,e.desiredState.seekPosition.stateChangeStarted$,e.desiredState.videoTrack.stateChangeStarted$,e.desiredState.autoVideoTrackSwitching.stateChangeStarted$,this.videoState.stateChangeEnded$,d(['init'])).pipe(v(0)).subscribe(this.syncPlayback,a))}return e.prototype.destroy=function(){this.subscription.unsubscribe(),this.textTracksManager.destroy(),this.video.remove(),this.params.output.element$.next(void 0),this.dash.destroy()},e.prototype.createLiveDashPlayer=function(){var t=this,e=new Jl({videoElement:this.video,config:{CHUNK_DURATION:this.params.config.chunkDuration,BUFFER_OPTIMAL_DURATION:this.params.config.optimalBufferDuration,MAX_PARALLEL_REQUESTS:this.params.config.maxParallelRequests},playerCallback:this._dashCb,logger:function(e){t.params.dependencies.logger.log({message:String(e),component:'LiveDashPlayer'})}});return e.pause(),e},e.prototype.prepare=function(){var t,e,r,n,a,o,s=this.representations$.getValue(),u=null!==(e=null===(t=this.params.desiredState.videoTrack.getTransition())||void 0===t?void 0:t.to)&&void 0!==e?e:this.params.desiredState.videoTrack.getState(),c=null!==(n=null===(r=this.params.desiredState.autoVideoTrackSwitching.getTransition())||void 0===r?void 0:r.to)&&void 0!==n?n:this.params.desiredState.autoVideoTrackSwitching.getState(),d=!c&&i(u)?u:null===(a=ji(s.map((function(t){return t.track})),{container:{width:this.video.offsetWidth,height:this.video.offsetHeight},throughput:this.params.dependencies.throughputEstimator.throughput$.getValue(),tuning:this.params.tuning.autoTrackSelection}))||void 0===a?void 0:a.id,l=null===(o=s.find((function(t){return t.track.id===d})))||void 0===o?void 0:o.representation;p(l),this.dash.startPlay(l,c),this.params.desiredState.videoTrack.getTransition()&&this.params.desiredState.videoTrack.setState(d),this.params.desiredState.autoVideoTrackSwitching.getTransition()&&this.params.desiredState.autoVideoTrackSwitching.setState(c)},e.prototype.setVideoTrack=function(t){var e,r=null===(e=this.representations$.getValue().find((function(e){return e.track.id===t})))||void 0===e?void 0:e.representation;p(r),this.dash.switchByName(r.name),this.params.desiredState.videoTrack.setState(t)},e.prototype.setAutoQuality=function(t){this.dash.setAutoQualityEnabled(t),this.params.desiredState.autoVideoTrackSwitching.setState(t)},e.prototype.seek=function(t){this.log({message:'[seek] position: '.concat(t)}),this.params.output.willSeekEvent$.next();var e=-Math.round(1e3*t),r=e<this.maxSeekBackTime$.getValue()?e:0;this.liveOffset.resetTo(r),this.params.output.position$.next(ep(r)),this.dash.reinit(El(this.params.source.url,r)),this.params.output.seekedEvent$.next()},e}(),ep=function(t){return-t/1e3},rp=function(t){switch(t){case'mobile':return yi.Q_144P;case'lowest':return yi.Q_240P;case'low':return yi.Q_360P;case'sd':case'medium':return yi.Q_480P;case'hd':case'high':return yi.Q_720P;case'fullhd':case'full':return yi.Q_1080P;case'quadhd':case'quad':return yi.Q_1440P;case'ultrahd':case'ultra':return yi.Q_2160P}},ip=function(t){var e=null;if(t.QUALITY&&(e=rp(t.QUALITY)),!e&&t.RESOLUTION){var r=O(t.RESOLUTION.split('x').map((function(t){return parseInt(t,10)})),2),i=r[0],n=r[1];e=Bi({width:i,height:n})}return null!=e?e:null},np=function(t,e){return void 0===e&&(e=t),I(void 0,void 0,void 0,(function(){var r,i,n,a,o,s,u,c,d,l,p,h,f,v,m,S,g;return x(this,(function(y){switch(y.label){case 0:return[4,Gs(fetch).fetch(t)];case 1:return[4,y.sent().text()];case 2:for(r=y.sent(),i=r.split('\n'),n=[],a=0;a<i.length;a++)o=i[a],(s=o.match(/^#EXT-X-STREAM-INF:(.+)/))&&(u=Ds(s[1].split(',').map((function(t){return t.split('=')}))),c=null!==(g=u.QUALITY)&&void 0!==g?g:'stream-'.concat(u.BANDWIDTH),d=ip(u),l=void 0,u.BANDWIDTH&&(l=parseInt(u.BANDWIDTH,10)/1e3||void 0),!l&&u['AVERAGE-BANDWIDTH']&&(l=parseInt(u['AVERAGE-BANDWIDTH'],10)/1e3||void 0),p=u['FRAME-RATE']?parseFloat(u['FRAME-RATE']):void 0,h=void 0,u.RESOLUTION&&(f=O(u.RESOLUTION.split('x').map((function(t){return parseInt(t,10)})),2),v=f[0],m=f[1],v&&m&&(h={width:v,height:m})),S=new URL(i[++a],e).toString(),d&&n.push({id:c,quality:d,url:S,bandwidth:l,size:h,fps:p}));return[2,n]}}))}))};!function(t){t.STOPPED='stopped',t.READY='ready',t.PLAYING='playing',t.CHANGING_MANIFEST='changing_manifest',t.PAUSED='paused'}(Kl||(Kl={}));var ap,op=function(){function e(e){var a=this;this.subscription=new r,this.videoState=new Ji(Kl.STOPPED),this.textTracksManager=new ki,this.manifests$=new t([]),this.syncPlayback=function(){var t=a.videoState.getState(),e=a.params.desiredState.playbackState.getState(),r=a.params.desiredState.playbackState.getTransition(),s=a.params.desiredState.videoTrack.getTransition(),u=a.params.desiredState.autoVideoTrackSwitching.getTransition();if(e!==P.STOPPED){if(!a.videoState.getTransition()){var c=a.params.desiredState.seekPosition.getTransition();if(t===Kl.STOPPED)return a.videoState.startTransitionTo(Kl.READY),void a.prepare();if(s||u){var d=a.videoState.getState();a.videoState.setState(Kl.CHANGING_MANIFEST),a.videoState.startTransitionTo(d);var l=a.video.currentTime;return a.prepare(),void(c&&!n(c.to)||a.params.desiredState.seekPosition.startTransitionTo(l))}var p=null==c?void 0:c.to;switch((null==r?void 0:r.to)!==P.PAUSED&&i(p)&&a.seek(p),t){case Kl.READY:return void(e===P.PAUSED?(a.videoState.setState(Kl.PAUSED),Li(a.params.desiredState.playbackState,P.PAUSED)):e===P.PLAYING&&(a.videoState.startTransitionTo(Kl.PLAYING),a.playIfAllowed()));case Kl.PLAYING:return void(e===P.PAUSED?(a.videoState.startTransitionTo(Kl.PAUSED),a.video.pause()):(null==r?void 0:r.to)===P.PLAYING&&Li(a.params.desiredState.playbackState,P.PLAYING));case Kl.PAUSED:return void(e===P.PLAYING?(a.videoState.startTransitionTo(Kl.PLAYING),a.playIfAllowed()):(null==r?void 0:r.to)===P.PAUSED&&Li(a.params.desiredState.playbackState,P.PAUSED));case Kl.CHANGING_MANIFEST:break;default:return o(t)}}}else t!==Kl.STOPPED&&(a.videoState.startTransitionTo(Kl.STOPPED),a.video.setAttribute('src',''),a.video.load(),a.params.output.position$.next(0),a.params.output.duration$.next(1/0),a.params.output.currentBuffer$.next(void 0),a.params.output.hostname$.next(void 0),a.videoState.setState(Kl.STOPPED),Li(a.params.desiredState.playbackState,P.STOPPED,!0))},this.params=e,this.video=$i(e.container),this.params.output.element$.next(this.video);var s={id:'master',quality:yi.INVARIANT,url:this.params.source.url};this.manifests$.next([s]),this.params.output.isLive$.next(!1),this.params.output.hostname$.next(Qi(this.params.source.url)),np(this.params.source.url).then((function(t){a.manifests$.next(C([s],O(t),!1))}),(function(t){return a.params.output.error$.next({id:'ExtractHlsQualities',message:'Error fetching manifest and extracting qualities',thrown:t})})),this.subscribe()}return e.prototype.selectManifest=function(){var t,e,r=this.params.desiredState,i=r.autoVideoTrackSwitching,n=r.videoTrack,a=i.getState(),o=n.getTransition(),s=null!==(e=null!==(t=null==o?void 0:o.to)&&void 0!==t?t:n.getState())&&void 0!==e?e:'master',u=this.manifests$.getValue();if(u){var c=a?'master':s;return a&&!o&&n.startTransitionTo('master'),u.find((function(t){return t.id===c}))}},e.prototype.subscribe=function(){var t=this,e=this.params,r=e.output,n=e.desiredState,a=function(t){r.error$.next({id:'HlsProvider',message:'HlsProvider internal logic error',thrown:t})},o=xi(this.video),u=function(e,r){return t.subscription.add(e.subscribe(r))};u(o.timeUpdate$,r.position$),u(o.durationChange$,r.duration$),u(o.ended$,r.endedEvent$),u(o.error$,r.error$),u(o.isBuffering$,r.isBuffering$),u(o.currentBuffer$,r.currentBuffer$),u(o.firstBytes$,r.firstBytesEvent$),u(o.firstFrame$,r.firstFrameEvent$),u(o.seeked$,r.seekedEvent$),this.subscription.add(wi(this.video,n.isLooped,a)),this.subscription.add(Pi(this.video,n.volume,o.volumeState$,a)),this.subscription.add(o.volumeState$.subscribe(this.params.output.volume$,a)),this.textTracksManager.connect(this.video,n,r),this.subscription.add(o.playing$.subscribe((function(){t.videoState.setState(Kl.PLAYING),Li(n.playbackState,P.PLAYING)}),a)).add(o.pause$.subscribe((function(){t.videoState.setState(Kl.PAUSED),Li(n.playbackState,P.PAUSED)}),a)).add(o.canplay$.subscribe((function(){var e;(null===(e=t.videoState.getTransition())||void 0===e?void 0:e.to)===Kl.READY&&t.videoState.setState(Kl.READY),t.videoState.getState()===Kl.PLAYING&&t.playIfAllowed()}),a).add(o.loadedMetadata$.subscribe((function(){var e=t.params.desiredState.seekPosition.getTransition(),r=t.videoState.getTransition(),n=t.params.desiredState.videoTrack.getTransition(),a=t.params.desiredState.autoVideoTrackSwitching.getTransition();if(n&&i(n.to)){var o=n.to;t.params.desiredState.videoTrack.setState(o);var s=t.manifests$.getValue().find((function(t){return t.id===o}));s&&(t.params.output.currentVideoTrack$.next(s),t.params.output.hostname$.next(Qi(s.url)))}a&&t.params.desiredState.autoVideoTrackSwitching.setState(a.to),r&&r.from===Kl.CHANGING_MANIFEST&&t.videoState.setState(r.to),e&&i(e.to)&&t.seek(e.to)}),a))),this.subscription.add(this.manifests$.pipe(c((function(t){return t.map((function(t){var e=t.id,r=t.quality,i=t.size,n=t.bandwidth;return{id:e,quality:r,size:i,fps:t.fps,bitrate:n}}))}))).subscribe(this.params.output.availableVideoTracks$,a));var l=s(n.playbackState.stateChangeStarted$,n.seekPosition.stateChangeStarted$,n.videoTrack.stateChangeStarted$,n.autoVideoTrackSwitching.stateChangeStarted$,this.videoState.stateChangeEnded$,d(['init'])).pipe(v(0));this.subscription.add(l.subscribe(this.syncPlayback,a))},e.prototype.destroy=function(){this.subscription.unsubscribe(),this.textTracksManager.destroy(),this.video.remove(),this.params.output.element$.next(void 0)},e.prototype.prepare=function(){var t=this.selectManifest();n(t)||(this.video.setAttribute('src',t.url),this.video.load())},e.prototype.playIfAllowed=function(){var t=this;Ti(this.video).then((function(e){e||(t.videoState.setState(Kl.PAUSED),Li(t.params.desiredState.playbackState,P.PAUSED,!0))}))},e.prototype.seek=function(t){this.params.output.willSeekEvent$.next(),this.video.currentTime=t},e}();!function(t){t.STOPPED='stopped',t.READY='ready',t.PLAYING='playing',t.CHANGING_MANIFEST='changing_manifest',t.PAUSED='paused'}(ap||(ap={}));var sp,up=function(){function e(e){var a,s=this;this.subscription=new r,this.videoState=new Ji(ap.STOPPED),this.textTracksManager=new ki,this.manifests$=new t([]),this.liveOffset=new Bl,this.manifestStartTime$=new t(void 0),this.syncPlayback=function(){var t=s.videoState.getState(),e=s.params.desiredState.playbackState.getState(),r=s.params.desiredState.playbackState.getTransition(),a=s.params.desiredState.videoTrack.getTransition(),u=s.params.desiredState.autoVideoTrackSwitching.getTransition();if(e!==P.STOPPED){if(!s.videoState.getTransition()){var c=s.params.desiredState.seekPosition.getTransition();if(t===ap.STOPPED)return s.videoState.startTransitionTo(ap.READY),void s.prepare();if(a||u){var d=s.videoState.getState();s.videoState.setState(ap.CHANGING_MANIFEST),s.videoState.startTransitionTo(d);var l=cp(s.liveOffset.getTotalOffset());return s.prepare(),void(c&&!n(c.to)||s.params.desiredState.seekPosition.startTransitionTo(l))}var p=null==c?void 0:c.to;if((null==r?void 0:r.to)!==P.PAUSED&&i(p))return s.videoState.startTransitionTo(ap.READY),s.seek(p+cp(s.liveOffset.getTotalPausedTime())),void s.prepare();switch(t){case ap.READY:return void(e===P.PAUSED?(s.videoState.setState(ap.PAUSED),s.liveOffset.pause(),Li(s.params.desiredState.playbackState,P.PAUSED)):e===P.PLAYING&&(s.videoState.startTransitionTo(ap.PLAYING),s.playIfAllowed()));case ap.PLAYING:return void(e===P.PAUSED?(s.videoState.startTransitionTo(ap.PAUSED),s.liveOffset.pause(),s.video.pause()):(null==r?void 0:r.to)===P.PLAYING&&Li(s.params.desiredState.playbackState,P.PLAYING));case ap.PAUSED:return void(e===P.PLAYING?(s.videoState.startTransitionTo(ap.PLAYING),s.liveOffset.getTotalPausedTime()<s.params.config.maxPausedTime&&s.liveOffset.getTotalOffset()<s.maxSeekBackTime$.getValue()?(s.liveOffset.resume(),s.playIfAllowed(),s.params.output.position$.next(cp(s.liveOffset.getTotalOffset()))):s.seek(cp(s.liveOffset.getTotalOffset()))):(null==r?void 0:r.to)===P.PAUSED&&(Li(s.params.desiredState.playbackState,P.PAUSED),s.liveOffset.pause()));case ap.CHANGING_MANIFEST:break;default:return o(t)}}}else t!==ap.STOPPED&&(s.videoState.startTransitionTo(ap.STOPPED),s.video.setAttribute('src',''),s.video.load(),s.params.output.position$.next(0),s.params.output.duration$.next(1/0),s.params.output.currentBuffer$.next(void 0),s.params.output.hostname$.next(void 0),s.videoState.setState(ap.STOPPED),Li(s.params.desiredState.playbackState,P.STOPPED,!0))},this.params=e,this.video=$i(e.container),this.params.output.element$.next(this.video);var u={id:'master',quality:yi.INVARIANT,url:this.params.source.url};this.manifests$.next([u]),np(El(this.params.source.url)).then((function(t){s.manifests$.next(C([u],O(t),!1))}),(function(t){return s.params.output.error$.next({id:'ExtractHlsQualities',message:'Error fetching manifest and extracting qualities',thrown:t})})),this.params.output.isLive$.next(!0),this.params.output.hostname$.next(Qi(this.params.source.url)),this.maxSeekBackTime$=new t(null!==(a=e.source.maxSeekBackTime)&&void 0!==a?a:1/0),this.subscribe()}return e.prototype.selectManifest=function(){var t,e,r=this.params.desiredState,i=r.autoVideoTrackSwitching,n=r.videoTrack,a=i.getState(),o=n.getTransition(),s=null!==(e=null!==(t=null==o?void 0:o.to)&&void 0!==t?t:n.getState())&&void 0!==e?e:'master',u=this.manifests$.getValue();if(u){var c=a?'master':s;return a&&!o&&n.startTransitionTo('master'),u.find((function(t){return t.id===c}))}},e.prototype.subscribe=function(){var t=this,e=this.params,r=e.output,n=e.desiredState,a=function(t){r.error$.next({id:'HlsLiveProvider',message:'HlsLiveProvider internal logic error',thrown:t})},o=xi(this.video),u=function(e,r){return t.subscription.add(e.subscribe(r,a))};u(o.ended$,r.endedEvent$),u(o.error$,r.error$),u(o.isBuffering$,r.isBuffering$),u(o.currentBuffer$,r.currentBuffer$),u(o.firstBytes$,r.firstBytesEvent$),u(o.firstFrame$,r.firstFrameEvent$),this.subscription.add(n.isLooped.stateChangeStarted$.subscribe((function(){return n.isLooped.setState(!1)}),a)),this.subscription.add(Pi(this.video,n.volume,o.volumeState$,a)),this.subscription.add(o.volumeState$.subscribe(this.params.output.volume$,a)),this.textTracksManager.connect(this.video,n,r),this.subscription.add(o.playing$.subscribe((function(){t.videoState.setState(ap.PLAYING),Li(n.playbackState,P.PLAYING)}),a)).add(o.pause$.subscribe((function(){t.videoState.setState(ap.PAUSED),Li(n.playbackState,P.PAUSED)}),a)).add(o.canplay$.subscribe((function(){var e;(null===(e=t.videoState.getTransition())||void 0===e?void 0:e.to)===ap.READY&&t.videoState.setState(ap.READY),t.videoState.getState()===ap.PLAYING&&t.playIfAllowed()}),a)),this.subscription.add(this.maxSeekBackTime$.pipe(l(),c(cp)).subscribe(this.params.output.duration$,a)),this.subscription.add(o.loadedMetadata$.subscribe((function(){var e=t.params.desiredState.seekPosition.getTransition(),r=t.videoState.getTransition(),n=t.params.desiredState.videoTrack.getTransition(),a=t.params.desiredState.autoVideoTrackSwitching.getTransition();if(n&&i(n.to)){var o=n.to;t.params.desiredState.videoTrack.setState(o);var s=t.manifests$.getValue().find((function(t){return t.id===o}));s&&(t.params.output.currentVideoTrack$.next(s),t.params.output.hostname$.next(Qi(s.url)))}a&&t.params.desiredState.autoVideoTrackSwitching.setState(a.to),r&&r.from===ap.CHANGING_MANIFEST&&t.videoState.setState(r.to),e&&i(e.to)&&t.seek(e.to)}),a)),this.subscription.add(o.loadedData$.subscribe((function(){var e,r,i=null===(r=null===(e=t.video)||void 0===e?void 0:e.getStartDate())||void 0===r?void 0:r.getTime();t.manifestStartTime$.next(i||void 0)}),a)),this.subscription.add(S({startTime:this.manifestStartTime$.pipe(g(i)),currentTime:o.timeUpdate$}).subscribe((function(e){var r=e.startTime,i=e.currentTime;return t.params.output.liveTime$.next(r+1e3*i)}),a)),this.subscription.add(this.manifests$.pipe(c((function(t){return t.map((function(t){var e=t.id,r=t.quality,i=t.size,n=t.bandwidth;return{id:e,quality:r,size:i,fps:t.fps,bitrate:n}}))}))).subscribe(this.params.output.availableVideoTracks$,a));var p=s(n.playbackState.stateChangeStarted$,n.seekPosition.stateChangeStarted$,this.videoState.stateChangeEnded$,n.videoTrack.stateChangeStarted$,n.autoVideoTrackSwitching.stateChangeStarted$,d(['init'])).pipe(v(0));this.subscription.add(p.subscribe(this.syncPlayback,a))},e.prototype.destroy=function(){this.subscription.unsubscribe(),this.textTracksManager.destroy(),this.video.remove(),this.params.output.element$.next(void 0)},e.prototype.prepare=function(){var t=this,e=this.selectManifest();if(!n(e)){var r,i=El(e.url,this.liveOffset.getTotalOffset());this.video.setAttribute('src',i),this.video.load(),(r=i,I(void 0,void 0,void 0,(function(){var t;return x(this,(function(e){switch(e.label){case 0:return[4,Gs(fetch).fetch(r,{method:'HEAD'})];case 1:return[2,(t=e.sent()).headers.has('X-Playback-Duration')?parseInt(t.headers.get('X-Playback-Duration'),10):void 0]}}))}))).then((function(e){n(e)||t.maxSeekBackTime$.next(e)}))}},e.prototype.playIfAllowed=function(){var t=this;Ti(this.video).then((function(e){e||(t.videoState.setState(ap.PAUSED),t.liveOffset.pause(),Li(t.params.desiredState.playbackState,P.PAUSED,!0))}))},e.prototype.seek=function(t){this.params.output.willSeekEvent$.next();var e=-Math.round(1e3*t),r=e<this.maxSeekBackTime$.getValue()?e:0;this.liveOffset.resetTo(r),this.params.output.position$.next(cp(r)),this.params.output.seekedEvent$.next()},e}(),cp=function(t){return-t/1e3},dp={};!function(t){t.INITIALIZING='initializing',t.STOPPED='stopped',t.READY='ready',t.PLAYING='playing',t.PAUSED='paused'}(sp||(sp={}));var lp,pp,hp,fp,vp,mp,Sp,gp,yp,bp,Tp,Ep,wp,Pp,Ap,kp,$p,_p,Dp=function(t,e){return new h((function(r){var i=function(t,e){return r.next(e)};return t.on(e,i),function(){return t.off(e,i)}}))},Rp=function(){function t(t){var e=this;this.subscription=new r,this.videoState=new Ji(sp.INITIALIZING),this.textTracksManager=new ki,this.trackLevels=new Map,this.syncPlayback=function(){var t=e.videoState.getState(),r=e.params.desiredState.playbackState.getState(),n=e.params.desiredState.playbackState.getTransition(),a=e.params.desiredState.seekPosition.getTransition();if(t!==sp.INITIALIZING){var s=null==a?void 0:a.to;switch((null==n?void 0:n.to)!==P.PAUSED&&i(s)&&e.seek(s),r){case P.STOPPED:switch(t){case sp.STOPPED:break;case sp.READY:case sp.PLAYING:case sp.PAUSED:e.stop();break;default:o(t)}break;case P.PLAYING:switch(t){case sp.PLAYING:break;case sp.STOPPED:e.prepare();break;case sp.READY:case sp.PAUSED:e.playIfAllowed();break;default:o(t)}break;case P.PAUSED:switch(t){case sp.PAUSED:break;case sp.STOPPED:e.prepare();break;case sp.READY:e.videoState.setState(sp.PAUSED),Li(e.params.desiredState.playbackState,P.PAUSED);break;case sp.PLAYING:e.pause();break;default:o(t)}break;default:o(r)}}},this.video=$i(t.container),this.params=t,this.params.output.element$.next(this.video),this.params.output.isLive$.next(!1),this.params.output.hostname$.next(Qi(this.params.source.url)),this.loadHlsJs()}return t.prototype.destroy=function(){var t,e;this.subscription.unsubscribe(),this.trackLevels.clear(),this.textTracksManager.destroy(),null===(t=this.hls)||void 0===t||t.detachMedia(),null===(e=this.hls)||void 0===e||e.destroy(),this.video.remove(),this.params.output.element$.next(void 0)},t.prototype.loadHlsJs=function(){var t=this,e=!1,r=function(r){e||t.params.output.error$.next({id:'timeout'===r?'HlsJsTimeout':'HlsJsLoadError',message:'Failed to load Hls.js',thrown:r}),e=!0},i=window.setTimeout((function(){return r('timeout')}),5e3);Wd(import('hls.js').then((function(r){e||(dp.Hls=r.default,dp.Events=r.default.Events,t.init())}),r),(function(){window.clearTimeout(i),e=!0}))},t.prototype.init=function(){p(dp.Hls,'hls.js not loaded'),this.hls=new dp.Hls({fragLoadingMaxRetry:5,levelLoadingMaxRetry:2,manifestLoadingMaxRetry:2,fragLoadingMaxRetryTimeout:16e3,manifestLoadingMaxRetryTimeout:2e3,levelLoadingMaxRetryTimeout:2e3}),this.subscribe(),this.videoState.setState(sp.STOPPED)},t.prototype.subscribe=function(){var t=this;p(dp.Events,'hls.js not loaded');var e=this.params,r=e.desiredState,a=e.output,o=function(t){a.error$.next({id:'HlsJsProvider',message:'HlsJsProvider internal logic error',thrown:t})},u=xi(this.video),l=function(e,r){return t.subscription.add(e.subscribe(r,o))};l(u.timeUpdate$,a.position$),l(u.durationChange$,a.duration$),l(u.ended$,a.endedEvent$),l(u.error$,a.error$),l(u.isBuffering$,a.isBuffering$),l(u.currentBuffer$,a.currentBuffer$),l(u.firstBytes$,a.firstBytesEvent$),l(u.firstFrame$,a.firstFrameEvent$),l(u.seeked$,a.seekedEvent$),this.subscription.add(wi(this.video,r.isLooped,o)),this.subscription.add(Pi(this.video,r.volume,u.volumeState$,o)),this.subscription.add(u.volumeState$.subscribe(this.params.output.volume$)),this.subscription.add(Dp(this.hls,dp.Events.ERROR).subscribe((function(t){var e;t.fatal&&a.error$.next({id:['HlsJsFatal',t.type,t.details].join('_'),message:'HlsJs fatal '.concat(t.type,' ').concat(t.details,', ').concat(null===(e=t.err)||void 0===e?void 0:e.message,' ').concat(t.reason),thrown:t.error})}))),this.subscription.add(u.playing$.subscribe((function(){t.videoState.setState(sp.PLAYING),Li(r.playbackState,P.PLAYING)}),o)).add(u.pause$.subscribe((function(){t.videoState.setState(sp.PAUSED),Li(r.playbackState,P.PAUSED)}),o)).add(u.canplay$.subscribe((function(){var e;(null===(e=t.videoState.getTransition())||void 0===e?void 0:e.to)===sp.READY&&t.videoState.setState(sp.READY),t.videoState.getState()===sp.PLAYING&&t.playIfAllowed()}),o)),l(Dp(this.hls,dp.Events.MANIFEST_PARSED).pipe(c((function(e){return e.levels.reduce((function(e,r){var i,n,a=r.name||r.height.toString(10),o=r.width,s=r.height,u=null!==(n=rp(null!==(i=r.attrs.QUALITY)&&void 0!==i?i:''))&&void 0!==n?n:Bi({width:o,height:s});if(!u)return e;var c=r.attrs['FRAME-RATE']?parseFloat(r.attrs['FRAME-RATE']):void 0,d={id:a.toString(),quality:u,bitrate:r.bitrate/1e3,size:{width:o,height:s},fps:c};return t.trackLevels.set(a,{track:d,level:r}),e.push(d),e}),[])}))),a.availableVideoTracks$),l(Dp(this.hls,dp.Events.LEVEL_LOADING).pipe(c((function(t){var e=t.url;return Qi(e)}))),a.hostname$),this.subscription.add(Ei(r.autoVideoTrackSwitching,(function(){return t.hls.autoLevelEnabled}),(function(e){t.hls.nextLevel=e?-1:t.hls.currentLevel,t.hls.loadLevel=e?-1:t.hls.loadLevel}),{onError:o}));var h=function(e){var r;return null===(r=Array.from(t.trackLevels.values()).find((function(t){return t.level===e})))||void 0===r?void 0:r.track},f=Dp(this.hls,dp.Events.LEVEL_SWITCHED).pipe(c((function(e){var r=e.level;return h(t.hls.levels[r])})));f.pipe(g(i)).subscribe(a.currentVideoTrack$,o),this.subscription.add(Ei(r.videoTrack,(function(){var e;return null===(e=h(t.hls.levels[t.hls.currentLevel]))||void 0===e?void 0:e.id}),(function(e){var r;if(!n(e)){var i=null===(r=t.trackLevels.get(e))||void 0===r?void 0:r.level;if(i){var a=t.hls.levels.indexOf(i),o=t.hls.currentLevel,s=t.hls.levels[o];!s||i.bitrate>s.bitrate?t.hls.nextLevel=a:(t.hls.loadLevel=a,t.hls.loadLevel=a)}}}),{changed$:f.pipe(c((function(t){return null==t?void 0:t.id}))),onError:o})),l(u.progress$,(function(){t.params.dependencies.throughputEstimator.addRawThroughput(t.hls.bandwidthEstimate/1e3)})),this.textTracksManager.connect(this.video,r,a);var m=s(r.playbackState.stateChangeStarted$,r.videoTrack.stateChangeStarted$,r.seekPosition.stateChangeStarted$,this.videoState.stateChangeEnded$,d(['init'])).pipe(v(0));this.subscription.add(m.subscribe(this.syncPlayback,o))},t.prototype.prepare=function(){this.videoState.startTransitionTo(sp.READY),this.hls.attachMedia(this.video),this.hls.loadSource(this.params.source.url)},t.prototype.playIfAllowed=function(){return I(this,void 0,void 0,(function(){return x(this,(function(t){switch(t.label){case 0:return this.videoState.startTransitionTo(sp.PLAYING),[4,Ti(this.video)];case 1:return t.sent()||(this.videoState.setState(sp.PAUSED),Li(this.params.desiredState.playbackState,P.PAUSED,!0)),[2]}}))}))},t.prototype.pause=function(){this.videoState.startTransitionTo(sp.PAUSED),this.video.pause()},t.prototype.seek=function(t){this.params.output.willSeekEvent$.next(),this.video.currentTime=t},t.prototype.stop=function(){this.params.output.position$.next(0),this.params.output.duration$.next(1/0),this.params.output.currentBuffer$.next(void 0),this.params.output.hostname$.next(void 0),this.hls.stopLoad(),this.hls.detachMedia(),this.video.setAttribute('src',''),this.video.load(),this.videoState.setState(sp.STOPPED),Li(this.params.desiredState.playbackState,P.STOPPED,!0)},t}(),Ip=function(){function t(t){this.iterator=t[Symbol.iterator](),this.next()}return t.prototype.next=function(){this.current=this.iterator.next()},t.prototype.getValue=function(){if(this.current.done)throw new Error('Iterable is completed');return this.current.value},t.prototype.isCompleted=function(){return Boolean(this.current.done)},t}(),xp=function(){var t=window.navigator.userAgent;return!/chrome/i.test(t)&&/webkit|safari|khtml/i.test(t)}(),Lp=(null===(lp=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===lp?void 0:lp.mobile)||/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test(navigator.appVersion),Op=document.createElement('video'),Cp={mse:Boolean(window.MediaSource&&window.MediaStreamTrack&&(null===(hp=null===(pp=window.SourceBuffer)||void 0===pp?void 0:pp.prototype)||void 0===hp?void 0:hp.appendBuffer)),hls:Boolean((null===(fp=Op.canPlayType)||void 0===fp?void 0:fp.call(Op,'application/x-mpegurl'))||(null===(vp=Op.canPlayType)||void 0===vp?void 0:vp.call(Op,'vnd.apple.mpegURL')))},Np={mp4:Boolean(null===(mp=Op.canPlayType)||void 0===mp?void 0:mp.call(Op,'video/mp4')),webm:Boolean(null===(Sp=Op.canPlayType)||void 0===Sp?void 0:Sp.call(Op,'video/webm'))},Mp={h264:Boolean(null===(yp=null===(gp=window.MediaSource)||void 0===gp?void 0:gp.isTypeSupported)||void 0===yp?void 0:yp.call(gp,'video/mp4; codecs="avc1.42000a,mp4a.40.2"')),h265:Boolean(null===(Tp=null===(bp=window.MediaSource)||void 0===bp?void 0:bp.isTypeSupported)||void 0===Tp?void 0:Tp.call(bp,'video/mp4; codecs="hev1.1.6.L93.B0"')),vp9:Boolean(null===(wp=null===(Ep=window.MediaSource)||void 0===Ep?void 0:Ep.isTypeSupported)||void 0===wp?void 0:wp.call(Ep,'video/webm; codecs="vp9"')),aac:Boolean(null===(Ap=null===(Pp=window.MediaSource)||void 0===Pp?void 0:Pp.isTypeSupported)||void 0===Ap?void 0:Ap.call(Pp,'audio/mp4; codecs="mp4a.40.2"')),opus:Boolean(null===($p=null===(kp=window.MediaSource)||void 0===kp?void 0:kp.isTypeSupported)||void 0===$p?void 0:$p.call(kp,'audio/webm; codecs="opus"'))},Bp=(Mp.h264||Mp.h265)&&Mp.aac,Up=!xp,Vp=Lp||xp,Fp=!Cp.hls||!Vp,Hp=3e4,qp=18e4,Gp=3,Yp=100,jp={cacheDuration:12e4},zp={maxPausedTime:3e4,chunkDuration:5e3,optimalBufferDuration:1e4,maxParallelRequests:5},Qp={maxPausedTime:3e4},Wp={maxPausedTime:3e4},Jp=function(){function a(n){this.current$=new t({type:void 0}),this.providerError$=new e,this.noAvailableProvidersError$=new e,this.providerOutput={position$:new t(0),duration$:new t(1/0),volume$:new t({muted:!1,volume:1}),currentVideoTrack$:new t(void 0),availableVideoTracks$:new t([]),currentBuffer$:new t(void 0),isBuffering$:new t(!0),error$:new e,willSeekEvent$:new e,seekedEvent$:new e,endedEvent$:new e,firstBytesEvent$:new e,firstFrameEvent$:new e,isLive$:new t(void 0),liveTime$:new t(void 0),availableTextTracks$:new t([]),currentTextTrack$:new t(void 0),hostname$:new t(void 0),httpConnectionType$:new t(void 0),httpConnectionReused$:new t(void 0),element$:new t(void 0)},this.subscription=new r,this.params=n,this.log=this.params.dependencies.logger.createComponentLog('ProviderContainer');var a=this.params.tuning.formatsToAvoid,s=a.length?C(C([],O(n.screenFormatsPriority.filter((function(t){return!a.includes(t)}))),!1),O(n.screenFormatsPriority.filter((function(t){return a.includes(t)}))),!1):n.screenFormatsPriority;this.screenFormatsIterator=new Ip(s.filter((function(t){return i(n.sources[t])})).filter((function(t){switch(t){case A.DASH:return Cp.mse&&Np.mp4&&Bp&&Up;case A.DASH_SEP:case A.DASH_SEP_VK:return Cp.mse&&Np.mp4&&Bp;case A.DASH_WEBM:case A.DASH_WEBM_VK:case A.DASH_LIVE_WEBM:return Cp.mse&&Np.webm&&Mp.vp9&&Mp.opus;case A.DASH_LIVE:case A.DASH_ONDEMAND:return Cp.mse&&Np.mp4&&Bp;case A.HLS:case A.HLS_LIVE:case A.HLS_ONDEMAND:return Cp.hls&&Np.mp4&&Vp;case A.HLS_JS:return Cp.mse&&Np.mp4&&Bp&&Fp;case A.MPEG:return Np.mp4;default:return o(t)}}))),this.chromecastFormatsIterator=new Ip(n.chromecastFormatsPriority.filter((function(t){return i(n.sources[t])})))}return a.prototype.init=function(){var t=this;this.subscription.add(this.initProviderErrorHandling()),this.subscription.add(this.params.dependencies.chromecastInitializer.connection$.subscribe((function(){t.reinitProvider()})))},a.prototype.destroy=function(){this.destroyProvider(),this.current$.next({type:void 0}),this.subscription.unsubscribe()},a.prototype.initProvider=function(){var t=this.chooseDestination(),e=this.chooseFormat(t);if(n(e))this.handleNoFormatsError(t);else{var r;try{r=this.createProvider(t,e)}catch(t){this.providerError$.next({id:'ProviderNotConstructed',message:'Failed to create provider',thrown:t})}r?this.current$.next({type:e,provider:r,destination:t}):this.switchToNextProvider()}},a.prototype.reinitProvider=function(){this.destroyProvider(),this.initProvider()},a.prototype.switchToNextProvider=function(){this.destroyProvider();var t=this.current$.getValue().destination;p(t),this.skipFormat(t),this.initProvider()},a.prototype.destroyProvider=function(){var t=this.current$.getValue().provider;if(t){this.log({message:'destroyProvider'});var e=this.params.desiredState.seekPosition,r=e.getTransition();r?i(r.from)&&e.startTransitionTo(r.from):e.startTransitionTo(this.providerOutput.position$.getValue()),t.destroy();var n=this.providerOutput.isBuffering$;n.getValue()||n.next(!0)}},a.prototype.createProvider=function(t,e){switch(this.log({message:'createProvider: '.concat(t,':').concat(e)}),t){case k.SCREEN:return this.createScreenProvider(e);case k.CHROMECAST:return this.createChromecastProvider(e);default:return o(t)}},a.prototype.createScreenProvider=function(t){var e=this.params,r=e.sources,i=e.container,n=e.desiredState,a=this.providerOutput;switch(t){case A.DASH:var s=r[t];return p(s),new xl({container:i,source:s,desiredState:n,output:a,config:jp,dependencies:this.params.dependencies,tuning:this.params.tuning});case A.DASH_SEP_VK:case A.DASH_WEBM_VK:s=r[t];return p(s),new bl({container:i,source:s,desiredState:n,output:a,dependencies:this.params.dependencies,tuning:this.params.tuning});case A.DASH_SEP:case A.DASH_WEBM:case A.DASH_ONDEMAND:case A.DASH_LIVE_WEBM:s=r[t];return p(s),new Fl({container:i,source:s,desiredState:n,output:a,format:t,config:Wp,dependencies:this.params.dependencies,tuning:this.params.tuning});case A.HLS:case A.HLS_ONDEMAND:s=r[t];return p(s),new op({container:i,source:s,desiredState:n,output:a,dependencies:this.params.dependencies,tuning:this.params.tuning});case A.HLS_LIVE:s=r[t];return p(s),new up({container:i,source:s,desiredState:n,output:a,config:Qp,dependencies:this.params.dependencies,tuning:this.params.tuning});case A.HLS_JS:s=r[t];return p(s),new Rp({container:i,source:s,desiredState:n,output:a,dependencies:this.params.dependencies,tuning:this.params.tuning});case A.MPEG:s=r[t];return p(s),new kl({container:i,source:s,desiredState:n,output:a,dependencies:this.params.dependencies,tuning:this.params.tuning});case A.DASH_LIVE:s=r[t];return p(s),new tp({container:i,source:s,desiredState:n,output:a,config:zp,dependencies:this.params.dependencies,tuning:this.params.tuning});default:return o(t)}},a.prototype.createChromecastProvider=function(t){var e=this.params,r=e.sources,i=e.container,n=e.desiredState,a=e.meta,o=this.providerOutput,s=this.params.dependencies.chromecastInitializer.connection$.getValue();return p(s),new Pl({connection:s,meta:a,container:i,source:r,format:t,desiredState:n,output:o,dependencies:this.params.dependencies,tuning:this.params.tuning})},a.prototype.chooseDestination=function(){return this.params.dependencies.chromecastInitializer.connection$.getValue()?k.CHROMECAST:k.SCREEN},a.prototype.chooseFormat=function(t){switch(t){case k.SCREEN:return this.screenFormatsIterator.isCompleted()?void 0:this.screenFormatsIterator.getValue();case k.CHROMECAST:return this.chromecastFormatsIterator.isCompleted()?void 0:this.chromecastFormatsIterator.getValue();default:return o(t)}},a.prototype.skipFormat=function(t){switch(t){case k.SCREEN:return this.screenFormatsIterator.next();case k.CHROMECAST:return this.chromecastFormatsIterator.next();default:return o(t)}},a.prototype.handleNoFormatsError=function(t){switch(t){case k.SCREEN:return this.noAvailableProvidersError$.next(),void this.current$.next({type:void 0});case k.CHROMECAST:return void this.params.dependencies.chromecastInitializer.disconnect();default:return o(t)}},a.prototype.initProviderErrorHandling=function(){var e,n=this,a=[],o=0,u=new r;return u.add(s(this.providerOutput.error$,(e={desiredPlaybackState$:this.params.desiredState.playbackState,maxTransitionInterval:Hp,position$:this.providerOutput.position$,providerChanged$:this.current$},new h((function(i){var n=new r,a=y(e.maxTransitionInterval),o=new t(void 0);s(e.desiredPlaybackState$.stateChangeStarted$.pipe(b(a)),e.desiredPlaybackState$.stateChangeEnded$.pipe(b(void 0)),e.providerChanged$.pipe(c((function(){return o.getValue()})))).subscribe(o);var u=new r;return n.add(u),n.add(o.subscribe((function(t){u.unsubscribe(),t&&u.add(t.subscribe(i))}))),n}))).pipe(b({id:'ProviderHangup',message:'An operation failed to complete within reasonable time'}))).subscribe(this.providerError$)),u.add(this.providerError$.pipe(T(Yp,{leading:!1,trailing:!0})).subscribe((function(){var t=Date.now();n.current$.getValue().destination===k.CHROMECAST?(n.destroyProvider(),n.params.dependencies.chromecastInitializer.stopMedia().then((function(){n.switchToNextProvider()}),(function(){n.params.dependencies.chromecastInitializer.disconnect()}))):i(a[o])&&t<a[o]+qp?(a=[],n.switchToNextProvider()):(a[o]=t,n.reinitProvider()),o=(o+1)%Gp}))),u},a}(),Kp=function(t,e,r){return r*e+(1-r)*t},Xp=function(){function e(e){var r;this.prevReported=void 0,this.params=e,this.slow=this.fast=this.smoothed=this.prevReported=e.initial,this.smoothed$=new t(e.initial),this.debounced$=new t(e.initial);var i=null!==(r=e.label)&&void 0!==r?r:'value'+Math.random().toString(16).substring(2,6);this.rawSeries$=new Gi('raw_'.concat(i)),this.smoothedSeries$=new Gi('smoothed_'.concat(i)),this.reportedSeries$=new Gi('reported_'.concat(i))}return e.prototype.next=function(t){this.slow=Kp(this.slow,t,this.params.emaAlphaSlow),this.fast=Kp(this.fast,t,this.params.emaAlphaFast);var e=this.params.fastDirection>0?Math.max:Math.min;this.smoothed=e(this.slow,this.fast),this.smoothed$.next(this.smoothed),(n(this.prevReported)||Math.abs(this.smoothed-this.prevReported)/this.prevReported>=this.params.changeThreshold)&&(this.prevReported=this.smoothed,this.debounced$.next(this.smoothed),this.reportedSeries$.next(this.smoothed)),this.rawSeries$.next(t),this.smoothedSeries$.next(this.smoothed)},e}();!function(t){t[t.LOCAL_STORAGE=0]='LOCAL_STORAGE',t[t.SESSION_STORAGE=1]='SESSION_STORAGE',t[t.RUNTIME=2]='RUNTIME'}(_p||(_p={}));var Zp=new Map,th=_p.RUNTIME,eh='vk-videoplayer-dummy-key-'.concat(Math.random());!function(){try{localStorage.setItem(eh,'test'),localStorage.removeItem(eh),th=_p.LOCAL_STORAGE}catch(t){if(!(t instanceof DOMException))throw t;try{sessionStorage.getItem(eh),th=_p.SESSION_STORAGE}catch(t){if(!(t instanceof DOMException))throw t;th=_p.RUNTIME}}}();var rh,ih=function(t,e){switch(th){case _p.LOCAL_STORAGE:try{localStorage.setItem(t,e)}catch(t){if(!(t instanceof DOMException))throw t;console.error(t)}break;case _p.SESSION_STORAGE:try{sessionStorage.setItem(t,e)}catch(t){if(!(t instanceof DOMException))throw t;console.error(t)}break;case _p.RUNTIME:return void Zp.set(t,e);default:o(th)}},nh=window.navigator.connection,ah=function(){var t=null==nh?void 0:nh.downlink;if(i(t)&&10!==t)return 1e3*t},oh=function(){var t=null==nh?void 0:nh.rtt;if(i(t)&&3e3!==t)return t},sh=function(t,e,r){var i=8*r;return i/(i/t+e)},uh=function(){function e(n){var o,s,u=this;this.subscription=new r,this.tuningConfig=n;var d=e.load('one_video_throughput')||(n.useBrowserEstimation?ah():void 0)||5e3,l=null!==(s=null!==(o=e.load('one_video_rtt'))&&void 0!==o?o:n.useBrowserEstimation?oh():void 0)&&void 0!==s?s:0;if(this.throughput$=new t(d),this.rtt$=new t(l),this.rttAdjustedThroughput$=new t(sh(d,l,n.rttPenaltyRequestSize)),this.throughput=new Xp({initial:d,emaAlphaSlow:n.emaAlphaSlow,emaAlphaFast:n.emaAlphaFast,changeThreshold:n.changeThreshold,fastDirection:-1,label:'throughput'}),this.rtt=new Xp({initial:l,emaAlphaSlow:n.emaAlphaSlow,emaAlphaFast:n.emaAlphaFast,changeThreshold:n.changeThreshold,fastDirection:1,label:'rtt'}),n.useBrowserEstimation){var p=function(){var t=ah();t&&u.throughput.next(t);var e=oh();i(e)&&u.rtt.next(e)};nh&&'onchange'in nh&&this.subscription.add(a(nh,'change').subscribe(p)),p()}this.subscription.add(this.throughput.smoothed$.subscribe((function(t){ih('one_video_throughput',t.toFixed(0))}))),this.subscription.add(this.rtt.smoothed$.subscribe((function(t){ih('one_video_rtt',t.toFixed(0))}))),this.subscription.add(this.throughput.debounced$.subscribe(this.throughput$)),this.subscription.add(this.rtt.debounced$.subscribe(this.rtt$)),this.subscription.add(S({throughput:this.throughput.smoothed$,rtt:this.rtt.smoothed$}).pipe(c((function(t){var e=t.throughput,r=t.rtt;return sh(e,r,n.rttPenaltyRequestSize)})),g((function(t){var e=u.rttAdjustedThroughput$.getValue()||0;return Math.abs(t-e)/e>=n.changeThreshold}))).subscribe(this.rttAdjustedThroughput$))}return e.prototype.destroy=function(){this.subscription.unsubscribe()},e.prototype.trackXHR=function(t){var e=this,i=0,n=m(),o=new r;switch(this.subscription.add(o),t.readyState){case 4:break;case 3:case 2:o.add(a(t,'progress').pipe(f()).subscribe((function(t){i=t.loaded,n=m()})));break;case 1:case 0:o.add(a(t,'loadstart').subscribe((function(){i=0,n=m()})))}o.add(a(t,'loadend').subscribe((function(r){if(200===t.status){var a=r.loaded,s=m(),u=a-i,c=s-n;e.addRawSpeed(u,c)}o.unsubscribe()})))},e.prototype.trackStream=function(t){var e=this,r=t.getReader();if(r){var i=0,n=m(),a=0,o=m(),s=function(e){r.releaseLock(),t.cancel('Throughput Estimator error: '.concat(e)).catch((function(){}))},u=function(t){var c=t.done,d=t.value;return I(e,void 0,void 0,(function(){return x(this,(function(t){switch(t.label){case 0:return c?(this.addRawSpeed(i,m()-n),[3,3]):[3,1];case 1:return d?(i+=d.byteLength,(a+=d.byteLength)>=this.tuningConfig.streamMinSampleSize&&m()-o>=this.tuningConfig.streamMinSampleTime&&(this.addRawSpeed(a,m()-o),a=0,o=m()),[4,null==r?void 0:r.read().then(u,s)]):[3,3];case 2:t.sent(),t.label=3;case 3:return[2]}}))}))};null==r||r.read().then(u,s)}else t.cancel('Could not get reader')},e.prototype.addRawSpeed=function(t,r){if(e.sanityCheck(t,r)){var i=8*t/r;this.throughput.next(i)}},e.prototype.addRawThroughput=function(t){this.throughput.next(t)},e.prototype.addRawRtt=function(t){this.rtt.next(t)},e.sanityCheck=function(t,e){var r=8*t/e;return!(!r||!isFinite(r))&&(!(r>1e6)&&(!(r<30)&&(!(t<10240)&&!(e<=20))))},e.load=function(t){var e,r=function(t){var e,r;switch(th){case _p.LOCAL_STORAGE:return null!==(e=localStorage.getItem(t))&&void 0!==e?e:void 0;case _p.SESSION_STORAGE:return null!==(r=sessionStorage.getItem(t))&&void 0!==r?r:void 0;case _p.RUNTIME:return Zp.get(t);default:o(th)}}(t);if(i(r))return null!==(e=parseInt(r,10))&&void 0!==e?e:void 0},e}(),ch=function(t){return void 0===t&&(t=function(t){return t}),function(e){var a=e.playbackState,o=e.seekPosition,u=e.playbackAbort$,d=e.position$;return new h((function(e){var l,p=a.transitionEnded$.pipe(g((function(t){return(t.from===P.PAUSED||t.from===P.STOPPED)&&t.to===P.PLAYING}))),h=a.stateChangeEnded$.pipe(g((function(t){return t.from===P.PLAYING&&t.to===P.PAUSED}))),f=o.stateChangeEnded$.pipe(g((function(t){var e,r;return i(t.to)&&(null!==(r=null===(e=a.getTransition())||void 0===e?void 0:e.from)&&void 0!==r?r:a.getState())===P.PLAYING}))),v=o.stateChangeEnded$.pipe(g((function(t){var e,r;return n(t.to)&&(null!==(r=null===(e=a.getTransition())||void 0===e?void 0:e.from)&&void 0!==r?r:a.getState())===P.PLAYING}))),m=s(p,v).pipe(c((function(){return t(d.getValue())}))),S=s(h,f,u).pipe(c((function(){return t(d.getValue())})));return(new r).add(m.subscribe((function(e){l=t(e)}))).add(S.subscribe((function(r){if(!n(l)){var i={start:l,end:t(r)};l=void 0,e.next(i)}})))}))}},dh=ch((function(t){return t})),lh=ch((function(t){return Math.round(1e3*t)+Date.now()})),ph=((rh={})[k.SCREEN]={vod:[A.HLS,A.HLS_ONDEMAND,A.DASH_WEBM_VK,A.DASH_WEBM,A.DASH,A.DASH_SEP_VK,A.DASH_SEP,A.DASH_ONDEMAND,A.HLS_JS,A.MPEG],live:[A.HLS_LIVE,A.DASH_LIVE,A.DASH_LIVE_WEBM]},rh[k.CHROMECAST]={vod:[A.DASH_WEBM_VK,A.DASH_WEBM,A.DASH_SEP_VK,A.DASH_SEP,A.DASH_ONDEMAND,A.HLS,A.HLS_ONDEMAND,A.MPEG],live:[A.HLS_LIVE]},rh),hh=function(){function o(i){void 0===i&&(i={});var n=this;if(this.subscription=new r,this.logger=new E,this.isPlaybackStarted=!1,this.desiredState={playbackState:new Ji(P.STOPPED),seekPosition:new Ji(void 0),volume:new Ji({volume:1,muted:!1}),videoTrack:new Ji(void 0),autoVideoTrackSwitching:new Ji(!0),isLooped:new Ji(!1),externalTextTracks:new Ji([]),currentTextTrack:new Ji(void 0),textTrackCuesSettings:new Ji({})},this.info={playbackState$:new t(P.STOPPED),position$:new t(0),duration$:new t(1/0),muted$:new t(!1),volume$:new t(1),availableQualities$:new t([]),availableQualitiesFps$:new t({}),currentQuality$:new t(void 0),isAutoQualityEnabled$:new t(!0),currentBuffer$:new t(void 0),isBuffering$:new t(!0),isStalled$:new t(!1),isEnded$:new t(!1),isLooped$:new t(!1),isLive$:new t(void 0),liveTime$:new t(void 0),currentFormat$:new t(void 0),availableTextTracks$:new t([]),currentTextTrack$:new t(void 0),throughputEstimation$:new t(void 0),rttEstimation$:new t(void 0),videoBitrate$:new t(void 0),hostname$:new t(void 0),httpConnectionType$:new t(void 0),httpConnectionReused$:new t(void 0),chromecastState$:new t($.NOT_AVAILABLE),chromecastDeviceName$:new t(void 0),intrinsicVideoSize$:new t(void 0)},this.events={started$:new e,startAttempt$:new e,willPause$:new e,willResume$:new e,willDestruct$:new e,watchCoverageRecord$:new e,watchCoverageLive$:new e,managedError$:new e,fatalError$:new e,ended$:new e,seeked$:new e,willSeek$:new e,firstBytes$:new e,firstFrame$:new e,log$:new e},this.experimental={element$:new t(void 0),enableDebugTelemetry$:new t(!1),dumpTelemetry:Hi},this.initLogs(),this.tuning=function(t){var e,r,i={};try{for(var n=L(Object.keys(N)),a=n.next();!a.done;a=n.next()){var o=a.value,s=N[o],u=t[o];Array.isArray(s)&&Array.isArray(u)?i[o]=u:i[o]='object'==typeof s&&'object'==typeof u?R(R({},s),u):null!=u?u:s}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}return i}(i),this.chromecastInitializer=new M({receiverApplicationId:i.chromecastReceiverId,isDisabled:i.disableChromecast,dependencies:{logger:this.logger}}),this.throughputEstimator=new uh(this.tuning.throughputEstimator),this.initChromecastSubscription(),this.initDesiredStateSubscriptions(),Proxy&&Reflect)return new Proxy(this,{get:function(t,e,r){var i=Reflect.get(t,e,r);return'function'!=typeof i?i:function(){for(var r=[],a=0;a<arguments.length;a++)r[a]=arguments[a];try{return i.apply(t,r)}catch(t){var o=r.map((function(t){return JSON.stringify(t,(function(t,e){var r=typeof e;return['number','string','boolean'].includes(r)?e:null===e?null:'<'.concat(r,'>')}))})),s='Player.'.concat(String(e)),u='Exception calling '.concat(s,' (').concat(o.join(', '),')');throw n.events.fatalError$.next({id:s,message:u,thrown:t}),t}}}})}return o.prototype.initVideo=function(t){var e,r;return this.config=t,this.domContainer=function(t){var e='string'==typeof t.container?document.getElementById(t.container):t.container;return p(e,'Wrong container or containerId {'.concat(t.container,'}')),e}(t),this.chromecastInitializer.contentId=null===(e=t.meta)||void 0===e?void 0:e.videoId,this.providerContainer=new Jp({screenFormatsPriority:C(C([],O(ph[k.SCREEN].live),!1),O(ph[k.SCREEN].vod),!1),chromecastFormatsPriority:C(C([],O(ph[k.CHROMECAST].live),!1),O(ph[k.CHROMECAST].vod),!1),sources:t.sources,meta:null!==(r=t.meta)&&void 0!==r?r:{},container:this.domContainer,desiredState:this.desiredState,dependencies:{throughputEstimator:this.throughputEstimator,chromecastInitializer:this.chromecastInitializer,logger:this.logger},tuning:this.tuning}),this.initProviderContainerSubscription(this.providerContainer),this.initStartingVideoTrack(this.providerContainer),this.providerContainer.init(),this.initDebugTelemetry(),this},o.prototype.destroy=function(){var t;this.events.willDestruct$.next(),null===(t=this.providerContainer)||void 0===t||t.destroy(),this.throughputEstimator.destroy(),this.chromecastInitializer.destroy(),this.subscription.unsubscribe()},o.prototype.play=function(){var t=this.desiredState.playbackState;return t.getState()!==P.PLAYING&&t.startTransitionTo(P.PLAYING),this},o.prototype.pause=function(){var t=this.desiredState.playbackState;return t.getState()!==P.PAUSED&&t.startTransitionTo(P.PAUSED),this},o.prototype.stop=function(){var t=this.desiredState.playbackState;return t.getState()!==P.STOPPED&&t.startTransitionTo(P.STOPPED),this},o.prototype.seekTime=function(t){return this.events.willSeek$.next({from:this.getExactTime(),to:t}),this.desiredState.seekPosition.startTransitionTo(t),this},o.prototype.seekPercent=function(t){var e=this.info.duration$.getValue();return isFinite(e)&&this.seekTime(Math.abs(e)*t),this},o.prototype.setVolume=function(t){return this.chromecastInitializer.castState$.getValue()===$.CONNECTED?this.chromecastInitializer.setVolume(t):this.desiredState.volume.startTransitionTo({volume:t,muted:this.desiredState.volume.getState().muted}),this},o.prototype.setMuted=function(t){return this.chromecastInitializer.castState$.getValue()===$.CONNECTED?this.chromecastInitializer.setMuted(t):this.desiredState.volume.startTransitionTo({volume:this.desiredState.volume.getState().volume,muted:t}),this},o.prototype.setQuality=function(t){p(this.providerContainer);var e=this.providerContainer.providerOutput.availableVideoTracks$.getValue();e.length||(this.explicitInitialQuality=t);var r=e.find((function(e){return e.quality===t}));return r&&this.desiredState.videoTrack.startTransitionTo(r.id),this},o.prototype.setAutoQuality=function(t){return this.desiredState.autoVideoTrackSwitching.startTransitionTo(t),this},o.prototype.setExternalTextTracks=function(t){return this.desiredState.externalTextTracks.startTransitionTo(t.map((function(t){return R({type:'external'},t)}))),this},o.prototype.selectTextTrack=function(t){var e;return(void 0===t||(null===(e=this.providerContainer)||void 0===e?void 0:e.providerOutput.availableTextTracks$.getValue().find((function(e){return e.id===t}))))&&this.desiredState.currentTextTrack.startTransitionTo(t),this},o.prototype.setTextTrackCueSettings=function(t){return this.desiredState.textTrackCuesSettings.startTransitionTo(t),this},o.prototype.setLooped=function(t){return this.desiredState.isLooped.startTransitionTo(t),this},o.prototype.toggleChromecast=function(){this.chromecastInitializer.toggleConnection()},o.prototype.getExactTime=function(){var t;p(this.providerContainer);var e=this.providerContainer.providerOutput.element$.getValue();if(n(e))return this.info.position$.getValue();var r=this.desiredState.seekPosition.getTransition(),a=null!==(t=null==r?void 0:r.to)&&void 0!==t?t:null==r?void 0:r.from;return i(a)?a:e.currentTime},o.prototype.getAllLogs=function(){return this.logger.getAllLogs()},o.prototype.initDesiredStateSubscriptions=function(){var t=this;this.subscription.add(s(this.desiredState.playbackState.stateChangeStarted$,this.desiredState.playbackState.forceChanged$).pipe(c((function(t){return t.to}))).subscribe(this.info.playbackState$)).add(this.desiredState.isLooped.stateChangeEnded$.pipe(c((function(t){return t.to}))).subscribe(this.info.isLooped$)).add(this.desiredState.autoVideoTrackSwitching.stateChangeEnded$.pipe(c((function(t){return t.to}))).subscribe(this.info.isAutoQualityEnabled$));var e=new r;this.subscription.add(e),this.subscription.add(this.desiredState.playbackState.stateChangeStarted$.pipe(g((function(t){return t.to===P.PLAYING}))).subscribe((function(){e.unsubscribe(),e.add(t.desiredState.playbackState.stateChangeEnded$.pipe(g((function(t){return t.to===P.PLAYING||t.to===P.PAUSED})),v(0),f()).subscribe((function(e){var r=e.to===P.PLAYING,i=t.info.muted$.getValue(),n=r?i?_.SuccessWithoutSound:_.SuccessWithSound:_.Failed;t.events.startAttempt$.next(n)})))}))),this.subscription.add(this.desiredState.playbackState.stateChangeEnded$.pipe(g((function(t){return t.to===P.PLAYING})),v(0)).subscribe((function(){if(!t.isPlaybackStarted){var e=t.info.muted$.getValue();t.isPlaybackStarted=!0,t.events.started$.next(e)}}))).add(this.desiredState.playbackState.stateChangeStarted$.subscribe((function(e){switch(e.to){case P.PAUSED:t.events.willPause$.next();break;case P.PLAYING:t.isPlaybackStarted&&t.events.willResume$.next()}})))},o.prototype.initProviderContainerSubscription=function(e){var o=this;this.subscription.add(e.providerOutput.willSeekEvent$.subscribe((function(){var t=o.desiredState.seekPosition.getTransition(),e=null==t?void 0:t.to;i(e)&&(o.desiredState.seekPosition.setState(e),o.desiredState.seekPosition.startTransitionTo(void 0))}))).add(e.providerOutput.seekedEvent$.subscribe((function(){var t=o.desiredState.seekPosition.getTransition();i(null==t?void 0:t.to)||o.desiredState.seekPosition.setState(void 0),o.events.seeked$.next()}))).add(e.current$.pipe(c((function(t){return t.type}))).subscribe(this.info.currentFormat$)).add(e.current$.pipe(c((function(t){return t.destination})),l()).subscribe((function(){o.isPlaybackStarted=!1}))).add(e.providerOutput.availableVideoTracks$.pipe(c((function(t){return t.map((function(t){return t.quality})).sort((function(t,e){return Ui(t)?1:Ui(e)?-1:Ci(e,t)?1:-1}))}))).subscribe(this.info.availableQualities$)).add(e.providerOutput.availableVideoTracks$.subscribe((function(t){var e,r,i={};try{for(var n=L(t),a=n.next();!a.done;a=n.next()){var s=a.value;s.fps&&(i[s.quality]=s.fps)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}o.info.availableQualitiesFps$.next(i)}))).add(e.providerOutput.currentVideoTrack$.subscribe((function(t){o.info.currentQuality$.next(null==t?void 0:t.quality),o.info.videoBitrate$.next(null==t?void 0:t.bitrate);var r=e.providerOutput.element$.getValue();r&&o.info.intrinsicVideoSize$.next({width:r.videoWidth,height:r.videoHeight})}))).add(e.providerOutput.hostname$.pipe(l()).subscribe(this.info.hostname$)).add(e.providerOutput.httpConnectionType$.pipe(l()).subscribe(this.info.httpConnectionType$)).add(e.providerOutput.httpConnectionReused$.pipe(l()).subscribe(this.info.httpConnectionReused$)).add(e.providerOutput.currentTextTrack$.subscribe(this.info.currentTextTrack$)).add(e.providerOutput.availableTextTracks$.subscribe(this.info.availableTextTracks$)).add(e.providerOutput.currentBuffer$.subscribe(this.info.currentBuffer$)).add(e.providerOutput.duration$.subscribe(this.info.duration$)).add(e.providerOutput.isBuffering$.subscribe(this.info.isBuffering$)).add(e.providerOutput.isLive$.subscribe(this.info.isLive$)).add(e.providerOutput.liveTime$.subscribe(this.info.liveTime$)).add(e.providerOutput.volume$.pipe(c((function(t){return t.muted})),l()).subscribe(this.info.muted$)).add(e.providerOutput.volume$.pipe(c((function(t){return t.volume})),l()).subscribe(this.info.volume$)).add(function(t){var e=t.seekPosition,r=t.position$;return s(e.stateChangeStarted$.pipe(c((function(t){return t.to})),g(i)),r.pipe(g((function(){return n(e.getState())&&n(e.getTransition())}))))}({seekPosition:this.desiredState.seekPosition,position$:e.providerOutput.position$}).subscribe(this.info.position$)).add(s(e.providerOutput.endedEvent$.pipe(b(!0)),e.providerOutput.seekedEvent$.pipe(b(!1))).pipe(l()).subscribe(this.info.isEnded$)).add(e.providerOutput.endedEvent$.subscribe(this.events.ended$)).add(e.providerError$.subscribe(this.events.managedError$)).add(e.noAvailableProvidersError$.pipe(c((function(t){return{id:'NoProviders',message:'No suitable providers or all providers failed'}}))).subscribe(this.events.fatalError$)).add(e.providerOutput.element$.subscribe(this.experimental.element$)).add(e.providerOutput.firstBytesEvent$.subscribe(this.events.firstBytes$)).add(e.providerOutput.firstFrameEvent$.subscribe(this.events.firstFrame$)).add(this.throughputEstimator.throughput$.subscribe(this.info.throughputEstimation$)).add(this.throughputEstimator.rtt$.subscribe(this.info.rttEstimation$));var u=new t(!1);this.subscription.add(e.providerOutput.seekedEvent$.subscribe((function(){return u.next(!1)}))).add(e.providerOutput.willSeekEvent$.subscribe((function(){return u.next(!0)})));var d=new t(!0);this.subscription.add(e.current$.subscribe((function(){return d.next(!0)}))).add(this.desiredState.playbackState.stateChangeEnded$.pipe(g((function(t){return t.to===P.PLAYING})),f()).subscribe((function(){return d.next(!1)})));var h=0,v=s(e.providerOutput.isBuffering$,u,d).pipe(c((function(){var t=e.providerOutput.isBuffering$.getValue(),r=u.getValue()||d.getValue();return t&&!r})),l());this.subscription.add(v.subscribe((function(t){t?h=window.setTimeout((function(){return o.info.isStalled$.next(!0)}),o.tuning.stallIgnoreThreshold):(window.clearTimeout(h),o.info.isStalled$.next(!1))})));var m=new r;this.subscription.add(m);var S=s(a(window,'beforeunload'),this.events.willDestruct$,e.current$.pipe(g((function(t){return Boolean(null==t?void 0:t.provider)}))));e.providerOutput.isLive$.pipe(l()).subscribe((function(t){switch(p(o.providerContainer),m.unsubscribe(),t){case!0:m.add(lh({seekPosition:o.desiredState.seekPosition,playbackState:o.desiredState.playbackState,playbackAbort$:S,position$:o.providerContainer.providerOutput.position$}).subscribe(o.events.watchCoverageLive$));break;case!1:m.add(dh({seekPosition:o.desiredState.seekPosition,playbackState:o.desiredState.playbackState,playbackAbort$:S,position$:o.providerContainer.providerOutput.position$}).subscribe(o.events.watchCoverageRecord$))}}))},o.prototype.initChromecastSubscription=function(){this.subscription.add(this.chromecastInitializer.castState$.subscribe(this.info.chromecastState$)),this.subscription.add(this.chromecastInitializer.connection$.pipe(c((function(t){return null==t?void 0:t.castDevice.friendlyName}))).subscribe(this.info.chromecastDeviceName$)),this.subscription.add(this.chromecastInitializer.errorEvent$.subscribe(this.events.managedError$))},o.prototype.initStartingVideoTrack=function(t){var e=this,i=new r;this.subscription.add(i),this.subscription.add(t.current$.pipe(l((function(t,e){return t.provider===e.provider}))).subscribe((function(){i.unsubscribe(),i.add(t.providerOutput.availableVideoTracks$.pipe(g((function(t){return t.length>0})),f()).subscribe((function(t){e.setStartingVideoTrack(t)})))})))},o.prototype.setStartingVideoTrack=function(t){var e,r=this;this.explicitInitialQuality&&(e=t.find((function(t){return t.quality===r.explicitInitialQuality})),this.explicitInitialQuality=void 0),e||(e=ji(t,{container:this.domContainer.getBoundingClientRect(),throughput:this.throughputEstimator.throughput$.getValue(),tuning:this.tuning.autoTrackSelection,forwardBufferHealth:0})),this.desiredState.videoTrack.startTransitionTo(e.id),this.info.currentQuality$.next(e.quality),this.info.videoBitrate$.next(e.bitrate)},o.prototype.initLogs=function(){this.subscription.add(s(this.desiredState.videoTrack.stateChangeStarted$.pipe(c((function(t){return{transition:t,entity:'quality',type:'start'}}))),this.desiredState.videoTrack.stateChangeEnded$.pipe(c((function(t){return{transition:t,entity:'quality',type:'end'}}))),this.desiredState.autoVideoTrackSwitching.stateChangeStarted$.pipe(c((function(t){return{transition:t,entity:'autoQualityEnabled',type:'start'}}))),this.desiredState.autoVideoTrackSwitching.stateChangeEnded$.pipe(c((function(t){return{transition:t,entity:'autoQualityEnabled',type:'end'}}))),this.desiredState.seekPosition.stateChangeStarted$.pipe(c((function(t){return{transition:t,entity:'seekPosition',type:'start'}}))),this.desiredState.seekPosition.stateChangeEnded$.pipe(c((function(t){return{transition:t,entity:'seekPosition',type:'end'}}))),this.desiredState.playbackState.stateChangeStarted$.pipe(c((function(t){return{transition:t,entity:'playbackState',type:'start'}}))),this.desiredState.playbackState.stateChangeEnded$.pipe(c((function(t){return{transition:t,entity:'playbackState',type:'end'}})))).pipe(c((function(t){return{component:'desiredState',message:'['.concat(t.entity,' change] ').concat(t.type,': ').concat(JSON.stringify(t.transition))}}))).subscribe(this.logger.log)),this.subscription.add(this.logger.log$.subscribe(this.events.log$))},o.prototype.initDebugTelemetry=function(){var t,e=this,r=null===(t=this.providerContainer)||void 0===t?void 0:t.providerOutput;p(this.providerContainer),p(r),Fi={},this.experimental.enableDebugTelemetry$.next(this.tuning.enableTelemetryAtStart),[this.experimental.enableDebugTelemetry$.subscribe((function(t){Vi=t})),this.providerContainer.current$.subscribe((function(t){var e=t.type;return qi('provider',e)})),r.duration$.subscribe((function(t){return qi('duration',t)})),r.availableVideoTracks$.pipe(g((function(t){return!!t.length})),f()).subscribe((function(t){return qi('tracks',t)})),this.events.fatalError$.subscribe(new Gi('fatalError')),this.events.managedError$.subscribe(new Gi('managedError')),r.position$.subscribe(new Gi('position')),r.currentVideoTrack$.pipe(c((function(t){return null==t?void 0:t.quality}))).subscribe(new Gi('quality')),r.currentBuffer$.subscribe(new Gi('buffer')),r.isBuffering$.subscribe(new Gi('isBuffering'))].forEach((function(t){return e.subscription.add(t)})),qi('codecs',Object.keys(Mp).filter((function(t){return Mp[t]})))},o}(),fh=''.concat('@vkontakte/videoplayer-core','@').concat('2.0.42');export{$ as ChromecastState,D as HttpConnectionType,P as PlaybackState,hh as Player,fh as SDK_VERSION,_ as StartStatus,A as VideoFormat,yi as VideoQuality};
|