@vkontakte/videoplayer-core 2.0.94 → 2.0.95
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 +7 -7
- package/es2015.esm.js +5 -5
- package/es2018.cjs.js +5 -5
- package/es2018.esm.js +5 -5
- package/esnext.cjs.js +5 -5
- package/esnext.esm.js +5 -5
- package/evergreen.esm.js +5 -5
- package/package.json +1 -1
package/es2015.esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-core v2.0.
|
|
3
|
-
*
|
|
4
|
-
* https://st.mycdn.me/static/vkontakte-videoplayer/2-0-
|
|
2
|
+
* @vkontakte/videoplayer-core v2.0.95
|
|
3
|
+
* Tue, 12 Dec 2023 10:39:51 GMT
|
|
4
|
+
* https://st.mycdn.me/static/vkontakte-videoplayer/2-0-95/doc/
|
|
5
5
|
*/
|
|
6
|
-
import{ValueSubject as S,Subject as x,Subscription as ae,isNonNullable as k,ErrorCategory as L,isNullable as ie,fromEvent as B,assertNever as H,merge as V,tap as Is,map as w,observableFrom as De,filterChanged as ve,assertNonNullable as P,debounce as je,getHighestQuality as Tl,timeout as El,getCurrentBrowser as Ua,CurrentClientBrowser as yd,combine as Ne,once as ge,mapTo as ui,filter as re,now as me,videoSizeToQuality as Vt,isInvariantQuality as Oi,isHigher as Ii,isLower as ws,isHigherOrEqual as pa,isLowerOrEqual as Td,Observable as Hs,interval as Cs,VideoQuality as He,videoQualityToHeight as $l,abortable as Oe,getExponentialDelay as kn,throttle as Al,CurrentClientDevice as _l,safeStorage as vr,fillWithDefault as wl,Logger as kl}from"@vkontakte/videoplayer-shared/es2015.esm.js";import{Observable as BT,Subject as NT,Subscription as FT,ValueSubject as UT,VideoQuality as VT}from"@vkontakte/videoplayer-shared/es2015.esm.js";import Pl from"lodash/debounce.js";const Rl="2.0.94";var p;(function(s){s.STOPPED="stopped",s.READY="ready",s.PLAYING="playing",s.PAUSED="paused"})(p||(p={}));var y;(function(s){s.MPEG="MPEG",s.DASH="DASH",s.DASH_SEP="DASH_SEP",s.DASH_SEP_VK="DASH_SEP",s.DASH_WEBM="DASH_WEBM",s.DASH_WEBM_AV1="DASH_WEBM_AV1",s.DASH_WEBM_VK="DASH_WEBM",s.DASH_ONDEMAND="DASH_ONDEMAND",s.DASH_ONDEMAND_VK="DASH_ONDEMAND",s.DASH_LIVE="DASH_LIVE",s.DASH_LIVE_CMAF="DASH_LIVE_CMAF",s.DASH_LIVE_WEBM="DASH_LIVE_WEBM",s.HLS="HLS",s.HLS_ONDEMAND="HLS_ONDEMAND",s.HLS_JS="HLS",s.HLS_LIVE="HLS_LIVE",s.HLS_LIVE_CMAF="HLS_LIVE_CMAF",s.WEB_RTC_LIVE="WEB_RTC_LIVE"})(y||(y={}));var we;(function(s){s.SCREEN="SCREEN",s.CHROMECAST="CHROMECAST"})(we||(we={}));var $e;(function(s){s.NOT_AVAILABLE="NOT_AVAILABLE",s.AVAILABLE="AVAILABLE",s.CONNECTING="CONNECTING",s.CONNECTED="CONNECTED"})($e||($e={}));var Mi;(function(s){s.HTTP1="http1",s.HTTP2="http2",s.QUIC="quic"})(Mi||(Mi={}));var W;(function(s){s.None="none",s.Requested="requested",s.Applying="applying"})(W||(W={}));var At;(function(s){s.NONE="none",s.INLINE="inline",s.FULLSCREEN="fullscreen",s.SECOND_SCREEN="second_screen",s.PIP="pip"})(At||(At={}));function ue(s,e,t,i){function r(a){return a instanceof t?a:new t(function(n){n(a)})}return new(t||(t=Promise))(function(a,n){function o(l){try{d(i.next(l))}catch(c){n(c)}}function u(l){try{d(i.throw(l))}catch(c){n(c)}}function d(l){l.done?a(l.value):r(l.value).then(o,u)}d((i=i.apply(s,e||[])).next())})}function M(s){return this instanceof M?(this.v=s,this):new M(s)}function Me(s,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=t.apply(s,e||[]),r,a=[];return r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r;function n(h){i[h]&&(r[h]=function(f){return new Promise(function(v,g){a.push([h,f,v,g])>1||o(h,f)})})}function o(h,f){try{u(i[h](f))}catch(v){c(a[0][3],v)}}function u(h){h.value instanceof M?Promise.resolve(h.value.v).then(d,l):c(a[0][2],h)}function d(h){o("next",h)}function l(h){o("throw",h)}function c(h,f){h(f),a.shift(),a.length&&o(a[0][0],a[0][1])}}var Dl=s=>new Promise((e,t)=>{const i=document.createElement("script");i.setAttribute("src",s),i.onload=()=>e,i.onerror=()=>t,document.body.appendChild(i)});class Il{constructor(e){var t;this.connection$=new S(void 0),this.castState$=new S($e.NOT_AVAILABLE),this.errorEvent$=new x,this.realCastState$=new S($e.NOT_AVAILABLE),this.subscription=new ae,this.params=e,this.log=this.params.dependencies.logger.createComponentLog("ChromecastInitializer");const i="chrome"in window;if(this.log({message:`[constructor] receiverApplicationId: ${this.params.receiverApplicationId}, isDisabled: ${this.params.isDisabled}, isSupported: ${i}`}),e.isDisabled||!i)return;const r=k((t=window.chrome)===null||t===void 0?void 0:t.cast),a=!!window.__onGCastApiAvailable;r?this.initializeCastApi():(window.__onGCastApiAvailable=n=>{delete window.__onGCastApiAvailable,n&&this.initializeCastApi()},a||Dl("https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1").catch(()=>this.errorEvent$.next({id:"ChromecastLoading",category:L.NETWORK,message:"Script loading failed!"})))}connect(){var e;(e=cast.framework.CastContext.getInstance())===null||e===void 0||e.requestSession()}disconnect(){var e,t;(t=(e=cast.framework.CastContext.getInstance())===null||e===void 0?void 0:e.getCurrentSession())===null||t===void 0||t.endSession(!0)}stopMedia(){return new Promise((e,t)=>{var i,r,a;(a=(r=(i=cast.framework.CastContext.getInstance())===null||i===void 0?void 0:i.getCurrentSession())===null||r===void 0?void 0:r.getMediaSession())===null||a===void 0||a.stop(new chrome.cast.media.StopRequest,e,t)})}toggleConnection(){k(this.connection$.getValue())?this.disconnect():this.connect()}setVolume(e){const t=this.connection$.getValue();ie(t)||(t.remotePlayer.volumeLevel=e,t.remotePlayerController.setVolumeLevel())}setMuted(e){const t=this.connection$.getValue();ie(t)||e!==t.remotePlayer.isMuted&&t.remotePlayerController.muteOrUnmute()}destroy(){this.subscription.unsubscribe()}initListeners(){const e=new cast.framework.RemotePlayer,t=new cast.framework.RemotePlayerController(e),i=cast.framework.CastContext.getInstance();this.subscription.add(B(i,cast.framework.CastContextEventType.SESSION_STATE_CHANGED).subscribe(r=>{var a,n;switch(r.sessionState){case cast.framework.SessionState.SESSION_STARTED:case cast.framework.SessionState.SESSION_STARTING:case cast.framework.SessionState.SESSION_RESUMED:this.contentId=(n=(a=i.getCurrentSession())===null||a===void 0?void 0:a.getMediaSession())===null||n===void 0?void 0:n.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:this.contentId=void 0;break;default:return H(r.sessionState)}})).add(V(B(i,cast.framework.CastContextEventType.CAST_STATE_CHANGED).pipe(Is(r=>{this.log({message:`[cast.framework.RemotePlayerEventType.CAST_STATE_CHANGED]: ${JSON.stringify(r)}`})}),w(r=>r.castState)),De([i.getCastState()])).pipe(ve(),w(Cl),Is(r=>{this.log({message:`realCastState$: ${r}`})})).subscribe(this.realCastState$)).add(this.realCastState$.subscribe(r=>{var a;const n=r===$e.CONNECTED,o=k(this.connection$.getValue());if(n&&!o){const u=i.getCurrentSession();P(u);const d=u.getCastDevice(),l=(a=u.getMediaSession())===null||a===void 0?void 0:a.media.contentId;(ie(l)||l===this.contentId)&&(this.log({message:"connection created"}),this.connection$.next({remotePlayer:e,remotePlayerController:t,session:u,castDevice:d}))}else!n&&o&&(this.log({message:"connection destroyed"}),this.connection$.next(void 0));this.castState$.next(r===$e.CONNECTED?k(this.connection$.getValue())?$e.CONNECTED:$e.AVAILABLE:r)}))}initializeCastApi(){var e;let t,i,r;try{t=cast.framework.CastContext.getInstance(),i=chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,r=chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}catch(a){return}try{t.setOptions({receiverApplicationId:(e=this.params.receiverApplicationId)!==null&&e!==void 0?e:i,autoJoinPolicy:r}),this.initListeners()}catch(a){this.errorEvent$.next({id:"ChromecastInitializer",category:L.EXTERNAL_API,message:"[initializeCastApi] failed",thrown:a})}}}const Cl=s=>{switch(s){case cast.framework.CastState.NO_DEVICES_AVAILABLE:return $e.NOT_AVAILABLE;case cast.framework.CastState.NOT_CONNECTED:return $e.AVAILABLE;case cast.framework.CastState.CONNECTING:return $e.CONNECTING;case cast.framework.CastState.CONNECTED:return $e.CONNECTED;default:return H(s)}};var mr=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Gs(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var qe=function(s){try{return!!s()}catch(e){return!0}},xl=qe,Ys=!xl(function(){var s=function(){}.bind();return typeof s!="function"||s.hasOwnProperty("prototype")}),Ed=Ys,$d=Function.prototype,va=$d.call,Ll=Ed&&$d.bind.bind(va,va),ze=Ed?Ll:function(s){return function(){return va.apply(s,arguments)}},Ad=ze,Ol=Ad({}.toString),Ml=Ad("".slice),Vi=function(s){return Ml(Ol(s),8,-1)},Bl=ze,Nl=qe,Fl=Vi,gr=Object,Ul=Bl("".split),Vl=Nl(function(){return!gr("z").propertyIsEnumerable(0)})?function(s){return Fl(s)=="String"?Ul(s,""):gr(s)}:gr,Hi=function(s){return s==null},Hl=Hi,Gl=TypeError,Va=function(s){if(Hl(s))throw Gl("Can't call method on "+s);return s},Yl=Vl,jl=Va,Gi=function(s){return Yl(jl(s))},pi={},ss=function(s){return s&&s.Math==Math&&s},_e=ss(typeof globalThis=="object"&&globalThis)||ss(typeof window=="object"&&window)||ss(typeof self=="object"&&self)||ss(typeof mr=="object"&&mr)||function(){return this}()||mr||Function("return this")(),ma=typeof document=="object"&&document.all,ql=typeof ma=="undefined"&&ma!==void 0,_d={all:ma,IS_HTMLDDA:ql},wd=_d,zl=wd.all,Ee=wd.IS_HTMLDDA?function(s){return typeof s=="function"||s===zl}:function(s){return typeof s=="function"},Wl=_e,Ql=Ee,Pn=Wl.WeakMap,Kl=Ql(Pn)&&/native code/.test(String(Pn)),Rn=Ee,kd=_d,Jl=kd.all,vt=kd.IS_HTMLDDA?function(s){return typeof s=="object"?s!==null:Rn(s)||s===Jl}:function(s){return typeof s=="object"?s!==null:Rn(s)},Xl=qe,Rt=!Xl(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),Ht={},Zl=_e,Dn=vt,ga=Zl.document,ec=Dn(ga)&&Dn(ga.createElement),Ha=function(s){return ec?ga.createElement(s):{}},tc=Rt,ic=qe,sc=Ha,Pd=!tc&&!ic(function(){return Object.defineProperty(sc("div"),"a",{get:function(){return 7}}).a!=7}),rc=Rt,ac=qe,Rd=rc&&ac(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),nc=vt,oc=String,dc=TypeError,mt=function(s){if(nc(s))return s;throw dc(oc(s)+" is not an object")},uc=Ys,rs=Function.prototype.call,Fe=uc?rs.bind(rs):function(){return rs.apply(rs,arguments)},Ga={},Sr=Ga,br=_e,lc=Ee,In=function(s){return lc(s)?s:void 0},Gt=function(s,e){return arguments.length<2?In(Sr[s])||In(br[s]):Sr[s]&&Sr[s][e]||br[s]&&br[s][e]},cc=ze,js=cc({}.isPrototypeOf),qs=typeof navigator!="undefined"&&String(navigator.userAgent)||"",Dd=_e,yr=qs,Cn=Dd.process,xn=Dd.Deno,Ln=Cn&&Cn.versions||xn&&xn.version,On=Ln&&Ln.v8,Ke,xs;On&&(Ke=On.split("."),xs=Ke[0]>0&&Ke[0]<4?1:+(Ke[0]+Ke[1]));!xs&&yr&&(Ke=yr.match(/Edge\/(\d+)/),(!Ke||Ke[1]>=74)&&(Ke=yr.match(/Chrome\/(\d+)/),Ke&&(xs=+Ke[1])));var Id=xs,Mn=Id,hc=qe,fc=_e,pc=fc.String,Cd=!!Object.getOwnPropertySymbols&&!hc(function(){var s=Symbol();return!pc(s)||!(Object(s)instanceof Symbol)||!Symbol.sham&&Mn&&Mn<41}),vc=Cd,xd=vc&&!Symbol.sham&&typeof Symbol.iterator=="symbol",mc=Gt,gc=Ee,Sc=js,bc=xd,yc=Object,Ld=bc?function(s){return typeof s=="symbol"}:function(s){var e=mc("Symbol");return gc(e)&&Sc(e.prototype,yc(s))},Tc=String,zs=function(s){try{return Tc(s)}catch(e){return"Object"}},Ec=Ee,$c=zs,Ac=TypeError,Yt=function(s){if(Ec(s))return s;throw Ac($c(s)+" is not a function")},_c=Yt,wc=Hi,Ws=function(s,e){var t=s[e];return wc(t)?void 0:_c(t)},Tr=Fe,Er=Ee,$r=vt,kc=TypeError,Pc=function(s,e){var t,i;if(e==="string"&&Er(t=s.toString)&&!$r(i=Tr(t,s))||Er(t=s.valueOf)&&!$r(i=Tr(t,s))||e!=="string"&&Er(t=s.toString)&&!$r(i=Tr(t,s)))return i;throw kc("Can't convert object to primitive value")},Od={exports:{}},Rc=!0,Bn=_e,Dc=Object.defineProperty,Ic=function(s,e){try{Dc(Bn,s,{value:e,configurable:!0,writable:!0})}catch(t){Bn[s]=e}return e},Cc=_e,xc=Ic,Nn="__core-js_shared__",Lc=Cc[Nn]||xc(Nn,{}),Ya=Lc,Fn=Ya;(Od.exports=function(s,e){return Fn[s]||(Fn[s]=e!==void 0?e:{})})("versions",[]).push({version:"3.31.0",mode:"pure",copyright:"\xA9 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.31.0/LICENSE",source:"https://github.com/zloirock/core-js"});var Md=Od.exports,Oc=Va,Mc=Object,Qs=function(s){return Mc(Oc(s))},Bc=ze,Nc=Qs,Fc=Bc({}.hasOwnProperty),ot=Object.hasOwn||function(e,t){return Fc(Nc(e),t)},Uc=ze,Vc=0,Hc=Math.random(),Gc=Uc(1 .toString),Bd=function(s){return"Symbol("+(s===void 0?"":s)+")_"+Gc(++Vc+Hc,36)},Yc=_e,jc=Md,Un=ot,qc=Bd,zc=Cd,Wc=xd,si=Yc.Symbol,Ar=jc("wks"),Qc=Wc?si.for||si:si&&si.withoutSetter||qc,Pe=function(s){return Un(Ar,s)||(Ar[s]=zc&&Un(si,s)?si[s]:Qc("Symbol."+s)),Ar[s]},Kc=Fe,Vn=vt,Hn=Ld,Jc=Ws,Xc=Pc,Zc=Pe,eh=TypeError,th=Zc("toPrimitive"),ih=function(s,e){if(!Vn(s)||Hn(s))return s;var t=Jc(s,th),i;if(t){if(e===void 0&&(e="default"),i=Kc(t,s,e),!Vn(i)||Hn(i))return i;throw eh("Can't convert object to primitive value")}return e===void 0&&(e="number"),Xc(s,e)},sh=ih,rh=Ld,ja=function(s){var e=sh(s,"string");return rh(e)?e:e+""},ah=Rt,nh=Pd,oh=Rd,as=mt,Gn=ja,dh=TypeError,_r=Object.defineProperty,uh=Object.getOwnPropertyDescriptor,wr="enumerable",kr="configurable",Pr="writable";Ht.f=ah?oh?function(e,t,i){if(as(e),t=Gn(t),as(i),typeof e=="function"&&t==="prototype"&&"value"in i&&Pr in i&&!i[Pr]){var r=uh(e,t);r&&r[Pr]&&(e[t]=i.value,i={configurable:kr in i?i[kr]:r[kr],enumerable:wr in i?i[wr]:r[wr],writable:!1})}return _r(e,t,i)}:_r:function(e,t,i){if(as(e),t=Gn(t),as(i),nh)try{return _r(e,t,i)}catch(r){}if("get"in i||"set"in i)throw dh("Accessors not supported");return"value"in i&&(e[t]=i.value),e};var Ks=function(s,e){return{enumerable:!(s&1),configurable:!(s&2),writable:!(s&4),value:e}},lh=Rt,ch=Ht,hh=Ks,Yi=lh?function(s,e,t){return ch.f(s,e,hh(1,t))}:function(s,e,t){return s[e]=t,s},fh=Md,ph=Bd,Yn=fh("keys"),qa=function(s){return Yn[s]||(Yn[s]=ph(s))},za={},vh=Kl,Nd=_e,mh=vt,gh=Yi,Rr=ot,Dr=Ya,Sh=qa,bh=za,jn="Object already initialized",Sa=Nd.TypeError,yh=Nd.WeakMap,Ls,Bi,Os,Th=function(s){return Os(s)?Bi(s):Ls(s,{})},Eh=function(s){return function(e){var t;if(!mh(e)||(t=Bi(e)).type!==s)throw Sa("Incompatible receiver, "+s+" required");return t}};if(vh||Dr.state){var tt=Dr.state||(Dr.state=new yh);tt.get=tt.get,tt.has=tt.has,tt.set=tt.set,Ls=function(s,e){if(tt.has(s))throw Sa(jn);return e.facade=s,tt.set(s,e),e},Bi=function(s){return tt.get(s)||{}},Os=function(s){return tt.has(s)}}else{var Jt=Sh("state");bh[Jt]=!0,Ls=function(s,e){if(Rr(s,Jt))throw Sa(jn);return e.facade=s,gh(s,Jt,e),e},Bi=function(s){return Rr(s,Jt)?s[Jt]:{}},Os=function(s){return Rr(s,Jt)}}var Fd={set:Ls,get:Bi,has:Os,enforce:Th,getterFor:Eh},$h=Ys,Ud=Function.prototype,qn=Ud.apply,zn=Ud.call,Vd=typeof Reflect=="object"&&Reflect.apply||($h?zn.bind(qn):function(){return zn.apply(qn,arguments)}),Ah=Vi,_h=ze,Hd=function(s){if(Ah(s)==="Function")return _h(s)},Wa={},Gd={},Yd={}.propertyIsEnumerable,jd=Object.getOwnPropertyDescriptor,wh=jd&&!Yd.call({1:2},1);Gd.f=wh?function(e){var t=jd(this,e);return!!t&&t.enumerable}:Yd;var kh=Rt,Ph=Fe,Rh=Gd,Dh=Ks,Ih=Gi,Ch=ja,xh=ot,Lh=Pd,Wn=Object.getOwnPropertyDescriptor;Wa.f=kh?Wn:function(e,t){if(e=Ih(e),t=Ch(t),Lh)try{return Wn(e,t)}catch(i){}if(xh(e,t))return Dh(!Ph(Rh.f,e,t),e[t])};var Oh=qe,Mh=Ee,Bh=/#|\.prototype\./,ji=function(s,e){var t=Fh[Nh(s)];return t==Vh?!0:t==Uh?!1:Mh(e)?Oh(e):!!e},Nh=ji.normalize=function(s){return String(s).replace(Bh,".").toLowerCase()},Fh=ji.data={},Uh=ji.NATIVE="N",Vh=ji.POLYFILL="P",qd=ji,Qn=Hd,Hh=Yt,Gh=Ys,Yh=Qn(Qn.bind),Js=function(s,e){return Hh(s),e===void 0?s:Gh?Yh(s,e):function(){return s.apply(e,arguments)}},ns=_e,jh=Vd,qh=Hd,zh=Ee,Wh=Wa.f,Qh=qd,Xt=Ga,Kh=Js,Zt=Yi,Kn=ot,Jh=function(s){var e=function(t,i,r){if(this instanceof e){switch(arguments.length){case 0:return new s;case 1:return new s(t);case 2:return new s(t,i)}return new s(t,i,r)}return jh(s,this,arguments)};return e.prototype=s.prototype,e},Ze=function(s,e){var t=s.target,i=s.global,r=s.stat,a=s.proto,n=i?ns:r?ns[t]:(ns[t]||{}).prototype,o=i?Xt:Xt[t]||Zt(Xt,t,{})[t],u=o.prototype,d,l,c,h,f,v,g,T,A;for(h in e)d=Qh(i?h:t+(r?".":"#")+h,s.forced),l=!d&&n&&Kn(n,h),v=o[h],l&&(s.dontCallGetSet?(A=Wh(n,h),g=A&&A.value):g=n[h]),f=l&&g?g:e[h],!(l&&typeof v==typeof f)&&(s.bind&&l?T=Kh(f,ns):s.wrap&&l?T=Jh(f):a&&zh(f)?T=qh(f):T=f,(s.sham||f&&f.sham||v&&v.sham)&&Zt(T,"sham",!0),Zt(o,h,T),a&&(c=t+"Prototype",Kn(Xt,c)||Zt(Xt,c,{}),Zt(Xt[c],h,f),s.real&&u&&(d||!u[h])&&Zt(u,h,f)))},ba=Rt,Xh=ot,zd=Function.prototype,Zh=ba&&Object.getOwnPropertyDescriptor,Qa=Xh(zd,"name"),ef=Qa&&function(){}.name==="something",tf=Qa&&(!ba||ba&&Zh(zd,"name").configurable),sf={EXISTS:Qa,PROPER:ef,CONFIGURABLE:tf},Wd={},rf=Math.ceil,af=Math.floor,nf=Math.trunc||function(e){var t=+e;return(t>0?af:rf)(t)},of=nf,Ka=function(s){var e=+s;return e!==e||e===0?0:of(e)},df=Ka,uf=Math.max,lf=Math.min,cf=function(s,e){var t=df(s);return t<0?uf(t+e,0):lf(t,e)},hf=Ka,ff=Math.min,pf=function(s){return s>0?ff(hf(s),9007199254740991):0},vf=pf,Ja=function(s){return vf(s.length)},mf=Gi,gf=cf,Sf=Ja,Jn=function(s){return function(e,t,i){var r=mf(e),a=Sf(r),n=gf(i,a),o;if(s&&t!=t){for(;a>n;)if(o=r[n++],o!=o)return!0}else for(;a>n;n++)if((s||n in r)&&r[n]===t)return s||n||0;return!s&&-1}},bf={includes:Jn(!0),indexOf:Jn(!1)},yf=ze,Ir=ot,Tf=Gi,Ef=bf.indexOf,$f=za,Xn=yf([].push),Af=function(s,e){var t=Tf(s),i=0,r=[],a;for(a in t)!Ir($f,a)&&Ir(t,a)&&Xn(r,a);for(;e.length>i;)Ir(t,a=e[i++])&&(~Ef(r,a)||Xn(r,a));return r},Qd=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],_f=Af,wf=Qd,kf=Object.keys||function(e){return _f(e,wf)},Pf=Rt,Rf=Rd,Df=Ht,If=mt,Cf=Gi,xf=kf;Wd.f=Pf&&!Rf?Object.defineProperties:function(e,t){If(e);for(var i=Cf(t),r=xf(t),a=r.length,n=0,o;a>n;)Df.f(e,o=r[n++],i[o]);return e};var Lf=Gt,Kd=Lf("document","documentElement"),Of=mt,Mf=Wd,Zn=Qd,Bf=za,Nf=Kd,Ff=Ha,Uf=qa,eo=">",to="<",ya="prototype",Ta="script",Jd=Uf("IE_PROTO"),Cr=function(){},Xd=function(s){return to+Ta+eo+s+to+"/"+Ta+eo},io=function(s){s.write(Xd("")),s.close();var e=s.parentWindow.Object;return s=null,e},Vf=function(){var s=Ff("iframe"),e="java"+Ta+":",t;return s.style.display="none",Nf.appendChild(s),s.src=String(e),t=s.contentWindow.document,t.open(),t.write(Xd("document.F=Object")),t.close(),t.F},os,ks=function(){try{os=new ActiveXObject("htmlfile")}catch(e){}ks=typeof document!="undefined"?document.domain&&os?io(os):Vf():io(os);for(var s=Zn.length;s--;)delete ks[ya][Zn[s]];return ks()};Bf[Jd]=!0;var Zd=Object.create||function(e,t){var i;return e!==null?(Cr[ya]=Of(e),i=new Cr,Cr[ya]=null,i[Jd]=e):i=ks(),t===void 0?i:Mf.f(i,t)},Hf=qe,Gf=!Hf(function(){function s(){}return s.prototype.constructor=null,Object.getPrototypeOf(new s)!==s.prototype}),Yf=ot,jf=Ee,qf=Qs,zf=qa,Wf=Gf,so=zf("IE_PROTO"),Ea=Object,Qf=Ea.prototype,eu=Wf?Ea.getPrototypeOf:function(s){var e=qf(s);if(Yf(e,so))return e[so];var t=e.constructor;return jf(t)&&e instanceof t?t.prototype:e instanceof Ea?Qf:null},Kf=Yi,Xa=function(s,e,t,i){return i&&i.enumerable?s[e]=t:Kf(s,e,t),s},Jf=qe,Xf=Ee,Zf=vt,ep=Zd,ro=eu,tp=Xa,ip=Pe,$a=ip("iterator"),tu=!1,ht,xr,Lr;[].keys&&(Lr=[].keys(),"next"in Lr?(xr=ro(ro(Lr)),xr!==Object.prototype&&(ht=xr)):tu=!0);var sp=!Zf(ht)||Jf(function(){var s={};return ht[$a].call(s)!==s});sp?ht={}:ht=ep(ht);Xf(ht[$a])||tp(ht,$a,function(){return this});var iu={IteratorPrototype:ht,BUGGY_SAFARI_ITERATORS:tu},rp=Pe,ap=rp("toStringTag"),su={};su[ap]="z";var Za=String(su)==="[object z]",np=Za,op=Ee,Ps=Vi,dp=Pe,up=dp("toStringTag"),lp=Object,cp=Ps(function(){return arguments}())=="Arguments",hp=function(s,e){try{return s[e]}catch(t){}},qi=np?Ps:function(s){var e,t,i;return s===void 0?"Undefined":s===null?"Null":typeof(t=hp(e=lp(s),up))=="string"?t:cp?Ps(e):(i=Ps(e))=="Object"&&op(e.callee)?"Arguments":i},fp=Za,pp=qi,vp=fp?{}.toString:function(){return"[object "+pp(this)+"]"},mp=Za,gp=Ht.f,Sp=Yi,bp=ot,yp=vp,Tp=Pe,ao=Tp("toStringTag"),en=function(s,e,t,i){if(s){var r=t?s:s.prototype;bp(r,ao)||gp(r,ao,{configurable:!0,value:e}),i&&!mp&&Sp(r,"toString",yp)}},Ep=iu.IteratorPrototype,$p=Zd,Ap=Ks,_p=en,wp=pi,kp=function(){return this},Pp=function(s,e,t,i){var r=e+" Iterator";return s.prototype=$p(Ep,{next:Ap(+!i,t)}),_p(s,r,!1,!0),wp[r]=kp,s},Rp=Ze,Dp=Fe,ru=sf,Ip=Pp,Cp=eu,xp=en,no=Xa,Lp=Pe,oo=pi,au=iu,Op=ru.PROPER;ru.CONFIGURABLE;au.IteratorPrototype;var ds=au.BUGGY_SAFARI_ITERATORS,Or=Lp("iterator"),uo="keys",us="values",lo="entries",Mp=function(){return this},Bp=function(s,e,t,i,r,a,n){Ip(t,e,i);var o=function(A){if(A===r&&h)return h;if(!ds&&A in l)return l[A];switch(A){case uo:return function(){return new t(this,A)};case us:return function(){return new t(this,A)};case lo:return function(){return new t(this,A)}}return function(){return new t(this)}},u=e+" Iterator",d=!1,l=s.prototype,c=l[Or]||l["@@iterator"]||r&&l[r],h=!ds&&c||o(r),f=e=="Array"&&l.entries||c,v,g,T;if(f&&(v=Cp(f.call(new s)),v!==Object.prototype&&v.next&&(xp(v,u,!0,!0),oo[u]=Mp)),Op&&r==us&&c&&c.name!==us&&(d=!0,h=function(){return Dp(c,this)}),r)if(g={values:o(us),keys:a?h:o(uo),entries:o(lo)},n)for(T in g)(ds||d||!(T in l))&&no(l,T,g[T]);else Rp({target:e,proto:!0,forced:ds||d},g);return n&&l[Or]!==h&&no(l,Or,h,{name:r}),oo[e]=h,g},Np=function(s,e){return{value:s,done:e}},Fp=Gi,co=pi,nu=Fd;Ht.f;var Up=Bp,ls=Np,ou="Array Iterator",Vp=nu.set,Hp=nu.getterFor(ou);Up(Array,"Array",function(s,e){Vp(this,{type:ou,target:Fp(s),index:0,kind:e})},function(){var s=Hp(this),e=s.target,t=s.kind,i=s.index++;return!e||i>=e.length?(s.target=void 0,ls(void 0,!0)):t=="keys"?ls(i,!1):t=="values"?ls(e[i],!1):ls([i,e[i]],!1)},"values");co.Arguments=co.Array;var Gp=Pe,Yp=pi,jp=Gp("iterator"),qp=Array.prototype,zp=function(s){return s!==void 0&&(Yp.Array===s||qp[jp]===s)},Wp=qi,ho=Ws,Qp=Hi,Kp=pi,Jp=Pe,Xp=Jp("iterator"),du=function(s){if(!Qp(s))return ho(s,Xp)||ho(s,"@@iterator")||Kp[Wp(s)]},Zp=Fe,ev=Yt,tv=mt,iv=zs,sv=du,rv=TypeError,av=function(s,e){var t=arguments.length<2?sv(s):e;if(ev(t))return tv(Zp(t,s));throw rv(iv(s)+" is not iterable")},nv=Fe,fo=mt,ov=Ws,dv=function(s,e,t){var i,r;fo(s);try{if(i=ov(s,"return"),!i){if(e==="throw")throw t;return t}i=nv(i,s)}catch(a){r=!0,i=a}if(e==="throw")throw t;if(r)throw i;return fo(i),t},uv=Js,lv=Fe,cv=mt,hv=zs,fv=zp,pv=Ja,po=js,vv=av,mv=du,vo=dv,gv=TypeError,Rs=function(s,e){this.stopped=s,this.result=e},mo=Rs.prototype,tn=function(s,e,t){var i=t&&t.that,r=!!(t&&t.AS_ENTRIES),a=!!(t&&t.IS_RECORD),n=!!(t&&t.IS_ITERATOR),o=!!(t&&t.INTERRUPTED),u=uv(e,i),d,l,c,h,f,v,g,T=function(E){return d&&vo(d,"normal",E),new Rs(!0,E)},A=function(E){return r?(cv(E),o?u(E[0],E[1],T):u(E[0],E[1])):o?u(E,T):u(E)};if(a)d=s.iterator;else if(n)d=s;else{if(l=mv(s),!l)throw gv(hv(s)+" is not iterable");if(fv(l)){for(c=0,h=pv(s);h>c;c++)if(f=A(s[c]),f&&po(mo,f))return f;return new Rs(!1)}d=vv(s,l)}for(v=a?s.next:d.next;!(g=lv(v,d)).done;){try{f=A(g.value)}catch(E){vo(d,"throw",E)}if(typeof f=="object"&&f&&po(mo,f))return f}return new Rs(!1)},Sv=ja,bv=Ht,yv=Ks,Tv=function(s,e,t){var i=Sv(e);i in s?bv.f(s,i,yv(0,t)):s[i]=t},Ev=Ze,$v=tn,Av=Tv;Ev({target:"Object",stat:!0},{fromEntries:function(e){var t={};return $v(e,function(i,r){Av(t,i,r)},{AS_ENTRIES:!0}),t}});var _v=Ga,wv=_v.Object.fromEntries,kv={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},Pv=kv,Rv=_e,Dv=qi,Iv=Yi,go=pi,Cv=Pe,So=Cv("toStringTag");for(var Mr in Pv){var bo=Rv[Mr],Br=bo&&bo.prototype;Br&&Dv(Br)!==So&&Iv(Br,So,Mr),go[Mr]=go.Array}var xv=wv,Lv=xv,Ov=Lv,Mv=Ov,li=Gs(Mv),Bv=Vi,Xs=typeof process!="undefined"&&Bv(process)=="process",Nv=Ht,Fv=function(s,e,t){return Nv.f(s,e,t)},Uv=Gt,Vv=Fv,Hv=Pe,Gv=Rt,yo=Hv("species"),Yv=function(s){var e=Uv(s);Gv&&e&&!e[yo]&&Vv(e,yo,{configurable:!0,get:function(){return this}})},jv=js,qv=TypeError,zv=function(s,e){if(jv(e,s))return s;throw qv("Incorrect invocation")},Wv=ze,Qv=Ee,Aa=Ya,Kv=Wv(Function.toString);Qv(Aa.inspectSource)||(Aa.inspectSource=function(s){return Kv(s)});var uu=Aa.inspectSource,Jv=ze,Xv=qe,lu=Ee,Zv=qi,em=Gt,tm=uu,cu=function(){},im=[],hu=em("Reflect","construct"),sn=/^\s*(?:class|function)\b/,sm=Jv(sn.exec),rm=!sn.exec(cu),_i=function(e){if(!lu(e))return!1;try{return hu(cu,im,e),!0}catch(t){return!1}},fu=function(e){if(!lu(e))return!1;switch(Zv(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return rm||!!sm(sn,tm(e))}catch(t){return!0}};fu.sham=!0;var am=!hu||Xv(function(){var s;return _i(_i.call)||!_i(Object)||!_i(function(){s=!0})||s})?fu:_i,nm=am,om=zs,dm=TypeError,um=function(s){if(nm(s))return s;throw dm(om(s)+" is not a constructor")},To=mt,lm=um,cm=Hi,hm=Pe,fm=hm("species"),pu=function(s,e){var t=To(s).constructor,i;return t===void 0||cm(i=To(t)[fm])?e:lm(i)},pm=ze,vm=pm([].slice),mm=TypeError,gm=function(s,e){if(s<e)throw mm("Not enough arguments");return s},Sm=qs,vu=/(?:ipad|iphone|ipod).*applewebkit/i.test(Sm),Be=_e,bm=Vd,ym=Js,Eo=Ee,Tm=ot,mu=qe,$o=Kd,Em=vm,Ao=Ha,$m=gm,Am=vu,_m=Xs,_a=Be.setImmediate,wa=Be.clearImmediate,wm=Be.process,Nr=Be.Dispatch,km=Be.Function,_o=Be.MessageChannel,Pm=Be.String,Fr=0,Ci={},wo="onreadystatechange",Ni,Mt,Ur,Vr;mu(function(){Ni=Be.location});var rn=function(s){if(Tm(Ci,s)){var e=Ci[s];delete Ci[s],e()}},Hr=function(s){return function(){rn(s)}},ko=function(s){rn(s.data)},Po=function(s){Be.postMessage(Pm(s),Ni.protocol+"//"+Ni.host)};(!_a||!wa)&&(_a=function(e){$m(arguments.length,1);var t=Eo(e)?e:km(e),i=Em(arguments,1);return Ci[++Fr]=function(){bm(t,void 0,i)},Mt(Fr),Fr},wa=function(e){delete Ci[e]},_m?Mt=function(s){wm.nextTick(Hr(s))}:Nr&&Nr.now?Mt=function(s){Nr.now(Hr(s))}:_o&&!Am?(Ur=new _o,Vr=Ur.port2,Ur.port1.onmessage=ko,Mt=ym(Vr.postMessage,Vr)):Be.addEventListener&&Eo(Be.postMessage)&&!Be.importScripts&&Ni&&Ni.protocol!=="file:"&&!mu(Po)?(Mt=Po,Be.addEventListener("message",ko,!1)):wo in Ao("script")?Mt=function(s){$o.appendChild(Ao("script"))[wo]=function(){$o.removeChild(this),rn(s)}}:Mt=function(s){setTimeout(Hr(s),0)});var gu={set:_a,clear:wa},Su=function(){this.head=null,this.tail=null};Su.prototype={add:function(s){var e={item:s,next:null},t=this.tail;t?t.next=e:this.head=e,this.tail=e},get:function(){var s=this.head;if(s){var e=this.head=s.next;return e===null&&(this.tail=null),s.item}}};var bu=Su,Rm=qs,Dm=/ipad|iphone|ipod/i.test(Rm)&&typeof Pebble!="undefined",Im=qs,Cm=/web0s(?!.*chrome)/i.test(Im),Ut=_e,Ro=Js,xm=Wa.f,Gr=gu.set,Lm=bu,Om=vu,Mm=Dm,Bm=Cm,Yr=Xs,Do=Ut.MutationObserver||Ut.WebKitMutationObserver,Io=Ut.document,Co=Ut.process,cs=Ut.Promise,xo=xm(Ut,"queueMicrotask"),ka=xo&&xo.value,ei,jr,qr,hs,Lo;if(!ka){var fs=new Lm,ps=function(){var s,e;for(Yr&&(s=Co.domain)&&s.exit();e=fs.get();)try{e()}catch(t){throw fs.head&&ei(),t}s&&s.enter()};!Om&&!Yr&&!Bm&&Do&&Io?(jr=!0,qr=Io.createTextNode(""),new Do(ps).observe(qr,{characterData:!0}),ei=function(){qr.data=jr=!jr}):!Mm&&cs&&cs.resolve?(hs=cs.resolve(void 0),hs.constructor=cs,Lo=Ro(hs.then,hs),ei=function(){Lo(ps)}):Yr?ei=function(){Co.nextTick(ps)}:(Gr=Ro(Gr,Ut),ei=function(){Gr(ps)}),ka=function(s){fs.head||ei(),fs.add(s)}}var Nm=ka,Fm=function(s,e){try{arguments.length==1?console.error(s):console.error(s,e)}catch(t){}},an=function(s){try{return{error:!1,value:s()}}catch(e){return{error:!0,value:e}}},Um=_e,vi=Um.Promise,yu=typeof Deno=="object"&&Deno&&typeof Deno.version=="object",Vm=yu,Hm=Xs,Gm=!Vm&&!Hm&&typeof window=="object"&&typeof document=="object",Ym=_e,xi=vi,jm=Ee,qm=qd,zm=uu,Wm=Pe,Qm=Gm,Km=yu,zr=Id,Oo=xi&&xi.prototype,Jm=Wm("species"),Pa=!1,Tu=jm(Ym.PromiseRejectionEvent),Xm=qm("Promise",function(){var s=zm(xi),e=s!==String(xi);if(!e&&zr===66||!(Oo.catch&&Oo.finally))return!0;if(!zr||zr<51||!/native code/.test(s)){var t=new xi(function(a){a(1)}),i=function(a){a(function(){},function(){})},r=t.constructor={};if(r[Jm]=i,Pa=t.then(function(){})instanceof i,!Pa)return!0}return!e&&(Qm||Km)&&!Tu}),zi={CONSTRUCTOR:Xm,REJECTION_EVENT:Tu,SUBCLASSING:Pa},mi={},Mo=Yt,Zm=TypeError,eg=function(s){var e,t;this.promise=new s(function(i,r){if(e!==void 0||t!==void 0)throw Zm("Bad Promise constructor");e=i,t=r}),this.resolve=Mo(e),this.reject=Mo(t)};mi.f=function(s){return new eg(s)};var tg=Ze,Ms=Xs,Pt=_e,Wi=Fe,ig=Xa,sg=en,rg=Yv,ag=Yt,Ra=Ee,ng=vt,og=zv,dg=pu,Eu=gu.set,nn=Nm,ug=Fm,lg=an,cg=bu,$u=Fd,Da=vi,on=zi,Au=mi,Zs="Promise",_u=on.CONSTRUCTOR,hg=on.REJECTION_EVENT;on.SUBCLASSING;var Wr=$u.getterFor(Zs),fg=$u.set,pg=Da&&Da.prototype,ri=Da,Qr=pg,wu=Pt.TypeError,Ia=Pt.document,dn=Pt.process,Ca=Au.f,vg=Ca,mg=!!(Ia&&Ia.createEvent&&Pt.dispatchEvent),ku="unhandledrejection",gg="rejectionhandled",Bo=0,Pu=1,Sg=2,un=1,Ru=2,vs,No,bg,Du=function(s){var e;return ng(s)&&Ra(e=s.then)?e:!1},Iu=function(s,e){var t=e.value,i=e.state==Pu,r=i?s.ok:s.fail,a=s.resolve,n=s.reject,o=s.domain,u,d,l;try{r?(i||(e.rejection===Ru&&Tg(e),e.rejection=un),r===!0?u=t:(o&&o.enter(),u=r(t),o&&(o.exit(),l=!0)),u===s.promise?n(wu("Promise-chain cycle")):(d=Du(u))?Wi(d,u,a,n):a(u)):n(t)}catch(c){o&&!l&&o.exit(),n(c)}},Cu=function(s,e){s.notified||(s.notified=!0,nn(function(){for(var t=s.reactions,i;i=t.get();)Iu(i,s);s.notified=!1,e&&!s.rejection&&yg(s)}))},xu=function(s,e,t){var i,r;mg?(i=Ia.createEvent("Event"),i.promise=e,i.reason=t,i.initEvent(s,!1,!0),Pt.dispatchEvent(i)):i={promise:e,reason:t},!hg&&(r=Pt["on"+s])?r(i):s===ku&&ug("Unhandled promise rejection",t)},yg=function(s){Wi(Eu,Pt,function(){var e=s.facade,t=s.value,i=Fo(s),r;if(i&&(r=lg(function(){Ms?dn.emit("unhandledRejection",t,e):xu(ku,e,t)}),s.rejection=Ms||Fo(s)?Ru:un,r.error))throw r.value})},Fo=function(s){return s.rejection!==un&&!s.parent},Tg=function(s){Wi(Eu,Pt,function(){var e=s.facade;Ms?dn.emit("rejectionHandled",e):xu(gg,e,s.value)})},ai=function(s,e,t){return function(i){s(e,i,t)}},oi=function(s,e,t){s.done||(s.done=!0,t&&(s=t),s.value=e,s.state=Sg,Cu(s,!0))},xa=function(s,e,t){if(!s.done){s.done=!0,t&&(s=t);try{if(s.facade===e)throw wu("Promise can't be resolved itself");var i=Du(e);i?nn(function(){var r={done:!1};try{Wi(i,e,ai(xa,r,s),ai(oi,r,s))}catch(a){oi(r,a,s)}}):(s.value=e,s.state=Pu,Cu(s,!1))}catch(r){oi({done:!1},r,s)}}};_u&&(ri=function(e){og(this,Qr),ag(e),Wi(vs,this);var t=Wr(this);try{e(ai(xa,t),ai(oi,t))}catch(i){oi(t,i)}},Qr=ri.prototype,vs=function(e){fg(this,{type:Zs,done:!1,notified:!1,parent:!1,reactions:new cg,rejection:!1,state:Bo,value:void 0})},vs.prototype=ig(Qr,"then",function(e,t){var i=Wr(this),r=Ca(dg(this,ri));return i.parent=!0,r.ok=Ra(e)?e:!0,r.fail=Ra(t)&&t,r.domain=Ms?dn.domain:void 0,i.state==Bo?i.reactions.add(r):nn(function(){Iu(r,i)}),r.promise}),No=function(){var s=new vs,e=Wr(s);this.promise=s,this.resolve=ai(xa,e),this.reject=ai(oi,e)},Au.f=Ca=function(s){return s===ri||s===bg?new No(s):vg(s)});tg({global:!0,constructor:!0,wrap:!0,forced:_u},{Promise:ri});sg(ri,Zs,!1,!0);rg(Zs);var Eg=Pe,Lu=Eg("iterator"),Ou=!1;try{var $g=0,Uo={next:function(){return{done:!!$g++}},return:function(){Ou=!0}};Uo[Lu]=function(){return this},Array.from(Uo,function(){throw 2})}catch(s){}var Ag=function(s,e){if(!e&&!Ou)return!1;var t=!1;try{var i={};i[Lu]=function(){return{next:function(){return{done:t=!0}}}},s(i)}catch(r){}return t},_g=vi,wg=Ag,kg=zi.CONSTRUCTOR,Mu=kg||!wg(function(s){_g.all(s).then(void 0,function(){})}),Pg=Ze,Rg=Fe,Dg=Yt,Ig=mi,Cg=an,xg=tn,Lg=Mu;Pg({target:"Promise",stat:!0,forced:Lg},{all:function(e){var t=this,i=Ig.f(t),r=i.resolve,a=i.reject,n=Cg(function(){var o=Dg(t.resolve),u=[],d=0,l=1;xg(e,function(c){var h=d++,f=!1;l++,Rg(o,t,c).then(function(v){f||(f=!0,u[h]=v,--l||r(u))},a)}),--l||r(u)});return n.error&&a(n.value),i.promise}});var Og=Ze,Mg=zi.CONSTRUCTOR,Vo=vi;Vo&&Vo.prototype;Og({target:"Promise",proto:!0,forced:Mg,real:!0},{catch:function(s){return this.then(void 0,s)}});var Bg=Ze,Ng=Fe,Fg=Yt,Ug=mi,Vg=an,Hg=tn,Gg=Mu;Bg({target:"Promise",stat:!0,forced:Gg},{race:function(e){var t=this,i=Ug.f(t),r=i.reject,a=Vg(function(){var n=Fg(t.resolve);Hg(e,function(o){Ng(n,t,o).then(i.resolve,r)})});return a.error&&r(a.value),i.promise}});var Yg=Ze,jg=Fe,qg=mi,zg=zi.CONSTRUCTOR;Yg({target:"Promise",stat:!0,forced:zg},{reject:function(e){var t=qg.f(this);return jg(t.reject,void 0,e),t.promise}});var Wg=mt,Qg=vt,Kg=mi,Bu=function(s,e){if(Wg(s),Qg(e)&&e.constructor===s)return e;var t=Kg.f(s),i=t.resolve;return i(e),t.promise},Jg=Ze,Xg=Gt,Zg=Rc,eS=vi,tS=zi.CONSTRUCTOR,iS=Bu,sS=Xg("Promise"),rS=!tS;Jg({target:"Promise",stat:!0,forced:Zg},{resolve:function(e){return iS(rS&&this===sS?eS:this,e)}});var aS=Ze,La=vi,nS=qe,oS=Gt,dS=Ee,uS=pu,Ho=Bu,lS=La&&La.prototype,cS=!!La&&nS(function(){lS.finally.call({then:function(){}},function(){})});aS({target:"Promise",proto:!0,real:!0,forced:cS},{finally:function(s){var e=uS(this,oS("Promise")),t=dS(s);return this.then(t?function(i){return Ho(e,s()).then(function(){return i})}:s,t?function(i){return Ho(e,s()).then(function(){throw i})}:s)}});var hS=Gt,ln=hS,fS=ln,pS=fS("Promise","finally"),vS=pS,mS=vS,gS=mS,SS=gS,er=Gs(SS),Te;(function(s){s[s.OFFSET_P=0]="OFFSET_P",s[s.PLAYBACK_SHIFT=1]="PLAYBACK_SHIFT",s[s.DASH_CMAF_OFFSET_P=2]="DASH_CMAF_OFFSET_P"})(Te||(Te={}));var Je=(s,e=0,t=Te.OFFSET_P)=>{switch(t){case Te.OFFSET_P:return s.replace("_offset_p",e===0?"":"_"+e.toFixed(0));case Te.PLAYBACK_SHIFT:{if(e===0)return s;const i=new URL(s);return i.searchParams.append("playback_shift",e.toFixed(0)),i.toString()}case Te.DASH_CMAF_OFFSET_P:{if(e===0)return s;const i=new URL(s);return i.searchParams.set("offset_p",e.toFixed(0)),i.toString()}default:H(t)}return s};const Go=(s,e)=>{var t;switch(e){case Te.OFFSET_P:return NaN;case Te.PLAYBACK_SHIFT:{const i=new URL(s);return Number(i.searchParams.get("playback_shift"))}case Te.DASH_CMAF_OFFSET_P:{const i=new URL(s);return Number((t=i.searchParams.get("offset_p"))!==null&&t!==void 0?t:0)}default:H(e)}};var D=(s,e,t=!1)=>{const i=s.getTransition();(t||!i||i.to===e)&&s.setState(e)};class ce{constructor(e){this.transitionStarted$=new x,this.transitionEnded$=new x,this.transitionUpdated$=new x,this.forceChanged$=new x,this.stateChangeStarted$=V(this.transitionStarted$,this.transitionUpdated$),this.stateChangeEnded$=V(this.transitionEnded$,this.forceChanged$),this.state=e,this.prevState=void 0}setState(e){const t=this.transition,i=this.state;this.transition=void 0,this.prevState=i,this.state=e,t?t.to===e?this.transitionEnded$.next(t):this.forceChanged$.next({from:t.from,to:e,canceledTransition:t}):this.forceChanged$.next({from:i,to:e,canceledTransition:t})}startTransitionTo(e){const t=this.transition,i=this.state;i===e||k(t)&&t.to===e||(this.prevState=i,this.state=e,t?(this.transition={from:t.from,to:e,canceledTransition:t},this.transitionUpdated$.next(this.transition)):(this.transition={from:i,to:e},this.transitionStarted$.next(this.transition)))}getTransition(){return this.transition}getState(){return this.state}getPrevState(){return this.prevState}}const bS=s=>{switch(s){case y.MPEG:case y.DASH:case y.DASH_SEP:case y.DASH_ONDEMAND:case y.DASH_WEBM:case y.DASH_WEBM_AV1:case y.HLS:case y.HLS_ONDEMAND:return!1;case y.DASH_LIVE:case y.DASH_LIVE_CMAF:case y.HLS_LIVE:case y.HLS_LIVE_CMAF:case y.DASH_LIVE_WEBM:case y.WEB_RTC_LIVE:return!0;default:return H(s)}};var q;(function(s){s.STOPPED="stopped",s.READY="ready",s.PLAYING="playing",s.PAUSED="paused"})(q||(q={}));const yS=5,TS=5,ES=500,Yo=7e3;class $S{constructor(e){this.subscription=new ae,this.loadMediaTimeoutSubscription=new ae,this.videoState=new ce(q.STOPPED),this.syncPlayback=()=>{const i=this.videoState.getState(),r=this.videoState.getTransition(),a=this.params.desiredState.playbackState.getState(),n=this.params.desiredState.playbackState.getTransition(),o=this.params.desiredState.seekState.getState();if(this.log({message:`[syncPlayback] videoState: ${i}; videoTransition: ${JSON.stringify(r)}; desiredPlaybackState: ${a}; desiredPlaybackStateTransition: ${this.params.desiredState.playbackState.getTransition()}; seekState: ${JSON.stringify(o)};`}),a===p.STOPPED){i!==q.STOPPED&&(this.videoState.startTransitionTo(q.STOPPED),this.stop());return}if(!r){if((n==null?void 0:n.to)!==p.PAUSED&&o.state===W.Requested&&i!==q.STOPPED){this.seek(o.position/1e3);return}switch(a){case p.READY:{switch(i){case q.PLAYING:case q.PAUSED:case q.READY:break;case q.STOPPED:this.videoState.startTransitionTo(q.READY),this.prepare();break;default:H(i)}break}case p.PLAYING:{switch(i){case q.PLAYING:break;case q.PAUSED:this.videoState.startTransitionTo(q.PLAYING),this.params.connection.remotePlayerController.playOrPause();break;case q.READY:this.videoState.startTransitionTo(q.PLAYING),this.params.connection.remotePlayerController.playOrPause();break;case q.STOPPED:this.videoState.startTransitionTo(q.READY),this.prepare();break;default:H(i)}break}case p.PAUSED:{switch(i){case q.PLAYING:this.videoState.startTransitionTo(q.PAUSED),this.params.connection.remotePlayerController.playOrPause();break;case q.PAUSED:break;case q.READY:this.videoState.startTransitionTo(q.PAUSED),this.videoState.setState(q.PAUSED);break;case q.STOPPED:this.videoState.startTransitionTo(q.READY),this.prepare();break;default:H(i)}break}default:H(a)}}},this.params=e,this.log=this.params.dependencies.logger.createComponentLog("ChromecastProvider"),this.log({message:`constructor, format: ${e.format}`}),this.params.output.isLive$.next(bS(e.format)),this.params.output.isAudioAvailable$.next(!0),this.handleRemoteVolumeChange({volume:this.params.connection.remotePlayer.volumeLevel,muted:this.params.connection.remotePlayer.isMuted});const t=this.params.connection.session.getMediaSession();t&&this.restoreSession(t),this.subscribe()}destroy(){this.log({message:"[destroy]"}),this.subscription.unsubscribe()}subscribe(){this.subscription.add(this.loadMediaTimeoutSubscription);const e=new ae;this.subscription.add(e),this.subscription.add(V(this.videoState.stateChangeStarted$.pipe(w(r=>`stateChangeStarted$ ${JSON.stringify(r)}`)),this.videoState.stateChangeEnded$.pipe(w(r=>`stateChangeEnded$ ${JSON.stringify(r)}`))).subscribe(r=>this.log({message:`[videoState] ${r}`})));const t=(r,a)=>this.subscription.add(r.subscribe(a));if(this.params.output.isLive$.getValue())this.params.output.position$.next(0),this.params.output.duration$.next(0);else{const r=new x;e.add(r.pipe(je(ES)).subscribe(()=>{this.params.output.seekedEvent$.next()}));let a=NaN;e.add(B(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED).subscribe(n=>{this.logRemoteEvent(n);const o=n.value;this.params.output.position$.next(o),(this.params.desiredState.seekState.getState().state===W.Applying||Math.abs(o-a)>yS)&&r.next(o),a=o})),e.add(B(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.DURATION_CHANGED).subscribe(n=>{this.logRemoteEvent(n),this.params.output.duration$.next(n.value)}))}t(B(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED),r=>{this.logRemoteEvent(r),r.value?this.handleRemoteReady():(this.handleRemoteStop(),e.unsubscribe())}),t(B(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED),r=>{this.logRemoteEvent(r),r.value?this.handleRemotePause():this.handleRemotePlay()}),t(B(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED),r=>{this.logRemoteEvent(r);const{remotePlayer:a}=this.params.connection,n=r.value,o=this.params.output.isBuffering$.getValue(),u=n===chrome.cast.media.PlayerState.BUFFERING;switch(o!==u&&this.params.output.isBuffering$.next(u),n){case chrome.cast.media.PlayerState.IDLE:!this.params.output.isLive$.getValue()&&a.duration-a.currentTime<TS&&this.params.output.endedEvent$.next(),this.handleRemoteStop(),D(this.params.desiredState.playbackState,p.STOPPED);break;case chrome.cast.media.PlayerState.PAUSED:{this.handleRemotePause();break}case chrome.cast.media.PlayerState.PLAYING:this.handleRemotePlay();break;case chrome.cast.media.PlayerState.BUFFERING:break;default:H(n)}}),t(B(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED),r=>{this.logRemoteEvent(r),this.handleRemoteVolumeChange({volume:r.value})}),t(B(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED),r=>{this.logRemoteEvent(r),this.handleRemoteVolumeChange({muted:r.value})});const i=V(this.params.desiredState.playbackState.stateChangeStarted$,this.params.desiredState.seekState.stateChangeEnded$,this.videoState.stateChangeEnded$,De(["init"])).pipe(je(0));t(i,this.syncPlayback)}restoreSession(e){this.log({message:"restoreSession"});const{remotePlayer:t}=this.params.connection;if(e.playerState!==chrome.cast.media.PlayerState.IDLE){t.isPaused?(this.videoState.setState(q.PAUSED),D(this.params.desiredState.playbackState,p.PAUSED)):(this.videoState.setState(q.PLAYING),D(this.params.desiredState.playbackState,p.PLAYING));const i=this.params.output.isLive$.getValue();this.params.output.duration$.next(i?0:t.duration),this.params.output.position$.next(i?0:t.currentTime),this.params.desiredState.seekState.setState({state:W.None})}}prepare(){const e=this.params.format;this.log({message:`[prepare] format: ${e}`});const t=this.createMediaInfo(e),i=this.createLoadRequest(t);this.loadMedia(i)}handleRemotePause(){const e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)===q.PAUSED||e===q.PLAYING)&&(this.videoState.setState(q.PAUSED),D(this.params.desiredState.playbackState,p.PAUSED))}handleRemotePlay(){const e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)===q.PLAYING||e===q.PAUSED)&&(this.videoState.setState(q.PLAYING),D(this.params.desiredState.playbackState,p.PLAYING))}handleRemoteReady(){var e;const t=this.videoState.getTransition();(t==null?void 0:t.to)===q.READY&&this.videoState.setState(q.READY),((e=this.params.desiredState.playbackState.getTransition())===null||e===void 0?void 0:e.to)===p.READY&&D(this.params.desiredState.playbackState,p.READY)}handleRemoteStop(){this.videoState.getState()!==q.STOPPED&&this.videoState.setState(q.STOPPED)}handleRemoteVolumeChange(e){var t,i;const r=this.params.output.volume$.getValue(),a={volume:(t=e.volume)!==null&&t!==void 0?t:r.volume,muted:(i=e.muted)!==null&&i!==void 0?i:r.muted};(a.volume!==r.volume||a.muted!==a.muted)&&this.params.output.volume$.next(a)}seek(e){this.params.output.willSeekEvent$.next();const{remotePlayer:t,remotePlayerController:i}=this.params.connection;t.currentTime=e,i.seek()}stop(){const{remotePlayerController:e}=this.params.connection;e.stop()}createMediaInfo(e){var t;const i=this.params.source;let r,a,n;switch(e){case y.MPEG:{const l=i[e];P(l);const c=Tl(Object.keys(l));P(c);const h=l[c];P(h),r=h,a="video/mp4",n=chrome.cast.media.StreamType.BUFFERED;break}case y.HLS:case y.HLS_ONDEMAND:{const l=i[e];P(l),r=l.url,a="application/x-mpegurl",n=chrome.cast.media.StreamType.BUFFERED;break}case y.DASH_SEP:case y.DASH_ONDEMAND:case y.DASH_WEBM:case y.DASH_WEBM_AV1:{const l=i[e];P(l),r=l.url,a="application/dash+xml",n=chrome.cast.media.StreamType.BUFFERED;break}case y.DASH_LIVE_CMAF:{const l=i[e];P(l),r=l.url,a="application/dash+xml",n=chrome.cast.media.StreamType.LIVE;break}case y.HLS_LIVE:case y.HLS_LIVE_CMAF:{const l=i[e];P(l),r=Je(l.url),a="application/x-mpegurl",n=chrome.cast.media.StreamType.LIVE;break}case y.DASH:case y.DASH_LIVE:case y.WEB_RTC_LIVE:{const l="Unsupported format for Chromecast",c=new Error(l);throw this.params.output.error$.next({id:"ChromecastProvider.createMediaInfo()",category:L.VIDEO_PIPELINE,message:l,thrown:c}),c}case y.DASH_LIVE_WEBM:throw new Error("DASH_LIVE_WEBM is no longer supported");default:return H(e)}const o=new chrome.cast.media.MediaInfo((t=this.params.meta.videoId)!==null&&t!==void 0?t:r,a);o.contentUrl=r,o.streamType=n,o.metadata=new chrome.cast.media.GenericMediaMetadata;const{title:u,subtitle:d}=this.params.meta;return k(u)&&(o.metadata.title=u),k(d)&&(o.metadata.subtitle=d),o}createLoadRequest(e){const t=new chrome.cast.media.LoadRequest(e);t.autoplay=!1;const i=this.params.desiredState.seekState.getState();return i.state===W.Applying||i.state===W.Requested?t.currentTime=this.params.output.isLive$.getValue()?0:i.position/1e3:t.currentTime=0,t}loadMedia(e){const t=this.params.connection.session.loadMedia(e),i=new Promise((r,a)=>{this.loadMediaTimeoutSubscription.add(El(Yo).subscribe(()=>a(`timeout(${Yo})`)))});er(Promise.race([t,i]).then(()=>{this.log({message:`[loadMedia] completed, format: ${this.params.format}`}),this.params.desiredState.seekState.getState().state===W.Applying&&this.params.output.seekedEvent$.next(),this.handleRemoteReady()},r=>{const a=`[prepare] loadMedia failed, format: ${this.params.format}, reason: ${r}`;this.log({message:a}),this.params.output.error$.next({id:"ChromecastProvider.loadMedia",category:L.VIDEO_PIPELINE,message:a,thrown:r})}),()=>{this.loadMediaTimeoutSubscription.unsubscribe()})}logRemoteEvent(e){this.log({message:`[remoteEvent] ${JSON.stringify(e)}`})}}var AS=s=>{let e,t=!1,i=!1;s.on("playbackTimeUpdated",({timeToEnd:r})=>{i=r<=3,t&&i&&(e==null||e())}),s.extend("MediaSourceController",function(){const{parent:r}=this,a=r.signalEndOfStream;return{signalEndOfStream:n=>{t=!0,e=()=>a(n),t&&i&&(e==null||e())}}},!0)},_S=s=>{const e=new S(1/0),t=new x,i=new S(void 0),r=new S(void 0);let a=NaN,n=!1;const o=()=>{a=Date.now(),n=!1},u=l=>{var c,h,f,v,g;const T=li(l.getAllResponseHeaders().trim().split(/[\n\r]+/).map(m=>m.split(": ")));if("x-playback-duration"in T||"x-playback-duration-millis"in T){const m=parseInt((c=l.getResponseHeader("X-Playback-Duration"))!==null&&c!==void 0?c:"",10),b=parseInt((h=l.getResponseHeader("X-Playback-Duration-Millis"))!==null&&h!==void 0?h:"",10),$=(f=b!=null?b:m*1e3)!==null&&f!==void 0?f:NaN;k($)&&!isNaN($)&&e.next($)}const A=(v=T["x-delivery-type"])!==null&&v!==void 0?v:Mi.HTTP1,E=(g={1:!0,0:!1}[T["x-reused"]])!==null&&g!==void 0?g:void 0;i.next(A),r.next(E)},d=l=>{l.readyState>=2&&!n&&(n=!0,t.next(Date.now()-a))};return s.extend("XHRLoader",function(){const{parent:l}=this,c=l.load.bind(l);return{load:function(h){if(h.request.type==="MPD"){const f=h.onload,v=h.progress;h.onload=function(...g){return u(this),f(...g)},h.progress=function(...g){return d(this),v(...g)},o()}return c(h)}}},!0),{playbackDuration$:e,ping$:t,connectionReused$:r,connectionType$:i}},ci=s=>{const e=new URL(s);return e.searchParams.set("quic","1"),e.toString()},wS=s=>s.extend("RequestModifier",()=>({modifyRequestURL:ci}),!0),kS=s=>{s.extend("HTTPLoader",function(){const{parent:e}=this,t=e.load;return{load:i=>{if(i.request&&i.request.range){const[r,a]=i.request.range.split("-").map(o=>parseInt(o,10)),n=new URL(i.request.url,location.href);n.searchParams.append("bytes",`${r}-${a}`),i.request.url=n.toString(),i.request.range=void 0}t(i)}}},!0)};const Xe=(s,e,t,{equal:i=(n,o)=>n===o,changed$:r,onError:a}={})=>{const n=s.getState(),o=e(),u=ie(r),d=new ae;return r&&d.add(r.subscribe(l=>{const c=s.getState();i(l,c)&&s.setState(l)},a)),i(o,n)||(t(n),u&&s.setState(n)),d.add(s.stateChangeStarted$.subscribe(l=>{t(l.to),u&&s.setState(l.to)},a)),d},jt=(s,e,t)=>Xe(e,()=>s.loop,i=>{k(i)&&(s.loop=i)},{onError:t}),gt=(s,e,t,i)=>Xe(e,()=>({muted:s.muted,volume:s.volume}),r=>{k(r)&&(s.muted=r.muted,s.volume=r.volume)},{equal:(r,a)=>r===a||(r==null?void 0:r.muted)===(a==null?void 0:a.muted)&&(r==null?void 0:r.volume)===(a==null?void 0:a.volume),changed$:t,onError:i}),Dt=(s,e,t,i)=>Xe(e,()=>s.playbackRate,r=>{k(r)&&(s.playbackRate=r)},{changed$:t,onError:i}),PS=s=>["__",s.language,s.label].join("|"),RS=(s,e)=>{if(s.id===e)return!0;const[t,i,r]=e.split("|");return s.language===i&&s.label===r};class dt{constructor(){this.available$=new x,this.current$=new S(void 0),this.error$=new x,this.subscription=new ae,this.externalTracks=new Map,this.internalTracks=new Map}connect(e,t,i){this.video=e,this.cueSettings=t.textTrackCuesSettings,this.subscribe();const r=a=>{this.error$.next({id:"TextTracksManager",category:L.WTF,message:"Generic HtmlVideoTextTrackManager error",thrown:a})};this.subscription.add(this.available$.subscribe(i.availableTextTracks$)),this.subscription.add(this.current$.subscribe(i.currentTextTrack$)),this.subscription.add(this.error$.subscribe(i.error$)),this.subscription.add(Xe(t.internalTextTracks,()=>Object.values(this.internalTracks),a=>{k(a)&&this.setInternal(a)},{equal:(a,n)=>k(a)&&k(n)&&a.length===n.length&&a.every(({id:o},u)=>o===n[u].id),changed$:this.available$.pipe(w(a=>a.filter(({type:n})=>n==="internal"))),onError:r})),this.subscription.add(Xe(t.externalTextTracks,()=>Object.values(this.externalTracks),a=>{k(a)&&this.setExternal(a)},{equal:(a,n)=>k(a)&&k(n)&&a.length===n.length&&a.every(({id:o},u)=>o===n[u].id),changed$:this.available$.pipe(w(a=>a.filter(({type:n})=>n==="external"))),onError:r})),this.subscription.add(Xe(t.currentTextTrack,()=>{if(this.video)return;const a=this.htmlTextTracksAsArray().find(({mode:n})=>n==="showing");return a&&this.htmlTextTrackToITextTrack(a).id},a=>this.select(a),{changed$:this.current$,onError:r})),this.subscription.add(Xe(t.textTrackCuesSettings,()=>({}),()=>{if(this.video)for(const a of this.htmlTextTracksAsArray())this.applyCueSettings(a.cues),this.applyCueSettings(a.activeCues)}))}subscribe(){P(this.video);const{textTracks:e}=this.video;this.subscription.add(B(e,"addtrack").subscribe(()=>{const i=this.current$.getValue();i&&this.select(i)})),this.subscription.add(V(B(e,"addtrack"),B(e,"removetrack"),De(["init"])).pipe(w(()=>this.htmlTextTracksAsArray().map(i=>this.htmlTextTrackToITextTrack(i))),ve((i,r)=>i.length===r.length&&i.every(({id:a},n)=>a===r[n].id))).subscribe(this.available$)),this.subscription.add(V(B(e,"change"),De(["init"])).pipe(w(()=>this.htmlTextTracksAsArray().find(({mode:i})=>i==="showing")),w(i=>i&&this.htmlTextTrackToITextTrack(i).id),ve()).subscribe(this.current$));const t=i=>{var r,a;return this.applyCueSettings((a=(r=i.target)===null||r===void 0?void 0:r.activeCues)!==null&&a!==void 0?a:null)};this.subscription.add(B(e,"addtrack").subscribe(i=>{var r,a;(r=i.track)===null||r===void 0||r.addEventListener("cuechange",t);const n=o=>{var u,d,l,c,h;const f=(d=(u=o.target)===null||u===void 0?void 0:u.cues)!==null&&d!==void 0?d:null;f&&f.length&&(this.applyCueSettings((c=(l=o.target)===null||l===void 0?void 0:l.cues)!==null&&c!==void 0?c:null),(h=o.target)===null||h===void 0||h.removeEventListener("cuechange",n))};(a=i.track)===null||a===void 0||a.addEventListener("cuechange",n)})),this.subscription.add(B(e,"removetrack").subscribe(i=>{var r;(r=i.track)===null||r===void 0||r.removeEventListener("cuechange",t)}))}applyCueSettings(e){if(!e||!e.length)return;const t=this.cueSettings.getState();for(const i of Array.from(e)){const r=i;k(t.align)&&(r.align=t.align),k(t.position)&&(r.position=t.position),k(t.size)&&(r.size=t.size),k(t.line)&&(r.line=t.line)}}htmlTextTracksAsArray(e=!1){P(this.video);const t=[...this.video.textTracks];return e?t:t.filter(dt.isHealthyTrack)}htmlTextTrackToITextTrack(e){var t,i;const{language:r,label:a}=e,n=e.id?e.id:PS(e),o=this.externalTracks.has(n),u=n.includes("auto");return o?{id:n,type:"external",isAuto:u,language:r,label:a,url:(t=this.externalTracks.get(n))===null||t===void 0?void 0:t.url}:{id:n,type:"internal",isAuto:u,language:r,label:a,url:(i=this.internalTracks.get(n))===null||i===void 0?void 0:i.url}}static isHealthyTrack(e){return!(e.kind==="metadata"||e.groupId||e.id===""&&e.label===""&&e.language==="")}setExternal(e){this.internalTracks.size>0&&Array.from(this.internalTracks).forEach(([,t])=>this.detach(t)),e.filter(({id:t})=>!this.externalTracks.has(t)).forEach(t=>this.attach(t)),Array.from(this.externalTracks).filter(([t])=>!e.find(i=>i.id===t)).forEach(([,t])=>this.detach(t))}setInternal(e){const t=[...this.externalTracks];e.filter(({id:i,language:r,isAuto:a})=>!this.internalTracks.has(i)&&!t.some(([,n])=>n.language===r&&n.isAuto===a)).forEach(i=>this.attach(i)),Array.from(this.internalTracks).filter(([i])=>!e.find(r=>r.id===i)).forEach(([,i])=>this.detach(i))}select(e){P(this.video);for(const t of this.htmlTextTracksAsArray(!0))t.mode="showing";for(const t of this.htmlTextTracksAsArray(!0))(ie(e)||!RS(t,e))&&(t.mode="disabled")}destroy(){if(this.subscription.unsubscribe(),this.video)for(const e of Array.from(this.video.getElementsByTagName("track"))){const t=e.getAttribute("id");t&&this.externalTracks.has(t)&&this.video.removeChild(e)}this.externalTracks.clear()}attach(e){P(this.video);const t=document.createElement("track");t.setAttribute("src",e.url),t.setAttribute("id",e.id),e.label&&t.setAttribute("label",e.label),e.language&&t.setAttribute("srclang",e.language),e.type==="external"?this.externalTracks.set(e.id,e):e.type==="internal"&&this.internalTracks.set(e.id,e),this.video.appendChild(t)}detach(e){P(this.video);const t=Array.prototype.find.call(this.video.getElementsByTagName("track"),i=>i.getAttribute("id")===e.id);t&&this.video.removeChild(t),e.type==="external"?this.externalTracks.delete(e.id):e.type==="internal"&&this.internalTracks.delete(e.id)}}const cn=s=>{s.removeAttribute("src"),s.load()},DS=s=>{try{s.pause(),s.playbackRate=0,cn(s),s.remove()}catch(e){console.error(e)}};class IS{constructor(){this.attribute="data-pool-reused"}get(e){return e.hasAttribute(this.attribute)}set(e,t){e.toggleAttribute(this.attribute,t)}delete(e){e.removeAttribute(this.attribute)}}const Oa=window.WeakMap?new WeakMap:new IS,St=s=>{let e=s.querySelector("video");const t=!!e;return e?cn(e):(e=document.createElement("video"),s.appendChild(e)),Oa.set(e,t),e.setAttribute("crossorigin","anonymous"),e.setAttribute("playsinline","playsinline"),e.controls=!1,e.setAttribute("poster","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),e},bt=s=>{const e=Oa.get(s);Oa.delete(s),e?cn(s):DS(s)};class tr{constructor(){this.pausedTime=0,this.streamOffset=0,this.pauseTimestamp=0}getTotalPausedTime(){return this.pausedTime+this.getCurrentPausedTime()}getCurrentPausedTime(){return this.pauseTimestamp>0?Date.now()-this.pauseTimestamp:0}getStreamOffset(){return this.streamOffset}getTotalOffset(){return this.getTotalPausedTime()+this.streamOffset}pause(){this.pauseTimestamp===0&&(this.pauseTimestamp=Date.now())}resume(){this.pauseTimestamp>0&&(this.pausedTime+=this.getCurrentPausedTime(),this.pauseTimestamp=0)}resetTo(e,t=!1){this.streamOffset=e,this.pauseTimestamp=0,this.pausedTime=0,t&&this.pause()}}const Nu=s=>{var e;let t=s;for(;!(t instanceof Document)&&!(t instanceof ShadowRoot)&&t!==null;)t=t==null?void 0:t.parentNode;return(e=t)!==null&&e!==void 0?e:void 0},jo=s=>{const e=Nu(s);return!!(e&&e.fullscreenElement&&e.fullscreenElement===s)},CS=s=>{const e=Nu(s);return!!(e&&e.pictureInPictureElement&&e.pictureInPictureElement===s)},Ma=3;class xS{constructor(e){this._buffer=[],this._source=e}fill(){this._buffer=[];const e=this._source.currentTime;for(let t=0,i=this._source.buffered.length;t<i;t++){let r=this._source.buffered.start(t);const a=this._source.buffered.end(t);r>e&&r-e<Ma&&(r=e),this._buffer.push({from:r,to:a,i:t})}return this._buffer.sort(function(t,i){return t.from-i.from}),this._buffer}getByTime(e){return this._buffer.find(t=>e>=t.from&&e<t.to)}getNextWithGap(e,t){const i=this.getNext(e);if(i&&i.from-e.to<(t||Ma))return i}getNext(e){let t=this._buffer.indexOf(e);if(~t&&this._buffer.length-1>t)return this._buffer[++t]}smartRemove(e,t,i){this._buffer.forEach(({from:r,to:a})=>{const n=r>=e&&r<t,o=a>=e&&a<t;n&&o||(n?i(t,a):o?i(r,e):r<e&&a>t?(i(t,a),i(r,e)):i(r,a))})}destroy(){this._buffer=[]}}var Fu=(s,e,t=Ma)=>{let i=0,r=0;for(let a=0;a<s.length;a++){const n=s.start(a),o=s.end(a);if(n<=e&&e<=o){if(i=n,r=o,!t)return{from:i,to:r};for(let u=a-1;u>=0;u--)s.end(u)+t>=i&&(i=s.start(u));for(let u=a+1;u<s.length;u++)s.start(u)-t<=r&&(r=s.end(u))}}return{from:i,to:r}};const yt=s=>{const e=m=>B(s,m).pipe(ui(void 0)),i=V(...["waiting","pause","canplay","play","canplaythrough","playing","seeking","seeked","ended"].map(m=>B(s,m))).pipe(w(m=>m.type==="ended"?s.readyState<2:s.readyState<3),ve()),r=V(B(s,"progress"),B(s,"timeupdate")).pipe(w(()=>Fu(s.buffered,s.currentTime))),n=Ua().browser===yd.Safari?Ne({play:e("play").pipe(ge()),playing:e("playing")}).pipe(ui(void 0)):e("playing"),o=B(s,"volumechange").pipe(w(()=>({muted:s.muted,volume:s.volume}))),u=B(s,"ratechange").pipe(w(()=>s.playbackRate)),d=B(s,"error").pipe(re(()=>!!(s.error||s.played.length)),w(()=>{var m;const b=s.error;return{id:b?`MediaError#${b.code}`:"HtmlVideoError",category:L.VIDEO_PIPELINE,message:b?b.message:"Error event from HTML video element",thrown:(m=s.error)!==null&&m!==void 0?m:void 0}})),l=B(s,"timeupdate").pipe(w(()=>s.currentTime)),c=new x,h=.3;let f;l.subscribe(m=>{s.loop&&k(f)&&k(m)&&f>=s.duration-h&&m<=h&&c.next(f),f=m});const v=B(s,"enterpictureinpicture"),g=B(s,"leavepictureinpicture"),T=new S(CS(s));v.subscribe(()=>T.next(!0)),g.subscribe(()=>T.next(!1));const A=new S(jo(s));return B(s,"fullscreenchange").pipe(w(()=>jo(s))).subscribe(A),{playing$:n,pause$:e("pause").pipe(re(()=>!s.error)),canplay$:e("canplay"),ended$:e("ended"),looped$:c,error$:d,seeked$:e("seeked"),seeking$:e("seeking"),progress$:e("progress"),loadStart$:e("loadstart"),loadedMetadata$:e("loadedmetadata"),loadedData$:e("loadeddata"),timeUpdate$:l,durationChange$:B(s,"durationchange").pipe(w(()=>s.duration)),isBuffering$:i,currentBuffer$:r,volumeState$:o,playbackRateState$:u,inPiP$:T,inFullscreen$:A}},hn=s=>{if(s.includes("/")){const e=s.split("/");return parseInt(e[0])/parseInt(e[1])}else return parseFloat(s)};var LS=Ze,OS=Qs,MS=Ja,BS=Ka;LS({target:"Array",proto:!0},{at:function(e){var t=OS(this),i=MS(t),r=BS(e),a=r>=0?r:i+r;return a<0||a>=i?void 0:t[a]}});var NS=ln,FS=NS("Array","at"),US=FS,VS=US,HS=VS,GS=HS,st=Gs(GS);let fn=!1,ct={};const YS=s=>{fn=s},jS=()=>{ct={}},qS=s=>{s(ct)},ms=(s,e)=>{var t;fn&&(ct.meta=(t=ct.meta)!==null&&t!==void 0?t:{},ct.meta[s]=e)};class rt{constructor(e){this.name=e}next(e){var t,i;if(!fn)return;ct.series=(t=ct.series)!==null&&t!==void 0?t:{};const r=(i=ct.series[this.name])!==null&&i!==void 0?i:[];r.push([Date.now(),e]),ct.series[this.name]=r}}var Nt;(function(s){s.FitsContainer="FitsContainer",s.FitsThroughput="FitsThroughput",s.Buffer="Buffer",s.DroppedFramesLimit="DroppedFramesLimit",s.FitsQualityLimits="FitsQualityLimits"})(Nt||(Nt={}));const zS=new rt("best_bitrate"),WS=(s,e,t)=>(e-t)*Math.pow(2,-10*s)+t;class QS{constructor(){this.history={}}recordSelection(e){this.history[e.id]=me()}recordSwitch(e){this.last=e}clear(){this.last=void 0,this.history={}}}const gi=(s,{container:e,throughput:t,tuning:i,limits:r,reserve:a=0,forwardBufferHealth:n,playbackRate:o,current:u,history:d,droppedVideoMaxQualityLimit:l,abrLogger:c})=>{var h,f,v,g,T;const A=i.usePixelRatio&&(h=window.devicePixelRatio)!==null&&h!==void 0?h:1,E=i.limitByContainer&&e&&e.width>0&&e.height>0&&{width:e.width*A*i.containerSizeFactor,height:e.height*A*i.containerSizeFactor},m=E&&Vt(E),b=i.considerPlaybackRate&&k(o)?o:1,$=s.filter(U=>!Oi(U.quality)).sort((U,I)=>Ii(U.quality,I.quality)?-1:1),R=(f=st($,-1))===null||f===void 0?void 0:f.quality,j=(v=st($,0))===null||v===void 0?void 0:v.quality,X=ie(r)||k(r.min)&&k(r.max)&&ws(r.max,r.min)||k(r.min)&&j&&Ii(r.min,j)||k(r.max)&&R&&ws(r.max,R),F=b*WS(n!=null?n:.5,i.bitrateFactorAtEmptyBuffer,i.bitrateFactorAtFullBuffer),Y={},O=$.filter(U=>(m?ws(U.quality,m):!0)?(k(t)&&isFinite(t)&&k(U.bitrate)?t-a>=U.bitrate*F:!0)?i.lazyQualitySwitch&&k(i.minBufferToSwitchUp)&&u&&!Oi(u.quality)&&(n!=null?n:0)<i.minBufferToSwitchUp&&Ii(U.quality,u.quality)?(Y[U.quality]=Nt.Buffer,!1):!!l&&pa(U.quality,l)?(Y[U.quality]=Nt.DroppedFramesLimit,!1):X||(ie(r.max)||Td(U.quality,r.max))&&(ie(r.min)||pa(U.quality,r.min))?!0:(Y[U.quality]=Nt.FitsQualityLimits,!1):(Y[U.quality]=Nt.FitsThroughput,!1):(Y[U.quality]=Nt.FitsContainer,!1))[0];O&&O.bitrate&&zS.next(O.bitrate);const G=(g=O!=null?O:$[Math.ceil(($.length-1)/2)])!==null&&g!==void 0?g:s[0];G.quality!==((T=d==null?void 0:d.last)===null||T===void 0?void 0:T.quality)&&c({message:`
|
|
6
|
+
import{ValueSubject as S,Subject as x,Subscription as ae,isNonNullable as k,ErrorCategory as L,isNullable as ie,fromEvent as B,assertNever as H,merge as V,tap as Is,map as w,observableFrom as De,filterChanged as ve,assertNonNullable as P,debounce as je,getHighestQuality as Tl,timeout as El,getCurrentBrowser as Ua,CurrentClientBrowser as yd,combine as Ne,once as ge,mapTo as ui,filter as re,now as me,videoSizeToQuality as Vt,isInvariantQuality as Oi,isHigher as Ii,isLower as ws,isHigherOrEqual as pa,isLowerOrEqual as Td,Observable as Hs,interval as Cs,VideoQuality as He,videoQualityToHeight as $l,abortable as Oe,getExponentialDelay as kn,throttle as Al,CurrentClientDevice as _l,safeStorage as vr,fillWithDefault as wl,Logger as kl}from"@vkontakte/videoplayer-shared/es2015.esm.js";import{Observable as BT,Subject as NT,Subscription as FT,ValueSubject as UT,VideoQuality as VT}from"@vkontakte/videoplayer-shared/es2015.esm.js";import Pl from"lodash/debounce.js";const Rl="2.0.95";var p;(function(s){s.STOPPED="stopped",s.READY="ready",s.PLAYING="playing",s.PAUSED="paused"})(p||(p={}));var y;(function(s){s.MPEG="MPEG",s.DASH="DASH",s.DASH_SEP="DASH_SEP",s.DASH_SEP_VK="DASH_SEP",s.DASH_WEBM="DASH_WEBM",s.DASH_WEBM_AV1="DASH_WEBM_AV1",s.DASH_WEBM_VK="DASH_WEBM",s.DASH_ONDEMAND="DASH_ONDEMAND",s.DASH_ONDEMAND_VK="DASH_ONDEMAND",s.DASH_LIVE="DASH_LIVE",s.DASH_LIVE_CMAF="DASH_LIVE_CMAF",s.DASH_LIVE_WEBM="DASH_LIVE_WEBM",s.HLS="HLS",s.HLS_ONDEMAND="HLS_ONDEMAND",s.HLS_JS="HLS",s.HLS_LIVE="HLS_LIVE",s.HLS_LIVE_CMAF="HLS_LIVE_CMAF",s.WEB_RTC_LIVE="WEB_RTC_LIVE"})(y||(y={}));var we;(function(s){s.SCREEN="SCREEN",s.CHROMECAST="CHROMECAST"})(we||(we={}));var $e;(function(s){s.NOT_AVAILABLE="NOT_AVAILABLE",s.AVAILABLE="AVAILABLE",s.CONNECTING="CONNECTING",s.CONNECTED="CONNECTED"})($e||($e={}));var Mi;(function(s){s.HTTP1="http1",s.HTTP2="http2",s.QUIC="quic"})(Mi||(Mi={}));var W;(function(s){s.None="none",s.Requested="requested",s.Applying="applying"})(W||(W={}));var At;(function(s){s.NONE="none",s.INLINE="inline",s.FULLSCREEN="fullscreen",s.SECOND_SCREEN="second_screen",s.PIP="pip"})(At||(At={}));function ue(s,e,t,i){function r(a){return a instanceof t?a:new t(function(n){n(a)})}return new(t||(t=Promise))(function(a,n){function o(l){try{d(i.next(l))}catch(c){n(c)}}function u(l){try{d(i.throw(l))}catch(c){n(c)}}function d(l){l.done?a(l.value):r(l.value).then(o,u)}d((i=i.apply(s,e||[])).next())})}function M(s){return this instanceof M?(this.v=s,this):new M(s)}function Me(s,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=t.apply(s,e||[]),r,a=[];return r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r;function n(h){i[h]&&(r[h]=function(f){return new Promise(function(v,g){a.push([h,f,v,g])>1||o(h,f)})})}function o(h,f){try{u(i[h](f))}catch(v){c(a[0][3],v)}}function u(h){h.value instanceof M?Promise.resolve(h.value.v).then(d,l):c(a[0][2],h)}function d(h){o("next",h)}function l(h){o("throw",h)}function c(h,f){h(f),a.shift(),a.length&&o(a[0][0],a[0][1])}}var Dl=s=>new Promise((e,t)=>{const i=document.createElement("script");i.setAttribute("src",s),i.onload=()=>e,i.onerror=()=>t,document.body.appendChild(i)});class Il{constructor(e){var t;this.connection$=new S(void 0),this.castState$=new S($e.NOT_AVAILABLE),this.errorEvent$=new x,this.realCastState$=new S($e.NOT_AVAILABLE),this.subscription=new ae,this.params=e,this.log=this.params.dependencies.logger.createComponentLog("ChromecastInitializer");const i="chrome"in window;if(this.log({message:`[constructor] receiverApplicationId: ${this.params.receiverApplicationId}, isDisabled: ${this.params.isDisabled}, isSupported: ${i}`}),e.isDisabled||!i)return;const r=k((t=window.chrome)===null||t===void 0?void 0:t.cast),a=!!window.__onGCastApiAvailable;r?this.initializeCastApi():(window.__onGCastApiAvailable=n=>{delete window.__onGCastApiAvailable,n&&this.initializeCastApi()},a||Dl("https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1").catch(()=>this.errorEvent$.next({id:"ChromecastLoading",category:L.NETWORK,message:"Script loading failed!"})))}connect(){var e;(e=cast.framework.CastContext.getInstance())===null||e===void 0||e.requestSession()}disconnect(){var e,t;(t=(e=cast.framework.CastContext.getInstance())===null||e===void 0?void 0:e.getCurrentSession())===null||t===void 0||t.endSession(!0)}stopMedia(){return new Promise((e,t)=>{var i,r,a;(a=(r=(i=cast.framework.CastContext.getInstance())===null||i===void 0?void 0:i.getCurrentSession())===null||r===void 0?void 0:r.getMediaSession())===null||a===void 0||a.stop(new chrome.cast.media.StopRequest,e,t)})}toggleConnection(){k(this.connection$.getValue())?this.disconnect():this.connect()}setVolume(e){const t=this.connection$.getValue();ie(t)||(t.remotePlayer.volumeLevel=e,t.remotePlayerController.setVolumeLevel())}setMuted(e){const t=this.connection$.getValue();ie(t)||e!==t.remotePlayer.isMuted&&t.remotePlayerController.muteOrUnmute()}destroy(){this.subscription.unsubscribe()}initListeners(){const e=new cast.framework.RemotePlayer,t=new cast.framework.RemotePlayerController(e),i=cast.framework.CastContext.getInstance();this.subscription.add(B(i,cast.framework.CastContextEventType.SESSION_STATE_CHANGED).subscribe(r=>{var a,n;switch(r.sessionState){case cast.framework.SessionState.SESSION_STARTED:case cast.framework.SessionState.SESSION_STARTING:case cast.framework.SessionState.SESSION_RESUMED:this.contentId=(n=(a=i.getCurrentSession())===null||a===void 0?void 0:a.getMediaSession())===null||n===void 0?void 0:n.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:this.contentId=void 0;break;default:return H(r.sessionState)}})).add(V(B(i,cast.framework.CastContextEventType.CAST_STATE_CHANGED).pipe(Is(r=>{this.log({message:`[cast.framework.RemotePlayerEventType.CAST_STATE_CHANGED]: ${JSON.stringify(r)}`})}),w(r=>r.castState)),De([i.getCastState()])).pipe(ve(),w(Cl),Is(r=>{this.log({message:`realCastState$: ${r}`})})).subscribe(this.realCastState$)).add(this.realCastState$.subscribe(r=>{var a;const n=r===$e.CONNECTED,o=k(this.connection$.getValue());if(n&&!o){const u=i.getCurrentSession();P(u);const d=u.getCastDevice(),l=(a=u.getMediaSession())===null||a===void 0?void 0:a.media.contentId;(ie(l)||l===this.contentId)&&(this.log({message:"connection created"}),this.connection$.next({remotePlayer:e,remotePlayerController:t,session:u,castDevice:d}))}else!n&&o&&(this.log({message:"connection destroyed"}),this.connection$.next(void 0));this.castState$.next(r===$e.CONNECTED?k(this.connection$.getValue())?$e.CONNECTED:$e.AVAILABLE:r)}))}initializeCastApi(){var e;let t,i,r;try{t=cast.framework.CastContext.getInstance(),i=chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,r=chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}catch(a){return}try{t.setOptions({receiverApplicationId:(e=this.params.receiverApplicationId)!==null&&e!==void 0?e:i,autoJoinPolicy:r}),this.initListeners()}catch(a){this.errorEvent$.next({id:"ChromecastInitializer",category:L.EXTERNAL_API,message:"[initializeCastApi] failed",thrown:a})}}}const Cl=s=>{switch(s){case cast.framework.CastState.NO_DEVICES_AVAILABLE:return $e.NOT_AVAILABLE;case cast.framework.CastState.NOT_CONNECTED:return $e.AVAILABLE;case cast.framework.CastState.CONNECTING:return $e.CONNECTING;case cast.framework.CastState.CONNECTED:return $e.CONNECTED;default:return H(s)}};var mr=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Gs(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var qe=function(s){try{return!!s()}catch(e){return!0}},xl=qe,Ys=!xl(function(){var s=function(){}.bind();return typeof s!="function"||s.hasOwnProperty("prototype")}),Ed=Ys,$d=Function.prototype,va=$d.call,Ll=Ed&&$d.bind.bind(va,va),ze=Ed?Ll:function(s){return function(){return va.apply(s,arguments)}},Ad=ze,Ol=Ad({}.toString),Ml=Ad("".slice),Vi=function(s){return Ml(Ol(s),8,-1)},Bl=ze,Nl=qe,Fl=Vi,gr=Object,Ul=Bl("".split),Vl=Nl(function(){return!gr("z").propertyIsEnumerable(0)})?function(s){return Fl(s)=="String"?Ul(s,""):gr(s)}:gr,Hi=function(s){return s==null},Hl=Hi,Gl=TypeError,Va=function(s){if(Hl(s))throw Gl("Can't call method on "+s);return s},Yl=Vl,jl=Va,Gi=function(s){return Yl(jl(s))},pi={},ss=function(s){return s&&s.Math==Math&&s},_e=ss(typeof globalThis=="object"&&globalThis)||ss(typeof window=="object"&&window)||ss(typeof self=="object"&&self)||ss(typeof mr=="object"&&mr)||function(){return this}()||mr||Function("return this")(),ma=typeof document=="object"&&document.all,ql=typeof ma=="undefined"&&ma!==void 0,_d={all:ma,IS_HTMLDDA:ql},wd=_d,zl=wd.all,Ee=wd.IS_HTMLDDA?function(s){return typeof s=="function"||s===zl}:function(s){return typeof s=="function"},Wl=_e,Ql=Ee,Pn=Wl.WeakMap,Kl=Ql(Pn)&&/native code/.test(String(Pn)),Rn=Ee,kd=_d,Jl=kd.all,vt=kd.IS_HTMLDDA?function(s){return typeof s=="object"?s!==null:Rn(s)||s===Jl}:function(s){return typeof s=="object"?s!==null:Rn(s)},Xl=qe,Rt=!Xl(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),Ht={},Zl=_e,Dn=vt,ga=Zl.document,ec=Dn(ga)&&Dn(ga.createElement),Ha=function(s){return ec?ga.createElement(s):{}},tc=Rt,ic=qe,sc=Ha,Pd=!tc&&!ic(function(){return Object.defineProperty(sc("div"),"a",{get:function(){return 7}}).a!=7}),rc=Rt,ac=qe,Rd=rc&&ac(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),nc=vt,oc=String,dc=TypeError,mt=function(s){if(nc(s))return s;throw dc(oc(s)+" is not an object")},uc=Ys,rs=Function.prototype.call,Fe=uc?rs.bind(rs):function(){return rs.apply(rs,arguments)},Ga={},Sr=Ga,br=_e,lc=Ee,In=function(s){return lc(s)?s:void 0},Gt=function(s,e){return arguments.length<2?In(Sr[s])||In(br[s]):Sr[s]&&Sr[s][e]||br[s]&&br[s][e]},cc=ze,js=cc({}.isPrototypeOf),qs=typeof navigator!="undefined"&&String(navigator.userAgent)||"",Dd=_e,yr=qs,Cn=Dd.process,xn=Dd.Deno,Ln=Cn&&Cn.versions||xn&&xn.version,On=Ln&&Ln.v8,Ke,xs;On&&(Ke=On.split("."),xs=Ke[0]>0&&Ke[0]<4?1:+(Ke[0]+Ke[1]));!xs&&yr&&(Ke=yr.match(/Edge\/(\d+)/),(!Ke||Ke[1]>=74)&&(Ke=yr.match(/Chrome\/(\d+)/),Ke&&(xs=+Ke[1])));var Id=xs,Mn=Id,hc=qe,fc=_e,pc=fc.String,Cd=!!Object.getOwnPropertySymbols&&!hc(function(){var s=Symbol();return!pc(s)||!(Object(s)instanceof Symbol)||!Symbol.sham&&Mn&&Mn<41}),vc=Cd,xd=vc&&!Symbol.sham&&typeof Symbol.iterator=="symbol",mc=Gt,gc=Ee,Sc=js,bc=xd,yc=Object,Ld=bc?function(s){return typeof s=="symbol"}:function(s){var e=mc("Symbol");return gc(e)&&Sc(e.prototype,yc(s))},Tc=String,zs=function(s){try{return Tc(s)}catch(e){return"Object"}},Ec=Ee,$c=zs,Ac=TypeError,Yt=function(s){if(Ec(s))return s;throw Ac($c(s)+" is not a function")},_c=Yt,wc=Hi,Ws=function(s,e){var t=s[e];return wc(t)?void 0:_c(t)},Tr=Fe,Er=Ee,$r=vt,kc=TypeError,Pc=function(s,e){var t,i;if(e==="string"&&Er(t=s.toString)&&!$r(i=Tr(t,s))||Er(t=s.valueOf)&&!$r(i=Tr(t,s))||e!=="string"&&Er(t=s.toString)&&!$r(i=Tr(t,s)))return i;throw kc("Can't convert object to primitive value")},Od={exports:{}},Rc=!0,Bn=_e,Dc=Object.defineProperty,Ic=function(s,e){try{Dc(Bn,s,{value:e,configurable:!0,writable:!0})}catch(t){Bn[s]=e}return e},Cc=_e,xc=Ic,Nn="__core-js_shared__",Lc=Cc[Nn]||xc(Nn,{}),Ya=Lc,Fn=Ya;(Od.exports=function(s,e){return Fn[s]||(Fn[s]=e!==void 0?e:{})})("versions",[]).push({version:"3.31.0",mode:"pure",copyright:"\xA9 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.31.0/LICENSE",source:"https://github.com/zloirock/core-js"});var Md=Od.exports,Oc=Va,Mc=Object,Qs=function(s){return Mc(Oc(s))},Bc=ze,Nc=Qs,Fc=Bc({}.hasOwnProperty),ot=Object.hasOwn||function(e,t){return Fc(Nc(e),t)},Uc=ze,Vc=0,Hc=Math.random(),Gc=Uc(1 .toString),Bd=function(s){return"Symbol("+(s===void 0?"":s)+")_"+Gc(++Vc+Hc,36)},Yc=_e,jc=Md,Un=ot,qc=Bd,zc=Cd,Wc=xd,si=Yc.Symbol,Ar=jc("wks"),Qc=Wc?si.for||si:si&&si.withoutSetter||qc,Pe=function(s){return Un(Ar,s)||(Ar[s]=zc&&Un(si,s)?si[s]:Qc("Symbol."+s)),Ar[s]},Kc=Fe,Vn=vt,Hn=Ld,Jc=Ws,Xc=Pc,Zc=Pe,eh=TypeError,th=Zc("toPrimitive"),ih=function(s,e){if(!Vn(s)||Hn(s))return s;var t=Jc(s,th),i;if(t){if(e===void 0&&(e="default"),i=Kc(t,s,e),!Vn(i)||Hn(i))return i;throw eh("Can't convert object to primitive value")}return e===void 0&&(e="number"),Xc(s,e)},sh=ih,rh=Ld,ja=function(s){var e=sh(s,"string");return rh(e)?e:e+""},ah=Rt,nh=Pd,oh=Rd,as=mt,Gn=ja,dh=TypeError,_r=Object.defineProperty,uh=Object.getOwnPropertyDescriptor,wr="enumerable",kr="configurable",Pr="writable";Ht.f=ah?oh?function(e,t,i){if(as(e),t=Gn(t),as(i),typeof e=="function"&&t==="prototype"&&"value"in i&&Pr in i&&!i[Pr]){var r=uh(e,t);r&&r[Pr]&&(e[t]=i.value,i={configurable:kr in i?i[kr]:r[kr],enumerable:wr in i?i[wr]:r[wr],writable:!1})}return _r(e,t,i)}:_r:function(e,t,i){if(as(e),t=Gn(t),as(i),nh)try{return _r(e,t,i)}catch(r){}if("get"in i||"set"in i)throw dh("Accessors not supported");return"value"in i&&(e[t]=i.value),e};var Ks=function(s,e){return{enumerable:!(s&1),configurable:!(s&2),writable:!(s&4),value:e}},lh=Rt,ch=Ht,hh=Ks,Yi=lh?function(s,e,t){return ch.f(s,e,hh(1,t))}:function(s,e,t){return s[e]=t,s},fh=Md,ph=Bd,Yn=fh("keys"),qa=function(s){return Yn[s]||(Yn[s]=ph(s))},za={},vh=Kl,Nd=_e,mh=vt,gh=Yi,Rr=ot,Dr=Ya,Sh=qa,bh=za,jn="Object already initialized",Sa=Nd.TypeError,yh=Nd.WeakMap,Ls,Bi,Os,Th=function(s){return Os(s)?Bi(s):Ls(s,{})},Eh=function(s){return function(e){var t;if(!mh(e)||(t=Bi(e)).type!==s)throw Sa("Incompatible receiver, "+s+" required");return t}};if(vh||Dr.state){var tt=Dr.state||(Dr.state=new yh);tt.get=tt.get,tt.has=tt.has,tt.set=tt.set,Ls=function(s,e){if(tt.has(s))throw Sa(jn);return e.facade=s,tt.set(s,e),e},Bi=function(s){return tt.get(s)||{}},Os=function(s){return tt.has(s)}}else{var Jt=Sh("state");bh[Jt]=!0,Ls=function(s,e){if(Rr(s,Jt))throw Sa(jn);return e.facade=s,gh(s,Jt,e),e},Bi=function(s){return Rr(s,Jt)?s[Jt]:{}},Os=function(s){return Rr(s,Jt)}}var Fd={set:Ls,get:Bi,has:Os,enforce:Th,getterFor:Eh},$h=Ys,Ud=Function.prototype,qn=Ud.apply,zn=Ud.call,Vd=typeof Reflect=="object"&&Reflect.apply||($h?zn.bind(qn):function(){return zn.apply(qn,arguments)}),Ah=Vi,_h=ze,Hd=function(s){if(Ah(s)==="Function")return _h(s)},Wa={},Gd={},Yd={}.propertyIsEnumerable,jd=Object.getOwnPropertyDescriptor,wh=jd&&!Yd.call({1:2},1);Gd.f=wh?function(e){var t=jd(this,e);return!!t&&t.enumerable}:Yd;var kh=Rt,Ph=Fe,Rh=Gd,Dh=Ks,Ih=Gi,Ch=ja,xh=ot,Lh=Pd,Wn=Object.getOwnPropertyDescriptor;Wa.f=kh?Wn:function(e,t){if(e=Ih(e),t=Ch(t),Lh)try{return Wn(e,t)}catch(i){}if(xh(e,t))return Dh(!Ph(Rh.f,e,t),e[t])};var Oh=qe,Mh=Ee,Bh=/#|\.prototype\./,ji=function(s,e){var t=Fh[Nh(s)];return t==Vh?!0:t==Uh?!1:Mh(e)?Oh(e):!!e},Nh=ji.normalize=function(s){return String(s).replace(Bh,".").toLowerCase()},Fh=ji.data={},Uh=ji.NATIVE="N",Vh=ji.POLYFILL="P",qd=ji,Qn=Hd,Hh=Yt,Gh=Ys,Yh=Qn(Qn.bind),Js=function(s,e){return Hh(s),e===void 0?s:Gh?Yh(s,e):function(){return s.apply(e,arguments)}},ns=_e,jh=Vd,qh=Hd,zh=Ee,Wh=Wa.f,Qh=qd,Xt=Ga,Kh=Js,Zt=Yi,Kn=ot,Jh=function(s){var e=function(t,i,r){if(this instanceof e){switch(arguments.length){case 0:return new s;case 1:return new s(t);case 2:return new s(t,i)}return new s(t,i,r)}return jh(s,this,arguments)};return e.prototype=s.prototype,e},Ze=function(s,e){var t=s.target,i=s.global,r=s.stat,a=s.proto,n=i?ns:r?ns[t]:(ns[t]||{}).prototype,o=i?Xt:Xt[t]||Zt(Xt,t,{})[t],u=o.prototype,d,l,c,h,f,v,g,T,A;for(h in e)d=Qh(i?h:t+(r?".":"#")+h,s.forced),l=!d&&n&&Kn(n,h),v=o[h],l&&(s.dontCallGetSet?(A=Wh(n,h),g=A&&A.value):g=n[h]),f=l&&g?g:e[h],!(l&&typeof v==typeof f)&&(s.bind&&l?T=Kh(f,ns):s.wrap&&l?T=Jh(f):a&&zh(f)?T=qh(f):T=f,(s.sham||f&&f.sham||v&&v.sham)&&Zt(T,"sham",!0),Zt(o,h,T),a&&(c=t+"Prototype",Kn(Xt,c)||Zt(Xt,c,{}),Zt(Xt[c],h,f),s.real&&u&&(d||!u[h])&&Zt(u,h,f)))},ba=Rt,Xh=ot,zd=Function.prototype,Zh=ba&&Object.getOwnPropertyDescriptor,Qa=Xh(zd,"name"),ef=Qa&&function(){}.name==="something",tf=Qa&&(!ba||ba&&Zh(zd,"name").configurable),sf={EXISTS:Qa,PROPER:ef,CONFIGURABLE:tf},Wd={},rf=Math.ceil,af=Math.floor,nf=Math.trunc||function(e){var t=+e;return(t>0?af:rf)(t)},of=nf,Ka=function(s){var e=+s;return e!==e||e===0?0:of(e)},df=Ka,uf=Math.max,lf=Math.min,cf=function(s,e){var t=df(s);return t<0?uf(t+e,0):lf(t,e)},hf=Ka,ff=Math.min,pf=function(s){return s>0?ff(hf(s),9007199254740991):0},vf=pf,Ja=function(s){return vf(s.length)},mf=Gi,gf=cf,Sf=Ja,Jn=function(s){return function(e,t,i){var r=mf(e),a=Sf(r),n=gf(i,a),o;if(s&&t!=t){for(;a>n;)if(o=r[n++],o!=o)return!0}else for(;a>n;n++)if((s||n in r)&&r[n]===t)return s||n||0;return!s&&-1}},bf={includes:Jn(!0),indexOf:Jn(!1)},yf=ze,Ir=ot,Tf=Gi,Ef=bf.indexOf,$f=za,Xn=yf([].push),Af=function(s,e){var t=Tf(s),i=0,r=[],a;for(a in t)!Ir($f,a)&&Ir(t,a)&&Xn(r,a);for(;e.length>i;)Ir(t,a=e[i++])&&(~Ef(r,a)||Xn(r,a));return r},Qd=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],_f=Af,wf=Qd,kf=Object.keys||function(e){return _f(e,wf)},Pf=Rt,Rf=Rd,Df=Ht,If=mt,Cf=Gi,xf=kf;Wd.f=Pf&&!Rf?Object.defineProperties:function(e,t){If(e);for(var i=Cf(t),r=xf(t),a=r.length,n=0,o;a>n;)Df.f(e,o=r[n++],i[o]);return e};var Lf=Gt,Kd=Lf("document","documentElement"),Of=mt,Mf=Wd,Zn=Qd,Bf=za,Nf=Kd,Ff=Ha,Uf=qa,eo=">",to="<",ya="prototype",Ta="script",Jd=Uf("IE_PROTO"),Cr=function(){},Xd=function(s){return to+Ta+eo+s+to+"/"+Ta+eo},io=function(s){s.write(Xd("")),s.close();var e=s.parentWindow.Object;return s=null,e},Vf=function(){var s=Ff("iframe"),e="java"+Ta+":",t;return s.style.display="none",Nf.appendChild(s),s.src=String(e),t=s.contentWindow.document,t.open(),t.write(Xd("document.F=Object")),t.close(),t.F},os,ks=function(){try{os=new ActiveXObject("htmlfile")}catch(e){}ks=typeof document!="undefined"?document.domain&&os?io(os):Vf():io(os);for(var s=Zn.length;s--;)delete ks[ya][Zn[s]];return ks()};Bf[Jd]=!0;var Zd=Object.create||function(e,t){var i;return e!==null?(Cr[ya]=Of(e),i=new Cr,Cr[ya]=null,i[Jd]=e):i=ks(),t===void 0?i:Mf.f(i,t)},Hf=qe,Gf=!Hf(function(){function s(){}return s.prototype.constructor=null,Object.getPrototypeOf(new s)!==s.prototype}),Yf=ot,jf=Ee,qf=Qs,zf=qa,Wf=Gf,so=zf("IE_PROTO"),Ea=Object,Qf=Ea.prototype,eu=Wf?Ea.getPrototypeOf:function(s){var e=qf(s);if(Yf(e,so))return e[so];var t=e.constructor;return jf(t)&&e instanceof t?t.prototype:e instanceof Ea?Qf:null},Kf=Yi,Xa=function(s,e,t,i){return i&&i.enumerable?s[e]=t:Kf(s,e,t),s},Jf=qe,Xf=Ee,Zf=vt,ep=Zd,ro=eu,tp=Xa,ip=Pe,$a=ip("iterator"),tu=!1,ht,xr,Lr;[].keys&&(Lr=[].keys(),"next"in Lr?(xr=ro(ro(Lr)),xr!==Object.prototype&&(ht=xr)):tu=!0);var sp=!Zf(ht)||Jf(function(){var s={};return ht[$a].call(s)!==s});sp?ht={}:ht=ep(ht);Xf(ht[$a])||tp(ht,$a,function(){return this});var iu={IteratorPrototype:ht,BUGGY_SAFARI_ITERATORS:tu},rp=Pe,ap=rp("toStringTag"),su={};su[ap]="z";var Za=String(su)==="[object z]",np=Za,op=Ee,Ps=Vi,dp=Pe,up=dp("toStringTag"),lp=Object,cp=Ps(function(){return arguments}())=="Arguments",hp=function(s,e){try{return s[e]}catch(t){}},qi=np?Ps:function(s){var e,t,i;return s===void 0?"Undefined":s===null?"Null":typeof(t=hp(e=lp(s),up))=="string"?t:cp?Ps(e):(i=Ps(e))=="Object"&&op(e.callee)?"Arguments":i},fp=Za,pp=qi,vp=fp?{}.toString:function(){return"[object "+pp(this)+"]"},mp=Za,gp=Ht.f,Sp=Yi,bp=ot,yp=vp,Tp=Pe,ao=Tp("toStringTag"),en=function(s,e,t,i){if(s){var r=t?s:s.prototype;bp(r,ao)||gp(r,ao,{configurable:!0,value:e}),i&&!mp&&Sp(r,"toString",yp)}},Ep=iu.IteratorPrototype,$p=Zd,Ap=Ks,_p=en,wp=pi,kp=function(){return this},Pp=function(s,e,t,i){var r=e+" Iterator";return s.prototype=$p(Ep,{next:Ap(+!i,t)}),_p(s,r,!1,!0),wp[r]=kp,s},Rp=Ze,Dp=Fe,ru=sf,Ip=Pp,Cp=eu,xp=en,no=Xa,Lp=Pe,oo=pi,au=iu,Op=ru.PROPER;ru.CONFIGURABLE;au.IteratorPrototype;var ds=au.BUGGY_SAFARI_ITERATORS,Or=Lp("iterator"),uo="keys",us="values",lo="entries",Mp=function(){return this},Bp=function(s,e,t,i,r,a,n){Ip(t,e,i);var o=function(A){if(A===r&&h)return h;if(!ds&&A in l)return l[A];switch(A){case uo:return function(){return new t(this,A)};case us:return function(){return new t(this,A)};case lo:return function(){return new t(this,A)}}return function(){return new t(this)}},u=e+" Iterator",d=!1,l=s.prototype,c=l[Or]||l["@@iterator"]||r&&l[r],h=!ds&&c||o(r),f=e=="Array"&&l.entries||c,v,g,T;if(f&&(v=Cp(f.call(new s)),v!==Object.prototype&&v.next&&(xp(v,u,!0,!0),oo[u]=Mp)),Op&&r==us&&c&&c.name!==us&&(d=!0,h=function(){return Dp(c,this)}),r)if(g={values:o(us),keys:a?h:o(uo),entries:o(lo)},n)for(T in g)(ds||d||!(T in l))&&no(l,T,g[T]);else Rp({target:e,proto:!0,forced:ds||d},g);return n&&l[Or]!==h&&no(l,Or,h,{name:r}),oo[e]=h,g},Np=function(s,e){return{value:s,done:e}},Fp=Gi,co=pi,nu=Fd;Ht.f;var Up=Bp,ls=Np,ou="Array Iterator",Vp=nu.set,Hp=nu.getterFor(ou);Up(Array,"Array",function(s,e){Vp(this,{type:ou,target:Fp(s),index:0,kind:e})},function(){var s=Hp(this),e=s.target,t=s.kind,i=s.index++;return!e||i>=e.length?(s.target=void 0,ls(void 0,!0)):t=="keys"?ls(i,!1):t=="values"?ls(e[i],!1):ls([i,e[i]],!1)},"values");co.Arguments=co.Array;var Gp=Pe,Yp=pi,jp=Gp("iterator"),qp=Array.prototype,zp=function(s){return s!==void 0&&(Yp.Array===s||qp[jp]===s)},Wp=qi,ho=Ws,Qp=Hi,Kp=pi,Jp=Pe,Xp=Jp("iterator"),du=function(s){if(!Qp(s))return ho(s,Xp)||ho(s,"@@iterator")||Kp[Wp(s)]},Zp=Fe,ev=Yt,tv=mt,iv=zs,sv=du,rv=TypeError,av=function(s,e){var t=arguments.length<2?sv(s):e;if(ev(t))return tv(Zp(t,s));throw rv(iv(s)+" is not iterable")},nv=Fe,fo=mt,ov=Ws,dv=function(s,e,t){var i,r;fo(s);try{if(i=ov(s,"return"),!i){if(e==="throw")throw t;return t}i=nv(i,s)}catch(a){r=!0,i=a}if(e==="throw")throw t;if(r)throw i;return fo(i),t},uv=Js,lv=Fe,cv=mt,hv=zs,fv=zp,pv=Ja,po=js,vv=av,mv=du,vo=dv,gv=TypeError,Rs=function(s,e){this.stopped=s,this.result=e},mo=Rs.prototype,tn=function(s,e,t){var i=t&&t.that,r=!!(t&&t.AS_ENTRIES),a=!!(t&&t.IS_RECORD),n=!!(t&&t.IS_ITERATOR),o=!!(t&&t.INTERRUPTED),u=uv(e,i),d,l,c,h,f,v,g,T=function(E){return d&&vo(d,"normal",E),new Rs(!0,E)},A=function(E){return r?(cv(E),o?u(E[0],E[1],T):u(E[0],E[1])):o?u(E,T):u(E)};if(a)d=s.iterator;else if(n)d=s;else{if(l=mv(s),!l)throw gv(hv(s)+" is not iterable");if(fv(l)){for(c=0,h=pv(s);h>c;c++)if(f=A(s[c]),f&&po(mo,f))return f;return new Rs(!1)}d=vv(s,l)}for(v=a?s.next:d.next;!(g=lv(v,d)).done;){try{f=A(g.value)}catch(E){vo(d,"throw",E)}if(typeof f=="object"&&f&&po(mo,f))return f}return new Rs(!1)},Sv=ja,bv=Ht,yv=Ks,Tv=function(s,e,t){var i=Sv(e);i in s?bv.f(s,i,yv(0,t)):s[i]=t},Ev=Ze,$v=tn,Av=Tv;Ev({target:"Object",stat:!0},{fromEntries:function(e){var t={};return $v(e,function(i,r){Av(t,i,r)},{AS_ENTRIES:!0}),t}});var _v=Ga,wv=_v.Object.fromEntries,kv={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},Pv=kv,Rv=_e,Dv=qi,Iv=Yi,go=pi,Cv=Pe,So=Cv("toStringTag");for(var Mr in Pv){var bo=Rv[Mr],Br=bo&&bo.prototype;Br&&Dv(Br)!==So&&Iv(Br,So,Mr),go[Mr]=go.Array}var xv=wv,Lv=xv,Ov=Lv,Mv=Ov,li=Gs(Mv),Bv=Vi,Xs=typeof process!="undefined"&&Bv(process)=="process",Nv=Ht,Fv=function(s,e,t){return Nv.f(s,e,t)},Uv=Gt,Vv=Fv,Hv=Pe,Gv=Rt,yo=Hv("species"),Yv=function(s){var e=Uv(s);Gv&&e&&!e[yo]&&Vv(e,yo,{configurable:!0,get:function(){return this}})},jv=js,qv=TypeError,zv=function(s,e){if(jv(e,s))return s;throw qv("Incorrect invocation")},Wv=ze,Qv=Ee,Aa=Ya,Kv=Wv(Function.toString);Qv(Aa.inspectSource)||(Aa.inspectSource=function(s){return Kv(s)});var uu=Aa.inspectSource,Jv=ze,Xv=qe,lu=Ee,Zv=qi,em=Gt,tm=uu,cu=function(){},im=[],hu=em("Reflect","construct"),sn=/^\s*(?:class|function)\b/,sm=Jv(sn.exec),rm=!sn.exec(cu),_i=function(e){if(!lu(e))return!1;try{return hu(cu,im,e),!0}catch(t){return!1}},fu=function(e){if(!lu(e))return!1;switch(Zv(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return rm||!!sm(sn,tm(e))}catch(t){return!0}};fu.sham=!0;var am=!hu||Xv(function(){var s;return _i(_i.call)||!_i(Object)||!_i(function(){s=!0})||s})?fu:_i,nm=am,om=zs,dm=TypeError,um=function(s){if(nm(s))return s;throw dm(om(s)+" is not a constructor")},To=mt,lm=um,cm=Hi,hm=Pe,fm=hm("species"),pu=function(s,e){var t=To(s).constructor,i;return t===void 0||cm(i=To(t)[fm])?e:lm(i)},pm=ze,vm=pm([].slice),mm=TypeError,gm=function(s,e){if(s<e)throw mm("Not enough arguments");return s},Sm=qs,vu=/(?:ipad|iphone|ipod).*applewebkit/i.test(Sm),Be=_e,bm=Vd,ym=Js,Eo=Ee,Tm=ot,mu=qe,$o=Kd,Em=vm,Ao=Ha,$m=gm,Am=vu,_m=Xs,_a=Be.setImmediate,wa=Be.clearImmediate,wm=Be.process,Nr=Be.Dispatch,km=Be.Function,_o=Be.MessageChannel,Pm=Be.String,Fr=0,Ci={},wo="onreadystatechange",Ni,Mt,Ur,Vr;mu(function(){Ni=Be.location});var rn=function(s){if(Tm(Ci,s)){var e=Ci[s];delete Ci[s],e()}},Hr=function(s){return function(){rn(s)}},ko=function(s){rn(s.data)},Po=function(s){Be.postMessage(Pm(s),Ni.protocol+"//"+Ni.host)};(!_a||!wa)&&(_a=function(e){$m(arguments.length,1);var t=Eo(e)?e:km(e),i=Em(arguments,1);return Ci[++Fr]=function(){bm(t,void 0,i)},Mt(Fr),Fr},wa=function(e){delete Ci[e]},_m?Mt=function(s){wm.nextTick(Hr(s))}:Nr&&Nr.now?Mt=function(s){Nr.now(Hr(s))}:_o&&!Am?(Ur=new _o,Vr=Ur.port2,Ur.port1.onmessage=ko,Mt=ym(Vr.postMessage,Vr)):Be.addEventListener&&Eo(Be.postMessage)&&!Be.importScripts&&Ni&&Ni.protocol!=="file:"&&!mu(Po)?(Mt=Po,Be.addEventListener("message",ko,!1)):wo in Ao("script")?Mt=function(s){$o.appendChild(Ao("script"))[wo]=function(){$o.removeChild(this),rn(s)}}:Mt=function(s){setTimeout(Hr(s),0)});var gu={set:_a,clear:wa},Su=function(){this.head=null,this.tail=null};Su.prototype={add:function(s){var e={item:s,next:null},t=this.tail;t?t.next=e:this.head=e,this.tail=e},get:function(){var s=this.head;if(s){var e=this.head=s.next;return e===null&&(this.tail=null),s.item}}};var bu=Su,Rm=qs,Dm=/ipad|iphone|ipod/i.test(Rm)&&typeof Pebble!="undefined",Im=qs,Cm=/web0s(?!.*chrome)/i.test(Im),Ut=_e,Ro=Js,xm=Wa.f,Gr=gu.set,Lm=bu,Om=vu,Mm=Dm,Bm=Cm,Yr=Xs,Do=Ut.MutationObserver||Ut.WebKitMutationObserver,Io=Ut.document,Co=Ut.process,cs=Ut.Promise,xo=xm(Ut,"queueMicrotask"),ka=xo&&xo.value,ei,jr,qr,hs,Lo;if(!ka){var fs=new Lm,ps=function(){var s,e;for(Yr&&(s=Co.domain)&&s.exit();e=fs.get();)try{e()}catch(t){throw fs.head&&ei(),t}s&&s.enter()};!Om&&!Yr&&!Bm&&Do&&Io?(jr=!0,qr=Io.createTextNode(""),new Do(ps).observe(qr,{characterData:!0}),ei=function(){qr.data=jr=!jr}):!Mm&&cs&&cs.resolve?(hs=cs.resolve(void 0),hs.constructor=cs,Lo=Ro(hs.then,hs),ei=function(){Lo(ps)}):Yr?ei=function(){Co.nextTick(ps)}:(Gr=Ro(Gr,Ut),ei=function(){Gr(ps)}),ka=function(s){fs.head||ei(),fs.add(s)}}var Nm=ka,Fm=function(s,e){try{arguments.length==1?console.error(s):console.error(s,e)}catch(t){}},an=function(s){try{return{error:!1,value:s()}}catch(e){return{error:!0,value:e}}},Um=_e,vi=Um.Promise,yu=typeof Deno=="object"&&Deno&&typeof Deno.version=="object",Vm=yu,Hm=Xs,Gm=!Vm&&!Hm&&typeof window=="object"&&typeof document=="object",Ym=_e,xi=vi,jm=Ee,qm=qd,zm=uu,Wm=Pe,Qm=Gm,Km=yu,zr=Id,Oo=xi&&xi.prototype,Jm=Wm("species"),Pa=!1,Tu=jm(Ym.PromiseRejectionEvent),Xm=qm("Promise",function(){var s=zm(xi),e=s!==String(xi);if(!e&&zr===66||!(Oo.catch&&Oo.finally))return!0;if(!zr||zr<51||!/native code/.test(s)){var t=new xi(function(a){a(1)}),i=function(a){a(function(){},function(){})},r=t.constructor={};if(r[Jm]=i,Pa=t.then(function(){})instanceof i,!Pa)return!0}return!e&&(Qm||Km)&&!Tu}),zi={CONSTRUCTOR:Xm,REJECTION_EVENT:Tu,SUBCLASSING:Pa},mi={},Mo=Yt,Zm=TypeError,eg=function(s){var e,t;this.promise=new s(function(i,r){if(e!==void 0||t!==void 0)throw Zm("Bad Promise constructor");e=i,t=r}),this.resolve=Mo(e),this.reject=Mo(t)};mi.f=function(s){return new eg(s)};var tg=Ze,Ms=Xs,Pt=_e,Wi=Fe,ig=Xa,sg=en,rg=Yv,ag=Yt,Ra=Ee,ng=vt,og=zv,dg=pu,Eu=gu.set,nn=Nm,ug=Fm,lg=an,cg=bu,$u=Fd,Da=vi,on=zi,Au=mi,Zs="Promise",_u=on.CONSTRUCTOR,hg=on.REJECTION_EVENT;on.SUBCLASSING;var Wr=$u.getterFor(Zs),fg=$u.set,pg=Da&&Da.prototype,ri=Da,Qr=pg,wu=Pt.TypeError,Ia=Pt.document,dn=Pt.process,Ca=Au.f,vg=Ca,mg=!!(Ia&&Ia.createEvent&&Pt.dispatchEvent),ku="unhandledrejection",gg="rejectionhandled",Bo=0,Pu=1,Sg=2,un=1,Ru=2,vs,No,bg,Du=function(s){var e;return ng(s)&&Ra(e=s.then)?e:!1},Iu=function(s,e){var t=e.value,i=e.state==Pu,r=i?s.ok:s.fail,a=s.resolve,n=s.reject,o=s.domain,u,d,l;try{r?(i||(e.rejection===Ru&&Tg(e),e.rejection=un),r===!0?u=t:(o&&o.enter(),u=r(t),o&&(o.exit(),l=!0)),u===s.promise?n(wu("Promise-chain cycle")):(d=Du(u))?Wi(d,u,a,n):a(u)):n(t)}catch(c){o&&!l&&o.exit(),n(c)}},Cu=function(s,e){s.notified||(s.notified=!0,nn(function(){for(var t=s.reactions,i;i=t.get();)Iu(i,s);s.notified=!1,e&&!s.rejection&&yg(s)}))},xu=function(s,e,t){var i,r;mg?(i=Ia.createEvent("Event"),i.promise=e,i.reason=t,i.initEvent(s,!1,!0),Pt.dispatchEvent(i)):i={promise:e,reason:t},!hg&&(r=Pt["on"+s])?r(i):s===ku&&ug("Unhandled promise rejection",t)},yg=function(s){Wi(Eu,Pt,function(){var e=s.facade,t=s.value,i=Fo(s),r;if(i&&(r=lg(function(){Ms?dn.emit("unhandledRejection",t,e):xu(ku,e,t)}),s.rejection=Ms||Fo(s)?Ru:un,r.error))throw r.value})},Fo=function(s){return s.rejection!==un&&!s.parent},Tg=function(s){Wi(Eu,Pt,function(){var e=s.facade;Ms?dn.emit("rejectionHandled",e):xu(gg,e,s.value)})},ai=function(s,e,t){return function(i){s(e,i,t)}},oi=function(s,e,t){s.done||(s.done=!0,t&&(s=t),s.value=e,s.state=Sg,Cu(s,!0))},xa=function(s,e,t){if(!s.done){s.done=!0,t&&(s=t);try{if(s.facade===e)throw wu("Promise can't be resolved itself");var i=Du(e);i?nn(function(){var r={done:!1};try{Wi(i,e,ai(xa,r,s),ai(oi,r,s))}catch(a){oi(r,a,s)}}):(s.value=e,s.state=Pu,Cu(s,!1))}catch(r){oi({done:!1},r,s)}}};_u&&(ri=function(e){og(this,Qr),ag(e),Wi(vs,this);var t=Wr(this);try{e(ai(xa,t),ai(oi,t))}catch(i){oi(t,i)}},Qr=ri.prototype,vs=function(e){fg(this,{type:Zs,done:!1,notified:!1,parent:!1,reactions:new cg,rejection:!1,state:Bo,value:void 0})},vs.prototype=ig(Qr,"then",function(e,t){var i=Wr(this),r=Ca(dg(this,ri));return i.parent=!0,r.ok=Ra(e)?e:!0,r.fail=Ra(t)&&t,r.domain=Ms?dn.domain:void 0,i.state==Bo?i.reactions.add(r):nn(function(){Iu(r,i)}),r.promise}),No=function(){var s=new vs,e=Wr(s);this.promise=s,this.resolve=ai(xa,e),this.reject=ai(oi,e)},Au.f=Ca=function(s){return s===ri||s===bg?new No(s):vg(s)});tg({global:!0,constructor:!0,wrap:!0,forced:_u},{Promise:ri});sg(ri,Zs,!1,!0);rg(Zs);var Eg=Pe,Lu=Eg("iterator"),Ou=!1;try{var $g=0,Uo={next:function(){return{done:!!$g++}},return:function(){Ou=!0}};Uo[Lu]=function(){return this},Array.from(Uo,function(){throw 2})}catch(s){}var Ag=function(s,e){if(!e&&!Ou)return!1;var t=!1;try{var i={};i[Lu]=function(){return{next:function(){return{done:t=!0}}}},s(i)}catch(r){}return t},_g=vi,wg=Ag,kg=zi.CONSTRUCTOR,Mu=kg||!wg(function(s){_g.all(s).then(void 0,function(){})}),Pg=Ze,Rg=Fe,Dg=Yt,Ig=mi,Cg=an,xg=tn,Lg=Mu;Pg({target:"Promise",stat:!0,forced:Lg},{all:function(e){var t=this,i=Ig.f(t),r=i.resolve,a=i.reject,n=Cg(function(){var o=Dg(t.resolve),u=[],d=0,l=1;xg(e,function(c){var h=d++,f=!1;l++,Rg(o,t,c).then(function(v){f||(f=!0,u[h]=v,--l||r(u))},a)}),--l||r(u)});return n.error&&a(n.value),i.promise}});var Og=Ze,Mg=zi.CONSTRUCTOR,Vo=vi;Vo&&Vo.prototype;Og({target:"Promise",proto:!0,forced:Mg,real:!0},{catch:function(s){return this.then(void 0,s)}});var Bg=Ze,Ng=Fe,Fg=Yt,Ug=mi,Vg=an,Hg=tn,Gg=Mu;Bg({target:"Promise",stat:!0,forced:Gg},{race:function(e){var t=this,i=Ug.f(t),r=i.reject,a=Vg(function(){var n=Fg(t.resolve);Hg(e,function(o){Ng(n,t,o).then(i.resolve,r)})});return a.error&&r(a.value),i.promise}});var Yg=Ze,jg=Fe,qg=mi,zg=zi.CONSTRUCTOR;Yg({target:"Promise",stat:!0,forced:zg},{reject:function(e){var t=qg.f(this);return jg(t.reject,void 0,e),t.promise}});var Wg=mt,Qg=vt,Kg=mi,Bu=function(s,e){if(Wg(s),Qg(e)&&e.constructor===s)return e;var t=Kg.f(s),i=t.resolve;return i(e),t.promise},Jg=Ze,Xg=Gt,Zg=Rc,eS=vi,tS=zi.CONSTRUCTOR,iS=Bu,sS=Xg("Promise"),rS=!tS;Jg({target:"Promise",stat:!0,forced:Zg},{resolve:function(e){return iS(rS&&this===sS?eS:this,e)}});var aS=Ze,La=vi,nS=qe,oS=Gt,dS=Ee,uS=pu,Ho=Bu,lS=La&&La.prototype,cS=!!La&&nS(function(){lS.finally.call({then:function(){}},function(){})});aS({target:"Promise",proto:!0,real:!0,forced:cS},{finally:function(s){var e=uS(this,oS("Promise")),t=dS(s);return this.then(t?function(i){return Ho(e,s()).then(function(){return i})}:s,t?function(i){return Ho(e,s()).then(function(){throw i})}:s)}});var hS=Gt,ln=hS,fS=ln,pS=fS("Promise","finally"),vS=pS,mS=vS,gS=mS,SS=gS,er=Gs(SS),Te;(function(s){s[s.OFFSET_P=0]="OFFSET_P",s[s.PLAYBACK_SHIFT=1]="PLAYBACK_SHIFT",s[s.DASH_CMAF_OFFSET_P=2]="DASH_CMAF_OFFSET_P"})(Te||(Te={}));var Je=(s,e=0,t=Te.OFFSET_P)=>{switch(t){case Te.OFFSET_P:return s.replace("_offset_p",e===0?"":"_"+e.toFixed(0));case Te.PLAYBACK_SHIFT:{if(e===0)return s;const i=new URL(s);return i.searchParams.append("playback_shift",e.toFixed(0)),i.toString()}case Te.DASH_CMAF_OFFSET_P:{if(e===0)return s;const i=new URL(s);return i.searchParams.set("offset_p",e.toFixed(0)),i.toString()}default:H(t)}return s};const Go=(s,e)=>{var t;switch(e){case Te.OFFSET_P:return NaN;case Te.PLAYBACK_SHIFT:{const i=new URL(s);return Number(i.searchParams.get("playback_shift"))}case Te.DASH_CMAF_OFFSET_P:{const i=new URL(s);return Number((t=i.searchParams.get("offset_p"))!==null&&t!==void 0?t:0)}default:H(e)}};var D=(s,e,t=!1)=>{const i=s.getTransition();(t||!i||i.to===e)&&s.setState(e)};class ce{constructor(e){this.transitionStarted$=new x,this.transitionEnded$=new x,this.transitionUpdated$=new x,this.forceChanged$=new x,this.stateChangeStarted$=V(this.transitionStarted$,this.transitionUpdated$),this.stateChangeEnded$=V(this.transitionEnded$,this.forceChanged$),this.state=e,this.prevState=void 0}setState(e){const t=this.transition,i=this.state;this.transition=void 0,this.prevState=i,this.state=e,t?t.to===e?this.transitionEnded$.next(t):this.forceChanged$.next({from:t.from,to:e,canceledTransition:t}):this.forceChanged$.next({from:i,to:e,canceledTransition:t})}startTransitionTo(e){const t=this.transition,i=this.state;i===e||k(t)&&t.to===e||(this.prevState=i,this.state=e,t?(this.transition={from:t.from,to:e,canceledTransition:t},this.transitionUpdated$.next(this.transition)):(this.transition={from:i,to:e},this.transitionStarted$.next(this.transition)))}getTransition(){return this.transition}getState(){return this.state}getPrevState(){return this.prevState}}const bS=s=>{switch(s){case y.MPEG:case y.DASH:case y.DASH_SEP:case y.DASH_ONDEMAND:case y.DASH_WEBM:case y.DASH_WEBM_AV1:case y.HLS:case y.HLS_ONDEMAND:return!1;case y.DASH_LIVE:case y.DASH_LIVE_CMAF:case y.HLS_LIVE:case y.HLS_LIVE_CMAF:case y.DASH_LIVE_WEBM:case y.WEB_RTC_LIVE:return!0;default:return H(s)}};var q;(function(s){s.STOPPED="stopped",s.READY="ready",s.PLAYING="playing",s.PAUSED="paused"})(q||(q={}));const yS=5,TS=5,ES=500,Yo=7e3;class $S{constructor(e){this.subscription=new ae,this.loadMediaTimeoutSubscription=new ae,this.videoState=new ce(q.STOPPED),this.syncPlayback=()=>{const i=this.videoState.getState(),r=this.videoState.getTransition(),a=this.params.desiredState.playbackState.getState(),n=this.params.desiredState.playbackState.getTransition(),o=this.params.desiredState.seekState.getState();if(this.log({message:`[syncPlayback] videoState: ${i}; videoTransition: ${JSON.stringify(r)}; desiredPlaybackState: ${a}; desiredPlaybackStateTransition: ${this.params.desiredState.playbackState.getTransition()}; seekState: ${JSON.stringify(o)};`}),a===p.STOPPED){i!==q.STOPPED&&(this.videoState.startTransitionTo(q.STOPPED),this.stop());return}if(!r){if((n==null?void 0:n.to)!==p.PAUSED&&o.state===W.Requested&&i!==q.STOPPED){this.seek(o.position/1e3);return}switch(a){case p.READY:{switch(i){case q.PLAYING:case q.PAUSED:case q.READY:break;case q.STOPPED:this.videoState.startTransitionTo(q.READY),this.prepare();break;default:H(i)}break}case p.PLAYING:{switch(i){case q.PLAYING:break;case q.PAUSED:this.videoState.startTransitionTo(q.PLAYING),this.params.connection.remotePlayerController.playOrPause();break;case q.READY:this.videoState.startTransitionTo(q.PLAYING),this.params.connection.remotePlayerController.playOrPause();break;case q.STOPPED:this.videoState.startTransitionTo(q.READY),this.prepare();break;default:H(i)}break}case p.PAUSED:{switch(i){case q.PLAYING:this.videoState.startTransitionTo(q.PAUSED),this.params.connection.remotePlayerController.playOrPause();break;case q.PAUSED:break;case q.READY:this.videoState.startTransitionTo(q.PAUSED),this.videoState.setState(q.PAUSED);break;case q.STOPPED:this.videoState.startTransitionTo(q.READY),this.prepare();break;default:H(i)}break}default:H(a)}}},this.params=e,this.log=this.params.dependencies.logger.createComponentLog("ChromecastProvider"),this.log({message:`constructor, format: ${e.format}`}),this.params.output.isLive$.next(bS(e.format)),this.params.output.isAudioAvailable$.next(!0),this.handleRemoteVolumeChange({volume:this.params.connection.remotePlayer.volumeLevel,muted:this.params.connection.remotePlayer.isMuted});const t=this.params.connection.session.getMediaSession();t&&this.restoreSession(t),this.subscribe()}destroy(){this.log({message:"[destroy]"}),this.subscription.unsubscribe()}subscribe(){this.subscription.add(this.loadMediaTimeoutSubscription);const e=new ae;this.subscription.add(e),this.subscription.add(V(this.videoState.stateChangeStarted$.pipe(w(r=>`stateChangeStarted$ ${JSON.stringify(r)}`)),this.videoState.stateChangeEnded$.pipe(w(r=>`stateChangeEnded$ ${JSON.stringify(r)}`))).subscribe(r=>this.log({message:`[videoState] ${r}`})));const t=(r,a)=>this.subscription.add(r.subscribe(a));if(this.params.output.isLive$.getValue())this.params.output.position$.next(0),this.params.output.duration$.next(0);else{const r=new x;e.add(r.pipe(je(ES)).subscribe(()=>{this.params.output.seekedEvent$.next()}));let a=NaN;e.add(B(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED).subscribe(n=>{this.logRemoteEvent(n);const o=n.value;this.params.output.position$.next(o),(this.params.desiredState.seekState.getState().state===W.Applying||Math.abs(o-a)>yS)&&r.next(o),a=o})),e.add(B(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.DURATION_CHANGED).subscribe(n=>{this.logRemoteEvent(n),this.params.output.duration$.next(n.value)}))}t(B(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED),r=>{this.logRemoteEvent(r),r.value?this.handleRemoteReady():(this.handleRemoteStop(),e.unsubscribe())}),t(B(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED),r=>{this.logRemoteEvent(r),r.value?this.handleRemotePause():this.handleRemotePlay()}),t(B(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED),r=>{this.logRemoteEvent(r);const{remotePlayer:a}=this.params.connection,n=r.value,o=this.params.output.isBuffering$.getValue(),u=n===chrome.cast.media.PlayerState.BUFFERING;switch(o!==u&&this.params.output.isBuffering$.next(u),n){case chrome.cast.media.PlayerState.IDLE:!this.params.output.isLive$.getValue()&&a.duration-a.currentTime<TS&&this.params.output.endedEvent$.next(),this.handleRemoteStop(),D(this.params.desiredState.playbackState,p.STOPPED);break;case chrome.cast.media.PlayerState.PAUSED:{this.handleRemotePause();break}case chrome.cast.media.PlayerState.PLAYING:this.handleRemotePlay();break;case chrome.cast.media.PlayerState.BUFFERING:break;default:H(n)}}),t(B(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED),r=>{this.logRemoteEvent(r),this.handleRemoteVolumeChange({volume:r.value})}),t(B(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED),r=>{this.logRemoteEvent(r),this.handleRemoteVolumeChange({muted:r.value})});const i=V(this.params.desiredState.playbackState.stateChangeStarted$,this.params.desiredState.seekState.stateChangeEnded$,this.videoState.stateChangeEnded$,De(["init"])).pipe(je(0));t(i,this.syncPlayback)}restoreSession(e){this.log({message:"restoreSession"});const{remotePlayer:t}=this.params.connection;if(e.playerState!==chrome.cast.media.PlayerState.IDLE){t.isPaused?(this.videoState.setState(q.PAUSED),D(this.params.desiredState.playbackState,p.PAUSED)):(this.videoState.setState(q.PLAYING),D(this.params.desiredState.playbackState,p.PLAYING));const i=this.params.output.isLive$.getValue();this.params.output.duration$.next(i?0:t.duration),this.params.output.position$.next(i?0:t.currentTime),this.params.desiredState.seekState.setState({state:W.None})}}prepare(){const e=this.params.format;this.log({message:`[prepare] format: ${e}`});const t=this.createMediaInfo(e),i=this.createLoadRequest(t);this.loadMedia(i)}handleRemotePause(){const e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)===q.PAUSED||e===q.PLAYING)&&(this.videoState.setState(q.PAUSED),D(this.params.desiredState.playbackState,p.PAUSED))}handleRemotePlay(){const e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)===q.PLAYING||e===q.PAUSED)&&(this.videoState.setState(q.PLAYING),D(this.params.desiredState.playbackState,p.PLAYING))}handleRemoteReady(){var e;const t=this.videoState.getTransition();(t==null?void 0:t.to)===q.READY&&this.videoState.setState(q.READY),((e=this.params.desiredState.playbackState.getTransition())===null||e===void 0?void 0:e.to)===p.READY&&D(this.params.desiredState.playbackState,p.READY)}handleRemoteStop(){this.videoState.getState()!==q.STOPPED&&this.videoState.setState(q.STOPPED)}handleRemoteVolumeChange(e){var t,i;const r=this.params.output.volume$.getValue(),a={volume:(t=e.volume)!==null&&t!==void 0?t:r.volume,muted:(i=e.muted)!==null&&i!==void 0?i:r.muted};(a.volume!==r.volume||a.muted!==a.muted)&&this.params.output.volume$.next(a)}seek(e){this.params.output.willSeekEvent$.next();const{remotePlayer:t,remotePlayerController:i}=this.params.connection;t.currentTime=e,i.seek()}stop(){const{remotePlayerController:e}=this.params.connection;e.stop()}createMediaInfo(e){var t;const i=this.params.source;let r,a,n;switch(e){case y.MPEG:{const l=i[e];P(l);const c=Tl(Object.keys(l));P(c);const h=l[c];P(h),r=h,a="video/mp4",n=chrome.cast.media.StreamType.BUFFERED;break}case y.HLS:case y.HLS_ONDEMAND:{const l=i[e];P(l),r=l.url,a="application/x-mpegurl",n=chrome.cast.media.StreamType.BUFFERED;break}case y.DASH_SEP:case y.DASH_ONDEMAND:case y.DASH_WEBM:case y.DASH_WEBM_AV1:{const l=i[e];P(l),r=l.url,a="application/dash+xml",n=chrome.cast.media.StreamType.BUFFERED;break}case y.DASH_LIVE_CMAF:{const l=i[e];P(l),r=l.url,a="application/dash+xml",n=chrome.cast.media.StreamType.LIVE;break}case y.HLS_LIVE:case y.HLS_LIVE_CMAF:{const l=i[e];P(l),r=Je(l.url),a="application/x-mpegurl",n=chrome.cast.media.StreamType.LIVE;break}case y.DASH:case y.DASH_LIVE:case y.WEB_RTC_LIVE:{const l="Unsupported format for Chromecast",c=new Error(l);throw this.params.output.error$.next({id:"ChromecastProvider.createMediaInfo()",category:L.VIDEO_PIPELINE,message:l,thrown:c}),c}case y.DASH_LIVE_WEBM:throw new Error("DASH_LIVE_WEBM is no longer supported");default:return H(e)}const o=new chrome.cast.media.MediaInfo((t=this.params.meta.videoId)!==null&&t!==void 0?t:r,a);o.contentUrl=r,o.streamType=n,o.metadata=new chrome.cast.media.GenericMediaMetadata;const{title:u,subtitle:d}=this.params.meta;return k(u)&&(o.metadata.title=u),k(d)&&(o.metadata.subtitle=d),o}createLoadRequest(e){const t=new chrome.cast.media.LoadRequest(e);t.autoplay=!1;const i=this.params.desiredState.seekState.getState();return i.state===W.Applying||i.state===W.Requested?t.currentTime=this.params.output.isLive$.getValue()?0:i.position/1e3:t.currentTime=0,t}loadMedia(e){const t=this.params.connection.session.loadMedia(e),i=new Promise((r,a)=>{this.loadMediaTimeoutSubscription.add(El(Yo).subscribe(()=>a(`timeout(${Yo})`)))});er(Promise.race([t,i]).then(()=>{this.log({message:`[loadMedia] completed, format: ${this.params.format}`}),this.params.desiredState.seekState.getState().state===W.Applying&&this.params.output.seekedEvent$.next(),this.handleRemoteReady()},r=>{const a=`[prepare] loadMedia failed, format: ${this.params.format}, reason: ${r}`;this.log({message:a}),this.params.output.error$.next({id:"ChromecastProvider.loadMedia",category:L.VIDEO_PIPELINE,message:a,thrown:r})}),()=>{this.loadMediaTimeoutSubscription.unsubscribe()})}logRemoteEvent(e){this.log({message:`[remoteEvent] ${JSON.stringify(e)}`})}}var AS=s=>{let e,t=!1,i=!1;s.on("playbackTimeUpdated",({timeToEnd:r})=>{i=r<=3,t&&i&&(e==null||e())}),s.extend("MediaSourceController",function(){const{parent:r}=this,a=r.signalEndOfStream;return{signalEndOfStream:n=>{t=!0,e=()=>a(n),t&&i&&(e==null||e())}}},!0)},_S=s=>{const e=new S(1/0),t=new x,i=new S(void 0),r=new S(void 0);let a=NaN,n=!1;const o=()=>{a=Date.now(),n=!1},u=l=>{var c,h,f,v,g;const T=li(l.getAllResponseHeaders().trim().split(/[\n\r]+/).map(m=>m.split(": ")));if("x-playback-duration"in T||"x-playback-duration-millis"in T){const m=parseInt((c=l.getResponseHeader("X-Playback-Duration"))!==null&&c!==void 0?c:"",10),b=parseInt((h=l.getResponseHeader("X-Playback-Duration-Millis"))!==null&&h!==void 0?h:"",10),$=(f=b!=null?b:m*1e3)!==null&&f!==void 0?f:NaN;k($)&&!isNaN($)&&e.next($)}const A=(v=T["x-delivery-type"])!==null&&v!==void 0?v:Mi.HTTP1,E=(g={1:!0,0:!1}[T["x-reused"]])!==null&&g!==void 0?g:void 0;i.next(A),r.next(E)},d=l=>{l.readyState>=2&&!n&&(n=!0,t.next(Date.now()-a))};return s.extend("XHRLoader",function(){const{parent:l}=this,c=l.load.bind(l);return{load:function(h){if(h.request.type==="MPD"){const f=h.onload,v=h.progress;h.onload=function(...g){return u(this),f(...g)},h.progress=function(...g){return d(this),v(...g)},o()}return c(h)}}},!0),{playbackDuration$:e,ping$:t,connectionReused$:r,connectionType$:i}},ci=s=>{const e=new URL(s);return e.searchParams.set("quic","1"),e.toString()},wS=s=>s.extend("RequestModifier",()=>({modifyRequestURL:ci}),!0),kS=s=>{s.extend("HTTPLoader",function(){const{parent:e}=this,t=e.load;return{load:i=>{if(i.request&&i.request.range){const[r,a]=i.request.range.split("-").map(o=>parseInt(o,10)),n=new URL(i.request.url,location.href);n.searchParams.append("bytes",`${r}-${a}`),i.request.url=n.toString(),i.request.range=void 0}t(i)}}},!0)};const Xe=(s,e,t,{equal:i=(n,o)=>n===o,changed$:r,onError:a}={})=>{const n=s.getState(),o=e(),u=ie(r),d=new ae;return r&&d.add(r.subscribe(l=>{const c=s.getState();i(l,c)&&s.setState(l)},a)),i(o,n)||(t(n),u&&s.setState(n)),d.add(s.stateChangeStarted$.subscribe(l=>{t(l.to),u&&s.setState(l.to)},a)),d},jt=(s,e,t)=>Xe(e,()=>s.loop,i=>{k(i)&&(s.loop=i)},{onError:t}),gt=(s,e,t,i)=>Xe(e,()=>({muted:s.muted,volume:s.volume}),r=>{k(r)&&(s.muted=r.muted,s.volume=r.volume)},{equal:(r,a)=>r===a||(r==null?void 0:r.muted)===(a==null?void 0:a.muted)&&(r==null?void 0:r.volume)===(a==null?void 0:a.volume),changed$:t,onError:i}),Dt=(s,e,t,i)=>Xe(e,()=>s.playbackRate,r=>{k(r)&&(s.playbackRate=r)},{changed$:t,onError:i}),PS=s=>["__",s.language,s.label].join("|"),RS=(s,e)=>{if(s.id===e)return!0;const[t,i,r]=e.split("|");return s.language===i&&s.label===r};class dt{constructor(){this.available$=new x,this.current$=new S(void 0),this.error$=new x,this.subscription=new ae,this.externalTracks=new Map,this.internalTracks=new Map}connect(e,t,i){this.video=e,this.cueSettings=t.textTrackCuesSettings,this.subscribe();const r=a=>{this.error$.next({id:"TextTracksManager",category:L.WTF,message:"Generic HtmlVideoTextTrackManager error",thrown:a})};this.subscription.add(this.available$.subscribe(i.availableTextTracks$)),this.subscription.add(this.current$.subscribe(i.currentTextTrack$)),this.subscription.add(this.error$.subscribe(i.error$)),this.subscription.add(Xe(t.internalTextTracks,()=>Object.values(this.internalTracks),a=>{k(a)&&this.setInternal(a)},{equal:(a,n)=>k(a)&&k(n)&&a.length===n.length&&a.every(({id:o},u)=>o===n[u].id),changed$:this.available$.pipe(w(a=>a.filter(({type:n})=>n==="internal"))),onError:r})),this.subscription.add(Xe(t.externalTextTracks,()=>Object.values(this.externalTracks),a=>{k(a)&&this.setExternal(a)},{equal:(a,n)=>k(a)&&k(n)&&a.length===n.length&&a.every(({id:o},u)=>o===n[u].id),changed$:this.available$.pipe(w(a=>a.filter(({type:n})=>n==="external"))),onError:r})),this.subscription.add(Xe(t.currentTextTrack,()=>{if(this.video)return;const a=this.htmlTextTracksAsArray().find(({mode:n})=>n==="showing");return a&&this.htmlTextTrackToITextTrack(a).id},a=>this.select(a),{changed$:this.current$,onError:r})),this.subscription.add(Xe(t.textTrackCuesSettings,()=>({}),()=>{if(this.video)for(const a of this.htmlTextTracksAsArray())this.applyCueSettings(a.cues),this.applyCueSettings(a.activeCues)}))}subscribe(){P(this.video);const{textTracks:e}=this.video;this.subscription.add(B(e,"addtrack").subscribe(()=>{const i=this.current$.getValue();i&&this.select(i)})),this.subscription.add(V(B(e,"addtrack"),B(e,"removetrack"),De(["init"])).pipe(w(()=>this.htmlTextTracksAsArray().map(i=>this.htmlTextTrackToITextTrack(i))),ve((i,r)=>i.length===r.length&&i.every(({id:a},n)=>a===r[n].id))).subscribe(this.available$)),this.subscription.add(V(B(e,"change"),De(["init"])).pipe(w(()=>this.htmlTextTracksAsArray().find(({mode:i})=>i==="showing")),w(i=>i&&this.htmlTextTrackToITextTrack(i).id),ve()).subscribe(this.current$));const t=i=>{var r,a;return this.applyCueSettings((a=(r=i.target)===null||r===void 0?void 0:r.activeCues)!==null&&a!==void 0?a:null)};this.subscription.add(B(e,"addtrack").subscribe(i=>{var r,a;(r=i.track)===null||r===void 0||r.addEventListener("cuechange",t);const n=o=>{var u,d,l,c,h;const f=(d=(u=o.target)===null||u===void 0?void 0:u.cues)!==null&&d!==void 0?d:null;f&&f.length&&(this.applyCueSettings((c=(l=o.target)===null||l===void 0?void 0:l.cues)!==null&&c!==void 0?c:null),(h=o.target)===null||h===void 0||h.removeEventListener("cuechange",n))};(a=i.track)===null||a===void 0||a.addEventListener("cuechange",n)})),this.subscription.add(B(e,"removetrack").subscribe(i=>{var r;(r=i.track)===null||r===void 0||r.removeEventListener("cuechange",t)}))}applyCueSettings(e){if(!e||!e.length)return;const t=this.cueSettings.getState();for(const i of Array.from(e)){const r=i;k(t.align)&&(r.align=t.align),k(t.position)&&(r.position=t.position),k(t.size)&&(r.size=t.size),k(t.line)&&(r.line=t.line)}}htmlTextTracksAsArray(e=!1){P(this.video);const t=[...this.video.textTracks];return e?t:t.filter(dt.isHealthyTrack)}htmlTextTrackToITextTrack(e){var t,i;const{language:r,label:a}=e,n=e.id?e.id:PS(e),o=this.externalTracks.has(n),u=n.includes("auto");return o?{id:n,type:"external",isAuto:u,language:r,label:a,url:(t=this.externalTracks.get(n))===null||t===void 0?void 0:t.url}:{id:n,type:"internal",isAuto:u,language:r,label:a,url:(i=this.internalTracks.get(n))===null||i===void 0?void 0:i.url}}static isHealthyTrack(e){return!(e.kind==="metadata"||e.groupId||e.id===""&&e.label===""&&e.language==="")}setExternal(e){this.internalTracks.size>0&&Array.from(this.internalTracks).forEach(([,t])=>this.detach(t)),e.filter(({id:t})=>!this.externalTracks.has(t)).forEach(t=>this.attach(t)),Array.from(this.externalTracks).filter(([t])=>!e.find(i=>i.id===t)).forEach(([,t])=>this.detach(t))}setInternal(e){const t=[...this.externalTracks];e.filter(({id:i,language:r,isAuto:a})=>!this.internalTracks.has(i)&&!t.some(([,n])=>n.language===r&&n.isAuto===a)).forEach(i=>this.attach(i)),Array.from(this.internalTracks).filter(([i])=>!e.find(r=>r.id===i)).forEach(([,i])=>this.detach(i))}select(e){P(this.video);for(const t of this.htmlTextTracksAsArray(!0))t.mode="showing";for(const t of this.htmlTextTracksAsArray(!0))(ie(e)||!RS(t,e))&&(t.mode="disabled")}destroy(){if(this.subscription.unsubscribe(),this.video)for(const e of Array.from(this.video.getElementsByTagName("track"))){const t=e.getAttribute("id");t&&this.externalTracks.has(t)&&this.video.removeChild(e)}this.externalTracks.clear()}attach(e){P(this.video);const t=document.createElement("track");t.setAttribute("src",e.url),t.setAttribute("id",e.id),e.label&&t.setAttribute("label",e.label),e.language&&t.setAttribute("srclang",e.language),e.type==="external"?this.externalTracks.set(e.id,e):e.type==="internal"&&this.internalTracks.set(e.id,e),this.video.appendChild(t)}detach(e){P(this.video);const t=Array.prototype.find.call(this.video.getElementsByTagName("track"),i=>i.getAttribute("id")===e.id);t&&this.video.removeChild(t),e.type==="external"?this.externalTracks.delete(e.id):e.type==="internal"&&this.internalTracks.delete(e.id)}}const cn=s=>{s.removeAttribute("src"),s.load()},DS=s=>{try{s.pause(),s.playbackRate=0,cn(s),s.remove()}catch(e){console.error(e)}};class IS{constructor(){this.attribute="data-pool-reused"}get(e){return e.hasAttribute(this.attribute)}set(e,t){e.toggleAttribute(this.attribute,t)}delete(e){e.removeAttribute(this.attribute)}}const Oa=window.WeakMap?new WeakMap:new IS,St=s=>{let e=s.querySelector("video");const t=!!e;return e?cn(e):(e=document.createElement("video"),s.appendChild(e)),Oa.set(e,t),e.setAttribute("crossorigin","anonymous"),e.setAttribute("playsinline","playsinline"),e.controls=!1,e.setAttribute("poster","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),e},bt=s=>{const e=Oa.get(s);Oa.delete(s),e?cn(s):DS(s)};class tr{constructor(){this.pausedTime=0,this.streamOffset=0,this.pauseTimestamp=0}getTotalPausedTime(){return this.pausedTime+this.getCurrentPausedTime()}getCurrentPausedTime(){return this.pauseTimestamp>0?Date.now()-this.pauseTimestamp:0}getStreamOffset(){return this.streamOffset}getTotalOffset(){return this.getTotalPausedTime()+this.streamOffset}pause(){this.pauseTimestamp===0&&(this.pauseTimestamp=Date.now())}resume(){this.pauseTimestamp>0&&(this.pausedTime+=this.getCurrentPausedTime(),this.pauseTimestamp=0)}resetTo(e,t=!1){this.streamOffset=e,this.pauseTimestamp=0,this.pausedTime=0,t&&this.pause()}}const Nu=s=>{var e;let t=s;for(;!(t instanceof Document)&&!(t instanceof ShadowRoot)&&t!==null;)t=t==null?void 0:t.parentNode;return(e=t)!==null&&e!==void 0?e:void 0},jo=s=>{const e=Nu(s);return!!(e&&e.fullscreenElement&&e.fullscreenElement===s)},CS=s=>{const e=Nu(s);return!!(e&&e.pictureInPictureElement&&e.pictureInPictureElement===s)},Ma=3;class xS{constructor(e){this._buffer=[],this._source=e}fill(){this._buffer=[];const e=this._source.currentTime;for(let t=0,i=this._source.buffered.length;t<i;t++){let r=this._source.buffered.start(t);const a=this._source.buffered.end(t);r>e&&r-e<Ma&&(r=e),this._buffer.push({from:r,to:a,i:t})}return this._buffer.sort(function(t,i){return t.from-i.from}),this._buffer}getByTime(e){return this._buffer.find(t=>e>=t.from&&e<t.to)}getNextWithGap(e,t){const i=this.getNext(e);if(i&&i.from-e.to<(t||Ma))return i}getNext(e){let t=this._buffer.indexOf(e);if(~t&&this._buffer.length-1>t)return this._buffer[++t]}smartRemove(e,t,i){this._buffer.forEach(({from:r,to:a})=>{const n=r>=e&&r<t,o=a>=e&&a<t;n&&o||(n?i(t,a):o?i(r,e):r<e&&a>t?(i(t,a),i(r,e)):i(r,a))})}destroy(){this._buffer=[]}}var Fu=(s,e,t=Ma)=>{let i=0,r=0;for(let a=0;a<s.length;a++){const n=s.start(a),o=s.end(a);if(n<=e&&e<=o){if(i=n,r=o,!t)return{from:i,to:r};for(let u=a-1;u>=0;u--)s.end(u)+t>=i&&(i=s.start(u));for(let u=a+1;u<s.length;u++)s.start(u)-t<=r&&(r=s.end(u))}}return{from:i,to:r}};const yt=s=>{const e=m=>B(s,m).pipe(ui(void 0)),i=V(...["waiting","pause","canplay","play","canplaythrough","playing","seeking","seeked","ended"].map(m=>B(s,m))).pipe(w(m=>m.type==="ended"?s.readyState<2:s.readyState<3),ve()),r=V(B(s,"progress"),B(s,"timeupdate")).pipe(w(()=>Fu(s.buffered,s.currentTime))),n=Ua().browser===yd.Safari?Ne({play:e("play").pipe(ge()),playing:e("playing")}).pipe(ui(void 0)):e("playing"),o=B(s,"volumechange").pipe(w(()=>({muted:s.muted,volume:s.volume}))),u=B(s,"ratechange").pipe(w(()=>s.playbackRate)),d=B(s,"error").pipe(re(()=>!!(s.error||s.played.length)),w(()=>{var m;const b=s.error;return{id:b?`MediaError#${b.code}`:"HtmlVideoError",category:L.VIDEO_PIPELINE,message:b?b.message:"Error event from HTML video element",thrown:(m=s.error)!==null&&m!==void 0?m:void 0}})),l=B(s,"timeupdate").pipe(w(()=>s.currentTime)),c=new x,h=.3;let f;l.subscribe(m=>{s.loop&&k(f)&&k(m)&&f>=s.duration-h&&m<=h&&c.next(f),f=m});const v=B(s,"enterpictureinpicture"),g=B(s,"leavepictureinpicture"),T=new S(CS(s));v.subscribe(()=>T.next(!0)),g.subscribe(()=>T.next(!1));const A=new S(jo(s));return B(s,"fullscreenchange").pipe(w(()=>jo(s))).subscribe(A),{playing$:n,pause$:e("pause").pipe(re(()=>!s.error)),canplay$:e("canplay"),ended$:e("ended"),looped$:c,error$:d,seeked$:e("seeked"),seeking$:e("seeking"),progress$:e("progress"),loadStart$:e("loadstart"),loadedMetadata$:e("loadedmetadata"),loadedData$:e("loadeddata"),timeUpdate$:l,durationChange$:B(s,"durationchange").pipe(w(()=>s.duration)),isBuffering$:i,currentBuffer$:r,volumeState$:o,playbackRateState$:u,inPiP$:T,inFullscreen$:A}},hn=s=>{if(s.includes("/")){const e=s.split("/");return parseInt(e[0])/parseInt(e[1])}else return parseFloat(s)};var LS=Ze,OS=Qs,MS=Ja,BS=Ka;LS({target:"Array",proto:!0},{at:function(e){var t=OS(this),i=MS(t),r=BS(e),a=r>=0?r:i+r;return a<0||a>=i?void 0:t[a]}});var NS=ln,FS=NS("Array","at"),US=FS,VS=US,HS=VS,GS=HS,st=Gs(GS);let fn=!1,ct={};const YS=s=>{fn=s},jS=()=>{ct={}},qS=s=>{s(ct)},ms=(s,e)=>{var t;fn&&(ct.meta=(t=ct.meta)!==null&&t!==void 0?t:{},ct.meta[s]=e)};class rt{constructor(e){this.name=e}next(e){var t,i;if(!fn)return;ct.series=(t=ct.series)!==null&&t!==void 0?t:{};const r=(i=ct.series[this.name])!==null&&i!==void 0?i:[];r.push([Date.now(),e]),ct.series[this.name]=r}}var Nt;(function(s){s.FitsContainer="FitsContainer",s.FitsThroughput="FitsThroughput",s.Buffer="Buffer",s.DroppedFramesLimit="DroppedFramesLimit",s.FitsQualityLimits="FitsQualityLimits"})(Nt||(Nt={}));const zS=new rt("best_bitrate"),WS=(s,e,t)=>(e-t)*Math.pow(2,-10*s)+t;class QS{constructor(){this.history={}}recordSelection(e){this.history[e.id]=me()}recordSwitch(e){this.last=e}clear(){this.last=void 0,this.history={}}}const gi=(s,{container:e,throughput:t,tuning:i,limits:r,reserve:a=0,forwardBufferHealth:n,playbackRate:o,current:u,history:d,droppedVideoMaxQualityLimit:l,abrLogger:c})=>{var h,f,v,g,T;const A=i.usePixelRatio&&(h=window.devicePixelRatio)!==null&&h!==void 0?h:1,E=i.limitByContainer&&e&&e.width>0&&e.height>0&&{width:e.width*A*i.containerSizeFactor,height:e.height*A*i.containerSizeFactor},m=E&&Vt(E),b=i.considerPlaybackRate&&k(o)?o:1,$=s.filter(U=>!Oi(U.quality)).sort((U,I)=>Ii(U.quality,I.quality)?-1:1),R=(f=st($,-1))===null||f===void 0?void 0:f.quality,j=(v=st($,0))===null||v===void 0?void 0:v.quality,X=ie(r)||k(r.min)&&k(r.max)&&ws(r.max,r.min)||k(r.min)&&j&&Ii(r.min,j)||k(r.max)&&R&&ws(r.max,R),F=b*WS(n!=null?n:.5,i.bitrateFactorAtEmptyBuffer,i.bitrateFactorAtFullBuffer),Y={},O=$.filter(U=>(m?ws(U.quality,m):!0)?(k(t)&&isFinite(t)&&k(U.bitrate)?t-a>=U.bitrate*F:!0)?i.lazyQualitySwitch&&k(i.minBufferToSwitchUp)&&u&&!Oi(u.quality)&&(n!=null?n:0)<i.minBufferToSwitchUp&&Ii(U.quality,u.quality)?(Y[U.quality]=Nt.Buffer,!1):!!l&&pa(U.quality,l)?(Y[U.quality]=Nt.DroppedFramesLimit,!1):X||(ie(r.max)||Td(U.quality,r.max))&&(ie(r.min)||pa(U.quality,r.min))?!0:(Y[U.quality]=Nt.FitsQualityLimits,!1):(Y[U.quality]=Nt.FitsThroughput,!1):(Y[U.quality]=Nt.FitsContainer,!1))[0];O&&O.bitrate&&zS.next(O.bitrate);const G=(g=O!=null?O:$[Math.ceil(($.length-1)/2)])!==null&&g!==void 0?g:s[0];G.quality!==((T=d==null?void 0:d.last)===null||T===void 0?void 0:T.quality)&&c({message:`
|
|
7
7
|
[available tracks] ${s.map(U=>U.quality).join(", ")}
|
|
8
8
|
|
|
9
9
|
[limit params]
|
|
@@ -35,4 +35,4 @@ precision highp float;
|
|
|
35
35
|
#endif
|
|
36
36
|
#define PI 3.14159265358979323846264
|
|
37
37
|
varying vec2 v_texel;uniform sampler2D u_texture;uniform vec2 u_focus;void main(void){float lambda0=u_focus.x/360.0;float phi0=u_focus.y/180.0;float lambda=PI*2.0*(v_texel.x-0.5-lambda0);float phi=PI*(v_texel.y-0.5-phi0);float p=sqrt(lambda*lambda+phi*phi);float c=atan(p);float cos_c=cos(c);float sin_c=sin(c);float x=lambda0+atan(lambda*sin_c,p*cos(phi0)*cos_c-phi*sin(phi0)*sin_c);float y=asin(cos_c*sin(phi0)+(phi*sin_c*cos(phi0))/p);vec2 tc=vec2(mod(x/(PI*2.0)-0.5,1.0),mod(y/PI-0.5,1.0));gl_FragColor=texture2D(u_texture,tc);}`;class Jy{constructor(e,t,i){this.videoInitialized=!1,this.active=!1,this.container=e,this.sourceVideoElement=t,this.params=i,this.canvas=this.createCanvas();const r=this.canvas.getContext("webgl");if(!r)throw new Error("Could not initialize WebGL context");this.gl=r,this.container.appendChild(this.canvas),this.camera=new zy(this.params.fov,this.params.orientation),this.cameraRotationManager=new Wy(this.camera,{rotationSpeed:this.params.rotationSpeed,maxYawAngle:this.params.maxYawAngle,rotationSpeedCorrection:this.params.rotationSpeedCorrection,degreeToPixelCorrection:this.params.degreeToPixelCorrection,speedFadeTime:this.params.speedFadeTime,speedFadeThreshold:this.params.speedFadeThreshold}),this.updateFrameSize(),this.vertexBuffer=this.createVertexBuffer(),this.textureMappingBuffer=this.createTextureMappingBuffer(),this.updateTextureMappingBuffer(),this.program=this.createProgram(),this.videoTexture=this.createTexture(),this.gl.useProgram(this.program),this.videoElementDataLoadedFn=this.onDataLoadedHandler.bind(this),this.renderFn=this.render.bind(this)}play(){this.active||(this.videoInitialized?this.doPlay():this.sourceVideoElement.readyState>=2?(this.videoInitialized=!0,this.doPlay()):this.sourceVideoElement.addEventListener("loadeddata",this.videoElementDataLoadedFn))}stop(){this.active=!1}startCameraManualRotation(e,t){this.cameraRotationManager.setRotationSpeed(e*this.params.rotationSpeed,t*this.params.rotationSpeed,0),this.cameraRotationManager.startRotation()}stopCameraManualRotation(e=!1){this.cameraRotationManager.stopRotation(e)}turnCamera(e,t){this.cameraRotationManager.turnCamera(e,t)}pointCameraTo(e,t){this.cameraRotationManager.pointCameraTo(e,t)}pixelToDegree(e){return{x:this.params.degreeToPixelCorrection*this.params.fov.x*-e.x/this.viewportWidth,y:this.params.degreeToPixelCorrection*this.params.fov.y*e.y/this.viewportHeight}}getCameraRotation(){return this.camera.orientation}holdCamera(){this.cameraRotationManager.stopRotation(!0)}releaseCamera(){this.cameraRotationManager.onCameraRelease()}destroy(){this.sourceVideoElement.removeEventListener("loadeddata",this.videoElementDataLoadedFn),this.stop(),this.canvas.remove()}setViewportSize(e,t){this.viewportWidth=e,this.viewportHeight=t,this.canvas.width=this.viewportWidth,this.canvas.height=this.viewportHeight,this.gl.viewport(0,0,this.canvas.width,this.canvas.height)}onDataLoadedHandler(){this.videoInitialized=!0,this.doPlay()}doPlay(){this.updateFrameSize(),this.vertexBuffer=this.createVertexBuffer(),this.active=!0,this.sourceVideoElement.removeEventListener("loadeddata",this.videoElementDataLoadedFn),requestAnimationFrame(this.renderFn)}render(e){this.cameraRotationManager.tick(e),this.updateTexture(),this.updateTextureMappingBuffer();const t=this.gl.getAttribLocation(this.program,"a_vertex"),i=this.gl.getAttribLocation(this.program,"a_texel"),r=this.gl.getUniformLocation(this.program,"u_texture"),a=this.gl.getUniformLocation(this.program,"u_focus");this.gl.enableVertexAttribArray(t),this.gl.enableVertexAttribArray(i),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexBuffer),this.gl.vertexAttribPointer(t,2,this.gl.FLOAT,!1,0,0),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.textureMappingBuffer),this.gl.vertexAttribPointer(i,2,this.gl.FLOAT,!1,0,0),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,this.videoTexture),this.gl.uniform1i(r,0),this.gl.uniform2f(a,-this.camera.orientation.x,-this.camera.orientation.y),this.gl.drawArrays(this.gl.TRIANGLE_FAN,0,4),this.gl.bindTexture(this.gl.TEXTURE_2D,null),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,null),this.gl.disableVertexAttribArray(t),this.gl.disableVertexAttribArray(i),this.active&&requestAnimationFrame(this.renderFn)}createShader(e,t){const i=this.gl.createShader(t);if(!i)throw this.destroy(),new Error(`Could not create shader (${t})`);if(this.gl.shaderSource(i,e),this.gl.compileShader(i),!this.gl.getShaderParameter(i,this.gl.COMPILE_STATUS))throw this.destroy(),new Error("An error occurred while compiling the shader: "+this.gl.getShaderInfoLog(i));return i}createProgram(){const e=this.gl.createProgram();if(!e)throw this.destroy(),new Error("Could not create shader program");const t=this.createShader(Qy,this.gl.VERTEX_SHADER),i=this.createShader(Ky,this.gl.FRAGMENT_SHADER);if(this.gl.attachShader(e,t),this.gl.attachShader(e,i),this.gl.linkProgram(e),!this.gl.getProgramParameter(e,this.gl.LINK_STATUS))throw this.destroy(),new Error("Could not link shader program.");return e}createTexture(){const e=this.gl.createTexture();if(!e)throw this.destroy(),new Error("Could not create texture");return this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.bindTexture(this.gl.TEXTURE_2D,null),e}updateTexture(){this.gl.bindTexture(this.gl.TEXTURE_2D,this.videoTexture),this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!0),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,this.sourceVideoElement),this.gl.bindTexture(this.gl.TEXTURE_2D,null)}createVertexBuffer(){const e=this.gl.createBuffer();if(!e)throw this.destroy(),new Error("Could not create vertex buffer");let t=1,i=1;const r=this.frameHeight/(this.frameWidth/this.viewportWidth);return r>this.viewportHeight?t=this.viewportHeight/r:i=r/this.viewportHeight,this.gl.bindBuffer(this.gl.ARRAY_BUFFER,e),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array([-t,-i,t,-i,t,i,-t,i]),this.gl.STATIC_DRAW),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,null),e}createTextureMappingBuffer(){const e=this.gl.createBuffer();if(!e)throw this.destroy(),new Error("Could not create texture mapping buffer");return e}calculateTexturePosition(){const e=.5-this.camera.orientation.x/360,t=.5-this.camera.orientation.y/180,i=this.camera.fov.x/360/2,r=this.camera.fov.y/180/2,a=e-i,n=t-r,o=e+i,u=t-r,d=e+i,l=t+r,c=e-i,h=t+r;return[a,n,o,u,d,l,c,h]}updateTextureMappingBuffer(){this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.textureMappingBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array([...this.calculateTexturePosition()]),this.gl.STATIC_DRAW),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,null)}updateFrameSize(){this.frameWidth=this.sourceVideoElement.videoWidth,this.frameHeight=this.sourceVideoElement.videoHeight}createCanvas(){const e=document.createElement("canvas");return e.style.position="absolute",e.style.left="0",e.style.top="0",e.style.width="100%",e.style.height="100%",e}}class Zu{constructor(e){this.subscription=new ae,this.videoState=new ce(he.STOPPED),this.elementSize$=new S(void 0),this.textTracksManager=new dt,this.droppedFramesManager=new ir,this.videoTracks$=new S([]),this.audioTracks=[],this.audioRepresentations=new Map,this.videoTrackSwitchHistory=new QS,this.textTracks=[],this.syncPlayback=()=>{var t,i,r;const a=this.videoState.getState(),n=this.params.desiredState.playbackState.getState(),o=this.params.desiredState.playbackState.getTransition(),u=this.params.desiredState.seekState.getState();if(!this.videoState.getTransition()){if(u.state===W.Requested&&(o==null?void 0:o.to)!==p.PAUSED&&a!==he.STOPPED&&n!==p.STOPPED){const l=(i=(t=this.liveOffset)===null||t===void 0?void 0:t.getTotalPausedTime())!==null&&i!==void 0?i:0;this.seek(u.position-l,u.forcePrecise)}if(n===p.STOPPED){a!==he.STOPPED&&(this.videoState.startTransitionTo(he.STOPPED),this.player.stop(),this.video.removeAttribute("src"),this.video.load(),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.videoState.setState(he.STOPPED),D(this.params.desiredState.playbackState,p.STOPPED,!0));return}switch(a){case he.STOPPED:this.videoState.startTransitionTo(he.READY),this.prepare();return;case he.READY:n===p.PAUSED?(this.videoState.setState(he.PAUSED),D(this.params.desiredState.playbackState,p.PAUSED)):n===p.PLAYING?(this.videoState.startTransitionTo(he.PLAYING),this.playIfAllowed()):(o==null?void 0:o.to)===p.READY&&D(this.params.desiredState.playbackState,p.READY);return;case he.PLAYING:n===p.PAUSED?(this.videoState.startTransitionTo(he.PAUSED),(r=this.liveOffset)===null||r===void 0||r.pause(),this.video.pause()):(o==null?void 0:o.to)===p.PLAYING&&D(this.params.desiredState.playbackState,p.PLAYING);return;case he.PAUSED:n===p.PLAYING?(this.videoState.startTransitionTo(he.PLAYING),this.liveOffset?this.liveOffset.getTotalOffset()/1e3<Math.abs(this.params.output.duration$.getValue())?(this.liveOffset.resume(),this.playIfAllowed(),this.params.output.position$.next(-this.liveOffset.getTotalOffset()/1e3)):this.seek(0,!1):this.playIfAllowed()):(o==null?void 0:o.to)===p.PAUSED&&D(this.params.desiredState.playbackState,p.PAUSED);return;default:return H(a)}}},this.init3DScene=t=>{var i,r,a;if(this.scene3D)return;this.scene3D=new Jy(this.params.container,this.video,{fov:this.params.tuning.spherical.fov,orientation:this.params.tuning.spherical.orientation||{x:((i=t.projectionData)===null||i===void 0?void 0:i.pose.yaw)||0,y:((r=t.projectionData)===null||r===void 0?void 0:r.pose.pitch)||0,z:((a=t.projectionData)===null||a===void 0?void 0:a.pose.roll)||0},rotationSpeed:this.params.tuning.spherical.rotationSpeed,maxYawAngle:this.params.tuning.spherical.maxYawAngle,rotationSpeedCorrection:this.params.tuning.spherical.rotationSpeedCorrection,degreeToPixelCorrection:this.params.tuning.spherical.degreeToPixelCorrection,speedFadeTime:this.params.tuning.spherical.speedFadeTime,speedFadeThreshold:this.params.tuning.spherical.speedFadeThreshold});const n=this.elementSize$.getValue();n&&this.scene3D.setViewportSize(n.width,n.height)},this.destroy3DScene=()=>{this.scene3D&&(this.scene3D.destroy(),this.scene3D=void 0)},this.params=e,this.video=St(e.container),this.params.output.element$.next(this.video),this.params.output.availableVideoTracks$.next([]),this.params.output.availableAudioTracks$.next([]),this.params.output.isAudioAvailable$.next(!0),this.params.output.hostname$.next(Ie(this.params.source.url)),this.params.output.isLive$.next(!1),this.params.output.autoVideoTrackLimitingAvailable$.next(!0),this.player=new qy({throughputEstimator:this.params.dependencies.throughputEstimator,tuning:this.params.tuning,compatibilityMode:this.params.source.compatibilityMode}),this.subscribe()}getProviderSubscriptionInfo(){const{output:e,desiredState:t}=this.params,i=yt(this.video),r=this.constructor.name,a=o=>{e.error$.next({id:r,category:L.WTF,message:`${r} internal logic error`,thrown:o})};return{output:e,desiredState:t,observableVideo:i,genericErrorListener:a,connect:(o,u)=>this.subscription.add(o.subscribe(u,a))}}subscribe(){const{output:e,desiredState:t,observableVideo:i,genericErrorListener:r,connect:a}=this.getProviderSubscriptionInfo();this.droppedFramesManager.connect({logger:this.params.dependencies.logger,video:this.video,droppedFramesChecker:this.params.tuning.droppedFramesChecker,isAuto:this.params.desiredState.autoVideoTrackSwitching,playing$:i.playing$,pause$:i.pause$,tracks$:this.videoTracks$.pipe(w(d=>d.map(({track:l})=>l)))}),a(i.ended$,e.endedEvent$),a(i.looped$,e.loopedEvent$),a(i.error$,e.error$),a(i.isBuffering$,e.isBuffering$),a(i.currentBuffer$,e.currentBuffer$),a(i.playing$,e.firstFrameEvent$),a(i.canplay$,e.canplay$),a(i.inPiP$,e.inPiP$),a(i.inFullscreen$,e.inFullscreen$),a(this.player.error$,e.error$),a(this.player.lastConnectionType$,e.httpConnectionType$),a(this.player.lastConnectionReused$,e.httpConnectionReused$),a(this.player.isLive$,e.isLive$),a(this.player.lastRequestFirstBytes$.pipe(re(k),ge()),e.firstBytesEvent$),this.subscription.add(i.seeked$.subscribe(e.seekedEvent$,r)),this.subscription.add(jt(this.video,t.isLooped,r)),this.subscription.add(gt(this.video,t.volume,i.volumeState$,r)),this.subscription.add(i.volumeState$.subscribe(this.params.output.volume$,r)),this.subscription.add(Dt(this.video,t.playbackRate,i.playbackRateState$,r)),a(Bs(this.video),this.elementSize$),this.subscription.add(i.playing$.subscribe(()=>{this.videoState.setState(he.PLAYING),D(t.playbackState,p.PLAYING),this.scene3D&&this.scene3D.play()},r)).add(i.pause$.subscribe(()=>{this.videoState.setState(he.PAUSED),D(t.playbackState,p.PAUSED)},r)).add(i.canplay$.subscribe(()=>{this.videoState.getState()===he.PLAYING&&this.playIfAllowed()},r)),this.subscription.add(this.player.state$.stateChangeEnded$.subscribe(({to:d})=>{var l;if(d===Ge.MANIFEST_READY){const c=[];this.audioTracks=[],this.textTracks=[];const h=this.player.getRepresentations();P(h,"Manifest not loaded or empty");const f=Array.from(h.audio).sort((A,E)=>E.bitrate-A.bitrate),v=Array.from(h.video).sort((A,E)=>E.bitrate-A.bitrate),g=Array.from(h.text);if(!this.params.tuning.isAudioDisabled)for(const A of f){const E=ty(A);E&&this.audioTracks.push({track:E,representation:A})}for(const A of v){const E=ey(A);if(E){c.push({track:E,representation:A});const m=!this.params.tuning.isAudioDisabled&&iy(f,v,A);m&&this.audioRepresentations.set(A.id,m)}}this.videoTracks$.next(c);for(const A of g){const E=sy(A);E&&this.textTracks.push({track:E,representation:A})}this.params.output.availableVideoTracks$.next(c.map(({track:A})=>A)),this.params.output.availableAudioTracks$.next(this.audioTracks.map(({track:A})=>A)),this.params.output.isAudioAvailable$.next(!!this.audioTracks.length),this.textTracks.length>0&&this.params.desiredState.internalTextTracks.startTransitionTo(this.textTracks.map(({track:A})=>A));const T=this.selectVideoRepresentation();P(T),this.player.initRepresentations(T.id,(l=this.audioRepresentations.get(T.id))===null||l===void 0?void 0:l.id)}else d===Ge.REPRESENTATIOS_READY&&(this.videoState.setState(he.READY),this.player.initBuffer())},r));const n=d=>e.error$.next({id:"RepresentationSwitch",category:L.WTF,message:"Switching representations threw",thrown:d});this.subscription.add(V(this.player.state$.stateChangeEnded$,t.videoTrack.stateChangeStarted$,t.autoVideoTrackSwitching.transitionStarted$,this.params.dependencies.throughputEstimator.rttAdjustedThroughput$,t.autoVideoTrackLimits.stateChangeStarted$,this.elementSize$,this.droppedFramesManager.onDroopedVideoFramesLimit$,B(this.video,"progress")).subscribe(()=>{const d=this.player.state$.getState(),l=this.player.state$.getTransition();if(d!==Ge.RUNNING||l||!this.videoTracks$.getValue().length)return;t.autoVideoTrackSwitching.getTransition()&&t.autoVideoTrackSwitching.setState(t.autoVideoTrackSwitching.getState());const c=this.selectVideoRepresentation(),h=this.params.desiredState.autoVideoTrackLimits.getTransition();if(h&&this.params.output.autoVideoTrackLimits$.next(h.to),c){this.player.switchRepresentation(Ae.VIDEO,c.id).catch(n);const f=this.audioRepresentations.get(c.id);f&&this.player.switchRepresentation(Ae.AUDIO,f.id).catch(n)}},r)),this.subscription.add(t.cameraOrientation.stateChangeEnded$.subscribe(({to:d})=>{this.scene3D&&d&&this.scene3D.pointCameraTo(d.x,d.y)})),this.subscription.add(this.elementSize$.subscribe(d=>{this.scene3D&&d&&this.scene3D.setViewportSize(d.width,d.height)})),this.subscription.add(this.player.currentVideoRepresentation$.pipe(ve(),w(d=>{var l;return d&&((l=this.videoTracks$.getValue().find(({representation:{id:c}})=>c===d))===null||l===void 0?void 0:l.track)})).subscribe(e.currentVideoTrack$,r)),this.subscription.add(this.player.currentVideoRepresentationInit$.subscribe(d=>{var l,c;if(d!=null&&d.is3dVideo&&(!((l=this.params.tuning.spherical)===null||l===void 0)&&l.enabled))try{this.init3DScene(d),e.is3DVideo$.next(!0)}catch(h){e.warning$.next({id:"DashVKProvider",message:`DashVKProvider could not initialize 3D-scene: ${h}`})}else this.destroy3DScene(),!((c=this.params.tuning.spherical)===null||c===void 0)&&c.enabled&&e.is3DVideo$.next(!1)},r)),this.textTracksManager.connect(this.video,t,e);const o=t.playbackState.stateChangeStarted$.pipe(w(({to:d})=>d===p.READY),ve());this.subscription.add(V(o,t.autoVideoTrackSwitching.stateChangeStarted$,this.player.state$.stateChangeEnded$).subscribe(()=>{const d=t.autoVideoTrackSwitching.getState(),c=t.playbackState.getState()===p.READY?this.params.tuning.dash.forwardBufferTargetPreload:d?this.params.tuning.dash.forwardBufferTargetAuto:this.params.tuning.dash.forwardBufferTargetManual;this.player.setBufferTarget(c)})),this.subscription.add(V(o,this.player.state$.stateChangeEnded$).subscribe(()=>this.player.setPreloadOnly(t.playbackState.getState()===p.READY)));const u=V(t.playbackState.stateChangeStarted$,t.videoTrack.stateChangeStarted$,t.seekState.stateChangeEnded$,this.videoState.stateChangeEnded$,De(["init"])).pipe(je(0));this.subscription.add(u.subscribe(this.syncPlayback,r))}selectVideoRepresentation(){var e,t,i,r,a,n;const o=this.params.desiredState.autoVideoTrackSwitching.getState(),u=this.params.desiredState.videoTrack.getState(),d=(e=this.videoTracks$.getValue().find(({track:{id:A}})=>A===u))===null||e===void 0?void 0:e.track,l=this.params.output.currentVideoTrack$.getValue(),c=wt(this.video.buffered,this.video.currentTime*1e3),h=o?this.params.tuning.dash.forwardBufferTargetAuto:this.params.tuning.dash.forwardBufferTargetManual,f=Math.min(c/Math.min(h,(this.video.duration*1e3||1/0)-this.video.currentTime*1e3),1),v=Math.max(d&&!o&&(i=(t=this.audioRepresentations.get(d.id))===null||t===void 0?void 0:t.bitrate)!==null&&i!==void 0?i:0,l&&(a=(r=this.audioRepresentations.get(l.id))===null||r===void 0?void 0:r.bitrate)!==null&&a!==void 0?a:0),g=gi(this.videoTracks$.getValue().map(({track:A})=>A),{container:this.elementSize$.getValue(),throughput:this.params.dependencies.throughputEstimator.rttAdjustedThroughput$.getValue(),tuning:this.params.tuning.autoTrackSelection,limits:this.params.desiredState.autoVideoTrackLimits.getState(),reserve:v,forwardBufferHealth:f,current:l,history:this.videoTrackSwitchHistory,playbackRate:this.video.playbackRate,droppedVideoMaxQualityLimit:this.droppedFramesManager.droppedVideoMaxQualityLimit,abrLogger:this.params.dependencies.abrLogger}),T=o?g!=null?g:d:d!=null?d:g;return T&&((n=this.videoTracks$.getValue().find(({track:A})=>A===T))===null||n===void 0?void 0:n.representation)}prepare(e=0){this.player.initManifest(this.video,this.params.source.url,e)}playIfAllowed(){It(this.video).then(e=>{var t;e||((t=this.liveOffset)===null||t===void 0||t.pause(),this.videoState.setState(he.PAUSED),D(this.params.desiredState.playbackState,p.PAUSED,!0))},e=>this.params.output.error$.next({id:"ForcePlay",message:"play() failed even with workarounds",category:L.DOM,thrown:e}))}destroy(){this.subscription.unsubscribe(),this.droppedFramesManager.destroy(),this.destroy3DScene(),this.textTracksManager.destroy(),this.player.destroy(),this.params.output.element$.next(void 0),bt(this.video)}}class Xy extends Zu{subscribe(){super.subscribe();const{output:e,observableVideo:t,connect:i}=this.getProviderSubscriptionInfo();i(t.timeUpdate$,e.position$),i(t.durationChange$,e.duration$)}seek(e,t){this.params.output.willSeekEvent$.next(),this.player.seek(e,t)}}class Zy extends Zu{constructor(e){super(e),this.liveOffset=new tr}subscribe(){super.subscribe();const{output:e,observableVideo:t,connect:i}=this.getProviderSubscriptionInfo();this.params.output.position$.next(0),i(t.timeUpdate$,e.liveBufferTime$),i(this.player.liveDuration$,e.duration$),this.subscription.add(Ne({interval:Cs(Na),playbackRate:t.playbackRateState$}).subscribe(({playbackRate:r})=>{var a;if(this.videoState.getState()===he.PLAYING){const n=e.position$.getValue()+(r-1);e.position$.next(n),(a=this.liveOffset)===null||a===void 0||a.resetTo(-n*1e3)}})).add(Ne({liveBufferTime:e.liveBufferTime$,liveAvailabilityStartTime:this.player.liveAvailabilityStartTime$}).pipe(w(({liveBufferTime:r,liveAvailabilityStartTime:a})=>r&&a?r+a:void 0)).subscribe(e.liveTime$))}seek(e){this.params.output.willSeekEvent$.next();const t=this.params.desiredState.playbackState.getState(),i=this.videoState.getState(),r=t===p.PAUSED&&i===he.PAUSED,a=-e,n=Math.trunc(a/1e3<=Math.abs(this.params.output.duration$.getValue())?a:0);this.player.seekLive(n).then(()=>{var o;this.params.output.position$.next(e/1e3),(o=this.liveOffset)===null||o===void 0||o.resetTo(n,r)})}}const it={};var se;(function(s){s.INITIALIZING="initializing",s.STOPPED="stopped",s.READY="ready",s.PLAYING="playing",s.PAUSED="paused"})(se||(se={}));const Pi=(s,e)=>new Hs(t=>{const i=(r,a)=>t.next(a);return s.on(e,i),()=>s.off(e,i)});class eT{constructor(e){this.subscription=new ae,this.videoState=new ce(se.INITIALIZING),this.textTracksManager=new dt,this.trackLevels=new Map,this.syncPlayback=()=>{const t=this.videoState.getState(),i=this.params.desiredState.playbackState.getState(),r=this.params.desiredState.playbackState.getTransition(),a=this.params.desiredState.seekState.getState();if(t!==se.INITIALIZING)switch((r==null?void 0:r.to)!==p.PAUSED&&a.state===W.Requested&&this.seek(a.position),i){case p.STOPPED:switch(t){case se.STOPPED:break;case se.READY:case se.PLAYING:case se.PAUSED:this.stop();break;default:H(t)}break;case p.READY:switch(t){case se.STOPPED:this.prepare();break;case se.READY:case se.PLAYING:case se.PAUSED:break;default:H(t)}break;case p.PLAYING:switch(t){case se.PLAYING:break;case se.STOPPED:this.prepare();break;case se.READY:case se.PAUSED:this.playIfAllowed();break;default:H(t)}break;case p.PAUSED:switch(t){case se.PAUSED:break;case se.STOPPED:this.prepare();break;case se.READY:this.videoState.setState(se.PAUSED),D(this.params.desiredState.playbackState,p.PAUSED);break;case se.PLAYING:this.pause();break;default:H(t)}break;default:H(i)}},this.video=St(e.container),this.params=e,this.params.output.element$.next(this.video),this.params.output.isLive$.next(!1),this.params.output.availableVideoTracks$.next([]),this.params.output.availableAudioTracks$.next([]),this.params.output.isAudioAvailable$.next(!0),this.params.output.hostname$.next(Ie(this.params.source.url)),this.loadHlsJs()}destroy(){var e,t;this.subscription.unsubscribe(),this.trackLevels.clear(),this.textTracksManager.destroy(),(e=this.hls)===null||e===void 0||e.detachMedia(),(t=this.hls)===null||t===void 0||t.destroy(),this.params.output.element$.next(void 0),bt(this.video)}loadHlsJs(){let e=!1;const t=r=>{e||this.params.output.error$.next({id:r==="timeout"?"HlsJsTimeout":"HlsJsLoadError",category:L.NETWORK,message:"Failed to load Hls.js",thrown:r}),e=!0},i=window.setTimeout(()=>t("timeout"),this.params.tuning.dynamicImportTimeout);er(import("hls.js").then(r=>{e||(it.Hls=r.default,it.Events=r.default.Events,this.init())},t),()=>{window.clearTimeout(i),e=!0})}init(){P(it.Hls,"hls.js not loaded"),this.hls=new it.Hls({fragLoadingMaxRetry:5,levelLoadingMaxRetry:2,manifestLoadingMaxRetry:2,fragLoadingMaxRetryTimeout:16e3,manifestLoadingMaxRetryTimeout:2e3,levelLoadingMaxRetryTimeout:2e3}),this.subscribe(),this.videoState.setState(se.STOPPED)}subscribe(){P(it.Events,"hls.js not loaded");const{desiredState:e,output:t}=this.params,i=d=>{t.error$.next({id:"HlsJsProvider",category:L.WTF,message:"HlsJsProvider internal logic error",thrown:d})},r=yt(this.video),a=(d,l)=>this.subscription.add(d.subscribe(l,i));a(r.timeUpdate$,t.position$),a(r.durationChange$,t.duration$),a(r.ended$,t.endedEvent$),a(r.looped$,t.loopedEvent$),a(r.error$,t.error$),a(r.isBuffering$,t.isBuffering$),a(r.currentBuffer$,t.currentBuffer$),a(r.loadStart$,t.firstBytesEvent$),a(r.playing$,t.firstFrameEvent$),a(r.canplay$,t.canplay$),a(r.seeked$,t.seekedEvent$),a(r.inPiP$,t.inPiP$),a(r.inFullscreen$,t.inFullscreen$),this.subscription.add(jt(this.video,e.isLooped,i)),this.subscription.add(gt(this.video,e.volume,r.volumeState$,i)),this.subscription.add(r.volumeState$.subscribe(this.params.output.volume$)),this.subscription.add(Dt(this.video,e.playbackRate,r.playbackRateState$,i)),this.subscription.add(Pi(this.hls,it.Events.ERROR).subscribe(d=>{var l;d.fatal&&t.error$.next({id:["HlsJsFatal",d.type,d.details].join("_"),category:L.WTF,message:`HlsJs fatal ${d.type} ${d.details}, ${(l=d.err)===null||l===void 0?void 0:l.message} ${d.reason}`,thrown:d.error})})),this.subscription.add(r.playing$.subscribe(()=>{this.videoState.setState(se.PLAYING),D(e.playbackState,p.PLAYING)},i)).add(r.pause$.subscribe(()=>{this.videoState.setState(se.PAUSED),D(e.playbackState,p.PAUSED)},i)).add(r.canplay$.subscribe(()=>{var d;((d=this.videoState.getTransition())===null||d===void 0?void 0:d.to)===se.READY&&this.videoState.setState(se.READY),this.videoState.getState()===se.PLAYING&&this.playIfAllowed()},i)),a(Pi(this.hls,it.Events.MANIFEST_PARSED).pipe(w(({levels:d})=>d.reduce((l,c)=>{var h,f;const v=c.name||c.height.toString(10),{width:g,height:T}=c,A=(f=Qi((h=c.attrs.QUALITY)!==null&&h!==void 0?h:""))!==null&&f!==void 0?f:Vt({width:g,height:T});if(!A)return l;const E=c.attrs["FRAME-RATE"]?parseFloat(c.attrs["FRAME-RATE"]):void 0,m={id:v.toString(),quality:A,bitrate:c.bitrate/1e3,size:{width:g,height:T},fps:E};return this.trackLevels.set(v,{track:m,level:c}),l.push(m),l},[]))),t.availableVideoTracks$),a(Pi(this.hls,it.Events.MANIFEST_PARSED),d=>{if(d.subtitleTracks.length>0){const l=[];for(const c of d.subtitleTracks){const h=c.name,f=c.attrs.URI||"",v=c.lang,g="internal";l.push({id:h,url:f,language:v,type:g})}e.internalTextTracks.startTransitionTo(l)}}),a(Pi(this.hls,it.Events.LEVEL_LOADING).pipe(w(({url:d})=>Ie(d))),t.hostname$),this.subscription.add(Xe(e.autoVideoTrackSwitching,()=>this.hls.autoLevelEnabled,d=>{this.hls.nextLevel=d?-1:this.hls.currentLevel,this.hls.loadLevel=d?-1:this.hls.loadLevel},{onError:i}));const n=d=>{var l;return(l=Array.from(this.trackLevels.values()).find(({level:c})=>c===d))===null||l===void 0?void 0:l.track},o=Pi(this.hls,it.Events.LEVEL_SWITCHED).pipe(w(({level:d})=>n(this.hls.levels[d])));o.pipe(re(k)).subscribe(t.currentVideoTrack$,i),this.subscription.add(Xe(e.videoTrack,()=>{var d;return(d=n(this.hls.levels[this.hls.currentLevel]))===null||d===void 0?void 0:d.id},d=>{var l;if(ie(d))return;const c=(l=this.trackLevels.get(d))===null||l===void 0?void 0:l.level;if(!c)return;const h=this.hls.levels.indexOf(c),f=this.hls.currentLevel,v=this.hls.levels[f];!v||c.bitrate>v.bitrate?this.hls.nextLevel=h:(this.hls.loadLevel=h,this.hls.loadLevel=h)},{changed$:o.pipe(w(d=>d==null?void 0:d.id)),onError:i})),a(r.progress$,()=>{this.params.dependencies.throughputEstimator.addRawThroughput(this.hls.bandwidthEstimate/1e3)}),this.textTracksManager.connect(this.video,e,t);const u=V(e.playbackState.stateChangeStarted$,e.videoTrack.stateChangeStarted$,e.seekState.stateChangeEnded$,this.videoState.stateChangeEnded$,De(["init"])).pipe(je(0));this.subscription.add(u.subscribe(this.syncPlayback,i))}prepare(){this.videoState.startTransitionTo(se.READY),this.hls.attachMedia(this.video),this.hls.loadSource(this.params.source.url)}playIfAllowed(){return ue(this,void 0,void 0,function*(){this.videoState.startTransitionTo(se.PLAYING),(yield It(this.video).catch(t=>this.params.output.error$.next({id:"ForcePlay",message:"play() failed even with workarounds",category:L.DOM,thrown:t})))||(this.videoState.setState(se.PAUSED),D(this.params.desiredState.playbackState,p.PAUSED,!0))})}pause(){this.videoState.startTransitionTo(se.PAUSED),this.video.pause()}seek(e){this.params.output.willSeekEvent$.next(),this.video.currentTime=e/1e3}stop(){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.removeAttribute("src"),this.video.load(),this.videoState.setState(se.STOPPED),D(this.params.desiredState.playbackState,p.STOPPED,!0)}}const od="X-Playback-Duration";var dd=s=>ue(void 0,void 0,void 0,function*(){var e;const t=yield Fi(s),i=yield t.text(),r=(e=/#EXT-X-VK-PLAYBACK-DURATION:(\d+)/m.exec(i))===null||e===void 0?void 0:e[1];return r?parseInt(r,10):t.headers.has(od)?parseInt(t.headers.get(od),10):void 0});const tT=s=>{let e=null;if(s.QUALITY&&(e=Qi(s.QUALITY)),!e&&s.RESOLUTION){const[t,i]=s.RESOLUTION.split("x").map(r=>parseInt(r,10));e=Vt({width:t,height:i})}return e!=null?e:null},el=(s,e=s)=>ue(void 0,void 0,void 0,function*(){var t,i;const n=(yield(yield Fi(s)).text()).split(`
|
|
38
|
-
`),o=[],u=[];for(let d=0;d<n.length;d++){const l=n[d],c=l.match(/^#EXT-X-STREAM-INF:(.+)/),h=l.match(/^#EXT-X-MEDIA:TYPE=SUBTITLES,(.+)/);if(!(!c&&!h)){if(c){const f=li(c[1].split(",").map(b=>b.split("="))),v=(t=f.QUALITY)!==null&&t!==void 0?t:`stream-${f.BANDWIDTH}`,g=tT(f);let T;f.BANDWIDTH&&(T=parseInt(f.BANDWIDTH,10)/1e3||void 0),!T&&f["AVERAGE-BANDWIDTH"]&&(T=parseInt(f["AVERAGE-BANDWIDTH"],10)/1e3||void 0);const A=f["FRAME-RATE"]?parseFloat(f["FRAME-RATE"]):void 0;let E;if(f.RESOLUTION){const[b,$]=f.RESOLUTION.split("x").map(R=>parseInt(R,10));b&&$&&(E={width:b,height:$})}const m=new URL(n[++d],e).toString();g&&o.push({id:v,quality:g,url:m,bandwidth:T,size:E,fps:A})}if(h){const f=li(h[1].split(",").map(A=>A.split("=")).map(([A,E])=>[A,E.replace(/^"|"$/g,"")])),v=(i=f.URI)===null||i===void 0?void 0:i.replace(/playlist$/,"subtitles.vtt"),g=f.LANGUAGE,T=f.NAME;v&&g&&u.push({type:"internal",id:g,label:T,language:g,url:v,isAuto:!1})}}}return{qualityManifests:o,textTracks:u}});var oe;(function(s){s.STOPPED="stopped",s.READY="ready",s.PLAYING="playing",s.CHANGING_MANIFEST="changing_manifest",s.PAUSED="paused"})(oe||(oe={}));class iT{constructor(e){var t;this.subscription=new ae,this.videoState=new ce(oe.STOPPED),this.textTracksManager=new dt,this.manifests$=new S([]),this.liveOffset=new tr,this.manifestStartTime$=new S(void 0),this.syncPlayback=()=>{if(!this.manifests$.getValue().length)return;const a=this.videoState.getState(),n=this.params.desiredState.playbackState.getState(),o=this.params.desiredState.playbackState.getTransition(),u=this.params.desiredState.videoTrack.getTransition(),d=this.params.desiredState.autoVideoTrackSwitching.getTransition();if(n===p.STOPPED){a!==oe.STOPPED&&(this.videoState.startTransitionTo(oe.STOPPED),this.video.removeAttribute("src"),this.video.load(),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.videoState.setState(oe.STOPPED),D(this.params.desiredState.playbackState,p.STOPPED,!0));return}if(this.videoState.getTransition())return;const c=this.params.desiredState.seekState.getState();if(a===oe.STOPPED){this.videoState.startTransitionTo(oe.READY),this.prepare();return}if(u||d){const h=this.videoState.getState();this.videoState.setState(oe.CHANGING_MANIFEST),this.videoState.startTransitionTo(h),this.prepare(),c.state===W.None&&this.params.desiredState.seekState.setState({state:W.Requested,position:-this.liveOffset.getTotalOffset(),forcePrecise:!0});return}if((o==null?void 0:o.to)!==p.PAUSED&&c.state===W.Requested){this.videoState.startTransitionTo(oe.READY),this.seek(c.position-this.liveOffset.getTotalPausedTime()),this.prepare();return}switch(a){case oe.READY:n===p.READY?D(this.params.desiredState.playbackState,p.READY):n===p.PAUSED?(this.videoState.setState(oe.PAUSED),this.liveOffset.pause(),D(this.params.desiredState.playbackState,p.PAUSED)):n===p.PLAYING&&(this.videoState.startTransitionTo(oe.PLAYING),this.playIfAllowed());return;case oe.PLAYING:n===p.PAUSED?(this.videoState.startTransitionTo(oe.PAUSED),this.liveOffset.pause(),this.video.pause()):(o==null?void 0:o.to)===p.PLAYING&&D(this.params.desiredState.playbackState,p.PLAYING);return;case oe.PAUSED:n===p.PLAYING?(this.videoState.startTransitionTo(oe.PLAYING),this.liveOffset.getTotalPausedTime()<this.params.config.maxPausedTime&&this.liveOffset.getTotalOffset()<this.maxSeekBackTime$.getValue()?(this.liveOffset.resume(),this.playIfAllowed(),this.params.output.position$.next(-this.liveOffset.getTotalOffset()/1e3)):this.seek(-this.liveOffset.getTotalOffset())):(o==null?void 0:o.to)===p.PAUSED&&(D(this.params.desiredState.playbackState,p.PAUSED),this.liveOffset.pause());return;case oe.CHANGING_MANIFEST:break;default:return H(a)}},this.params=e,this.video=St(e.container),this.params.output.element$.next(this.video);const i={id:"master",quality:He.INVARIANT,url:this.params.source.url};el(Je(this.params.source.url),this.params.source.url).then(({qualityManifests:r})=>{this.manifests$.next([i,...r])},r=>this.params.output.error$.next({id:"ExtractHlsQualities",category:L.NETWORK,message:"Error fetching manifest and extracting qualities",thrown:r})),this.params.output.isLive$.next(!0),this.params.output.canChangePlaybackSpeed$.next(!1),this.params.output.availableVideoTracks$.next([]),this.params.output.availableAudioTracks$.next([]),this.params.output.isAudioAvailable$.next(!0),this.params.output.hostname$.next(Ie(this.params.source.url)),this.maxSeekBackTime$=new S((t=e.source.maxSeekBackTime)!==null&&t!==void 0?t:1/0),this.subscribe()}selectManifest(){var e,t;const{autoVideoTrackSwitching:i,videoTrack:r}=this.params.desiredState,a=i.getState(),n=r.getTransition(),o=(t=(e=n==null?void 0:n.to)!==null&&e!==void 0?e:r.getState())!==null&&t!==void 0?t:"master",u=this.manifests$.getValue();if(!u.length)return;const d=a?"master":o;return a&&!n&&r.startTransitionTo("master"),u.find(l=>l.id===d)}subscribe(){const{output:e,desiredState:t}=this.params,i=o=>{e.error$.next({id:"HlsLiveProvider",category:L.WTF,message:"HlsLiveProvider internal logic error",thrown:o})},r=yt(this.video),a=(o,u)=>this.subscription.add(o.subscribe(u,i));a(r.ended$,e.endedEvent$),a(r.error$,e.error$),a(r.isBuffering$,e.isBuffering$),a(r.currentBuffer$,e.currentBuffer$),a(r.loadedMetadata$,e.firstBytesEvent$),a(r.playing$,e.firstFrameEvent$),a(r.canplay$,e.canplay$),a(r.inPiP$,e.inPiP$),a(r.inFullscreen$,e.inFullscreen$),this.subscription.add(t.isLooped.stateChangeStarted$.subscribe(()=>t.isLooped.setState(!1),i)),this.subscription.add(gt(this.video,t.volume,r.volumeState$,i)),this.subscription.add(r.volumeState$.subscribe(this.params.output.volume$,i)),this.subscription.add(Dt(this.video,t.playbackRate,r.playbackRateState$,i)),this.textTracksManager.connect(this.video,t,e),this.subscription.add(r.playing$.subscribe(()=>{this.videoState.setState(oe.PLAYING),D(t.playbackState,p.PLAYING)},i)).add(r.pause$.subscribe(()=>{this.videoState.setState(oe.PAUSED),D(t.playbackState,p.PAUSED)},i)).add(r.canplay$.subscribe(()=>{var o;((o=this.videoState.getTransition())===null||o===void 0?void 0:o.to)===oe.READY&&this.videoState.setState(oe.READY),this.videoState.getState()===oe.PLAYING&&this.playIfAllowed()},i)),this.subscription.add(this.maxSeekBackTime$.pipe(ve(),w(o=>-o/1e3)).subscribe(this.params.output.duration$,i)),this.subscription.add(r.loadedMetadata$.subscribe(()=>{const o=this.params.desiredState.seekState.getState(),u=this.videoState.getTransition(),d=this.params.desiredState.videoTrack.getTransition(),l=this.params.desiredState.autoVideoTrackSwitching.getTransition();if(d&&k(d.to)){const c=d.to;this.params.desiredState.videoTrack.setState(c);const h=this.manifests$.getValue().find(f=>f.id===c);h&&(this.params.output.currentVideoTrack$.next(h),this.params.output.hostname$.next(Ie(h.url)))}l&&this.params.desiredState.autoVideoTrackSwitching.setState(l.to),u&&u.from===oe.CHANGING_MANIFEST&&this.videoState.setState(u.to),o&&o.state===W.Requested&&this.seek(o.position)},i)),this.subscription.add(r.loadedData$.subscribe(()=>{var o,u,d;const l=(d=(u=(o=this.video)===null||o===void 0?void 0:o.getStartDate)===null||u===void 0?void 0:u.call(o))===null||d===void 0?void 0:d.getTime();this.manifestStartTime$.next(l||void 0)},i)),this.subscription.add(Ne({startTime:this.manifestStartTime$.pipe(re(k)),currentTime:r.timeUpdate$}).subscribe(({startTime:o,currentTime:u})=>this.params.output.liveTime$.next(o+u*1e3),i)),this.subscription.add(this.manifests$.pipe(w(o=>o.map(({id:u,quality:d,size:l,bandwidth:c,fps:h})=>({id:u,quality:d,size:l,fps:h,bitrate:c})))).subscribe(this.params.output.availableVideoTracks$,i));const n=V(t.playbackState.stateChangeStarted$,t.seekState.stateChangeEnded$,this.videoState.stateChangeEnded$,t.videoTrack.stateChangeStarted$,t.autoVideoTrackSwitching.stateChangeStarted$,this.manifests$,De(["init"])).pipe(je(0));this.subscription.add(n.subscribe(this.syncPlayback,i))}destroy(){this.subscription.unsubscribe(),this.textTracksManager.destroy(),this.params.output.element$.next(void 0),bt(this.video)}prepare(){const e=this.selectManifest();if(ie(e))return;const t=this.params.format===y.HLS_LIVE_CMAF?Te.DASH_CMAF_OFFSET_P:Te.OFFSET_P,i=Je(e.url,this.liveOffset.getTotalOffset(),t);this.video.setAttribute("src",i),this.video.load(),dd(i).then(r=>{var a;if(!ie(r))this.maxSeekBackTime$.next(r);else{const n=(a=this.params.source.maxSeekBackTime)!==null&&a!==void 0?a:this.maxSeekBackTime$.getValue();if(ie(n)||!isFinite(n))try{Fi(i).then(o=>o.text()).then(o=>{var u;const d=(u=/#EXT-X-STREAM-INF[^\n]+\n(.+)/m.exec(o))===null||u===void 0?void 0:u[1];if(d){const l=new URL(d,i).toString();dd(l).then(c=>{ie(c)||this.maxSeekBackTime$.next(c)})}})}catch(o){}}})}playIfAllowed(){It(this.video).then(e=>{e||(this.videoState.setState(oe.PAUSED),this.liveOffset.pause(),D(this.params.desiredState.playbackState,p.PAUSED,!0))},e=>this.params.output.error$.next({id:"ForcePlay",message:"play() failed even with workarounds",category:L.DOM,thrown:e}))}seek(e){this.params.output.willSeekEvent$.next();const t=-e,i=t<this.maxSeekBackTime$.getValue()?t:0;this.liveOffset.resetTo(i),this.params.output.position$.next(-i/1e3),this.params.output.seekedEvent$.next()}}var le;(function(s){s.STOPPED="stopped",s.READY="ready",s.PLAYING="playing",s.CHANGING_MANIFEST="changing_manifest",s.PAUSED="paused"})(le||(le={}));class sT{constructor(e){this.subscription=new ae,this.videoState=new ce(le.STOPPED),this.textTracksManager=new dt,this.manifests$=new S([]),this.syncPlayback=()=>{if(!this.manifests$.getValue().length)return;const r=this.videoState.getState(),a=this.params.desiredState.playbackState.getState(),n=this.params.desiredState.playbackState.getTransition(),o=this.params.desiredState.videoTrack.getTransition(),u=this.params.desiredState.autoVideoTrackSwitching.getTransition();if(a===p.STOPPED){r!==le.STOPPED&&(this.videoState.startTransitionTo(le.STOPPED),this.video.removeAttribute("src"),this.video.load(),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.videoState.setState(le.STOPPED),D(this.params.desiredState.playbackState,p.STOPPED,!0));return}if(this.videoState.getTransition())return;const l=this.params.desiredState.seekState.getState();if(r===le.STOPPED){this.videoState.startTransitionTo(le.READY),this.prepare();return}if(o||u){const c=this.videoState.getState();this.videoState.setState(le.CHANGING_MANIFEST),this.videoState.startTransitionTo(c);const{currentTime:h}=this.video;this.prepare(),l.state===W.None&&this.params.desiredState.seekState.setState({state:W.Requested,position:h*1e3,forcePrecise:!0});return}switch((n==null?void 0:n.to)!==p.PAUSED&&l.state===W.Requested&&this.seek(l.position),r){case le.READY:a===p.READY?D(this.params.desiredState.playbackState,p.READY):a===p.PAUSED?(this.videoState.setState(le.PAUSED),D(this.params.desiredState.playbackState,p.PAUSED)):a===p.PLAYING&&(this.videoState.startTransitionTo(le.PLAYING),this.playIfAllowed());return;case le.PLAYING:a===p.PAUSED?(this.videoState.startTransitionTo(le.PAUSED),this.video.pause()):(n==null?void 0:n.to)===p.PLAYING&&D(this.params.desiredState.playbackState,p.PLAYING);return;case le.PAUSED:a===p.PLAYING?(this.videoState.startTransitionTo(le.PLAYING),this.playIfAllowed()):(n==null?void 0:n.to)===p.PAUSED&&D(this.params.desiredState.playbackState,p.PAUSED);return;case le.CHANGING_MANIFEST:break;default:return H(r)}},this.params=e,this.video=St(e.container),this.params.output.element$.next(this.video);const t={id:"master",quality:He.INVARIANT,url:this.params.source.url};this.params.output.isLive$.next(!1),this.params.output.availableVideoTracks$.next([]),this.params.output.availableAudioTracks$.next([]),this.params.output.isAudioAvailable$.next(!0),this.params.output.hostname$.next(Ie(this.params.source.url)),el(this.params.source.url).then(({qualityManifests:i,textTracks:r})=>{this.manifests$.next([t,...i]),this.params.tuning.useNativeHLSTextTracks||this.params.desiredState.internalTextTracks.startTransitionTo(r)},i=>this.params.output.error$.next({id:"ExtractHlsQualities",category:L.NETWORK,message:"Error fetching manifest and extracting qualities",thrown:i})),this.subscribe()}selectManifest(){var e,t;const{autoVideoTrackSwitching:i,videoTrack:r}=this.params.desiredState,a=i.getState(),n=r.getTransition(),o=(t=(e=n==null?void 0:n.to)!==null&&e!==void 0?e:r.getState())!==null&&t!==void 0?t:"master",u=this.manifests$.getValue();if(!u.length)return;const d=a?"master":o;return a&&!n&&r.startTransitionTo("master"),u.find(l=>l.id===d)}subscribe(){const{output:e,desiredState:t}=this.params,i=o=>{e.error$.next({id:"HlsProvider",category:L.WTF,message:"HlsProvider internal logic error",thrown:o})},r=yt(this.video),a=(o,u)=>this.subscription.add(o.subscribe(u));if(a(r.timeUpdate$,e.position$),a(r.durationChange$,e.duration$),a(r.ended$,e.endedEvent$),a(r.looped$,e.loopedEvent$),a(r.error$,e.error$),a(r.isBuffering$,e.isBuffering$),a(r.currentBuffer$,e.currentBuffer$),a(r.loadedMetadata$,e.firstBytesEvent$),a(r.playing$,e.firstFrameEvent$),a(r.canplay$,e.canplay$),a(r.seeked$,e.seekedEvent$),a(r.inPiP$,e.inPiP$),a(r.inFullscreen$,e.inFullscreen$),this.subscription.add(jt(this.video,t.isLooped,i)),this.subscription.add(gt(this.video,t.volume,r.volumeState$,i)),this.subscription.add(r.volumeState$.subscribe(this.params.output.volume$,i)),this.subscription.add(Dt(this.video,t.playbackRate,r.playbackRateState$,i)),this.textTracksManager.connect(this.video,t,e),this.subscription.add(r.playing$.subscribe(()=>{this.videoState.setState(le.PLAYING),D(t.playbackState,p.PLAYING)},i)).add(r.pause$.subscribe(()=>{this.videoState.setState(le.PAUSED),D(t.playbackState,p.PAUSED)},i)).add(r.canplay$.subscribe(()=>{var o;((o=this.videoState.getTransition())===null||o===void 0?void 0:o.to)===le.READY&&this.videoState.setState(le.READY),this.videoState.getState()===le.PLAYING&&this.playIfAllowed()},i).add(r.loadedMetadata$.subscribe(()=>{const o=this.params.desiredState.seekState.getState(),u=this.videoState.getTransition(),d=this.params.desiredState.videoTrack.getTransition(),l=this.params.desiredState.autoVideoTrackSwitching.getTransition();if(d&&k(d.to)){const c=d.to;this.params.desiredState.videoTrack.setState(c);const h=this.manifests$.getValue().find(f=>f.id===c);h&&(this.params.output.currentVideoTrack$.next(h),this.params.output.hostname$.next(Ie(h.url)))}l&&this.params.desiredState.autoVideoTrackSwitching.setState(l.to),u&&u.from===le.CHANGING_MANIFEST&&this.videoState.setState(u.to),o.state===W.Requested&&this.seek(o.position)},i))),this.subscription.add(this.manifests$.pipe(w(o=>o.map(({id:u,quality:d,size:l,bandwidth:c,fps:h})=>({id:u,quality:d,size:l,fps:h,bitrate:c})))).subscribe(this.params.output.availableVideoTracks$,i)),!this.params.tuning.useNativeHLSTextTracks){const{textTracks:o}=this.video;this.subscription.add(V(B(o,"addtrack"),B(o,"removetrack"),B(o,"change"),De(["init"])).subscribe(()=>{for(let u=0;u<o.length;u++)o[u].mode="hidden"},i))}const n=V(t.playbackState.stateChangeStarted$,t.seekState.stateChangeEnded$,t.videoTrack.stateChangeStarted$,t.autoVideoTrackSwitching.stateChangeStarted$,this.videoState.stateChangeEnded$,this.manifests$,De(["init"])).pipe(je(0));this.subscription.add(n.subscribe(this.syncPlayback,i))}destroy(){this.subscription.unsubscribe(),this.textTracksManager.destroy(),this.params.output.element$.next(void 0),bt(this.video)}prepare(){const e=this.selectManifest();ie(e)||(this.video.setAttribute("src",e.url),this.video.load())}playIfAllowed(){It(this.video).then(e=>{e||(this.videoState.setState(le.PAUSED),D(this.params.desiredState.playbackState,p.PAUSED,!0))},e=>this.params.output.error$.next({id:"ForcePlay",message:"play() failed even with workarounds",category:L.DOM,thrown:e}))}seek(e){this.params.output.willSeekEvent$.next(),this.video.currentTime=e/1e3}}var fe;(function(s){s.STOPPED="stopped",s.READY="ready",s.PLAYING="playing",s.PAUSED="paused"})(fe||(fe={}));class rT{constructor(e){this.subscription=new ae,this.videoState=new ce(fe.STOPPED),this.trackUrls={},this.textTracksManager=new dt,this.syncPlayback=()=>{var t,i,r;const a=this.videoState.getState(),n=this.params.desiredState.playbackState.getState(),o=this.params.desiredState.playbackState.getTransition();if(n===p.STOPPED){a!==fe.STOPPED&&(this.videoState.startTransitionTo(fe.STOPPED),this.video.removeAttribute("src"),this.video.load(),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.videoState.setState(fe.STOPPED),D(this.params.desiredState.playbackState,p.STOPPED,!0));return}if(this.videoState.getTransition())return;const d=this.params.desiredState.autoVideoTrackLimits.getTransition(),l=this.params.desiredState.videoTrack.getTransition(),c=this.params.desiredState.seekState.getState();if(d&&a!==fe.READY&&!l){this.handleQualityLimitTransition(d.to.max);return}if(a===fe.STOPPED){this.videoState.startTransitionTo(fe.READY),this.prepare();return}if(l){const{currentTime:h}=this.video;this.prepare(),c.state===W.None&&this.params.desiredState.seekState.setState({state:W.Requested,position:h*1e3,forcePrecise:!0}),l.to&&((t=this.params.desiredState.autoVideoTrackLimits.getState())===null||t===void 0?void 0:t.max)!==((r=(i=this.trackUrls[l.to])===null||i===void 0?void 0:i.track)===null||r===void 0?void 0:r.quality)&&this.params.output.autoVideoTrackLimits$.next({max:void 0});return}switch((o==null?void 0:o.to)!==p.PAUSED&&c.state===W.Requested&&this.seek(c.position),a){case fe.READY:n===p.READY?D(this.params.desiredState.playbackState,p.READY):n===p.PAUSED?(this.videoState.setState(fe.PAUSED),D(this.params.desiredState.playbackState,p.PAUSED)):n===p.PLAYING&&(this.videoState.startTransitionTo(fe.PLAYING),this.playIfAllowed());return;case fe.PLAYING:n===p.PAUSED?(this.videoState.startTransitionTo(fe.PAUSED),this.video.pause()):(o==null?void 0:o.to)===p.PLAYING&&D(this.params.desiredState.playbackState,p.PLAYING);return;case fe.PAUSED:n===p.PLAYING?(this.videoState.startTransitionTo(fe.PLAYING),this.playIfAllowed()):(o==null?void 0:o.to)===p.PAUSED&&D(this.params.desiredState.playbackState,p.PAUSED);return;default:return H(a)}},this.params=e,this.video=St(e.container),this.params.output.element$.next(this.video),Object.entries(this.params.source).reverse().forEach(([t,i],r)=>{const a=r.toString(10);this.trackUrls[a]={track:{quality:t,id:a},url:i}}),this.params.output.isLive$.next(!1),this.params.output.availableVideoTracks$.next(Object.values(this.trackUrls).map(({track:t})=>t)),this.params.output.availableAudioTracks$.next([]),this.params.output.isAudioAvailable$.next(!0),this.params.desiredState.autoVideoTrackSwitching.setState(!1),this.params.output.autoVideoTrackLimitingAvailable$.next(!0),this.subscribe()}subscribe(){const{output:e,desiredState:t}=this.params,i=o=>{e.error$.next({id:"MpegProvider",category:L.WTF,message:"MpegProvider internal logic error",thrown:o})},r=yt(this.video),a=(o,u)=>this.subscription.add(o.subscribe(u,i));a(r.timeUpdate$,e.position$),a(r.durationChange$,e.duration$),a(r.ended$,e.endedEvent$),a(r.looped$,e.loopedEvent$),a(r.error$,e.error$),a(r.isBuffering$,e.isBuffering$),a(r.currentBuffer$,e.currentBuffer$),a(r.loadedMetadata$,e.firstBytesEvent$),a(r.playing$,e.firstFrameEvent$),a(r.canplay$,e.canplay$),a(r.seeked$,e.seekedEvent$),a(r.inPiP$,e.inPiP$),a(r.inFullscreen$,e.inFullscreen$),this.subscription.add(jt(this.video,t.isLooped,i)),this.subscription.add(gt(this.video,t.volume,r.volumeState$,i)),this.subscription.add(r.volumeState$.subscribe(this.params.output.volume$,i)),this.subscription.add(Dt(this.video,t.playbackRate,r.playbackRateState$,i)),this.subscription.add(r.playing$.subscribe(()=>{this.videoState.setState(fe.PLAYING),D(t.playbackState,p.PLAYING)},i)).add(r.pause$.subscribe(()=>{this.videoState.setState(fe.PAUSED),D(t.playbackState,p.PAUSED)},i)).add(r.canplay$.subscribe(()=>{var o;((o=this.videoState.getTransition())===null||o===void 0?void 0:o.to)===fe.READY&&this.videoState.setState(fe.READY);const u=this.params.desiredState.videoTrack.getTransition();u&&k(u.to)&&(this.params.desiredState.videoTrack.setState(u.to),this.params.output.currentVideoTrack$.next(this.trackUrls[u.to].track)),this.videoState.getState()===fe.PLAYING&&this.playIfAllowed()},i)),this.textTracksManager.connect(this.video,t,e);const n=V(t.playbackState.stateChangeStarted$,t.videoTrack.stateChangeStarted$,t.seekState.stateChangeEnded$,t.autoVideoTrackLimits.stateChangeStarted$,this.videoState.stateChangeEnded$,De(["init"])).pipe(je(0));this.subscription.add(n.subscribe(this.syncPlayback,i))}destroy(){this.subscription.unsubscribe(),this.textTracksManager.destroy(),this.trackUrls={},this.params.output.element$.next(void 0),bt(this.video)}prepare(){const e=this.params.desiredState.videoTrack.getState();P(e,"MpegProvider: track is not selected");let{url:t}=this.trackUrls[e];P(t,`MpegProvider: No url for ${e}`),this.params.tuning.requestQuick&&(t=ci(t)),this.video.setAttribute("src",t),this.video.load(),this.params.output.hostname$.next(Ie(t))}playIfAllowed(){It(this.video).then(e=>{e||(this.videoState.setState(fe.PAUSED),D(this.params.desiredState.playbackState,p.PAUSED,!0))},e=>this.params.output.error$.next({id:"ForcePlay",message:"play() failed even with workarounds",category:L.DOM,thrown:e}))}seek(e){this.params.output.willSeekEvent$.next(),this.video.currentTime=e/1e3}handleQualityLimitTransition(e){var t,i,r;let a;if(e&&((t=this.params.output.currentVideoTrack$.getValue())===null||t===void 0?void 0:t.quality)!==e){const n=(i=Object.values(this.trackUrls).find(d=>Td(d.track.quality,e)))===null||i===void 0?void 0:i.track,o=this.params.desiredState.videoTrack.getState(),u=(r=this.trackUrls[o!=null?o:"0"])===null||r===void 0?void 0:r.track;n&&u&&pa(u.quality,n.quality)&&(a=n)}else if(!e){const n=Object.values(this.trackUrls).map(o=>o.track);a=gi(n,{container:{width:this.video.offsetWidth,height:this.video.offsetHeight},throughput:this.params.dependencies.throughputEstimator.throughput$.getValue(),tuning:this.params.tuning.autoTrackSelection,forwardBufferHealth:0,abrLogger:this.params.dependencies.abrLogger})}a&&(this.params.output.currentVideoTrack$.next(a),this.params.desiredState.videoTrack.startTransitionTo(a.id)),this.params.output.autoVideoTrackLimits$.next({max:e})}}const ud=["stun:videostun.mycdn.me:80"],aT=1e3,nT=3,ta=()=>null;class oT{constructor(e,t){this.ws=null,this.peerConnection=null,this.serverUrl="",this.streamKey="",this.stream=null,this.signalingType="JOIN",this.retryCount=0,this.externalStartCallback=ta,this.externalStopCallback=ta,this.externalErrorCallback=ta,this.options=this.normalizeOptions(t);const i=e.split("/");this.serverUrl=i.slice(0,i.length-1).join("/"),this.streamKey=i[i.length-1]}onStart(e){try{this.externalStartCallback=e}catch(t){this.handleSystemError(t)}}onStop(e){try{this.externalStopCallback=e}catch(t){this.handleSystemError(t)}}onError(e){try{this.externalErrorCallback=e}catch(t){this.handleSystemError(t)}}connect(){this.connectWS()}disconnect(){try{this.externalStopCallback(),this.closeConnections()}catch(e){this.handleSystemError(e)}}connectWS(){this.ws||(this.ws=new WebSocket(this.serverUrl),this.ws.onopen=this.onSocketOpen.bind(this),this.ws.onmessage=this.onSocketMessage.bind(this),this.ws.onclose=this.onSocketClose.bind(this),this.ws.onerror=this.onSocketError.bind(this))}onSocketOpen(){this.handleLogin()}onSocketClose(e){try{if(!this.ws)return;this.ws=null,e.code>1e3?(this.retryCount++,this.retryCount>this.options.maxRetryNumber?this.handleNetworkError():this.scheduleRetry()):this.externalStopCallback()}catch(t){this.handleRTCError(t)}}onSocketError(e){try{this.externalErrorCallback(new Error(e.toString()))}catch(t){this.handleRTCError(t)}}onSocketMessage(e){try{const t=this.parseMessage(e.data);switch(t.type){case"JOIN":case"CALL_JOIN":this.handleJoinMessage(t);break;case"UPDATE":this.handleUpdateMessage(t);break;case"STATUS":this.handleStatusMessage(t);break}}catch(t){this.handleRTCError(t)}}handleJoinMessage(e){switch(e.inviteType){case"ANSWER":this.handleAnswer(e.sdp);break;case"CANDIDATE":this.handleCandidate(e.candidate);break}}handleStatusMessage(e){switch(e.status){case"UNPUBLISHED":this.handleUnpublished();break}}handleUpdateMessage(e){return ue(this,void 0,void 0,function*(){try{const t=yield this.createOffer();this.peerConnection&&(yield this.peerConnection.setLocalDescription(t)),this.handleAnswer(e.sdp)}catch(t){this.handleRTCError(t)}})}handleLogin(){return ue(this,void 0,void 0,function*(){try{const e={iceServers:[{urls:ud}]};this.peerConnection=new RTCPeerConnection(e),this.peerConnection.ontrack=this.onPeerConnectionStream.bind(this),this.peerConnection.onicecandidate=this.onPeerConnectionIceCandidate.bind(this),this.peerConnection.oniceconnectionstatechange=this.onPeerConnectionIceConnectionStateChange.bind(this);const t=yield this.createOffer();yield this.peerConnection.setLocalDescription(t),this.send({type:this.signalingType,inviteType:"OFFER",streamKey:this.streamKey,sdp:t.sdp,callSupport:!1})}catch(e){this.handleRTCError(e)}})}handleAnswer(e){return ue(this,void 0,void 0,function*(){try{this.peerConnection&&(yield this.peerConnection.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:e})))}catch(t){this.handleRTCError(t)}})}handleCandidate(e){return ue(this,void 0,void 0,function*(){if(e)try{this.peerConnection&&(yield this.peerConnection.addIceCandidate(e))}catch(t){this.handleRTCError(t)}})}handleUnpublished(){try{this.closeConnections(),this.externalStopCallback()}catch(e){this.handleRTCError(e)}}handleSystemError(e){this.options.errorChanel&&this.options.errorChanel.next({id:"webrtc-provider-error",category:L.WTF,message:e.message})}onPeerConnectionStream(e){return ue(this,void 0,void 0,function*(){const t=e.streams[0];this.stream&&this.stream.id===t.id||(this.stream=t,this.externalStartCallback(this.stream))})}onPeerConnectionIceCandidate(e){e.candidate&&this.send({type:this.signalingType,inviteType:"CANDIDATE",candidate:e.candidate})}onPeerConnectionIceConnectionStateChange(){if(this.peerConnection){const e=this.peerConnection.iceConnectionState;["failed","closed"].indexOf(e)>-1&&(this.retryCount++,this.retryCount>this.options.maxRetryNumber?this.handleNetworkError():(this.closeConnections(),this.scheduleRetry()))}}createOffer(){return ue(this,void 0,void 0,function*(){const e={offerToReceiveAudio:!0,offerToReceiveVideo:!0,voiceActivityDetection:!1};if(!this.peerConnection)throw new Error("Can not create offer - no peer connection instance ");const t=yield this.peerConnection.createOffer(e),i=t.sdp||"";if(!/^a=rtpmap:\d+ H264\/\d+$/m.test(i))throw new Error("No h264 codec support error");return t})}handleRTCError(e){try{this.externalErrorCallback(e||new Error("RTC connection error"))}catch(t){this.handleSystemError(t)}}handleNetworkError(){try{this.externalErrorCallback(new Error("Network error"))}catch(e){this.handleSystemError(e)}}send(e){this.ws&&this.ws.send(JSON.stringify(e))}parseMessage(e){try{return JSON.parse(e)}catch(t){throw new Error("Can not parse socket message")}}closeConnections(){const e=this.ws;e&&(this.ws=null,e.close(1e3)),this.removePeerConnection()}removePeerConnection(){let e=this.peerConnection;e&&(this.peerConnection=null,e.close(),e.ontrack=null,e.onicecandidate=null,e.oniceconnectionstatechange=null,e=null)}scheduleRetry(){this.retryTimeout=setTimeout(this.connectWS.bind(this),aT)}normalizeOptions(e={}){const t={stunServerList:ud,maxRetryNumber:nT,errorChanel:null};return e.stunServerList&&(t.stunServerList=e.stunServerList),e.maxRetryNumber&&e.maxRetryNumber>0&&(t.maxRetryNumber=e.maxRetryNumber),t}}var de;(function(s){s.STOPPED="stopped",s.READY="ready",s.PLAYING="playing",s.PAUSED="paused"})(de||(de={}));class dT{constructor(e){this.videoState=new ce(de.STOPPED),this.maxSeekBackTime$=new S(0),this.syncPlayback=()=>{const t=this.videoState.getState(),i=this.params.desiredState.playbackState.getState(),r=this.params.desiredState.playbackState.getTransition();if(i===p.STOPPED){t!==de.STOPPED&&(this.videoState.startTransitionTo(de.STOPPED),this.video.pause(),this.video.srcObject=null,this.params.output.position$.next(0),this.params.output.duration$.next(0),this.params.output.currentBuffer$.next(void 0),this.params.output.hostname$.next(void 0),this.videoState.setState(de.STOPPED),D(this.params.desiredState.playbackState,p.STOPPED,!0));return}if(this.videoState.getTransition())return;const n=this.params.desiredState.videoTrack.getTransition();if(t===de.STOPPED){this.videoState.startTransitionTo(de.READY),this.prepare();return}if(n){this.prepare();return}switch(t){case de.READY:i===p.PAUSED?(this.videoState.setState(de.PAUSED),D(this.params.desiredState.playbackState,p.PAUSED)):i===p.PLAYING&&(this.videoState.startTransitionTo(de.PLAYING),this.playIfAllowed());return;case de.PLAYING:i===p.PAUSED?(this.videoState.startTransitionTo(de.PAUSED),this.video.pause()):(r==null?void 0:r.to)===p.PLAYING&&D(this.params.desiredState.playbackState,p.PLAYING);return;case de.PAUSED:i===p.PLAYING?(this.videoState.startTransitionTo(de.PLAYING),this.playIfAllowed()):(r==null?void 0:r.to)===p.PAUSED&&D(this.params.desiredState.playbackState,p.PAUSED);return;default:return H(t)}},this.subscription=new ae,this.params=e,this.log=this.params.dependencies.logger.createComponentLog("WebRTCLiveProvider"),this.video=St(e.container),this.liveStreamClient=new oT(this.params.source.url,{maxRetryNumber:this.params.tuning.webrtc.connectionRetryMaxNumber,errorChanel:this.params.output.error$}),this.liveStreamClient.onStart(this.onLiveStreamStart.bind(this)),this.liveStreamClient.onStop(this.onLiveStreamStop.bind(this)),this.liveStreamClient.onError(this.onLiveStreamError.bind(this)),this.subscribe()}destroy(){this.subscription.unsubscribe(),this.liveStreamClient.disconnect(),this.params.output.element$.next(void 0),bt(this.video)}subscribe(){const{output:e,desiredState:t}=this.params,i=n=>{e.error$.next({id:"WebRTCLiveProvider",category:L.WTF,message:"WebRTCLiveProvider internal logic error",thrown:n})};V(this.videoState.stateChangeStarted$.pipe(w(n=>({transition:n,type:"start"}))),this.videoState.stateChangeEnded$.pipe(w(n=>({transition:n,type:"end"})))).subscribe(({transition:n,type:o})=>{this.log({message:`[videoState change] ${o}: ${JSON.stringify(n)}`})});const r=yt(this.video),a=(n,o)=>this.subscription.add(n.subscribe(o,i));a(r.timeUpdate$,e.liveTime$),a(r.ended$,e.endedEvent$),a(r.looped$,e.loopedEvent$),a(r.error$,e.error$),a(r.isBuffering$,e.isBuffering$),a(r.currentBuffer$,e.currentBuffer$),this.subscription.add(r.durationChange$.subscribe(n=>{e.duration$.next(n===1/0?0:n)})).add(r.canplay$.subscribe(()=>{var n;((n=this.videoState.getTransition())===null||n===void 0?void 0:n.to)===de.READY&&this.videoState.setState(de.READY)},i)).add(r.pause$.subscribe(()=>{this.videoState.setState(de.PAUSED)},i)).add(r.playing$.subscribe(()=>{this.videoState.setState(de.PLAYING)},i)).add(r.error$.subscribe(e.error$)).add(this.maxSeekBackTime$.subscribe(this.params.output.duration$)).add(gt(this.video,t.volume,r.volumeState$,i)).add(r.volumeState$.subscribe(e.volume$,i)).add(this.videoState.stateChangeEnded$.subscribe(n=>{switch(n.to){case de.STOPPED:e.position$.next(0),e.duration$.next(0),t.playbackState.setState(p.STOPPED);break;case de.READY:break;case de.PAUSED:t.playbackState.setState(p.PAUSED);break;case de.PLAYING:t.playbackState.setState(p.PLAYING);break;default:return H(n.to)}},i)).add(V(t.playbackState.stateChangeStarted$,this.videoState.stateChangeEnded$,De(["init"])).pipe(je(0)).subscribe(this.syncPlayback.bind(this),i)),this.subscription.add(t.isLooped.stateChangeStarted$.subscribe(()=>t.isLooped.setState(!1),i)),this.subscription.add(t.autoVideoTrackSwitching.stateChangeStarted$.subscribe(()=>t.autoVideoTrackSwitching.setState(!1),i))}onLiveStreamStart(e){this.params.output.element$.next(this.video),this.params.output.duration$.next(0),this.params.output.position$.next(0),this.params.output.isLive$.next(!0),this.params.output.canChangePlaybackSpeed$.next(!1),this.params.output.hostname$.next(Ie(this.params.source.url)),this.params.output.autoVideoTrackLimitingAvailable$.next(!1),this.params.output.availableVideoTracks$.next([]),this.params.output.availableAudioTracks$.next([]),this.params.output.isAudioAvailable$.next(!0),this.params.output.currentVideoTrack$.next({id:"webrtc",quality:He.INVARIANT}),this.video.srcObject=e,D(this.params.desiredState.playbackState,p.PLAYING)}onLiveStreamStop(){this.videoState.startTransitionTo(de.STOPPED),this.syncPlayback(),this.params.output.position$.next(0),this.params.output.duration$.next(0),this.params.output.currentBuffer$.next(void 0),this.params.output.hostname$.next(void 0),this.params.output.endedEvent$.next()}onLiveStreamError(e){this.onLiveStreamStop(),this.params.output.error$.next({id:"WebRTC stream runtime error",category:L.EXTERNAL_API,message:e.message,thrown:e})}playIfAllowed(){It(this.video).then(e=>{e||(this.videoState.setState(de.PAUSED),D(this.params.desiredState.playbackState,p.PAUSED,!0))},e=>this.params.output.error$.next({id:"ForcePlay",message:"play() failed even with workarounds",category:L.DOM,thrown:e}))}prepare(){this.liveStreamClient.connect()}}class ld{constructor(e){this.iterator=e[Symbol.iterator](),this.next()}next(){this.current=this.iterator.next()}getValue(){if(this.current.done)throw new Error("Iterable is completed");return this.current.value}isCompleted(){return!!this.current.done}}var ia,sa,ra,aa,na,oa,ys,da,Ts,ua,Es,la,$s,ca,As,ha,_s,fa;const tl=Ua().device===_l.Android,kt=document.createElement("video"),uT='video/mp4; codecs="avc1.42000a,mp4a.40.2"',lT='video/mp4; codecs="hev1.1.6.L93.B0"',il='video/webm; codecs="vp09.00.10.08"',sl='video/webm; codecs="av01.0.00M.08"',cT='audio/mp4; codecs="mp4a.40.2"',hT='audio/webm; codecs="opus"',Qe={mse:!!(window.MediaSource&&window.MediaStreamTrack&&(!((sa=(ia=window.SourceBuffer)===null||ia===void 0?void 0:ia.prototype)===null||sa===void 0)&&sa.appendBuffer)),hls:!!(!((ra=kt.canPlayType)===null||ra===void 0)&&ra.call(kt,"application/x-mpegurl")||!((aa=kt.canPlayType)===null||aa===void 0)&&aa.call(kt,"vnd.apple.mpegURL")),webrtc:!!window.RTCPeerConnection,ws:!!window.WebSocket},Le={mp4:!!(!((na=kt.canPlayType)===null||na===void 0)&&na.call(kt,"video/mp4")),webm:!!(!((oa=kt.canPlayType)===null||oa===void 0)&&oa.call(kt,"video/webm")),cmaf:!0},nt={h264:!!(!((da=(ys=window.MediaSource)===null||ys===void 0?void 0:ys.isTypeSupported)===null||da===void 0)&&da.call(ys,uT)),h265:!!(!((ua=(Ts=window.MediaSource)===null||Ts===void 0?void 0:Ts.isTypeSupported)===null||ua===void 0)&&ua.call(Ts,lT)),vp9:!!(!((la=(Es=window.MediaSource)===null||Es===void 0?void 0:Es.isTypeSupported)===null||la===void 0)&&la.call(Es,il)),av1:!!(!((ca=($s=window.MediaSource)===null||$s===void 0?void 0:$s.isTypeSupported)===null||ca===void 0)&&ca.call($s,sl)),aac:!!(!((ha=(As=window.MediaSource)===null||As===void 0?void 0:As.isTypeSupported)===null||ha===void 0)&&ha.call(As,cT)),opus:!!(!((fa=(_s=window.MediaSource)===null||_s===void 0?void 0:_s.isTypeSupported)===null||fa===void 0)&&fa.call(_s,hT))},ii=(nt.h264||nt.h265)&&nt.aac;var _t;(function(s){s.VP9="vp9",s.AV1="av1",s.NONE="none",s.SMOOTH="smooth",s.POWER_EFFICIENT="power_efficient"})(_t||(_t={}));var ft;(function(s){s.DASH="dash",s.HLS="hls",s.MPEG="mpeg"})(ft||(ft={}));let Bt;const fT=()=>ue(void 0,void 0,void 0,function*(){if(!window.navigator.mediaCapabilities)return;const s={type:"media-source",video:{contentType:"video/webm",width:1280,height:720,bitrate:1e6,framerate:30}},[e,t]=yield Promise.all([window.navigator.mediaCapabilities.decodingInfo(Object.assign(Object.assign({},s),{video:Object.assign(Object.assign({},s.video),{contentType:sl})})),window.navigator.mediaCapabilities.decodingInfo(Object.assign(Object.assign({},s),{video:Object.assign(Object.assign({},s.video),{contentType:il})}))]);Bt={[y.DASH_WEBM_AV1]:e,[y.DASH_WEBM]:t}});try{fT()}catch(s){console.error(s)}const Ui=Qe.hls&&Le.mp4,pT=()=>Object.keys(nt).filter(s=>nt[s]),vT=(s,e=!1)=>s.filter(t=>{switch(t){case y.DASH:return Qe.mse&&Le.mp4&ⅈcase y.DASH_SEP:return Qe.mse&&Le.mp4&ⅈcase y.DASH_WEBM:return Qe.mse&&Le.webm&&nt.vp9&&nt.opus;case y.DASH_WEBM_AV1:return Qe.mse&&Le.webm&&nt.av1&&nt.opus;case y.DASH_LIVE:return Qe.mse&&Le.mp4&ⅈcase y.DASH_LIVE_CMAF:return Qe.mse&&Le.mp4&&ii&&Le.cmaf;case y.DASH_ONDEMAND:return Qe.mse&&Le.mp4&ⅈcase y.HLS:case y.HLS_ONDEMAND:return Ui||e&&Qe.mse&&Le.mp4&ⅈcase y.HLS_LIVE:case y.HLS_LIVE_CMAF:return Ui;case y.MPEG:return Le.mp4;case y.DASH_LIVE_WEBM:return!1;case y.WEB_RTC_LIVE:return Qe.webrtc&&Qe.ws&&nt.h264&&(Le.mp4||Le.webm);default:return H(t)}}),Ri=s=>{const e=y.DASH_WEBM,t=y.DASH_WEBM_AV1;switch(s){case _t.VP9:return[e,t];case _t.AV1:return[t,e];case _t.NONE:return[];case _t.SMOOTH:return Bt?Bt[t].smooth?[t,e]:Bt[e].smooth?[e,t]:[t,e]:[e,t];case _t.POWER_EFFICIENT:return Bt?Bt[t].powerEfficient?[t,e]:Bt[e].powerEfficient?[e,t]:[t,e]:[e,t];default:H(s)}return[e,t]},mT=({webmCodec:s,androidPreferredFormat:e})=>{if(tl)switch(e){case ft.MPEG:return[y.MPEG,...Ri(s),y.DASH_SEP,y.DASH,y.DASH_ONDEMAND,y.HLS,y.HLS_ONDEMAND];case ft.HLS:return[y.HLS,y.HLS_ONDEMAND,...Ri(s),y.DASH_SEP,y.DASH,y.DASH_ONDEMAND,y.MPEG];case ft.DASH:return[...Ri(s),y.DASH_SEP,y.DASH,y.DASH_ONDEMAND,y.HLS,y.HLS_ONDEMAND,y.MPEG]}return Ui?[...Ri(s),y.DASH_SEP,y.DASH_ONDEMAND,y.HLS,y.HLS_ONDEMAND,y.MPEG,y.DASH]:[...Ri(s),y.DASH_SEP,y.DASH,y.DASH_ONDEMAND,y.HLS,y.HLS_ONDEMAND,y.MPEG]},gT=({androidPreferredFormat:s,preferCMAF:e,preferWebRTC:t})=>{const i=e?[y.DASH_LIVE_CMAF,y.DASH_LIVE]:[y.DASH_LIVE,y.DASH_LIVE_CMAF],r=e?[y.HLS_LIVE_CMAF,y.HLS_LIVE]:[y.HLS_LIVE,y.HLS_LIVE_CMAF],a=[...i,...r],n=[...r,...i];let o;if(tl)switch(s){case ft.DASH:{o=a;break}case ft.HLS:case ft.MPEG:{o=n;break}}else Ui?o=n:o=a;return t?[y.WEB_RTC_LIVE,...o]:[...o,y.WEB_RTC_LIVE]},cd=s=>s?[y.HLS_LIVE,y.HLS_LIVE_CMAF,y.DASH_LIVE_CMAF]:[y.DASH_WEBM,y.DASH_WEBM_AV1,y.DASH_SEP,y.DASH_ONDEMAND,y.HLS,y.HLS_ONDEMAND,y.MPEG];var ST=s=>new Hs(e=>{const t=new ae,i=s.desiredPlaybackState$.stateChangeStarted$.pipe(w(({from:d,to:l})=>`${d}-${l}`)),r=s.desiredPlaybackState$.stateChangeEnded$,a=s.providerChanged$.pipe(w(({type:d})=>d!==void 0)),n=new x;let o=0,u="unknown";return t.add(i.subscribe(d=>{o&&window.clearTimeout(o),u=d,o=window.setTimeout(()=>n.next(d),s.maxTransitionInterval)})),t.add(r.subscribe(()=>{window.clearTimeout(o),u="unknown",o=0})),t.add(a.subscribe(d=>{o&&(window.clearTimeout(o),o=0,d&&(o=window.setTimeout(()=>n.next(u),s.maxTransitionInterval)))})),t.add(n.subscribe(e)),()=>{window.clearTimeout(o),t.unsubscribe()}});const bT={cacheDuration:12e4},yT={chunkDuration:5e3,maxParallelRequests:5};class TT{constructor(e){this.current$=new S({type:void 0}),this.providerError$=new x,this.noAvailableProvidersError$=new x,this.providerOutput={position$:new S(0),duration$:new S(1/0),volume$:new S({muted:!1,volume:1}),currentVideoTrack$:new S(void 0),availableVideoTracks$:new S([]),availableAudioTracks$:new S([]),isAudioAvailable$:new S(!0),autoVideoTrackLimitingAvailable$:new S(!1),autoVideoTrackLimits$:new S(void 0),currentBuffer$:new S(void 0),isBuffering$:new S(!0),error$:new x,warning$:new x,willSeekEvent$:new x,seekedEvent$:new x,loopedEvent$:new x,endedEvent$:new x,firstBytesEvent$:new x,firstFrameEvent$:new x,canplay$:new x,isLive$:new S(void 0),isLowLatency$:new S(!1),canChangePlaybackSpeed$:new S(!0),liveTime$:new S(void 0),liveBufferTime$:new S(void 0),availableTextTracks$:new S([]),currentTextTrack$:new S(void 0),hostname$:new S(void 0),httpConnectionType$:new S(void 0),httpConnectionReused$:new S(void 0),inPiP$:new S(!1),inFullscreen$:new S(!1),element$:new S(void 0),availableSources$:new S(void 0),is3DVideo$:new S(!1)},this.subscription=new ae,this.params=e,this.log=this.params.dependencies.logger.createComponentLog("ProviderContainer");const t=vT([...gT(this.params.tuning),...mT(this.params.tuning)],this.params.tuning.useHlsJs).filter(o=>k(e.sources[o])),{forceFormat:i,formatsToAvoid:r}=this.params.tuning;let a=[];i?a=[i]:r.length?a=[...t.filter(o=>!r.includes(o)),...t.filter(o=>r.includes(o))]:a=t,this.log({message:`Selected formats: ${a.join(" > ")}`}),this.screenFormatsIterator=new ld(a);const n=[...cd(!0),...cd(!1)];this.chromecastFormatsIterator=new ld(n.filter(o=>k(e.sources[o]))),this.providerOutput.availableSources$.next(e.sources)}init(){this.subscription.add(this.initProviderErrorHandling()),this.subscription.add(this.params.dependencies.chromecastInitializer.connection$.subscribe(()=>{this.reinitProvider()}))}destroy(){this.destroyProvider(),this.current$.next({type:void 0}),this.subscription.unsubscribe()}initProvider(){const e=this.chooseDestination(),t=this.chooseFormat(e);if(ie(t)){this.handleNoFormatsError(e);return}let i;try{i=this.createProvider(e,t)}catch(r){this.providerError$.next({id:"ProviderNotConstructed",category:L.WTF,message:"Failed to create provider",thrown:r})}i?this.current$.next({type:t,provider:i,destination:e}):this.current$.next({type:void 0})}reinitProvider(){this.destroyProvider(),this.initProvider()}switchToNextProvider(e){this.destroyProvider(),this.failoverIndex=void 0,this.skipFormat(e),this.initProvider()}destroyProvider(){const e=this.current$.getValue().provider;if(!e)return;this.log({message:"destroyProvider"});const t=this.providerOutput.position$.getValue()*1e3,i=this.params.desiredState.seekState.getState(),r=i.state!==W.None;if(this.params.desiredState.seekState.setState({state:W.Requested,position:r?i.position:t,forcePrecise:r?i.forcePrecise:!1}),e.scene3D){const n=e.scene3D.getCameraRotation();this.params.desiredState.cameraOrientation.setState({x:n.x,y:n.y})}e.destroy();const a=this.providerOutput.isBuffering$;a.getValue()||a.next(!0)}createProvider(e,t){switch(this.log({message:`createProvider: ${e}:${t}`}),e){case we.SCREEN:return this.createScreenProvider(t);case we.CHROMECAST:return this.createChromecastProvider(t);default:return H(e)}}createScreenProvider(e){const{sources:t,container:i,desiredState:r}=this.params,a=this.providerOutput,n={container:i,source:null,desiredState:r,output:a,dependencies:this.params.dependencies,tuning:this.params.tuning};switch(e){case y.DASH:{const o=this.applyFailoverHost(t[e]);return P(o),new gb(Object.assign(Object.assign({},n),{source:o,config:bT}))}case y.DASH_SEP:case y.DASH_WEBM:case y.DASH_WEBM_AV1:case y.DASH_ONDEMAND:{const o=this.applyFailoverHost(t[e]);return P(o),this.params.tuning.useDashJs?new qo(Object.assign(Object.assign({},n),{source:o,format:e,config:{maxPausedTime:this.params.tuning.live.maxPausedTime}})):new Xy(Object.assign(Object.assign({},n),{source:o}))}case y.DASH_LIVE_CMAF:{const o=this.applyFailoverHost(t[e]);return P(o),this.params.tuning.useDashJsCMAF?new qo(Object.assign(Object.assign({},n),{source:o,format:e,config:{maxPausedTime:this.params.tuning.live.maxPausedTime}})):new Zy(Object.assign(Object.assign({},n),{source:o}))}case y.HLS:case y.HLS_ONDEMAND:{const o=this.applyFailoverHost(t[e]);return P(o),Ui||!this.params.tuning.useHlsJs?new sT(Object.assign(Object.assign({},n),{source:o})):new eT(Object.assign(Object.assign({},n),{source:o}))}case y.HLS_LIVE:case y.HLS_LIVE_CMAF:{const o=this.applyFailoverHost(t[e]);return P(o),new iT(Object.assign(Object.assign({},n),{source:o,config:{maxPausedTime:this.params.tuning.live.maxPausedTime},format:e}))}case y.MPEG:{const o=this.applyFailoverHost(t[e]);return P(o),new rT(Object.assign(Object.assign({},n),{source:o}))}case y.DASH_LIVE:{const o=this.applyFailoverHost(t[e]);return P(o),new hb(Object.assign(Object.assign({},n),{source:o,config:Object.assign(Object.assign({},yT),{maxPausedTime:this.params.tuning.live.maxPausedTime})}))}case y.WEB_RTC_LIVE:{const o=this.applyFailoverHost(t[e]);return P(o),new dT({container:i,source:o,desiredState:r,output:a,dependencies:this.params.dependencies,tuning:this.params.tuning})}case y.DASH_LIVE_WEBM:throw new Error("DASH_LIVE_WEBM is no longer supported");default:return H(e)}}createChromecastProvider(e){const{sources:t,container:i,desiredState:r,meta:a}=this.params,n=this.providerOutput,o=this.params.dependencies.chromecastInitializer.connection$.getValue();return P(o),new $S({connection:o,meta:a,container:i,source:t,format:e,desiredState:r,output:n,dependencies:this.params.dependencies,tuning:this.params.tuning})}chooseDestination(){return this.params.dependencies.chromecastInitializer.connection$.getValue()?we.CHROMECAST:we.SCREEN}chooseFormat(e){switch(e){case we.SCREEN:return this.screenFormatsIterator.isCompleted()?void 0:this.screenFormatsIterator.getValue();case we.CHROMECAST:return this.chromecastFormatsIterator.isCompleted()?void 0:this.chromecastFormatsIterator.getValue();default:return H(e)}}skipFormat(e){switch(e){case we.SCREEN:return this.screenFormatsIterator.next();case we.CHROMECAST:return this.chromecastFormatsIterator.next();default:return H(e)}}handleNoFormatsError(e){switch(e){case we.SCREEN:this.noAvailableProvidersError$.next(this.params.tuning.forceFormat),this.current$.next({type:void 0});return;case we.CHROMECAST:this.params.dependencies.chromecastInitializer.disconnect();return;default:return H(e)}}applyFailoverHost(e){if(this.failoverIndex===void 0)return e;const t=this.params.failoverHosts[this.failoverIndex];if(!t)return e;const i=r=>{const a=new URL(r);return a.host=t,a.toString()};if(e===void 0)return e;if("type"in e){if(e.type==="raw")return e;if(e.type==="url")return Object.assign(Object.assign({},e),{url:i(e.url)})}return li(Object.entries(e).map(([r,a])=>[r,i(a)]))}initProviderErrorHandling(){const e=new ae;let t=!1,i=0;return e.add(V(this.providerOutput.error$,ST({desiredPlaybackState$:this.params.desiredState.playbackState,maxTransitionInterval:this.params.tuning.maxPlaybackTransitionInterval,position$:this.providerOutput.position$,providerChanged$:this.current$}).pipe(w(r=>({id:`ProviderHangup:${r}`,category:L.WTF,message:`A ${r} transition failed to complete within reasonable time`})))).subscribe(this.providerError$)),e.add(this.current$.subscribe(()=>{t=!1;const r=this.params.desiredState.playbackState.transitionEnded$.pipe(re(({to:a})=>a===p.PLAYING),ge()).subscribe(()=>t=!0);e.add(r)})),e.add(this.providerError$.subscribe(r=>{const a=this.current$.getValue().destination;if(a===we.CHROMECAST)this.destroyProvider(),this.params.dependencies.chromecastInitializer.stopMedia().then(()=>this.switchToNextProvider(we.SCREEN),()=>this.params.dependencies.chromecastInitializer.disconnect());else{const n=r.category===L.NETWORK,o=this.params.failoverHosts.length>0&&(this.failoverIndex===void 0||this.failoverIndex<this.params.failoverHosts.length-1),u=i<this.params.tuning.providerErrorLimit;o&&(n&&t||!u)?(this.failoverIndex=this.failoverIndex===void 0?0:this.failoverIndex+1,this.reinitProvider()):u?(i++,this.reinitProvider()):this.switchToNextProvider(a!=null?a:we.SCREEN)}})),e}}const Fa=(s,e,t)=>t*e+(1-t)*s,rl=(s,e)=>s.reduce((t,i)=>t+i,0)/e,ET=(s,e,t,i)=>{let r=0,a=t;const n=rl(s,e),o=e<i?e:i;for(let u=0;u<o;u++)s[a]>n?r++:r--,a=(s.length+a-1)%s.length;return Math.abs(r)===o};class al{constructor(e){var t;this.prevReported=void 0,this.pastMeasures=[],this.takenMeasures=0,this.measuresCursor=0,this.params=e,this.pastMeasures=Array(e.deviationDepth),this.smoothed=this.prevReported=e.initial,this.smoothed$=new S(e.initial),this.debounced$=new S(e.initial);const i=(t=e.label)!==null&&t!==void 0?t:"value"+Math.random().toString(16).substring(2,6);this.rawSeries$=new rt(`raw_${i}`),this.smoothedSeries$=new rt(`smoothed_${i}`),this.reportedSeries$=new rt(`reported_${i}`),this.rawSeries$.next(e.initial),this.smoothedSeries$.next(e.initial),this.reportedSeries$.next(e.initial)}next(e){let t=0,i=0;for(let o=0;o<this.pastMeasures.length;o++)this.pastMeasures[o]!==void 0&&(t+=Math.pow(this.pastMeasures[o]-this.smoothed,2),i++);this.takenMeasures=i,t/=i;const r=Math.sqrt(t),a=this.smoothed+this.params.deviationFactor*r,n=this.smoothed-this.params.deviationFactor*r;this.pastMeasures[this.measuresCursor]=e,this.measuresCursor=(this.measuresCursor+1)%this.pastMeasures.length,this.rawSeries$.next(e),this.updateSmoothedValue(e),this.smoothed$.next(this.smoothed),this.smoothedSeries$.next(this.smoothed),!(this.smoothed>a||this.smoothed<n)&&(ie(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))}}class $T extends al{constructor(e){super(e),this.slow=this.fast=e.initial}updateSmoothedValue(e){this.slow=Fa(this.slow,e,this.params.emaAlphaSlow),this.fast=Fa(this.fast,e,this.params.emaAlphaFast);const t=this.params.fastDirection>0?Math.max:Math.min;this.smoothed=t(this.slow,this.fast)}}class AT extends al{constructor(e){super(e),this.emaSmoothed=e.initial}updateSmoothedValue(e){const t=rl(this.pastMeasures,this.takenMeasures);this.emaSmoothed=Fa(this.emaSmoothed,e,this.params.emaAlpha);const i=ET(this.pastMeasures,this.takenMeasures,this.measuresCursor-1,this.params.basisTrendChangeCount);this.smoothed=i?this.emaSmoothed:t}}class hd{static getSmoothedValue(e,t,i){return i.type==="TwoEma"?new $T({initial:e,emaAlphaSlow:i.emaAlphaSlow,emaAlphaFast:i.emaAlphaFast,changeThreshold:i.changeThreshold,fastDirection:t,deviationDepth:i.deviationDepth,deviationFactor:i.deviationFactor,label:"throughput"}):new AT({initial:e,emaAlpha:i.emaAlpha,basisTrendChangeCount:i.basisTrendChangeCount,changeThreshold:i.changeThreshold,deviationDepth:i.deviationDepth,deviationFactor:i.deviationFactor,label:"throughput"})}}const _T=5e3,fd="one_video_throughput",pd="one_video_rtt",pt=window.navigator.connection,vd=()=>{const s=pt==null?void 0:pt.downlink;if(k(s)&&s!==10)return s*1e3},md=()=>{const s=pt==null?void 0:pt.rtt;if(k(s)&&s!==3e3)return s},gd=(s,e,t)=>{const i=t*8,r=i/s;return i/(r+e)};class Li{constructor(e){var t,i;this.subscription=new ae,this.concurrentDownloads=new Set,this.tuningConfig=e;const r=Li.load(fd)||(e.useBrowserEstimation?vd():void 0)||_T,a=(i=(t=Li.load(pd))!==null&&t!==void 0?t:e.useBrowserEstimation?md():void 0)!==null&&i!==void 0?i:0;if(this.throughput$=new S(r),this.rtt$=new S(a),this.rttAdjustedThroughput$=new S(gd(r,a,e.rttPenaltyRequestSize)),this.throughput=hd.getSmoothedValue(r,-1,e),this.rtt=hd.getSmoothedValue(a,1,e),e.useBrowserEstimation){const n=()=>{const u=vd();u&&this.throughput.next(u);const d=md();k(d)&&this.rtt.next(d)};pt&&"onchange"in pt&&this.subscription.add(B(pt,"change").subscribe(n)),n()}this.subscription.add(this.throughput.smoothed$.subscribe(n=>{vr.set(fd,n.toFixed(0))})),this.subscription.add(this.rtt.smoothed$.subscribe(n=>{vr.set(pd,n.toFixed(0))})),this.subscription.add(this.throughput.debounced$.subscribe(this.throughput$)),this.subscription.add(this.rtt.debounced$.subscribe(this.rtt$)),this.subscription.add(Ne({throughput:this.throughput.smoothed$,rtt:this.rtt.smoothed$}).pipe(w(({throughput:n,rtt:o})=>gd(n,o,e.rttPenaltyRequestSize)),re(n=>{const o=this.rttAdjustedThroughput$.getValue()||0;return Math.abs(n-o)/o>=e.changeThreshold})).subscribe(this.rttAdjustedThroughput$))}destroy(){this.concurrentDownloads.clear(),this.subscription.unsubscribe()}trackXHR(e){let t=0,i=me();const r=new ae;switch(this.subscription.add(r),this.concurrentDownloads.add(e),e.readyState){case 4:break;case 3:case 2:r.add(B(e,"progress").pipe(ge()).subscribe(a=>{t=a.loaded,i=me()}));break;case 1:case 0:r.add(B(e,"loadstart").subscribe(()=>{t=0,i=me()}));break}r.add(B(e,"loadend").subscribe(a=>{if(e.status===200){const n=a.loaded,o=me(),u=n-t,d=o-i;this.addRawSpeed(u,d,1)}this.concurrentDownloads.delete(e),r.unsubscribe()}))}trackStream(e){const t=e.getReader();if(!t){e.cancel("Could not get reader");return}let i=0;const r=me();let a=0,n=me();const o=d=>{this.concurrentDownloads.delete(e),t.releaseLock(),e.cancel(`Throughput Estimator error: ${d}`).catch(()=>{})},u=({done:d,value:l})=>ue(this,void 0,void 0,function*(){d?(this.addRawSpeed(i,me()-r,1),this.concurrentDownloads.delete(e)):l&&(i+=l.byteLength,a+=l.byteLength,a>=this.tuningConfig.streamMinSampleSize&&me()-n>=this.tuningConfig.streamMinSampleTime&&(this.addRawSpeed(a,me()-n,this.concurrentDownloads.size),a=0,n=me()),yield t==null?void 0:t.read().then(u,o))});this.concurrentDownloads.add(e),t==null||t.read().then(u,o)}addRawSpeed(e,t,i=1){if(Li.sanityCheck(e,t)){const r=e*8/t;this.throughput.next(r*i)}}addRawThroughput(e){this.throughput.next(e)}addRawRtt(e){this.rtt.next(e)}static sanityCheck(e,t){const i=e*8/t;return!(!i||!isFinite(i)||i>1e6||i<30||e<10*1024||t<=20)}static load(e){var t;const i=vr.get(e);if(k(i))return(t=parseInt(i,10))!==null&&t!==void 0?t:void 0}}const Sd={configName:["core"],throughputEstimator:{type:"EmaAndMa",emaAlphaSlow:.2,emaAlphaFast:.7,emaAlpha:.45,basisTrendChangeCount:10,changeThreshold:.05,useBrowserEstimation:!0,rttPenaltyRequestSize:1*1024*1024,streamMinSampleSize:10*1024,streamMinSampleTime:300,deviationDepth:20,deviationFactor:.5},autoTrackSelection:{bitrateFactorAtEmptyBuffer:1.8,bitrateFactorAtFullBuffer:1.2,usePixelRatio:!0,limitByContainer:!0,containerSizeFactor:2,lazyQualitySwitch:!0,minBufferToSwitchUp:.4,considerPlaybackRate:!1,trackCooldown:3e3},droppedFramesChecker:{enabled:!1,percentLimit:.1,checkTime:1e3,countLimit:3,tickCountAfterQualityChange:5,qualityUpWaitingTime:5e3,minQualityBanLimit:He.Q_480P},dash:{forwardBufferTarget:6e4,forwardBufferTargetAuto:6e4,forwardBufferTargetManual:5*6e4,forwardBufferTargetPreload:5e3,minSafeBufferThreshold:.5,bufferPruningSafeZone:1e3,segmentRequestSize:1*1024*1024,representationSwitchForwardBufferGap:3e3,enableSubSegmentBufferFeeding:!0,segmentTimelineTolerance:100,useFetchPriorityHints:!0},live:{minBuffer:3e3,minBufferSegments:3,lowLatencyMinBuffer:1e3,lowLatencyMinBufferSegments:1,isLiveCatchUpMode:!1,lowLatencyActiveLiveDelay:3e3,activeLiveDelay:5e3,maxPausedTime:5e3},downloadBackoff:{bufferThreshold:100,start:100,factor:2,max:3*1e3,random:.1},enableWakeLock:!0,enableTelemetryAtStart:!1,forceFormat:void 0,formatsToAvoid:[],disableChromecast:!1,chromecastReceiverId:void 0,useWebmBigRequest:!1,webmCodec:_t.VP9,androidPreferredFormat:ft.MPEG,preferCMAF:!1,preferWebRTC:!1,bigRequestMinInitSize:50*1024,bigRequestMinDataSize:1*1024*1024,stripRangeHeader:!0,flushShortLoopedBuffers:!0,insufficientBufferRuleMargin:1e4,dashSeekInSegmentDurationThreshold:3*60*1e3,dashSeekInSegmentAlwaysSeekDelta:1e4,endGapTolerance:300,stallIgnoreThreshold:33,gapWatchdogInterval:50,requestQuick:!1,useDashJs:!1,useDashJsCMAF:!0,useHlsJs:!0,useDashAbortPartiallyFedSegment:!1,useNativeHLSTextTracks:!1,isAudioDisabled:!1,autoplayOnlyInActiveTab:!0,dynamicImportTimeout:5e3,maxPlaybackTransitionInterval:2e4,providerErrorLimit:3,webrtc:{connectionRetryMaxNumber:3},spherical:{enabled:!1,fov:{x:135,y:76},rotationSpeed:45,maxYawAngle:175,rotationSpeedCorrection:10,degreeToPixelCorrection:5,speedFadeTime:2e3,speedFadeThreshold:50}},wT=s=>{var e;return Object.assign(Object.assign({},wl(s,Sd)),{configName:[...(e=s.configName)!==null&&e!==void 0?e:[],...Sd.configName]})};var bd=({seekState:s,position$:e})=>V(s.stateChangeEnded$.pipe(w(({to:t})=>{var i;return t.state===W.None?void 0:((i=t.position)!==null&&i!==void 0?i:NaN)/1e3}),re(k)),e.pipe(re(()=>s.getState().state===W.None))),kT=s=>{const e=typeof s.container=="string"?document.getElementById(s.container):s.container;return P(e,`Wrong container or containerId {${s.container}}`),e};class xT{constructor(e={configName:[]}){if(this.subscription=new ae,this.logger=new kl,this.abrLogger=this.logger.createComponentLog("ABR"),this.isPlaybackStarted=!1,this.desiredState={playbackState:new ce(p.STOPPED),seekState:new ce({state:W.None}),volume:new ce({volume:1,muted:!1}),videoTrack:new ce(void 0),autoVideoTrackSwitching:new ce(!0),autoVideoTrackLimits:new ce({}),isLooped:new ce(!1),playbackRate:new ce(1),externalTextTracks:new ce([]),internalTextTracks:new ce([]),currentTextTrack:new ce(void 0),textTrackCuesSettings:new ce({}),cameraOrientation:new ce({x:0,y:0})},this.info={playbackState$:new S(p.STOPPED),position$:new S(0),duration$:new S(1/0),muted$:new S(!1),volume$:new S(1),availableQualities$:new S([]),availableQualitiesFps$:new S({}),availableAudioTracks$:new S([]),isAudioAvailable$:new S(!0),currentQuality$:new S(void 0),isAutoQualityEnabled$:new S(!0),autoQualityLimitingAvailable$:new S(!1),autoQualityLimits$:new S({}),currentPlaybackRate$:new S(1),currentBuffer$:new S({start:0,end:0}),isBuffering$:new S(!0),isStalled$:new S(!1),isEnded$:new S(!1),isLooped$:new S(!1),isLive$:new S(void 0),canChangePlaybackSpeed$:new S(void 0),atLiveEdge$:new S(void 0),atLiveDurationEdge$:new S(void 0),liveTime$:new S(void 0),liveBufferTime$:new S(void 0),currentFormat$:new S(void 0),availableTextTracks$:new S([]),currentTextTrack$:new S(void 0),throughputEstimation$:new S(void 0),rttEstimation$:new S(void 0),videoBitrate$:new S(void 0),hostname$:new S(void 0),httpConnectionType$:new S(void 0),httpConnectionReused$:new S(void 0),surface$:new S(At.NONE),chromecastState$:new S($e.NOT_AVAILABLE),chromecastDeviceName$:new S(void 0),intrinsicVideoSize$:new S(void 0),availableSources$:new S(void 0),is3DVideo$:new S(!1)},this.events={inited$:new x,ready$:new x,started$:new x,playing$:new x,paused$:new x,stopped$:new x,willStart$:new x,willResume$:new x,willPause$:new x,willStop$:new x,willDestruct$:new x,watchCoverageRecord$:new x,watchCoverageLive$:new x,managedError$:new x,fatalError$:new x,ended$:new x,looped$:new x,seeked$:new x,willSeek$:new x,firstBytes$:new x,firstFrame$:new x,canplay$:new x,log$:new x},this.experimental={element$:new S(void 0),tuningConfigName$:new S([]),enableDebugTelemetry$:new S(!1),dumpTelemetry:qS},this.initLogs(),this.tuning=wT(e),this.experimental.tuningConfigName$.next(this.tuning.configName),this.chromecastInitializer=new Il({receiverApplicationId:e.chromecastReceiverId,isDisabled:e.disableChromecast,dependencies:{logger:this.logger}}),this.throughputEstimator=new Li(this.tuning.throughputEstimator),this.initChromecastSubscription(),this.initDesiredStateSubscriptions(),Proxy&&Reflect)return new Proxy(this,{get:(t,i,r)=>{const a=Reflect.get(t,i,r);return typeof a!="function"?a:(...n)=>{try{return a.apply(t,n)}catch(o){const u=n.map(c=>JSON.stringify(c,(h,f)=>{const v=typeof f;return["number","string","boolean"].includes(v)?f:f===null?null:`<${v}>`})),d=`Player.${String(i)}`,l=`Exception calling ${d} (${u.join(", ")})`;throw this.events.fatalError$.next({id:d,category:L.WTF,message:l,thrown:o}),o}}}})}initVideo(e){var t,i,r;return this.config=e,this.domContainer=kT(e),this.chromecastInitializer.contentId=(t=e.meta)===null||t===void 0?void 0:t.videoId,this.providerContainer=new TT({sources:e.sources,meta:(i=e.meta)!==null&&i!==void 0?i:{},failoverHosts:(r=e.failoverHosts)!==null&&r!==void 0?r:[],container:this.domContainer,desiredState:this.desiredState,dependencies:{throughputEstimator:this.throughputEstimator,chromecastInitializer:this.chromecastInitializer,logger:this.logger,abrLogger:this.abrLogger},tuning:this.tuning}),this.initProviderContainerSubscription(this.providerContainer),this.initStartingVideoTrack(this.providerContainer),this.providerContainer.init(),this.setMuted(this.tuning.isAudioDisabled),this.initDebugTelemetry(),this.initWakeLock(),this}destroy(){var e;this.events.willDestruct$.next(),this.stop(),(e=this.providerContainer)===null||e===void 0||e.destroy(),this.throughputEstimator.destroy(),this.chromecastInitializer.destroy(),this.subscription.unsubscribe()}prepare(){const e=this.desiredState.playbackState;return e.getState()===p.STOPPED&&e.startTransitionTo(p.READY),this}play(){const e=()=>{const t=this.desiredState.playbackState;t.getState()!==p.PLAYING&&t.startTransitionTo(p.PLAYING)};return document.hidden&&this.tuning.autoplayOnlyInActiveTab?B(document,"visibilitychange").pipe(ge()).subscribe(e):e(),this}pause(){const e=this.desiredState.playbackState;return e.getState()!==p.PAUSED&&e.startTransitionTo(p.PAUSED),this}stop(){const e=this.desiredState.playbackState;return e.getState()!==p.STOPPED&&e.startTransitionTo(p.STOPPED),this}seekTime(e,t=!0){const i=this.info.duration$.getValue(),r=this.info.isLive$.getValue();return e>=i&&!r&&(e=i-.1),this.events.willSeek$.next({from:this.getExactTime(),to:e}),this.desiredState.seekState.setState({state:W.Requested,position:e*1e3,forcePrecise:t}),this}seekPercent(e){const t=this.info.duration$.getValue();return isFinite(t)&&this.seekTime(Math.abs(t)*e,!1),this}setVolume(e){const t=this.tuning.isAudioDisabled||this.desiredState.volume.getState().muted;return this.chromecastInitializer.castState$.getValue()===$e.CONNECTED?this.chromecastInitializer.setVolume(e):this.desiredState.volume.startTransitionTo({volume:e,muted:t}),this}setMuted(e){const t=this.tuning.isAudioDisabled||e;return this.chromecastInitializer.castState$.getValue()===$e.CONNECTED?this.chromecastInitializer.setMuted(t):this.desiredState.volume.startTransitionTo({volume:this.desiredState.volume.getState().volume,muted:t}),this}setQuality(e){P(this.providerContainer);const t=this.providerContainer.providerOutput.availableVideoTracks$.getValue();t.length||(this.explicitInitialQuality=e);const i=t.find(r=>r.quality===e);return i&&this.desiredState.videoTrack.startTransitionTo(i.id),this}setAutoQuality(e){return this.desiredState.autoVideoTrackSwitching.startTransitionTo(e),this}setAutoQualityLimits(e){return this.desiredState.autoVideoTrackLimits.startTransitionTo(e),this}setPlaybackRate(e){var t;P(this.providerContainer);const i=(t=this.providerContainer)===null||t===void 0?void 0:t.providerOutput.element$.getValue();return i&&(this.desiredState.playbackRate.setState(e),i.playbackRate=e),this}setExternalTextTracks(e){return this.desiredState.externalTextTracks.startTransitionTo(e.map(t=>Object.assign({type:"external"},t))),this}selectTextTrack(e){var t,i,r;return e!==void 0&&this.desiredState.currentTextTrack.getState()===void 0&&this.desiredState.currentTextTrack.getPrevState()===void 0&&((t=this.providerContainer)===null||t===void 0?void 0:t.providerOutput.availableTextTracks$.getValue().length)===0?(i=this.providerContainer)===null||i===void 0||i.providerOutput.availableTextTracks$.pipe(re(a=>a.length>0),ge()).subscribe(a=>{a.find(n=>n.id===e)&&this.desiredState.currentTextTrack.startTransitionTo(e)}):(e===void 0||!((r=this.providerContainer)===null||r===void 0)&&r.providerOutput.availableTextTracks$.getValue().find(a=>a.id===e))&&this.desiredState.currentTextTrack.startTransitionTo(e),this}setTextTrackCueSettings(e){return this.desiredState.textTrackCuesSettings.startTransitionTo(e),this}setLooped(e){return this.desiredState.isLooped.startTransitionTo(e),this}toggleChromecast(){this.chromecastInitializer.toggleConnection()}startCameraManualRotation(e,t){const i=this.getScene3D();return i&&i.startCameraManualRotation(e,t),this}stopCameraManualRotation(e=!1){const t=this.getScene3D();return t&&t.stopCameraManualRotation(e),this}moveCameraFocusPX(e,t){const i=this.getScene3D();if(i){const r=i.getCameraRotation(),a=i.pixelToDegree({x:e,y:t});this.desiredState.cameraOrientation.setState({x:r.x+a.x,y:r.y+a.y})}return this}holdCamera(){const e=this.getScene3D();return e&&e.holdCamera(),this}releaseCamera(){const e=this.getScene3D();return e&&e.releaseCamera(),this}getExactTime(){P(this.providerContainer);const e=this.providerContainer.providerOutput.element$.getValue();if(ie(e))return this.info.position$.getValue();const t=this.desiredState.seekState.getState(),i=t.state===W.None?void 0:t.position;return k(i)?i/1e3:e.currentTime}getAllLogs(){return this.logger.getAllLogs()}getScene3D(){var e,t;const i=(e=this.providerContainer)===null||e===void 0?void 0:e.current$.getValue();if(!((t=i==null?void 0:i.provider)===null||t===void 0)&&t.scene3D)return i.provider.scene3D}setIntrinsicVideoSize(...e){const t={width:e.reduce((i,{width:r})=>i||r||0,0),height:e.reduce((i,{height:r})=>i||r||0,0)};t.width&&t.height&&this.info.intrinsicVideoSize$.next({width:t.width,height:t.height})}initDesiredStateSubscriptions(){this.subscription.add(V(this.desiredState.playbackState.stateChangeStarted$,this.desiredState.playbackState.forceChanged$).pipe(w(e=>e.to)).subscribe(this.info.playbackState$)).add(this.desiredState.isLooped.stateChangeEnded$.pipe(w(e=>e.to)).subscribe(this.info.isLooped$)).add(this.desiredState.playbackRate.stateChangeEnded$.pipe(w(e=>e.to)).subscribe(this.info.currentPlaybackRate$)).add(this.desiredState.autoVideoTrackSwitching.stateChangeEnded$.pipe(w(e=>e.to)).subscribe(this.info.isAutoQualityEnabled$)).add(this.desiredState.autoVideoTrackLimits.stateChangeEnded$.pipe(w(e=>e.to)).subscribe(this.info.autoQualityLimits$)),this.subscription.add(this.desiredState.playbackState.stateChangeStarted$.pipe(re(({from:e})=>e===p.STOPPED),ge()).subscribe(()=>{this.initedAt=me(),this.events.inited$.next()})).add(this.desiredState.playbackState.stateChangeEnded$.subscribe(e=>{switch(e.to){case p.READY:this.events.ready$.next();break;case p.PLAYING:this.isPlaybackStarted||this.events.started$.next(),this.isPlaybackStarted=!0,this.events.playing$.next();break;case p.PAUSED:this.events.paused$.next();break;case p.STOPPED:this.events.stopped$.next()}})).add(this.desiredState.playbackState.stateChangeStarted$.subscribe(e=>{switch(e.to){case p.PAUSED:this.events.willPause$.next();break;case p.PLAYING:this.isPlaybackStarted?this.events.willResume$.next():this.events.willStart$.next();break;case p.STOPPED:this.events.willStop$.next();break}}))}initProviderContainerSubscription(e){this.subscription.add(e.providerOutput.willSeekEvent$.subscribe(()=>{const n=this.desiredState.seekState.getState();n.state===W.Requested?this.desiredState.seekState.setState(Object.assign(Object.assign({},n),{state:W.Applying})):this.events.managedError$.next({id:`WillSeekIn${n.state}`,category:L.WTF,message:"Received unexpeceted willSeek$"})})).add(e.providerOutput.seekedEvent$.subscribe(()=>{this.desiredState.seekState.getState().state===W.Applying&&(this.desiredState.seekState.setState({state:W.None}),this.events.seeked$.next())})).add(e.current$.pipe(w(n=>n.type)).subscribe(this.info.currentFormat$)).add(e.current$.pipe(w(n=>n.destination),ve()).subscribe(()=>{this.isPlaybackStarted=!1})).add(e.providerOutput.availableVideoTracks$.pipe(w(n=>n.map(({quality:o})=>o).sort((o,u)=>Oi(o)?1:Oi(u)?-1:Ii(u,o)?1:-1))).subscribe(this.info.availableQualities$)).add(e.providerOutput.availableVideoTracks$.subscribe(n=>{const o={};for(const u of n)u.fps&&(o[u.quality]=u.fps);this.info.availableQualitiesFps$.next(o)})).add(e.providerOutput.availableAudioTracks$.subscribe(this.info.availableAudioTracks$)).add(e.providerOutput.isAudioAvailable$.subscribe(this.info.isAudioAvailable$)).add(e.providerOutput.currentVideoTrack$.subscribe(n=>{this.info.currentQuality$.next(n==null?void 0:n.quality),this.info.videoBitrate$.next(n==null?void 0:n.bitrate)})).add(e.providerOutput.hostname$.pipe(ve()).subscribe(this.info.hostname$)).add(e.providerOutput.httpConnectionType$.pipe(ve()).subscribe(this.info.httpConnectionType$)).add(e.providerOutput.httpConnectionReused$.pipe(ve()).subscribe(this.info.httpConnectionReused$)).add(e.providerOutput.currentTextTrack$.subscribe(this.info.currentTextTrack$)).add(e.providerOutput.availableTextTracks$.subscribe(this.info.availableTextTracks$)).add(e.providerOutput.autoVideoTrackLimitingAvailable$.subscribe(this.info.autoQualityLimitingAvailable$)).add(e.providerOutput.autoVideoTrackLimits$.subscribe(n=>{this.desiredState.autoVideoTrackLimits.setState(n!=null?n:{})})).add(e.providerOutput.currentBuffer$.pipe(w(n=>n?{start:n.from,end:n.to}:{start:0,end:0})).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.canChangePlaybackSpeed$.subscribe(this.info.canChangePlaybackSpeed$)).add(e.providerOutput.liveTime$.subscribe(this.info.liveTime$)).add(e.providerOutput.liveBufferTime$.subscribe(this.info.liveBufferTime$)).add(Ne({isLive:e.providerOutput.isLive$,isLowLatency:e.providerOutput.isLowLatency$,position:bd({seekState:this.desiredState.seekState,position$:e.providerOutput.position$})}).pipe(w(({isLive:n,position:o,isLowLatency:u})=>{const d=u?this.tuning.live.lowLatencyActiveLiveDelay:this.tuning.live.activeLiveDelay;return n&&Math.abs(o)<d/1e3}),ve(),Is(n=>n&&this.setPlaybackRate(1))).subscribe(this.info.atLiveEdge$)).add(Ne({isLive:e.providerOutput.isLive$,position:e.providerOutput.position$,duration:e.providerOutput.duration$}).pipe(w(({isLive:n,position:o,duration:u})=>n&&Math.abs(u)-Math.abs(o)<this.tuning.live.activeLiveDelay),ve(),Is(n=>n&&this.setPlaybackRate(1))).subscribe(this.info.atLiveDurationEdge$)).add(e.providerOutput.volume$.pipe(w(n=>n.muted),ve()).subscribe(this.info.muted$)).add(e.providerOutput.volume$.pipe(w(n=>n.volume),ve()).subscribe(this.info.volume$)).add(bd({seekState:this.desiredState.seekState,position$:e.providerOutput.position$}).subscribe(this.info.position$)).add(V(e.providerOutput.endedEvent$.pipe(ui(!0)),e.providerOutput.seekedEvent$.pipe(ui(!1))).pipe(ve()).subscribe(this.info.isEnded$)).add(e.providerOutput.endedEvent$.subscribe(this.events.ended$)).add(e.providerOutput.loopedEvent$.subscribe(this.events.looped$)).add(e.providerError$.subscribe(this.events.managedError$)).add(e.noAvailableProvidersError$.pipe(w(n=>({id:n?`No${n}`:"NoProviders",category:L.VIDEO_PIPELINE,message:n?`${n} was forced but failed or not available`:"No suitable providers or all providers failed"}))).subscribe(this.events.fatalError$)).add(e.providerOutput.element$.subscribe(this.experimental.element$)).add(e.providerOutput.firstBytesEvent$.pipe(ge(),w(n=>n!=null?n:me()-this.initedAt)).subscribe(this.events.firstBytes$)).add(e.providerOutput.firstFrameEvent$.pipe(ge(),w(()=>me()-this.initedAt)).subscribe(this.events.firstFrame$)).add(e.providerOutput.canplay$.pipe(ge(),w(()=>me()-this.initedAt)).subscribe(this.events.canplay$)).add(this.throughputEstimator.throughput$.subscribe(this.info.throughputEstimation$)).add(this.throughputEstimator.rtt$.subscribe(this.info.rttEstimation$)).add(e.providerOutput.availableSources$.subscribe(this.info.availableSources$));const t=new S(!1);this.subscription.add(e.providerOutput.seekedEvent$.subscribe(()=>t.next(!1))).add(e.providerOutput.willSeekEvent$.subscribe(()=>t.next(!0)));const i=new S(!0);this.subscription.add(e.current$.subscribe(()=>i.next(!0))).add(this.desiredState.playbackState.stateChangeEnded$.pipe(re(({to:n})=>n===p.PLAYING),ge()).subscribe(()=>i.next(!1)));let r=0;const a=V(e.providerOutput.isBuffering$,t,i).pipe(w(()=>{const n=e.providerOutput.isBuffering$.getValue(),o=t.getValue()||i.getValue();return n&&!o}),ve());this.subscription.add(a.subscribe(n=>{n?r=window.setTimeout(()=>this.info.isStalled$.next(!0),this.tuning.stallIgnoreThreshold):(window.clearTimeout(r),this.info.isStalled$.next(!1))})),this.subscription.add(V(e.providerOutput.canplay$,e.providerOutput.firstFrameEvent$,e.providerOutput.firstBytesEvent$).subscribe(()=>{const n=e.providerOutput.element$.getValue();this.setIntrinsicVideoSize({width:n==null?void 0:n.videoWidth,height:n==null?void 0:n.videoHeight})})).add(e.providerOutput.currentVideoTrack$.subscribe(n=>{var o,u;const d=e.providerOutput.element$.getValue();this.setIntrinsicVideoSize({width:(o=n==null?void 0:n.size)===null||o===void 0?void 0:o.width,height:(u=n==null?void 0:n.size)===null||u===void 0?void 0:u.height},{width:d==null?void 0:d.videoWidth,height:d==null?void 0:d.videoHeight})})).add(e.providerOutput.is3DVideo$.subscribe(this.info.is3DVideo$)),this.subscription.add(V(e.providerOutput.inPiP$,e.providerOutput.inFullscreen$,e.providerOutput.element$,this.chromecastInitializer.castState$).subscribe(()=>{const n=e.providerOutput.inPiP$.getValue(),o=e.providerOutput.inFullscreen$.getValue(),u=e.providerOutput.element$.getValue(),d=this.chromecastInitializer.castState$.getValue();let l;d===$e.CONNECTED?l=At.SECOND_SCREEN:u?n?l=At.PIP:o?l=At.FULLSCREEN:l=At.INLINE:l=At.NONE,this.info.surface$.getValue()!==l&&this.info.surface$.next(l)}))}initChromecastSubscription(){this.subscription.add(this.chromecastInitializer.castState$.subscribe(this.info.chromecastState$)),this.subscription.add(this.chromecastInitializer.connection$.pipe(w(e=>e==null?void 0:e.castDevice.friendlyName)).subscribe(this.info.chromecastDeviceName$)),this.subscription.add(this.chromecastInitializer.errorEvent$.subscribe(this.events.managedError$))}initStartingVideoTrack(e){const t=new ae;this.subscription.add(t),this.subscription.add(e.current$.pipe(ve((i,r)=>i.provider===r.provider)).subscribe(()=>{t.unsubscribe(),t.add(e.providerOutput.availableVideoTracks$.pipe(re(i=>i.length>0),ge()).subscribe(i=>{this.setStartingVideoTrack(i)}))}))}setStartingVideoTrack(e){let t;this.explicitInitialQuality&&(t=e.find(({quality:i})=>i===this.explicitInitialQuality),this.explicitInitialQuality=void 0),t||(t=gi(e,{container:this.domContainer.getBoundingClientRect(),throughput:this.throughputEstimator.throughput$.getValue(),tuning:this.tuning.autoTrackSelection,limits:this.desiredState.autoVideoTrackLimits.getState(),playbackRate:this.info.currentPlaybackRate$.getValue(),forwardBufferHealth:0,abrLogger:this.abrLogger})),this.desiredState.videoTrack.startTransitionTo(t.id),this.info.currentQuality$.next(t.quality),this.info.videoBitrate$.next(t.bitrate)}initLogs(){this.subscription.add(V(this.desiredState.videoTrack.stateChangeStarted$.pipe(w(e=>({transition:e,entity:"quality",type:"start"}))),this.desiredState.videoTrack.stateChangeEnded$.pipe(w(e=>({transition:e,entity:"quality",type:"end"}))),this.desiredState.autoVideoTrackSwitching.stateChangeStarted$.pipe(w(e=>({transition:e,entity:"autoQualityEnabled",type:"start"}))),this.desiredState.autoVideoTrackSwitching.stateChangeEnded$.pipe(w(e=>({transition:e,entity:"autoQualityEnabled",type:"end"}))),this.desiredState.seekState.stateChangeStarted$.pipe(w(e=>({transition:e,entity:"seekState",type:"start"}))),this.desiredState.seekState.stateChangeEnded$.pipe(w(e=>({transition:e,entity:"seekState",type:"end"}))),this.desiredState.playbackState.stateChangeStarted$.pipe(w(e=>({transition:e,entity:"playbackState",type:"start"}))),this.desiredState.playbackState.stateChangeEnded$.pipe(w(e=>({transition:e,entity:"playbackState",type:"end"})))).pipe(w(e=>({component:"desiredState",message:`[${e.entity} change] ${e.type}: ${JSON.stringify(e.transition)}`}))).subscribe(this.logger.log)),this.subscription.add(this.logger.log$.subscribe(this.events.log$))}initDebugTelemetry(){var e;const t=(e=this.providerContainer)===null||e===void 0?void 0:e.providerOutput;P(this.providerContainer),P(t),jS(),this.experimental.enableDebugTelemetry$.next(this.tuning.enableTelemetryAtStart),[this.experimental.enableDebugTelemetry$.subscribe(i=>YS(i)),this.providerContainer.current$.subscribe(({type:i})=>ms("provider",i)),t.duration$.subscribe(i=>ms("duration",i)),t.availableVideoTracks$.pipe(re(i=>!!i.length),ge()).subscribe(i=>ms("tracks",i)),this.events.fatalError$.subscribe(new rt("fatalError")),this.events.managedError$.subscribe(new rt("managedError")),t.position$.subscribe(new rt("position")),t.currentVideoTrack$.pipe(w(i=>i==null?void 0:i.quality)).subscribe(new rt("quality")),this.info.currentBuffer$.subscribe(new rt("buffer")),t.isBuffering$.subscribe(new rt("isBuffering"))].forEach(i=>this.subscription.add(i)),ms("codecs",pT())}initWakeLock(){if(!window.navigator.wakeLock||!this.tuning.enableWakeLock)return;let e;const t=()=>{e==null||e.release(),e=void 0},i=()=>ue(this,void 0,void 0,function*(){t(),e=yield window.navigator.wakeLock.request("screen").catch(r=>{r instanceof DOMException&&r.name==="NotAllowedError"||this.events.managedError$.next({id:"WakeLock",category:L.DOM,message:String(r)})})});this.subscription.add(V(B(document,"visibilitychange"),B(document,"fullscreenchange"),this.desiredState.playbackState.stateChangeEnded$).subscribe(()=>{const r=document.visibilityState==="visible",a=this.desiredState.playbackState.getState()===p.PLAYING,n=!!e&&!(e!=null&&e.released);r&&a?n||i():t()})).add(this.events.willDestruct$.subscribe(t))}}const LT=`@vkontakte/videoplayer-core@${Rl}`;export{$e as ChromecastState,Mi as HttpConnectionType,BT as Observable,p as PlaybackState,xT as Player,LT as SDK_VERSION,NT as Subject,FT as Subscription,At as Surface,Rl as VERSION,UT as ValueSubject,y as VideoFormat,VT as VideoQuality};
|
|
38
|
+
`),o=[],u=[];for(let d=0;d<n.length;d++){const l=n[d],c=l.match(/^#EXT-X-STREAM-INF:(.+)/),h=l.match(/^#EXT-X-MEDIA:TYPE=SUBTITLES,(.+)/);if(!(!c&&!h)){if(c){const f=li(c[1].split(",").map(b=>b.split("="))),v=(t=f.QUALITY)!==null&&t!==void 0?t:`stream-${f.BANDWIDTH}`,g=tT(f);let T;f.BANDWIDTH&&(T=parseInt(f.BANDWIDTH,10)/1e3||void 0),!T&&f["AVERAGE-BANDWIDTH"]&&(T=parseInt(f["AVERAGE-BANDWIDTH"],10)/1e3||void 0);const A=f["FRAME-RATE"]?parseFloat(f["FRAME-RATE"]):void 0;let E;if(f.RESOLUTION){const[b,$]=f.RESOLUTION.split("x").map(R=>parseInt(R,10));b&&$&&(E={width:b,height:$})}const m=new URL(n[++d],e).toString();g&&o.push({id:v,quality:g,url:m,bandwidth:T,size:E,fps:A})}if(h){const f=li(h[1].split(",").map(A=>A.split("=")).map(([A,E])=>[A,E.replace(/^"|"$/g,"")])),v=(i=f.URI)===null||i===void 0?void 0:i.replace(/playlist$/,"subtitles.vtt"),g=f.LANGUAGE,T=f.NAME;v&&g&&u.push({type:"internal",id:g,label:T,language:g,url:v,isAuto:!1})}}}return{qualityManifests:o,textTracks:u}});var oe;(function(s){s.STOPPED="stopped",s.READY="ready",s.PLAYING="playing",s.CHANGING_MANIFEST="changing_manifest",s.PAUSED="paused"})(oe||(oe={}));class iT{constructor(e){var t;this.subscription=new ae,this.videoState=new ce(oe.STOPPED),this.textTracksManager=new dt,this.manifests$=new S([]),this.liveOffset=new tr,this.manifestStartTime$=new S(void 0),this.syncPlayback=()=>{if(!this.manifests$.getValue().length)return;const a=this.videoState.getState(),n=this.params.desiredState.playbackState.getState(),o=this.params.desiredState.playbackState.getTransition(),u=this.params.desiredState.videoTrack.getTransition(),d=this.params.desiredState.autoVideoTrackSwitching.getTransition();if(n===p.STOPPED){a!==oe.STOPPED&&(this.videoState.startTransitionTo(oe.STOPPED),this.video.removeAttribute("src"),this.video.load(),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.videoState.setState(oe.STOPPED),D(this.params.desiredState.playbackState,p.STOPPED,!0));return}if(this.videoState.getTransition())return;const c=this.params.desiredState.seekState.getState();if(a===oe.STOPPED){this.videoState.startTransitionTo(oe.READY),this.prepare();return}if(u||d){const h=this.videoState.getState();this.videoState.setState(oe.CHANGING_MANIFEST),this.videoState.startTransitionTo(h),this.prepare(),c.state===W.None&&this.params.desiredState.seekState.setState({state:W.Requested,position:-this.liveOffset.getTotalOffset(),forcePrecise:!0});return}if((o==null?void 0:o.to)!==p.PAUSED&&c.state===W.Requested){this.videoState.startTransitionTo(oe.READY),this.seek(c.position-this.liveOffset.getTotalPausedTime()),this.prepare();return}switch(a){case oe.READY:n===p.READY?D(this.params.desiredState.playbackState,p.READY):n===p.PAUSED?(this.videoState.setState(oe.PAUSED),this.liveOffset.pause(),D(this.params.desiredState.playbackState,p.PAUSED)):n===p.PLAYING&&(this.videoState.startTransitionTo(oe.PLAYING),this.playIfAllowed());return;case oe.PLAYING:n===p.PAUSED?(this.videoState.startTransitionTo(oe.PAUSED),this.liveOffset.pause(),this.video.pause()):(o==null?void 0:o.to)===p.PLAYING&&D(this.params.desiredState.playbackState,p.PLAYING);return;case oe.PAUSED:if(n===p.PLAYING)if(this.videoState.startTransitionTo(oe.PLAYING),this.liveOffset.getTotalPausedTime()<this.params.config.maxPausedTime&&this.liveOffset.getTotalOffset()<this.maxSeekBackTime$.getValue())this.liveOffset.resume(),this.playIfAllowed(),this.params.output.position$.next(-this.liveOffset.getTotalOffset()/1e3);else{let h=this.liveOffset.getTotalOffset();h>=this.maxSeekBackTime$.getValue()&&(h=0,this.liveOffset.resetTo(h)),this.liveOffset.resume(),this.params.output.position$.next(-h/1e3),this.prepare()}else(o==null?void 0:o.to)===p.PAUSED&&(D(this.params.desiredState.playbackState,p.PAUSED),this.liveOffset.pause());return;case oe.CHANGING_MANIFEST:break;default:return H(a)}},this.params=e,this.video=St(e.container),this.params.output.element$.next(this.video);const i={id:"master",quality:He.INVARIANT,url:this.params.source.url};el(Je(this.params.source.url),this.params.source.url).then(({qualityManifests:r})=>{this.manifests$.next([i,...r])},r=>this.params.output.error$.next({id:"ExtractHlsQualities",category:L.NETWORK,message:"Error fetching manifest and extracting qualities",thrown:r})),this.params.output.isLive$.next(!0),this.params.output.canChangePlaybackSpeed$.next(!1),this.params.output.availableVideoTracks$.next([]),this.params.output.availableAudioTracks$.next([]),this.params.output.isAudioAvailable$.next(!0),this.params.output.hostname$.next(Ie(this.params.source.url)),this.maxSeekBackTime$=new S((t=e.source.maxSeekBackTime)!==null&&t!==void 0?t:1/0),this.subscribe()}selectManifest(){var e,t;const{autoVideoTrackSwitching:i,videoTrack:r}=this.params.desiredState,a=i.getState(),n=r.getTransition(),o=(t=(e=n==null?void 0:n.to)!==null&&e!==void 0?e:r.getState())!==null&&t!==void 0?t:"master",u=this.manifests$.getValue();if(!u.length)return;const d=a?"master":o;return a&&!n&&r.startTransitionTo("master"),u.find(l=>l.id===d)}subscribe(){const{output:e,desiredState:t}=this.params,i=o=>{e.error$.next({id:"HlsLiveProvider",category:L.WTF,message:"HlsLiveProvider internal logic error",thrown:o})},r=yt(this.video),a=(o,u)=>this.subscription.add(o.subscribe(u,i));a(r.ended$,e.endedEvent$),a(r.error$,e.error$),a(r.isBuffering$,e.isBuffering$),a(r.currentBuffer$,e.currentBuffer$),a(r.loadedMetadata$,e.firstBytesEvent$),a(r.playing$,e.firstFrameEvent$),a(r.canplay$,e.canplay$),a(r.inPiP$,e.inPiP$),a(r.inFullscreen$,e.inFullscreen$),this.subscription.add(t.isLooped.stateChangeStarted$.subscribe(()=>t.isLooped.setState(!1),i)),this.subscription.add(gt(this.video,t.volume,r.volumeState$,i)),this.subscription.add(r.volumeState$.subscribe(this.params.output.volume$,i)),this.subscription.add(Dt(this.video,t.playbackRate,r.playbackRateState$,i)),this.textTracksManager.connect(this.video,t,e),this.subscription.add(r.playing$.subscribe(()=>{this.videoState.setState(oe.PLAYING),D(t.playbackState,p.PLAYING)},i)).add(r.pause$.subscribe(()=>{this.videoState.setState(oe.PAUSED),D(t.playbackState,p.PAUSED)},i)).add(r.canplay$.subscribe(()=>{var o;((o=this.videoState.getTransition())===null||o===void 0?void 0:o.to)===oe.READY&&this.videoState.setState(oe.READY),this.videoState.getState()===oe.PLAYING&&this.playIfAllowed()},i)),this.subscription.add(this.maxSeekBackTime$.pipe(ve(),w(o=>-o/1e3)).subscribe(this.params.output.duration$,i)),this.subscription.add(r.loadedMetadata$.subscribe(()=>{const o=this.params.desiredState.seekState.getState(),u=this.videoState.getTransition(),d=this.params.desiredState.videoTrack.getTransition(),l=this.params.desiredState.autoVideoTrackSwitching.getTransition();if(d&&k(d.to)){const c=d.to;this.params.desiredState.videoTrack.setState(c);const h=this.manifests$.getValue().find(f=>f.id===c);h&&(this.params.output.currentVideoTrack$.next(h),this.params.output.hostname$.next(Ie(h.url)))}l&&this.params.desiredState.autoVideoTrackSwitching.setState(l.to),u&&u.from===oe.CHANGING_MANIFEST&&this.videoState.setState(u.to),o&&o.state===W.Requested&&this.seek(o.position)},i)),this.subscription.add(r.loadedData$.subscribe(()=>{var o,u,d;const l=(d=(u=(o=this.video)===null||o===void 0?void 0:o.getStartDate)===null||u===void 0?void 0:u.call(o))===null||d===void 0?void 0:d.getTime();this.manifestStartTime$.next(l||void 0)},i)),this.subscription.add(Ne({startTime:this.manifestStartTime$.pipe(re(k)),currentTime:r.timeUpdate$}).subscribe(({startTime:o,currentTime:u})=>this.params.output.liveTime$.next(o+u*1e3),i)),this.subscription.add(this.manifests$.pipe(w(o=>o.map(({id:u,quality:d,size:l,bandwidth:c,fps:h})=>({id:u,quality:d,size:l,fps:h,bitrate:c})))).subscribe(this.params.output.availableVideoTracks$,i));const n=V(t.playbackState.stateChangeStarted$,t.seekState.stateChangeEnded$,this.videoState.stateChangeEnded$,t.videoTrack.stateChangeStarted$,t.autoVideoTrackSwitching.stateChangeStarted$,this.manifests$,De(["init"])).pipe(je(0));this.subscription.add(n.subscribe(this.syncPlayback,i))}destroy(){this.subscription.unsubscribe(),this.textTracksManager.destroy(),this.params.output.element$.next(void 0),bt(this.video)}prepare(){const e=this.selectManifest();if(ie(e))return;const t=this.params.format===y.HLS_LIVE_CMAF?Te.DASH_CMAF_OFFSET_P:Te.OFFSET_P,i=Je(e.url,this.liveOffset.getTotalOffset(),t);this.video.setAttribute("src",i),this.video.load(),dd(i).then(r=>{var a;if(!ie(r))this.maxSeekBackTime$.next(r);else{const n=(a=this.params.source.maxSeekBackTime)!==null&&a!==void 0?a:this.maxSeekBackTime$.getValue();if(ie(n)||!isFinite(n))try{Fi(i).then(o=>o.text()).then(o=>{var u;const d=(u=/#EXT-X-STREAM-INF[^\n]+\n(.+)/m.exec(o))===null||u===void 0?void 0:u[1];if(d){const l=new URL(d,i).toString();dd(l).then(c=>{ie(c)||this.maxSeekBackTime$.next(c)})}})}catch(o){}}})}playIfAllowed(){It(this.video).then(e=>{e||(this.videoState.setState(oe.PAUSED),this.liveOffset.pause(),D(this.params.desiredState.playbackState,p.PAUSED,!0))},e=>this.params.output.error$.next({id:"ForcePlay",message:"play() failed even with workarounds",category:L.DOM,thrown:e}))}seek(e){this.params.output.willSeekEvent$.next();const t=-e,i=t<this.maxSeekBackTime$.getValue()?t:0;this.liveOffset.resetTo(i),this.params.output.position$.next(-i/1e3),this.params.output.seekedEvent$.next()}}var le;(function(s){s.STOPPED="stopped",s.READY="ready",s.PLAYING="playing",s.CHANGING_MANIFEST="changing_manifest",s.PAUSED="paused"})(le||(le={}));class sT{constructor(e){this.subscription=new ae,this.videoState=new ce(le.STOPPED),this.textTracksManager=new dt,this.manifests$=new S([]),this.syncPlayback=()=>{if(!this.manifests$.getValue().length)return;const r=this.videoState.getState(),a=this.params.desiredState.playbackState.getState(),n=this.params.desiredState.playbackState.getTransition(),o=this.params.desiredState.videoTrack.getTransition(),u=this.params.desiredState.autoVideoTrackSwitching.getTransition();if(a===p.STOPPED){r!==le.STOPPED&&(this.videoState.startTransitionTo(le.STOPPED),this.video.removeAttribute("src"),this.video.load(),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.videoState.setState(le.STOPPED),D(this.params.desiredState.playbackState,p.STOPPED,!0));return}if(this.videoState.getTransition())return;const l=this.params.desiredState.seekState.getState();if(r===le.STOPPED){this.videoState.startTransitionTo(le.READY),this.prepare();return}if(o||u){const c=this.videoState.getState();this.videoState.setState(le.CHANGING_MANIFEST),this.videoState.startTransitionTo(c);const{currentTime:h}=this.video;this.prepare(),l.state===W.None&&this.params.desiredState.seekState.setState({state:W.Requested,position:h*1e3,forcePrecise:!0});return}switch((n==null?void 0:n.to)!==p.PAUSED&&l.state===W.Requested&&this.seek(l.position),r){case le.READY:a===p.READY?D(this.params.desiredState.playbackState,p.READY):a===p.PAUSED?(this.videoState.setState(le.PAUSED),D(this.params.desiredState.playbackState,p.PAUSED)):a===p.PLAYING&&(this.videoState.startTransitionTo(le.PLAYING),this.playIfAllowed());return;case le.PLAYING:a===p.PAUSED?(this.videoState.startTransitionTo(le.PAUSED),this.video.pause()):(n==null?void 0:n.to)===p.PLAYING&&D(this.params.desiredState.playbackState,p.PLAYING);return;case le.PAUSED:a===p.PLAYING?(this.videoState.startTransitionTo(le.PLAYING),this.playIfAllowed()):(n==null?void 0:n.to)===p.PAUSED&&D(this.params.desiredState.playbackState,p.PAUSED);return;case le.CHANGING_MANIFEST:break;default:return H(r)}},this.params=e,this.video=St(e.container),this.params.output.element$.next(this.video);const t={id:"master",quality:He.INVARIANT,url:this.params.source.url};this.params.output.isLive$.next(!1),this.params.output.availableVideoTracks$.next([]),this.params.output.availableAudioTracks$.next([]),this.params.output.isAudioAvailable$.next(!0),this.params.output.hostname$.next(Ie(this.params.source.url)),el(this.params.source.url).then(({qualityManifests:i,textTracks:r})=>{this.manifests$.next([t,...i]),this.params.tuning.useNativeHLSTextTracks||this.params.desiredState.internalTextTracks.startTransitionTo(r)},i=>this.params.output.error$.next({id:"ExtractHlsQualities",category:L.NETWORK,message:"Error fetching manifest and extracting qualities",thrown:i})),this.subscribe()}selectManifest(){var e,t;const{autoVideoTrackSwitching:i,videoTrack:r}=this.params.desiredState,a=i.getState(),n=r.getTransition(),o=(t=(e=n==null?void 0:n.to)!==null&&e!==void 0?e:r.getState())!==null&&t!==void 0?t:"master",u=this.manifests$.getValue();if(!u.length)return;const d=a?"master":o;return a&&!n&&r.startTransitionTo("master"),u.find(l=>l.id===d)}subscribe(){const{output:e,desiredState:t}=this.params,i=o=>{e.error$.next({id:"HlsProvider",category:L.WTF,message:"HlsProvider internal logic error",thrown:o})},r=yt(this.video),a=(o,u)=>this.subscription.add(o.subscribe(u));if(a(r.timeUpdate$,e.position$),a(r.durationChange$,e.duration$),a(r.ended$,e.endedEvent$),a(r.looped$,e.loopedEvent$),a(r.error$,e.error$),a(r.isBuffering$,e.isBuffering$),a(r.currentBuffer$,e.currentBuffer$),a(r.loadedMetadata$,e.firstBytesEvent$),a(r.playing$,e.firstFrameEvent$),a(r.canplay$,e.canplay$),a(r.seeked$,e.seekedEvent$),a(r.inPiP$,e.inPiP$),a(r.inFullscreen$,e.inFullscreen$),this.subscription.add(jt(this.video,t.isLooped,i)),this.subscription.add(gt(this.video,t.volume,r.volumeState$,i)),this.subscription.add(r.volumeState$.subscribe(this.params.output.volume$,i)),this.subscription.add(Dt(this.video,t.playbackRate,r.playbackRateState$,i)),this.textTracksManager.connect(this.video,t,e),this.subscription.add(r.playing$.subscribe(()=>{this.videoState.setState(le.PLAYING),D(t.playbackState,p.PLAYING)},i)).add(r.pause$.subscribe(()=>{this.videoState.setState(le.PAUSED),D(t.playbackState,p.PAUSED)},i)).add(r.canplay$.subscribe(()=>{var o;((o=this.videoState.getTransition())===null||o===void 0?void 0:o.to)===le.READY&&this.videoState.setState(le.READY),this.videoState.getState()===le.PLAYING&&this.playIfAllowed()},i).add(r.loadedMetadata$.subscribe(()=>{const o=this.params.desiredState.seekState.getState(),u=this.videoState.getTransition(),d=this.params.desiredState.videoTrack.getTransition(),l=this.params.desiredState.autoVideoTrackSwitching.getTransition();if(d&&k(d.to)){const c=d.to;this.params.desiredState.videoTrack.setState(c);const h=this.manifests$.getValue().find(f=>f.id===c);h&&(this.params.output.currentVideoTrack$.next(h),this.params.output.hostname$.next(Ie(h.url)))}l&&this.params.desiredState.autoVideoTrackSwitching.setState(l.to),u&&u.from===le.CHANGING_MANIFEST&&this.videoState.setState(u.to),o.state===W.Requested&&this.seek(o.position)},i))),this.subscription.add(this.manifests$.pipe(w(o=>o.map(({id:u,quality:d,size:l,bandwidth:c,fps:h})=>({id:u,quality:d,size:l,fps:h,bitrate:c})))).subscribe(this.params.output.availableVideoTracks$,i)),!this.params.tuning.useNativeHLSTextTracks){const{textTracks:o}=this.video;this.subscription.add(V(B(o,"addtrack"),B(o,"removetrack"),B(o,"change"),De(["init"])).subscribe(()=>{for(let u=0;u<o.length;u++)o[u].mode="hidden"},i))}const n=V(t.playbackState.stateChangeStarted$,t.seekState.stateChangeEnded$,t.videoTrack.stateChangeStarted$,t.autoVideoTrackSwitching.stateChangeStarted$,this.videoState.stateChangeEnded$,this.manifests$,De(["init"])).pipe(je(0));this.subscription.add(n.subscribe(this.syncPlayback,i))}destroy(){this.subscription.unsubscribe(),this.textTracksManager.destroy(),this.params.output.element$.next(void 0),bt(this.video)}prepare(){const e=this.selectManifest();ie(e)||(this.video.setAttribute("src",e.url),this.video.load())}playIfAllowed(){It(this.video).then(e=>{e||(this.videoState.setState(le.PAUSED),D(this.params.desiredState.playbackState,p.PAUSED,!0))},e=>this.params.output.error$.next({id:"ForcePlay",message:"play() failed even with workarounds",category:L.DOM,thrown:e}))}seek(e){this.params.output.willSeekEvent$.next(),this.video.currentTime=e/1e3}}var fe;(function(s){s.STOPPED="stopped",s.READY="ready",s.PLAYING="playing",s.PAUSED="paused"})(fe||(fe={}));class rT{constructor(e){this.subscription=new ae,this.videoState=new ce(fe.STOPPED),this.trackUrls={},this.textTracksManager=new dt,this.syncPlayback=()=>{var t,i,r;const a=this.videoState.getState(),n=this.params.desiredState.playbackState.getState(),o=this.params.desiredState.playbackState.getTransition();if(n===p.STOPPED){a!==fe.STOPPED&&(this.videoState.startTransitionTo(fe.STOPPED),this.video.removeAttribute("src"),this.video.load(),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.videoState.setState(fe.STOPPED),D(this.params.desiredState.playbackState,p.STOPPED,!0));return}if(this.videoState.getTransition())return;const d=this.params.desiredState.autoVideoTrackLimits.getTransition(),l=this.params.desiredState.videoTrack.getTransition(),c=this.params.desiredState.seekState.getState();if(d&&a!==fe.READY&&!l){this.handleQualityLimitTransition(d.to.max);return}if(a===fe.STOPPED){this.videoState.startTransitionTo(fe.READY),this.prepare();return}if(l){const{currentTime:h}=this.video;this.prepare(),c.state===W.None&&this.params.desiredState.seekState.setState({state:W.Requested,position:h*1e3,forcePrecise:!0}),l.to&&((t=this.params.desiredState.autoVideoTrackLimits.getState())===null||t===void 0?void 0:t.max)!==((r=(i=this.trackUrls[l.to])===null||i===void 0?void 0:i.track)===null||r===void 0?void 0:r.quality)&&this.params.output.autoVideoTrackLimits$.next({max:void 0});return}switch((o==null?void 0:o.to)!==p.PAUSED&&c.state===W.Requested&&this.seek(c.position),a){case fe.READY:n===p.READY?D(this.params.desiredState.playbackState,p.READY):n===p.PAUSED?(this.videoState.setState(fe.PAUSED),D(this.params.desiredState.playbackState,p.PAUSED)):n===p.PLAYING&&(this.videoState.startTransitionTo(fe.PLAYING),this.playIfAllowed());return;case fe.PLAYING:n===p.PAUSED?(this.videoState.startTransitionTo(fe.PAUSED),this.video.pause()):(o==null?void 0:o.to)===p.PLAYING&&D(this.params.desiredState.playbackState,p.PLAYING);return;case fe.PAUSED:n===p.PLAYING?(this.videoState.startTransitionTo(fe.PLAYING),this.playIfAllowed()):(o==null?void 0:o.to)===p.PAUSED&&D(this.params.desiredState.playbackState,p.PAUSED);return;default:return H(a)}},this.params=e,this.video=St(e.container),this.params.output.element$.next(this.video),Object.entries(this.params.source).reverse().forEach(([t,i],r)=>{const a=r.toString(10);this.trackUrls[a]={track:{quality:t,id:a},url:i}}),this.params.output.isLive$.next(!1),this.params.output.availableVideoTracks$.next(Object.values(this.trackUrls).map(({track:t})=>t)),this.params.output.availableAudioTracks$.next([]),this.params.output.isAudioAvailable$.next(!0),this.params.desiredState.autoVideoTrackSwitching.setState(!1),this.params.output.autoVideoTrackLimitingAvailable$.next(!0),this.subscribe()}subscribe(){const{output:e,desiredState:t}=this.params,i=o=>{e.error$.next({id:"MpegProvider",category:L.WTF,message:"MpegProvider internal logic error",thrown:o})},r=yt(this.video),a=(o,u)=>this.subscription.add(o.subscribe(u,i));a(r.timeUpdate$,e.position$),a(r.durationChange$,e.duration$),a(r.ended$,e.endedEvent$),a(r.looped$,e.loopedEvent$),a(r.error$,e.error$),a(r.isBuffering$,e.isBuffering$),a(r.currentBuffer$,e.currentBuffer$),a(r.loadedMetadata$,e.firstBytesEvent$),a(r.playing$,e.firstFrameEvent$),a(r.canplay$,e.canplay$),a(r.seeked$,e.seekedEvent$),a(r.inPiP$,e.inPiP$),a(r.inFullscreen$,e.inFullscreen$),this.subscription.add(jt(this.video,t.isLooped,i)),this.subscription.add(gt(this.video,t.volume,r.volumeState$,i)),this.subscription.add(r.volumeState$.subscribe(this.params.output.volume$,i)),this.subscription.add(Dt(this.video,t.playbackRate,r.playbackRateState$,i)),this.subscription.add(r.playing$.subscribe(()=>{this.videoState.setState(fe.PLAYING),D(t.playbackState,p.PLAYING)},i)).add(r.pause$.subscribe(()=>{this.videoState.setState(fe.PAUSED),D(t.playbackState,p.PAUSED)},i)).add(r.canplay$.subscribe(()=>{var o;((o=this.videoState.getTransition())===null||o===void 0?void 0:o.to)===fe.READY&&this.videoState.setState(fe.READY);const u=this.params.desiredState.videoTrack.getTransition();u&&k(u.to)&&(this.params.desiredState.videoTrack.setState(u.to),this.params.output.currentVideoTrack$.next(this.trackUrls[u.to].track)),this.videoState.getState()===fe.PLAYING&&this.playIfAllowed()},i)),this.textTracksManager.connect(this.video,t,e);const n=V(t.playbackState.stateChangeStarted$,t.videoTrack.stateChangeStarted$,t.seekState.stateChangeEnded$,t.autoVideoTrackLimits.stateChangeStarted$,this.videoState.stateChangeEnded$,De(["init"])).pipe(je(0));this.subscription.add(n.subscribe(this.syncPlayback,i))}destroy(){this.subscription.unsubscribe(),this.textTracksManager.destroy(),this.trackUrls={},this.params.output.element$.next(void 0),bt(this.video)}prepare(){const e=this.params.desiredState.videoTrack.getState();P(e,"MpegProvider: track is not selected");let{url:t}=this.trackUrls[e];P(t,`MpegProvider: No url for ${e}`),this.params.tuning.requestQuick&&(t=ci(t)),this.video.setAttribute("src",t),this.video.load(),this.params.output.hostname$.next(Ie(t))}playIfAllowed(){It(this.video).then(e=>{e||(this.videoState.setState(fe.PAUSED),D(this.params.desiredState.playbackState,p.PAUSED,!0))},e=>this.params.output.error$.next({id:"ForcePlay",message:"play() failed even with workarounds",category:L.DOM,thrown:e}))}seek(e){this.params.output.willSeekEvent$.next(),this.video.currentTime=e/1e3}handleQualityLimitTransition(e){var t,i,r;let a;if(e&&((t=this.params.output.currentVideoTrack$.getValue())===null||t===void 0?void 0:t.quality)!==e){const n=(i=Object.values(this.trackUrls).find(d=>Td(d.track.quality,e)))===null||i===void 0?void 0:i.track,o=this.params.desiredState.videoTrack.getState(),u=(r=this.trackUrls[o!=null?o:"0"])===null||r===void 0?void 0:r.track;n&&u&&pa(u.quality,n.quality)&&(a=n)}else if(!e){const n=Object.values(this.trackUrls).map(o=>o.track);a=gi(n,{container:{width:this.video.offsetWidth,height:this.video.offsetHeight},throughput:this.params.dependencies.throughputEstimator.throughput$.getValue(),tuning:this.params.tuning.autoTrackSelection,forwardBufferHealth:0,abrLogger:this.params.dependencies.abrLogger})}a&&(this.params.output.currentVideoTrack$.next(a),this.params.desiredState.videoTrack.startTransitionTo(a.id)),this.params.output.autoVideoTrackLimits$.next({max:e})}}const ud=["stun:videostun.mycdn.me:80"],aT=1e3,nT=3,ta=()=>null;class oT{constructor(e,t){this.ws=null,this.peerConnection=null,this.serverUrl="",this.streamKey="",this.stream=null,this.signalingType="JOIN",this.retryCount=0,this.externalStartCallback=ta,this.externalStopCallback=ta,this.externalErrorCallback=ta,this.options=this.normalizeOptions(t);const i=e.split("/");this.serverUrl=i.slice(0,i.length-1).join("/"),this.streamKey=i[i.length-1]}onStart(e){try{this.externalStartCallback=e}catch(t){this.handleSystemError(t)}}onStop(e){try{this.externalStopCallback=e}catch(t){this.handleSystemError(t)}}onError(e){try{this.externalErrorCallback=e}catch(t){this.handleSystemError(t)}}connect(){this.connectWS()}disconnect(){try{this.externalStopCallback(),this.closeConnections()}catch(e){this.handleSystemError(e)}}connectWS(){this.ws||(this.ws=new WebSocket(this.serverUrl),this.ws.onopen=this.onSocketOpen.bind(this),this.ws.onmessage=this.onSocketMessage.bind(this),this.ws.onclose=this.onSocketClose.bind(this),this.ws.onerror=this.onSocketError.bind(this))}onSocketOpen(){this.handleLogin()}onSocketClose(e){try{if(!this.ws)return;this.ws=null,e.code>1e3?(this.retryCount++,this.retryCount>this.options.maxRetryNumber?this.handleNetworkError():this.scheduleRetry()):this.externalStopCallback()}catch(t){this.handleRTCError(t)}}onSocketError(e){try{this.externalErrorCallback(new Error(e.toString()))}catch(t){this.handleRTCError(t)}}onSocketMessage(e){try{const t=this.parseMessage(e.data);switch(t.type){case"JOIN":case"CALL_JOIN":this.handleJoinMessage(t);break;case"UPDATE":this.handleUpdateMessage(t);break;case"STATUS":this.handleStatusMessage(t);break}}catch(t){this.handleRTCError(t)}}handleJoinMessage(e){switch(e.inviteType){case"ANSWER":this.handleAnswer(e.sdp);break;case"CANDIDATE":this.handleCandidate(e.candidate);break}}handleStatusMessage(e){switch(e.status){case"UNPUBLISHED":this.handleUnpublished();break}}handleUpdateMessage(e){return ue(this,void 0,void 0,function*(){try{const t=yield this.createOffer();this.peerConnection&&(yield this.peerConnection.setLocalDescription(t)),this.handleAnswer(e.sdp)}catch(t){this.handleRTCError(t)}})}handleLogin(){return ue(this,void 0,void 0,function*(){try{const e={iceServers:[{urls:ud}]};this.peerConnection=new RTCPeerConnection(e),this.peerConnection.ontrack=this.onPeerConnectionStream.bind(this),this.peerConnection.onicecandidate=this.onPeerConnectionIceCandidate.bind(this),this.peerConnection.oniceconnectionstatechange=this.onPeerConnectionIceConnectionStateChange.bind(this);const t=yield this.createOffer();yield this.peerConnection.setLocalDescription(t),this.send({type:this.signalingType,inviteType:"OFFER",streamKey:this.streamKey,sdp:t.sdp,callSupport:!1})}catch(e){this.handleRTCError(e)}})}handleAnswer(e){return ue(this,void 0,void 0,function*(){try{this.peerConnection&&(yield this.peerConnection.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:e})))}catch(t){this.handleRTCError(t)}})}handleCandidate(e){return ue(this,void 0,void 0,function*(){if(e)try{this.peerConnection&&(yield this.peerConnection.addIceCandidate(e))}catch(t){this.handleRTCError(t)}})}handleUnpublished(){try{this.closeConnections(),this.externalStopCallback()}catch(e){this.handleRTCError(e)}}handleSystemError(e){this.options.errorChanel&&this.options.errorChanel.next({id:"webrtc-provider-error",category:L.WTF,message:e.message})}onPeerConnectionStream(e){return ue(this,void 0,void 0,function*(){const t=e.streams[0];this.stream&&this.stream.id===t.id||(this.stream=t,this.externalStartCallback(this.stream))})}onPeerConnectionIceCandidate(e){e.candidate&&this.send({type:this.signalingType,inviteType:"CANDIDATE",candidate:e.candidate})}onPeerConnectionIceConnectionStateChange(){if(this.peerConnection){const e=this.peerConnection.iceConnectionState;["failed","closed"].indexOf(e)>-1&&(this.retryCount++,this.retryCount>this.options.maxRetryNumber?this.handleNetworkError():(this.closeConnections(),this.scheduleRetry()))}}createOffer(){return ue(this,void 0,void 0,function*(){const e={offerToReceiveAudio:!0,offerToReceiveVideo:!0,voiceActivityDetection:!1};if(!this.peerConnection)throw new Error("Can not create offer - no peer connection instance ");const t=yield this.peerConnection.createOffer(e),i=t.sdp||"";if(!/^a=rtpmap:\d+ H264\/\d+$/m.test(i))throw new Error("No h264 codec support error");return t})}handleRTCError(e){try{this.externalErrorCallback(e||new Error("RTC connection error"))}catch(t){this.handleSystemError(t)}}handleNetworkError(){try{this.externalErrorCallback(new Error("Network error"))}catch(e){this.handleSystemError(e)}}send(e){this.ws&&this.ws.send(JSON.stringify(e))}parseMessage(e){try{return JSON.parse(e)}catch(t){throw new Error("Can not parse socket message")}}closeConnections(){const e=this.ws;e&&(this.ws=null,e.close(1e3)),this.removePeerConnection()}removePeerConnection(){let e=this.peerConnection;e&&(this.peerConnection=null,e.close(),e.ontrack=null,e.onicecandidate=null,e.oniceconnectionstatechange=null,e=null)}scheduleRetry(){this.retryTimeout=setTimeout(this.connectWS.bind(this),aT)}normalizeOptions(e={}){const t={stunServerList:ud,maxRetryNumber:nT,errorChanel:null};return e.stunServerList&&(t.stunServerList=e.stunServerList),e.maxRetryNumber&&e.maxRetryNumber>0&&(t.maxRetryNumber=e.maxRetryNumber),t}}var de;(function(s){s.STOPPED="stopped",s.READY="ready",s.PLAYING="playing",s.PAUSED="paused"})(de||(de={}));class dT{constructor(e){this.videoState=new ce(de.STOPPED),this.maxSeekBackTime$=new S(0),this.syncPlayback=()=>{const t=this.videoState.getState(),i=this.params.desiredState.playbackState.getState(),r=this.params.desiredState.playbackState.getTransition();if(i===p.STOPPED){t!==de.STOPPED&&(this.videoState.startTransitionTo(de.STOPPED),this.video.pause(),this.video.srcObject=null,this.params.output.position$.next(0),this.params.output.duration$.next(0),this.params.output.currentBuffer$.next(void 0),this.params.output.hostname$.next(void 0),this.videoState.setState(de.STOPPED),D(this.params.desiredState.playbackState,p.STOPPED,!0));return}if(this.videoState.getTransition())return;const n=this.params.desiredState.videoTrack.getTransition();if(t===de.STOPPED){this.videoState.startTransitionTo(de.READY),this.prepare();return}if(n){this.prepare();return}switch(t){case de.READY:i===p.PAUSED?(this.videoState.setState(de.PAUSED),D(this.params.desiredState.playbackState,p.PAUSED)):i===p.PLAYING&&(this.videoState.startTransitionTo(de.PLAYING),this.playIfAllowed());return;case de.PLAYING:i===p.PAUSED?(this.videoState.startTransitionTo(de.PAUSED),this.video.pause()):(r==null?void 0:r.to)===p.PLAYING&&D(this.params.desiredState.playbackState,p.PLAYING);return;case de.PAUSED:i===p.PLAYING?(this.videoState.startTransitionTo(de.PLAYING),this.playIfAllowed()):(r==null?void 0:r.to)===p.PAUSED&&D(this.params.desiredState.playbackState,p.PAUSED);return;default:return H(t)}},this.subscription=new ae,this.params=e,this.log=this.params.dependencies.logger.createComponentLog("WebRTCLiveProvider"),this.video=St(e.container),this.liveStreamClient=new oT(this.params.source.url,{maxRetryNumber:this.params.tuning.webrtc.connectionRetryMaxNumber,errorChanel:this.params.output.error$}),this.liveStreamClient.onStart(this.onLiveStreamStart.bind(this)),this.liveStreamClient.onStop(this.onLiveStreamStop.bind(this)),this.liveStreamClient.onError(this.onLiveStreamError.bind(this)),this.subscribe()}destroy(){this.subscription.unsubscribe(),this.liveStreamClient.disconnect(),this.params.output.element$.next(void 0),bt(this.video)}subscribe(){const{output:e,desiredState:t}=this.params,i=n=>{e.error$.next({id:"WebRTCLiveProvider",category:L.WTF,message:"WebRTCLiveProvider internal logic error",thrown:n})};V(this.videoState.stateChangeStarted$.pipe(w(n=>({transition:n,type:"start"}))),this.videoState.stateChangeEnded$.pipe(w(n=>({transition:n,type:"end"})))).subscribe(({transition:n,type:o})=>{this.log({message:`[videoState change] ${o}: ${JSON.stringify(n)}`})});const r=yt(this.video),a=(n,o)=>this.subscription.add(n.subscribe(o,i));a(r.timeUpdate$,e.liveTime$),a(r.ended$,e.endedEvent$),a(r.looped$,e.loopedEvent$),a(r.error$,e.error$),a(r.isBuffering$,e.isBuffering$),a(r.currentBuffer$,e.currentBuffer$),this.subscription.add(r.durationChange$.subscribe(n=>{e.duration$.next(n===1/0?0:n)})).add(r.canplay$.subscribe(()=>{var n;((n=this.videoState.getTransition())===null||n===void 0?void 0:n.to)===de.READY&&this.videoState.setState(de.READY)},i)).add(r.pause$.subscribe(()=>{this.videoState.setState(de.PAUSED)},i)).add(r.playing$.subscribe(()=>{this.videoState.setState(de.PLAYING)},i)).add(r.error$.subscribe(e.error$)).add(this.maxSeekBackTime$.subscribe(this.params.output.duration$)).add(gt(this.video,t.volume,r.volumeState$,i)).add(r.volumeState$.subscribe(e.volume$,i)).add(this.videoState.stateChangeEnded$.subscribe(n=>{switch(n.to){case de.STOPPED:e.position$.next(0),e.duration$.next(0),t.playbackState.setState(p.STOPPED);break;case de.READY:break;case de.PAUSED:t.playbackState.setState(p.PAUSED);break;case de.PLAYING:t.playbackState.setState(p.PLAYING);break;default:return H(n.to)}},i)).add(V(t.playbackState.stateChangeStarted$,this.videoState.stateChangeEnded$,De(["init"])).pipe(je(0)).subscribe(this.syncPlayback.bind(this),i)),this.subscription.add(t.isLooped.stateChangeStarted$.subscribe(()=>t.isLooped.setState(!1),i)),this.subscription.add(t.autoVideoTrackSwitching.stateChangeStarted$.subscribe(()=>t.autoVideoTrackSwitching.setState(!1),i))}onLiveStreamStart(e){this.params.output.element$.next(this.video),this.params.output.duration$.next(0),this.params.output.position$.next(0),this.params.output.isLive$.next(!0),this.params.output.canChangePlaybackSpeed$.next(!1),this.params.output.hostname$.next(Ie(this.params.source.url)),this.params.output.autoVideoTrackLimitingAvailable$.next(!1),this.params.output.availableVideoTracks$.next([]),this.params.output.availableAudioTracks$.next([]),this.params.output.isAudioAvailable$.next(!0),this.params.output.currentVideoTrack$.next({id:"webrtc",quality:He.INVARIANT}),this.video.srcObject=e,D(this.params.desiredState.playbackState,p.PLAYING)}onLiveStreamStop(){this.videoState.startTransitionTo(de.STOPPED),this.syncPlayback(),this.params.output.position$.next(0),this.params.output.duration$.next(0),this.params.output.currentBuffer$.next(void 0),this.params.output.hostname$.next(void 0),this.params.output.endedEvent$.next()}onLiveStreamError(e){this.onLiveStreamStop(),this.params.output.error$.next({id:"WebRTC stream runtime error",category:L.EXTERNAL_API,message:e.message,thrown:e})}playIfAllowed(){It(this.video).then(e=>{e||(this.videoState.setState(de.PAUSED),D(this.params.desiredState.playbackState,p.PAUSED,!0))},e=>this.params.output.error$.next({id:"ForcePlay",message:"play() failed even with workarounds",category:L.DOM,thrown:e}))}prepare(){this.liveStreamClient.connect()}}class ld{constructor(e){this.iterator=e[Symbol.iterator](),this.next()}next(){this.current=this.iterator.next()}getValue(){if(this.current.done)throw new Error("Iterable is completed");return this.current.value}isCompleted(){return!!this.current.done}}var ia,sa,ra,aa,na,oa,ys,da,Ts,ua,Es,la,$s,ca,As,ha,_s,fa;const tl=Ua().device===_l.Android,kt=document.createElement("video"),uT='video/mp4; codecs="avc1.42000a,mp4a.40.2"',lT='video/mp4; codecs="hev1.1.6.L93.B0"',il='video/webm; codecs="vp09.00.10.08"',sl='video/webm; codecs="av01.0.00M.08"',cT='audio/mp4; codecs="mp4a.40.2"',hT='audio/webm; codecs="opus"',Qe={mse:!!(window.MediaSource&&window.MediaStreamTrack&&(!((sa=(ia=window.SourceBuffer)===null||ia===void 0?void 0:ia.prototype)===null||sa===void 0)&&sa.appendBuffer)),hls:!!(!((ra=kt.canPlayType)===null||ra===void 0)&&ra.call(kt,"application/x-mpegurl")||!((aa=kt.canPlayType)===null||aa===void 0)&&aa.call(kt,"vnd.apple.mpegURL")),webrtc:!!window.RTCPeerConnection,ws:!!window.WebSocket},Le={mp4:!!(!((na=kt.canPlayType)===null||na===void 0)&&na.call(kt,"video/mp4")),webm:!!(!((oa=kt.canPlayType)===null||oa===void 0)&&oa.call(kt,"video/webm")),cmaf:!0},nt={h264:!!(!((da=(ys=window.MediaSource)===null||ys===void 0?void 0:ys.isTypeSupported)===null||da===void 0)&&da.call(ys,uT)),h265:!!(!((ua=(Ts=window.MediaSource)===null||Ts===void 0?void 0:Ts.isTypeSupported)===null||ua===void 0)&&ua.call(Ts,lT)),vp9:!!(!((la=(Es=window.MediaSource)===null||Es===void 0?void 0:Es.isTypeSupported)===null||la===void 0)&&la.call(Es,il)),av1:!!(!((ca=($s=window.MediaSource)===null||$s===void 0?void 0:$s.isTypeSupported)===null||ca===void 0)&&ca.call($s,sl)),aac:!!(!((ha=(As=window.MediaSource)===null||As===void 0?void 0:As.isTypeSupported)===null||ha===void 0)&&ha.call(As,cT)),opus:!!(!((fa=(_s=window.MediaSource)===null||_s===void 0?void 0:_s.isTypeSupported)===null||fa===void 0)&&fa.call(_s,hT))},ii=(nt.h264||nt.h265)&&nt.aac;var _t;(function(s){s.VP9="vp9",s.AV1="av1",s.NONE="none",s.SMOOTH="smooth",s.POWER_EFFICIENT="power_efficient"})(_t||(_t={}));var ft;(function(s){s.DASH="dash",s.HLS="hls",s.MPEG="mpeg"})(ft||(ft={}));let Bt;const fT=()=>ue(void 0,void 0,void 0,function*(){if(!window.navigator.mediaCapabilities)return;const s={type:"media-source",video:{contentType:"video/webm",width:1280,height:720,bitrate:1e6,framerate:30}},[e,t]=yield Promise.all([window.navigator.mediaCapabilities.decodingInfo(Object.assign(Object.assign({},s),{video:Object.assign(Object.assign({},s.video),{contentType:sl})})),window.navigator.mediaCapabilities.decodingInfo(Object.assign(Object.assign({},s),{video:Object.assign(Object.assign({},s.video),{contentType:il})}))]);Bt={[y.DASH_WEBM_AV1]:e,[y.DASH_WEBM]:t}});try{fT()}catch(s){console.error(s)}const Ui=Qe.hls&&Le.mp4,pT=()=>Object.keys(nt).filter(s=>nt[s]),vT=(s,e=!1)=>s.filter(t=>{switch(t){case y.DASH:return Qe.mse&&Le.mp4&ⅈcase y.DASH_SEP:return Qe.mse&&Le.mp4&ⅈcase y.DASH_WEBM:return Qe.mse&&Le.webm&&nt.vp9&&nt.opus;case y.DASH_WEBM_AV1:return Qe.mse&&Le.webm&&nt.av1&&nt.opus;case y.DASH_LIVE:return Qe.mse&&Le.mp4&ⅈcase y.DASH_LIVE_CMAF:return Qe.mse&&Le.mp4&&ii&&Le.cmaf;case y.DASH_ONDEMAND:return Qe.mse&&Le.mp4&ⅈcase y.HLS:case y.HLS_ONDEMAND:return Ui||e&&Qe.mse&&Le.mp4&ⅈcase y.HLS_LIVE:case y.HLS_LIVE_CMAF:return Ui;case y.MPEG:return Le.mp4;case y.DASH_LIVE_WEBM:return!1;case y.WEB_RTC_LIVE:return Qe.webrtc&&Qe.ws&&nt.h264&&(Le.mp4||Le.webm);default:return H(t)}}),Ri=s=>{const e=y.DASH_WEBM,t=y.DASH_WEBM_AV1;switch(s){case _t.VP9:return[e,t];case _t.AV1:return[t,e];case _t.NONE:return[];case _t.SMOOTH:return Bt?Bt[t].smooth?[t,e]:Bt[e].smooth?[e,t]:[t,e]:[e,t];case _t.POWER_EFFICIENT:return Bt?Bt[t].powerEfficient?[t,e]:Bt[e].powerEfficient?[e,t]:[t,e]:[e,t];default:H(s)}return[e,t]},mT=({webmCodec:s,androidPreferredFormat:e})=>{if(tl)switch(e){case ft.MPEG:return[y.MPEG,...Ri(s),y.DASH_SEP,y.DASH,y.DASH_ONDEMAND,y.HLS,y.HLS_ONDEMAND];case ft.HLS:return[y.HLS,y.HLS_ONDEMAND,...Ri(s),y.DASH_SEP,y.DASH,y.DASH_ONDEMAND,y.MPEG];case ft.DASH:return[...Ri(s),y.DASH_SEP,y.DASH,y.DASH_ONDEMAND,y.HLS,y.HLS_ONDEMAND,y.MPEG]}return Ui?[...Ri(s),y.DASH_SEP,y.DASH_ONDEMAND,y.HLS,y.HLS_ONDEMAND,y.MPEG,y.DASH]:[...Ri(s),y.DASH_SEP,y.DASH,y.DASH_ONDEMAND,y.HLS,y.HLS_ONDEMAND,y.MPEG]},gT=({androidPreferredFormat:s,preferCMAF:e,preferWebRTC:t})=>{const i=e?[y.DASH_LIVE_CMAF,y.DASH_LIVE]:[y.DASH_LIVE,y.DASH_LIVE_CMAF],r=e?[y.HLS_LIVE_CMAF,y.HLS_LIVE]:[y.HLS_LIVE,y.HLS_LIVE_CMAF],a=[...i,...r],n=[...r,...i];let o;if(tl)switch(s){case ft.DASH:{o=a;break}case ft.HLS:case ft.MPEG:{o=n;break}}else Ui?o=n:o=a;return t?[y.WEB_RTC_LIVE,...o]:[...o,y.WEB_RTC_LIVE]},cd=s=>s?[y.HLS_LIVE,y.HLS_LIVE_CMAF,y.DASH_LIVE_CMAF]:[y.DASH_WEBM,y.DASH_WEBM_AV1,y.DASH_SEP,y.DASH_ONDEMAND,y.HLS,y.HLS_ONDEMAND,y.MPEG];var ST=s=>new Hs(e=>{const t=new ae,i=s.desiredPlaybackState$.stateChangeStarted$.pipe(w(({from:d,to:l})=>`${d}-${l}`)),r=s.desiredPlaybackState$.stateChangeEnded$,a=s.providerChanged$.pipe(w(({type:d})=>d!==void 0)),n=new x;let o=0,u="unknown";return t.add(i.subscribe(d=>{o&&window.clearTimeout(o),u=d,o=window.setTimeout(()=>n.next(d),s.maxTransitionInterval)})),t.add(r.subscribe(()=>{window.clearTimeout(o),u="unknown",o=0})),t.add(a.subscribe(d=>{o&&(window.clearTimeout(o),o=0,d&&(o=window.setTimeout(()=>n.next(u),s.maxTransitionInterval)))})),t.add(n.subscribe(e)),()=>{window.clearTimeout(o),t.unsubscribe()}});const bT={cacheDuration:12e4},yT={chunkDuration:5e3,maxParallelRequests:5};class TT{constructor(e){this.current$=new S({type:void 0}),this.providerError$=new x,this.noAvailableProvidersError$=new x,this.providerOutput={position$:new S(0),duration$:new S(1/0),volume$:new S({muted:!1,volume:1}),currentVideoTrack$:new S(void 0),availableVideoTracks$:new S([]),availableAudioTracks$:new S([]),isAudioAvailable$:new S(!0),autoVideoTrackLimitingAvailable$:new S(!1),autoVideoTrackLimits$:new S(void 0),currentBuffer$:new S(void 0),isBuffering$:new S(!0),error$:new x,warning$:new x,willSeekEvent$:new x,seekedEvent$:new x,loopedEvent$:new x,endedEvent$:new x,firstBytesEvent$:new x,firstFrameEvent$:new x,canplay$:new x,isLive$:new S(void 0),isLowLatency$:new S(!1),canChangePlaybackSpeed$:new S(!0),liveTime$:new S(void 0),liveBufferTime$:new S(void 0),availableTextTracks$:new S([]),currentTextTrack$:new S(void 0),hostname$:new S(void 0),httpConnectionType$:new S(void 0),httpConnectionReused$:new S(void 0),inPiP$:new S(!1),inFullscreen$:new S(!1),element$:new S(void 0),availableSources$:new S(void 0),is3DVideo$:new S(!1)},this.subscription=new ae,this.params=e,this.log=this.params.dependencies.logger.createComponentLog("ProviderContainer");const t=vT([...gT(this.params.tuning),...mT(this.params.tuning)],this.params.tuning.useHlsJs).filter(o=>k(e.sources[o])),{forceFormat:i,formatsToAvoid:r}=this.params.tuning;let a=[];i?a=[i]:r.length?a=[...t.filter(o=>!r.includes(o)),...t.filter(o=>r.includes(o))]:a=t,this.log({message:`Selected formats: ${a.join(" > ")}`}),this.screenFormatsIterator=new ld(a);const n=[...cd(!0),...cd(!1)];this.chromecastFormatsIterator=new ld(n.filter(o=>k(e.sources[o]))),this.providerOutput.availableSources$.next(e.sources)}init(){this.subscription.add(this.initProviderErrorHandling()),this.subscription.add(this.params.dependencies.chromecastInitializer.connection$.subscribe(()=>{this.reinitProvider()}))}destroy(){this.destroyProvider(),this.current$.next({type:void 0}),this.subscription.unsubscribe()}initProvider(){const e=this.chooseDestination(),t=this.chooseFormat(e);if(ie(t)){this.handleNoFormatsError(e);return}let i;try{i=this.createProvider(e,t)}catch(r){this.providerError$.next({id:"ProviderNotConstructed",category:L.WTF,message:"Failed to create provider",thrown:r})}i?this.current$.next({type:t,provider:i,destination:e}):this.current$.next({type:void 0})}reinitProvider(){this.destroyProvider(),this.initProvider()}switchToNextProvider(e){this.destroyProvider(),this.failoverIndex=void 0,this.skipFormat(e),this.initProvider()}destroyProvider(){const e=this.current$.getValue().provider;if(!e)return;this.log({message:"destroyProvider"});const t=this.providerOutput.position$.getValue()*1e3,i=this.params.desiredState.seekState.getState(),r=i.state!==W.None;if(this.params.desiredState.seekState.setState({state:W.Requested,position:r?i.position:t,forcePrecise:r?i.forcePrecise:!1}),e.scene3D){const n=e.scene3D.getCameraRotation();this.params.desiredState.cameraOrientation.setState({x:n.x,y:n.y})}e.destroy();const a=this.providerOutput.isBuffering$;a.getValue()||a.next(!0)}createProvider(e,t){switch(this.log({message:`createProvider: ${e}:${t}`}),e){case we.SCREEN:return this.createScreenProvider(t);case we.CHROMECAST:return this.createChromecastProvider(t);default:return H(e)}}createScreenProvider(e){const{sources:t,container:i,desiredState:r}=this.params,a=this.providerOutput,n={container:i,source:null,desiredState:r,output:a,dependencies:this.params.dependencies,tuning:this.params.tuning};switch(e){case y.DASH:{const o=this.applyFailoverHost(t[e]);return P(o),new gb(Object.assign(Object.assign({},n),{source:o,config:bT}))}case y.DASH_SEP:case y.DASH_WEBM:case y.DASH_WEBM_AV1:case y.DASH_ONDEMAND:{const o=this.applyFailoverHost(t[e]);return P(o),this.params.tuning.useDashJs?new qo(Object.assign(Object.assign({},n),{source:o,format:e,config:{maxPausedTime:this.params.tuning.live.maxPausedTime}})):new Xy(Object.assign(Object.assign({},n),{source:o}))}case y.DASH_LIVE_CMAF:{const o=this.applyFailoverHost(t[e]);return P(o),this.params.tuning.useDashJsCMAF?new qo(Object.assign(Object.assign({},n),{source:o,format:e,config:{maxPausedTime:this.params.tuning.live.maxPausedTime}})):new Zy(Object.assign(Object.assign({},n),{source:o}))}case y.HLS:case y.HLS_ONDEMAND:{const o=this.applyFailoverHost(t[e]);return P(o),Ui||!this.params.tuning.useHlsJs?new sT(Object.assign(Object.assign({},n),{source:o})):new eT(Object.assign(Object.assign({},n),{source:o}))}case y.HLS_LIVE:case y.HLS_LIVE_CMAF:{const o=this.applyFailoverHost(t[e]);return P(o),new iT(Object.assign(Object.assign({},n),{source:o,config:{maxPausedTime:this.params.tuning.live.maxPausedTime},format:e}))}case y.MPEG:{const o=this.applyFailoverHost(t[e]);return P(o),new rT(Object.assign(Object.assign({},n),{source:o}))}case y.DASH_LIVE:{const o=this.applyFailoverHost(t[e]);return P(o),new hb(Object.assign(Object.assign({},n),{source:o,config:Object.assign(Object.assign({},yT),{maxPausedTime:this.params.tuning.live.maxPausedTime})}))}case y.WEB_RTC_LIVE:{const o=this.applyFailoverHost(t[e]);return P(o),new dT({container:i,source:o,desiredState:r,output:a,dependencies:this.params.dependencies,tuning:this.params.tuning})}case y.DASH_LIVE_WEBM:throw new Error("DASH_LIVE_WEBM is no longer supported");default:return H(e)}}createChromecastProvider(e){const{sources:t,container:i,desiredState:r,meta:a}=this.params,n=this.providerOutput,o=this.params.dependencies.chromecastInitializer.connection$.getValue();return P(o),new $S({connection:o,meta:a,container:i,source:t,format:e,desiredState:r,output:n,dependencies:this.params.dependencies,tuning:this.params.tuning})}chooseDestination(){return this.params.dependencies.chromecastInitializer.connection$.getValue()?we.CHROMECAST:we.SCREEN}chooseFormat(e){switch(e){case we.SCREEN:return this.screenFormatsIterator.isCompleted()?void 0:this.screenFormatsIterator.getValue();case we.CHROMECAST:return this.chromecastFormatsIterator.isCompleted()?void 0:this.chromecastFormatsIterator.getValue();default:return H(e)}}skipFormat(e){switch(e){case we.SCREEN:return this.screenFormatsIterator.next();case we.CHROMECAST:return this.chromecastFormatsIterator.next();default:return H(e)}}handleNoFormatsError(e){switch(e){case we.SCREEN:this.noAvailableProvidersError$.next(this.params.tuning.forceFormat),this.current$.next({type:void 0});return;case we.CHROMECAST:this.params.dependencies.chromecastInitializer.disconnect();return;default:return H(e)}}applyFailoverHost(e){if(this.failoverIndex===void 0)return e;const t=this.params.failoverHosts[this.failoverIndex];if(!t)return e;const i=r=>{const a=new URL(r);return a.host=t,a.toString()};if(e===void 0)return e;if("type"in e){if(e.type==="raw")return e;if(e.type==="url")return Object.assign(Object.assign({},e),{url:i(e.url)})}return li(Object.entries(e).map(([r,a])=>[r,i(a)]))}initProviderErrorHandling(){const e=new ae;let t=!1,i=0;return e.add(V(this.providerOutput.error$,ST({desiredPlaybackState$:this.params.desiredState.playbackState,maxTransitionInterval:this.params.tuning.maxPlaybackTransitionInterval,position$:this.providerOutput.position$,providerChanged$:this.current$}).pipe(w(r=>({id:`ProviderHangup:${r}`,category:L.WTF,message:`A ${r} transition failed to complete within reasonable time`})))).subscribe(this.providerError$)),e.add(this.current$.subscribe(()=>{t=!1;const r=this.params.desiredState.playbackState.transitionEnded$.pipe(re(({to:a})=>a===p.PLAYING),ge()).subscribe(()=>t=!0);e.add(r)})),e.add(this.providerError$.subscribe(r=>{const a=this.current$.getValue().destination;if(a===we.CHROMECAST)this.destroyProvider(),this.params.dependencies.chromecastInitializer.stopMedia().then(()=>this.switchToNextProvider(we.SCREEN),()=>this.params.dependencies.chromecastInitializer.disconnect());else{const n=r.category===L.NETWORK,o=this.params.failoverHosts.length>0&&(this.failoverIndex===void 0||this.failoverIndex<this.params.failoverHosts.length-1),u=i<this.params.tuning.providerErrorLimit;o&&(n&&t||!u)?(this.failoverIndex=this.failoverIndex===void 0?0:this.failoverIndex+1,this.reinitProvider()):u?(i++,this.reinitProvider()):this.switchToNextProvider(a!=null?a:we.SCREEN)}})),e}}const Fa=(s,e,t)=>t*e+(1-t)*s,rl=(s,e)=>s.reduce((t,i)=>t+i,0)/e,ET=(s,e,t,i)=>{let r=0,a=t;const n=rl(s,e),o=e<i?e:i;for(let u=0;u<o;u++)s[a]>n?r++:r--,a=(s.length+a-1)%s.length;return Math.abs(r)===o};class al{constructor(e){var t;this.prevReported=void 0,this.pastMeasures=[],this.takenMeasures=0,this.measuresCursor=0,this.params=e,this.pastMeasures=Array(e.deviationDepth),this.smoothed=this.prevReported=e.initial,this.smoothed$=new S(e.initial),this.debounced$=new S(e.initial);const i=(t=e.label)!==null&&t!==void 0?t:"value"+Math.random().toString(16).substring(2,6);this.rawSeries$=new rt(`raw_${i}`),this.smoothedSeries$=new rt(`smoothed_${i}`),this.reportedSeries$=new rt(`reported_${i}`),this.rawSeries$.next(e.initial),this.smoothedSeries$.next(e.initial),this.reportedSeries$.next(e.initial)}next(e){let t=0,i=0;for(let o=0;o<this.pastMeasures.length;o++)this.pastMeasures[o]!==void 0&&(t+=Math.pow(this.pastMeasures[o]-this.smoothed,2),i++);this.takenMeasures=i,t/=i;const r=Math.sqrt(t),a=this.smoothed+this.params.deviationFactor*r,n=this.smoothed-this.params.deviationFactor*r;this.pastMeasures[this.measuresCursor]=e,this.measuresCursor=(this.measuresCursor+1)%this.pastMeasures.length,this.rawSeries$.next(e),this.updateSmoothedValue(e),this.smoothed$.next(this.smoothed),this.smoothedSeries$.next(this.smoothed),!(this.smoothed>a||this.smoothed<n)&&(ie(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))}}class $T extends al{constructor(e){super(e),this.slow=this.fast=e.initial}updateSmoothedValue(e){this.slow=Fa(this.slow,e,this.params.emaAlphaSlow),this.fast=Fa(this.fast,e,this.params.emaAlphaFast);const t=this.params.fastDirection>0?Math.max:Math.min;this.smoothed=t(this.slow,this.fast)}}class AT extends al{constructor(e){super(e),this.emaSmoothed=e.initial}updateSmoothedValue(e){const t=rl(this.pastMeasures,this.takenMeasures);this.emaSmoothed=Fa(this.emaSmoothed,e,this.params.emaAlpha);const i=ET(this.pastMeasures,this.takenMeasures,this.measuresCursor-1,this.params.basisTrendChangeCount);this.smoothed=i?this.emaSmoothed:t}}class hd{static getSmoothedValue(e,t,i){return i.type==="TwoEma"?new $T({initial:e,emaAlphaSlow:i.emaAlphaSlow,emaAlphaFast:i.emaAlphaFast,changeThreshold:i.changeThreshold,fastDirection:t,deviationDepth:i.deviationDepth,deviationFactor:i.deviationFactor,label:"throughput"}):new AT({initial:e,emaAlpha:i.emaAlpha,basisTrendChangeCount:i.basisTrendChangeCount,changeThreshold:i.changeThreshold,deviationDepth:i.deviationDepth,deviationFactor:i.deviationFactor,label:"throughput"})}}const _T=5e3,fd="one_video_throughput",pd="one_video_rtt",pt=window.navigator.connection,vd=()=>{const s=pt==null?void 0:pt.downlink;if(k(s)&&s!==10)return s*1e3},md=()=>{const s=pt==null?void 0:pt.rtt;if(k(s)&&s!==3e3)return s},gd=(s,e,t)=>{const i=t*8,r=i/s;return i/(r+e)};class Li{constructor(e){var t,i;this.subscription=new ae,this.concurrentDownloads=new Set,this.tuningConfig=e;const r=Li.load(fd)||(e.useBrowserEstimation?vd():void 0)||_T,a=(i=(t=Li.load(pd))!==null&&t!==void 0?t:e.useBrowserEstimation?md():void 0)!==null&&i!==void 0?i:0;if(this.throughput$=new S(r),this.rtt$=new S(a),this.rttAdjustedThroughput$=new S(gd(r,a,e.rttPenaltyRequestSize)),this.throughput=hd.getSmoothedValue(r,-1,e),this.rtt=hd.getSmoothedValue(a,1,e),e.useBrowserEstimation){const n=()=>{const u=vd();u&&this.throughput.next(u);const d=md();k(d)&&this.rtt.next(d)};pt&&"onchange"in pt&&this.subscription.add(B(pt,"change").subscribe(n)),n()}this.subscription.add(this.throughput.smoothed$.subscribe(n=>{vr.set(fd,n.toFixed(0))})),this.subscription.add(this.rtt.smoothed$.subscribe(n=>{vr.set(pd,n.toFixed(0))})),this.subscription.add(this.throughput.debounced$.subscribe(this.throughput$)),this.subscription.add(this.rtt.debounced$.subscribe(this.rtt$)),this.subscription.add(Ne({throughput:this.throughput.smoothed$,rtt:this.rtt.smoothed$}).pipe(w(({throughput:n,rtt:o})=>gd(n,o,e.rttPenaltyRequestSize)),re(n=>{const o=this.rttAdjustedThroughput$.getValue()||0;return Math.abs(n-o)/o>=e.changeThreshold})).subscribe(this.rttAdjustedThroughput$))}destroy(){this.concurrentDownloads.clear(),this.subscription.unsubscribe()}trackXHR(e){let t=0,i=me();const r=new ae;switch(this.subscription.add(r),this.concurrentDownloads.add(e),e.readyState){case 4:break;case 3:case 2:r.add(B(e,"progress").pipe(ge()).subscribe(a=>{t=a.loaded,i=me()}));break;case 1:case 0:r.add(B(e,"loadstart").subscribe(()=>{t=0,i=me()}));break}r.add(B(e,"loadend").subscribe(a=>{if(e.status===200){const n=a.loaded,o=me(),u=n-t,d=o-i;this.addRawSpeed(u,d,1)}this.concurrentDownloads.delete(e),r.unsubscribe()}))}trackStream(e){const t=e.getReader();if(!t){e.cancel("Could not get reader");return}let i=0;const r=me();let a=0,n=me();const o=d=>{this.concurrentDownloads.delete(e),t.releaseLock(),e.cancel(`Throughput Estimator error: ${d}`).catch(()=>{})},u=({done:d,value:l})=>ue(this,void 0,void 0,function*(){d?(this.addRawSpeed(i,me()-r,1),this.concurrentDownloads.delete(e)):l&&(i+=l.byteLength,a+=l.byteLength,a>=this.tuningConfig.streamMinSampleSize&&me()-n>=this.tuningConfig.streamMinSampleTime&&(this.addRawSpeed(a,me()-n,this.concurrentDownloads.size),a=0,n=me()),yield t==null?void 0:t.read().then(u,o))});this.concurrentDownloads.add(e),t==null||t.read().then(u,o)}addRawSpeed(e,t,i=1){if(Li.sanityCheck(e,t)){const r=e*8/t;this.throughput.next(r*i)}}addRawThroughput(e){this.throughput.next(e)}addRawRtt(e){this.rtt.next(e)}static sanityCheck(e,t){const i=e*8/t;return!(!i||!isFinite(i)||i>1e6||i<30||e<10*1024||t<=20)}static load(e){var t;const i=vr.get(e);if(k(i))return(t=parseInt(i,10))!==null&&t!==void 0?t:void 0}}const Sd={configName:["core"],throughputEstimator:{type:"EmaAndMa",emaAlphaSlow:.2,emaAlphaFast:.7,emaAlpha:.45,basisTrendChangeCount:10,changeThreshold:.05,useBrowserEstimation:!0,rttPenaltyRequestSize:1*1024*1024,streamMinSampleSize:10*1024,streamMinSampleTime:300,deviationDepth:20,deviationFactor:.5},autoTrackSelection:{bitrateFactorAtEmptyBuffer:1.8,bitrateFactorAtFullBuffer:1.2,usePixelRatio:!0,limitByContainer:!0,containerSizeFactor:2,lazyQualitySwitch:!0,minBufferToSwitchUp:.4,considerPlaybackRate:!1,trackCooldown:3e3},droppedFramesChecker:{enabled:!1,percentLimit:.1,checkTime:1e3,countLimit:3,tickCountAfterQualityChange:5,qualityUpWaitingTime:5e3,minQualityBanLimit:He.Q_480P},dash:{forwardBufferTarget:6e4,forwardBufferTargetAuto:6e4,forwardBufferTargetManual:5*6e4,forwardBufferTargetPreload:5e3,minSafeBufferThreshold:.5,bufferPruningSafeZone:1e3,segmentRequestSize:1*1024*1024,representationSwitchForwardBufferGap:3e3,enableSubSegmentBufferFeeding:!0,segmentTimelineTolerance:100,useFetchPriorityHints:!0},live:{minBuffer:3e3,minBufferSegments:3,lowLatencyMinBuffer:1e3,lowLatencyMinBufferSegments:1,isLiveCatchUpMode:!1,lowLatencyActiveLiveDelay:3e3,activeLiveDelay:5e3,maxPausedTime:5e3},downloadBackoff:{bufferThreshold:100,start:100,factor:2,max:3*1e3,random:.1},enableWakeLock:!0,enableTelemetryAtStart:!1,forceFormat:void 0,formatsToAvoid:[],disableChromecast:!1,chromecastReceiverId:void 0,useWebmBigRequest:!1,webmCodec:_t.VP9,androidPreferredFormat:ft.MPEG,preferCMAF:!1,preferWebRTC:!1,bigRequestMinInitSize:50*1024,bigRequestMinDataSize:1*1024*1024,stripRangeHeader:!0,flushShortLoopedBuffers:!0,insufficientBufferRuleMargin:1e4,dashSeekInSegmentDurationThreshold:3*60*1e3,dashSeekInSegmentAlwaysSeekDelta:1e4,endGapTolerance:300,stallIgnoreThreshold:33,gapWatchdogInterval:50,requestQuick:!1,useDashJs:!1,useDashJsCMAF:!0,useHlsJs:!0,useDashAbortPartiallyFedSegment:!1,useNativeHLSTextTracks:!1,isAudioDisabled:!1,autoplayOnlyInActiveTab:!0,dynamicImportTimeout:5e3,maxPlaybackTransitionInterval:2e4,providerErrorLimit:3,webrtc:{connectionRetryMaxNumber:3},spherical:{enabled:!1,fov:{x:135,y:76},rotationSpeed:45,maxYawAngle:175,rotationSpeedCorrection:10,degreeToPixelCorrection:5,speedFadeTime:2e3,speedFadeThreshold:50}},wT=s=>{var e;return Object.assign(Object.assign({},wl(s,Sd)),{configName:[...(e=s.configName)!==null&&e!==void 0?e:[],...Sd.configName]})};var bd=({seekState:s,position$:e})=>V(s.stateChangeEnded$.pipe(w(({to:t})=>{var i;return t.state===W.None?void 0:((i=t.position)!==null&&i!==void 0?i:NaN)/1e3}),re(k)),e.pipe(re(()=>s.getState().state===W.None))),kT=s=>{const e=typeof s.container=="string"?document.getElementById(s.container):s.container;return P(e,`Wrong container or containerId {${s.container}}`),e};class xT{constructor(e={configName:[]}){if(this.subscription=new ae,this.logger=new kl,this.abrLogger=this.logger.createComponentLog("ABR"),this.isPlaybackStarted=!1,this.desiredState={playbackState:new ce(p.STOPPED),seekState:new ce({state:W.None}),volume:new ce({volume:1,muted:!1}),videoTrack:new ce(void 0),autoVideoTrackSwitching:new ce(!0),autoVideoTrackLimits:new ce({}),isLooped:new ce(!1),playbackRate:new ce(1),externalTextTracks:new ce([]),internalTextTracks:new ce([]),currentTextTrack:new ce(void 0),textTrackCuesSettings:new ce({}),cameraOrientation:new ce({x:0,y:0})},this.info={playbackState$:new S(p.STOPPED),position$:new S(0),duration$:new S(1/0),muted$:new S(!1),volume$:new S(1),availableQualities$:new S([]),availableQualitiesFps$:new S({}),availableAudioTracks$:new S([]),isAudioAvailable$:new S(!0),currentQuality$:new S(void 0),isAutoQualityEnabled$:new S(!0),autoQualityLimitingAvailable$:new S(!1),autoQualityLimits$:new S({}),currentPlaybackRate$:new S(1),currentBuffer$:new S({start:0,end:0}),isBuffering$:new S(!0),isStalled$:new S(!1),isEnded$:new S(!1),isLooped$:new S(!1),isLive$:new S(void 0),canChangePlaybackSpeed$:new S(void 0),atLiveEdge$:new S(void 0),atLiveDurationEdge$:new S(void 0),liveTime$:new S(void 0),liveBufferTime$:new S(void 0),currentFormat$:new S(void 0),availableTextTracks$:new S([]),currentTextTrack$:new S(void 0),throughputEstimation$:new S(void 0),rttEstimation$:new S(void 0),videoBitrate$:new S(void 0),hostname$:new S(void 0),httpConnectionType$:new S(void 0),httpConnectionReused$:new S(void 0),surface$:new S(At.NONE),chromecastState$:new S($e.NOT_AVAILABLE),chromecastDeviceName$:new S(void 0),intrinsicVideoSize$:new S(void 0),availableSources$:new S(void 0),is3DVideo$:new S(!1)},this.events={inited$:new x,ready$:new x,started$:new x,playing$:new x,paused$:new x,stopped$:new x,willStart$:new x,willResume$:new x,willPause$:new x,willStop$:new x,willDestruct$:new x,watchCoverageRecord$:new x,watchCoverageLive$:new x,managedError$:new x,fatalError$:new x,ended$:new x,looped$:new x,seeked$:new x,willSeek$:new x,firstBytes$:new x,firstFrame$:new x,canplay$:new x,log$:new x},this.experimental={element$:new S(void 0),tuningConfigName$:new S([]),enableDebugTelemetry$:new S(!1),dumpTelemetry:qS},this.initLogs(),this.tuning=wT(e),this.experimental.tuningConfigName$.next(this.tuning.configName),this.chromecastInitializer=new Il({receiverApplicationId:e.chromecastReceiverId,isDisabled:e.disableChromecast,dependencies:{logger:this.logger}}),this.throughputEstimator=new Li(this.tuning.throughputEstimator),this.initChromecastSubscription(),this.initDesiredStateSubscriptions(),Proxy&&Reflect)return new Proxy(this,{get:(t,i,r)=>{const a=Reflect.get(t,i,r);return typeof a!="function"?a:(...n)=>{try{return a.apply(t,n)}catch(o){const u=n.map(c=>JSON.stringify(c,(h,f)=>{const v=typeof f;return["number","string","boolean"].includes(v)?f:f===null?null:`<${v}>`})),d=`Player.${String(i)}`,l=`Exception calling ${d} (${u.join(", ")})`;throw this.events.fatalError$.next({id:d,category:L.WTF,message:l,thrown:o}),o}}}})}initVideo(e){var t,i,r;return this.config=e,this.domContainer=kT(e),this.chromecastInitializer.contentId=(t=e.meta)===null||t===void 0?void 0:t.videoId,this.providerContainer=new TT({sources:e.sources,meta:(i=e.meta)!==null&&i!==void 0?i:{},failoverHosts:(r=e.failoverHosts)!==null&&r!==void 0?r:[],container:this.domContainer,desiredState:this.desiredState,dependencies:{throughputEstimator:this.throughputEstimator,chromecastInitializer:this.chromecastInitializer,logger:this.logger,abrLogger:this.abrLogger},tuning:this.tuning}),this.initProviderContainerSubscription(this.providerContainer),this.initStartingVideoTrack(this.providerContainer),this.providerContainer.init(),this.setMuted(this.tuning.isAudioDisabled),this.initDebugTelemetry(),this.initWakeLock(),this}destroy(){var e;this.events.willDestruct$.next(),this.stop(),(e=this.providerContainer)===null||e===void 0||e.destroy(),this.throughputEstimator.destroy(),this.chromecastInitializer.destroy(),this.subscription.unsubscribe()}prepare(){const e=this.desiredState.playbackState;return e.getState()===p.STOPPED&&e.startTransitionTo(p.READY),this}play(){const e=()=>{const t=this.desiredState.playbackState;t.getState()!==p.PLAYING&&t.startTransitionTo(p.PLAYING)};return document.hidden&&this.tuning.autoplayOnlyInActiveTab?B(document,"visibilitychange").pipe(ge()).subscribe(e):e(),this}pause(){const e=this.desiredState.playbackState;return e.getState()!==p.PAUSED&&e.startTransitionTo(p.PAUSED),this}stop(){const e=this.desiredState.playbackState;return e.getState()!==p.STOPPED&&e.startTransitionTo(p.STOPPED),this}seekTime(e,t=!0){const i=this.info.duration$.getValue(),r=this.info.isLive$.getValue();return e>=i&&!r&&(e=i-.1),this.events.willSeek$.next({from:this.getExactTime(),to:e}),this.desiredState.seekState.setState({state:W.Requested,position:e*1e3,forcePrecise:t}),this}seekPercent(e){const t=this.info.duration$.getValue();return isFinite(t)&&this.seekTime(Math.abs(t)*e,!1),this}setVolume(e){const t=this.tuning.isAudioDisabled||this.desiredState.volume.getState().muted;return this.chromecastInitializer.castState$.getValue()===$e.CONNECTED?this.chromecastInitializer.setVolume(e):this.desiredState.volume.startTransitionTo({volume:e,muted:t}),this}setMuted(e){const t=this.tuning.isAudioDisabled||e;return this.chromecastInitializer.castState$.getValue()===$e.CONNECTED?this.chromecastInitializer.setMuted(t):this.desiredState.volume.startTransitionTo({volume:this.desiredState.volume.getState().volume,muted:t}),this}setQuality(e){P(this.providerContainer);const t=this.providerContainer.providerOutput.availableVideoTracks$.getValue();t.length||(this.explicitInitialQuality=e);const i=t.find(r=>r.quality===e);return i&&this.desiredState.videoTrack.startTransitionTo(i.id),this}setAutoQuality(e){return this.desiredState.autoVideoTrackSwitching.startTransitionTo(e),this}setAutoQualityLimits(e){return this.desiredState.autoVideoTrackLimits.startTransitionTo(e),this}setPlaybackRate(e){var t;P(this.providerContainer);const i=(t=this.providerContainer)===null||t===void 0?void 0:t.providerOutput.element$.getValue();return i&&(this.desiredState.playbackRate.setState(e),i.playbackRate=e),this}setExternalTextTracks(e){return this.desiredState.externalTextTracks.startTransitionTo(e.map(t=>Object.assign({type:"external"},t))),this}selectTextTrack(e){var t,i,r;return e!==void 0&&this.desiredState.currentTextTrack.getState()===void 0&&this.desiredState.currentTextTrack.getPrevState()===void 0&&((t=this.providerContainer)===null||t===void 0?void 0:t.providerOutput.availableTextTracks$.getValue().length)===0?(i=this.providerContainer)===null||i===void 0||i.providerOutput.availableTextTracks$.pipe(re(a=>a.length>0),ge()).subscribe(a=>{a.find(n=>n.id===e)&&this.desiredState.currentTextTrack.startTransitionTo(e)}):(e===void 0||!((r=this.providerContainer)===null||r===void 0)&&r.providerOutput.availableTextTracks$.getValue().find(a=>a.id===e))&&this.desiredState.currentTextTrack.startTransitionTo(e),this}setTextTrackCueSettings(e){return this.desiredState.textTrackCuesSettings.startTransitionTo(e),this}setLooped(e){return this.desiredState.isLooped.startTransitionTo(e),this}toggleChromecast(){this.chromecastInitializer.toggleConnection()}startCameraManualRotation(e,t){const i=this.getScene3D();return i&&i.startCameraManualRotation(e,t),this}stopCameraManualRotation(e=!1){const t=this.getScene3D();return t&&t.stopCameraManualRotation(e),this}moveCameraFocusPX(e,t){const i=this.getScene3D();if(i){const r=i.getCameraRotation(),a=i.pixelToDegree({x:e,y:t});this.desiredState.cameraOrientation.setState({x:r.x+a.x,y:r.y+a.y})}return this}holdCamera(){const e=this.getScene3D();return e&&e.holdCamera(),this}releaseCamera(){const e=this.getScene3D();return e&&e.releaseCamera(),this}getExactTime(){P(this.providerContainer);const e=this.providerContainer.providerOutput.element$.getValue();if(ie(e))return this.info.position$.getValue();const t=this.desiredState.seekState.getState(),i=t.state===W.None?void 0:t.position;return k(i)?i/1e3:e.currentTime}getAllLogs(){return this.logger.getAllLogs()}getScene3D(){var e,t;const i=(e=this.providerContainer)===null||e===void 0?void 0:e.current$.getValue();if(!((t=i==null?void 0:i.provider)===null||t===void 0)&&t.scene3D)return i.provider.scene3D}setIntrinsicVideoSize(...e){const t={width:e.reduce((i,{width:r})=>i||r||0,0),height:e.reduce((i,{height:r})=>i||r||0,0)};t.width&&t.height&&this.info.intrinsicVideoSize$.next({width:t.width,height:t.height})}initDesiredStateSubscriptions(){this.subscription.add(V(this.desiredState.playbackState.stateChangeStarted$,this.desiredState.playbackState.forceChanged$).pipe(w(e=>e.to)).subscribe(this.info.playbackState$)).add(this.desiredState.isLooped.stateChangeEnded$.pipe(w(e=>e.to)).subscribe(this.info.isLooped$)).add(this.desiredState.playbackRate.stateChangeEnded$.pipe(w(e=>e.to)).subscribe(this.info.currentPlaybackRate$)).add(this.desiredState.autoVideoTrackSwitching.stateChangeEnded$.pipe(w(e=>e.to)).subscribe(this.info.isAutoQualityEnabled$)).add(this.desiredState.autoVideoTrackLimits.stateChangeEnded$.pipe(w(e=>e.to)).subscribe(this.info.autoQualityLimits$)),this.subscription.add(this.desiredState.playbackState.stateChangeStarted$.pipe(re(({from:e})=>e===p.STOPPED),ge()).subscribe(()=>{this.initedAt=me(),this.events.inited$.next()})).add(this.desiredState.playbackState.stateChangeEnded$.subscribe(e=>{switch(e.to){case p.READY:this.events.ready$.next();break;case p.PLAYING:this.isPlaybackStarted||this.events.started$.next(),this.isPlaybackStarted=!0,this.events.playing$.next();break;case p.PAUSED:this.events.paused$.next();break;case p.STOPPED:this.events.stopped$.next()}})).add(this.desiredState.playbackState.stateChangeStarted$.subscribe(e=>{switch(e.to){case p.PAUSED:this.events.willPause$.next();break;case p.PLAYING:this.isPlaybackStarted?this.events.willResume$.next():this.events.willStart$.next();break;case p.STOPPED:this.events.willStop$.next();break}}))}initProviderContainerSubscription(e){this.subscription.add(e.providerOutput.willSeekEvent$.subscribe(()=>{const n=this.desiredState.seekState.getState();n.state===W.Requested?this.desiredState.seekState.setState(Object.assign(Object.assign({},n),{state:W.Applying})):this.events.managedError$.next({id:`WillSeekIn${n.state}`,category:L.WTF,message:"Received unexpeceted willSeek$"})})).add(e.providerOutput.seekedEvent$.subscribe(()=>{this.desiredState.seekState.getState().state===W.Applying&&(this.desiredState.seekState.setState({state:W.None}),this.events.seeked$.next())})).add(e.current$.pipe(w(n=>n.type)).subscribe(this.info.currentFormat$)).add(e.current$.pipe(w(n=>n.destination),ve()).subscribe(()=>{this.isPlaybackStarted=!1})).add(e.providerOutput.availableVideoTracks$.pipe(w(n=>n.map(({quality:o})=>o).sort((o,u)=>Oi(o)?1:Oi(u)?-1:Ii(u,o)?1:-1))).subscribe(this.info.availableQualities$)).add(e.providerOutput.availableVideoTracks$.subscribe(n=>{const o={};for(const u of n)u.fps&&(o[u.quality]=u.fps);this.info.availableQualitiesFps$.next(o)})).add(e.providerOutput.availableAudioTracks$.subscribe(this.info.availableAudioTracks$)).add(e.providerOutput.isAudioAvailable$.subscribe(this.info.isAudioAvailable$)).add(e.providerOutput.currentVideoTrack$.subscribe(n=>{this.info.currentQuality$.next(n==null?void 0:n.quality),this.info.videoBitrate$.next(n==null?void 0:n.bitrate)})).add(e.providerOutput.hostname$.pipe(ve()).subscribe(this.info.hostname$)).add(e.providerOutput.httpConnectionType$.pipe(ve()).subscribe(this.info.httpConnectionType$)).add(e.providerOutput.httpConnectionReused$.pipe(ve()).subscribe(this.info.httpConnectionReused$)).add(e.providerOutput.currentTextTrack$.subscribe(this.info.currentTextTrack$)).add(e.providerOutput.availableTextTracks$.subscribe(this.info.availableTextTracks$)).add(e.providerOutput.autoVideoTrackLimitingAvailable$.subscribe(this.info.autoQualityLimitingAvailable$)).add(e.providerOutput.autoVideoTrackLimits$.subscribe(n=>{this.desiredState.autoVideoTrackLimits.setState(n!=null?n:{})})).add(e.providerOutput.currentBuffer$.pipe(w(n=>n?{start:n.from,end:n.to}:{start:0,end:0})).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.canChangePlaybackSpeed$.subscribe(this.info.canChangePlaybackSpeed$)).add(e.providerOutput.liveTime$.subscribe(this.info.liveTime$)).add(e.providerOutput.liveBufferTime$.subscribe(this.info.liveBufferTime$)).add(Ne({isLive:e.providerOutput.isLive$,isLowLatency:e.providerOutput.isLowLatency$,position:bd({seekState:this.desiredState.seekState,position$:e.providerOutput.position$})}).pipe(w(({isLive:n,position:o,isLowLatency:u})=>{const d=u?this.tuning.live.lowLatencyActiveLiveDelay:this.tuning.live.activeLiveDelay;return n&&Math.abs(o)<d/1e3}),ve(),Is(n=>n&&this.setPlaybackRate(1))).subscribe(this.info.atLiveEdge$)).add(Ne({isLive:e.providerOutput.isLive$,position:e.providerOutput.position$,duration:e.providerOutput.duration$}).pipe(w(({isLive:n,position:o,duration:u})=>n&&Math.abs(u)-Math.abs(o)<this.tuning.live.activeLiveDelay),ve(),Is(n=>n&&this.setPlaybackRate(1))).subscribe(this.info.atLiveDurationEdge$)).add(e.providerOutput.volume$.pipe(w(n=>n.muted),ve()).subscribe(this.info.muted$)).add(e.providerOutput.volume$.pipe(w(n=>n.volume),ve()).subscribe(this.info.volume$)).add(bd({seekState:this.desiredState.seekState,position$:e.providerOutput.position$}).subscribe(this.info.position$)).add(V(e.providerOutput.endedEvent$.pipe(ui(!0)),e.providerOutput.seekedEvent$.pipe(ui(!1))).pipe(ve()).subscribe(this.info.isEnded$)).add(e.providerOutput.endedEvent$.subscribe(this.events.ended$)).add(e.providerOutput.loopedEvent$.subscribe(this.events.looped$)).add(e.providerError$.subscribe(this.events.managedError$)).add(e.noAvailableProvidersError$.pipe(w(n=>({id:n?`No${n}`:"NoProviders",category:L.VIDEO_PIPELINE,message:n?`${n} was forced but failed or not available`:"No suitable providers or all providers failed"}))).subscribe(this.events.fatalError$)).add(e.providerOutput.element$.subscribe(this.experimental.element$)).add(e.providerOutput.firstBytesEvent$.pipe(ge(),w(n=>n!=null?n:me()-this.initedAt)).subscribe(this.events.firstBytes$)).add(e.providerOutput.firstFrameEvent$.pipe(ge(),w(()=>me()-this.initedAt)).subscribe(this.events.firstFrame$)).add(e.providerOutput.canplay$.pipe(ge(),w(()=>me()-this.initedAt)).subscribe(this.events.canplay$)).add(this.throughputEstimator.throughput$.subscribe(this.info.throughputEstimation$)).add(this.throughputEstimator.rtt$.subscribe(this.info.rttEstimation$)).add(e.providerOutput.availableSources$.subscribe(this.info.availableSources$));const t=new S(!1);this.subscription.add(e.providerOutput.seekedEvent$.subscribe(()=>t.next(!1))).add(e.providerOutput.willSeekEvent$.subscribe(()=>t.next(!0)));const i=new S(!0);this.subscription.add(e.current$.subscribe(()=>i.next(!0))).add(this.desiredState.playbackState.stateChangeEnded$.pipe(re(({to:n})=>n===p.PLAYING),ge()).subscribe(()=>i.next(!1)));let r=0;const a=V(e.providerOutput.isBuffering$,t,i).pipe(w(()=>{const n=e.providerOutput.isBuffering$.getValue(),o=t.getValue()||i.getValue();return n&&!o}),ve());this.subscription.add(a.subscribe(n=>{n?r=window.setTimeout(()=>this.info.isStalled$.next(!0),this.tuning.stallIgnoreThreshold):(window.clearTimeout(r),this.info.isStalled$.next(!1))})),this.subscription.add(V(e.providerOutput.canplay$,e.providerOutput.firstFrameEvent$,e.providerOutput.firstBytesEvent$).subscribe(()=>{const n=e.providerOutput.element$.getValue();this.setIntrinsicVideoSize({width:n==null?void 0:n.videoWidth,height:n==null?void 0:n.videoHeight})})).add(e.providerOutput.currentVideoTrack$.subscribe(n=>{var o,u;const d=e.providerOutput.element$.getValue();this.setIntrinsicVideoSize({width:(o=n==null?void 0:n.size)===null||o===void 0?void 0:o.width,height:(u=n==null?void 0:n.size)===null||u===void 0?void 0:u.height},{width:d==null?void 0:d.videoWidth,height:d==null?void 0:d.videoHeight})})).add(e.providerOutput.is3DVideo$.subscribe(this.info.is3DVideo$)),this.subscription.add(V(e.providerOutput.inPiP$,e.providerOutput.inFullscreen$,e.providerOutput.element$,this.chromecastInitializer.castState$).subscribe(()=>{const n=e.providerOutput.inPiP$.getValue(),o=e.providerOutput.inFullscreen$.getValue(),u=e.providerOutput.element$.getValue(),d=this.chromecastInitializer.castState$.getValue();let l;d===$e.CONNECTED?l=At.SECOND_SCREEN:u?n?l=At.PIP:o?l=At.FULLSCREEN:l=At.INLINE:l=At.NONE,this.info.surface$.getValue()!==l&&this.info.surface$.next(l)}))}initChromecastSubscription(){this.subscription.add(this.chromecastInitializer.castState$.subscribe(this.info.chromecastState$)),this.subscription.add(this.chromecastInitializer.connection$.pipe(w(e=>e==null?void 0:e.castDevice.friendlyName)).subscribe(this.info.chromecastDeviceName$)),this.subscription.add(this.chromecastInitializer.errorEvent$.subscribe(this.events.managedError$))}initStartingVideoTrack(e){const t=new ae;this.subscription.add(t),this.subscription.add(e.current$.pipe(ve((i,r)=>i.provider===r.provider)).subscribe(()=>{t.unsubscribe(),t.add(e.providerOutput.availableVideoTracks$.pipe(re(i=>i.length>0),ge()).subscribe(i=>{this.setStartingVideoTrack(i)}))}))}setStartingVideoTrack(e){let t;this.explicitInitialQuality&&(t=e.find(({quality:i})=>i===this.explicitInitialQuality),this.explicitInitialQuality=void 0),t||(t=gi(e,{container:this.domContainer.getBoundingClientRect(),throughput:this.throughputEstimator.throughput$.getValue(),tuning:this.tuning.autoTrackSelection,limits:this.desiredState.autoVideoTrackLimits.getState(),playbackRate:this.info.currentPlaybackRate$.getValue(),forwardBufferHealth:0,abrLogger:this.abrLogger})),this.desiredState.videoTrack.startTransitionTo(t.id),this.info.currentQuality$.next(t.quality),this.info.videoBitrate$.next(t.bitrate)}initLogs(){this.subscription.add(V(this.desiredState.videoTrack.stateChangeStarted$.pipe(w(e=>({transition:e,entity:"quality",type:"start"}))),this.desiredState.videoTrack.stateChangeEnded$.pipe(w(e=>({transition:e,entity:"quality",type:"end"}))),this.desiredState.autoVideoTrackSwitching.stateChangeStarted$.pipe(w(e=>({transition:e,entity:"autoQualityEnabled",type:"start"}))),this.desiredState.autoVideoTrackSwitching.stateChangeEnded$.pipe(w(e=>({transition:e,entity:"autoQualityEnabled",type:"end"}))),this.desiredState.seekState.stateChangeStarted$.pipe(w(e=>({transition:e,entity:"seekState",type:"start"}))),this.desiredState.seekState.stateChangeEnded$.pipe(w(e=>({transition:e,entity:"seekState",type:"end"}))),this.desiredState.playbackState.stateChangeStarted$.pipe(w(e=>({transition:e,entity:"playbackState",type:"start"}))),this.desiredState.playbackState.stateChangeEnded$.pipe(w(e=>({transition:e,entity:"playbackState",type:"end"})))).pipe(w(e=>({component:"desiredState",message:`[${e.entity} change] ${e.type}: ${JSON.stringify(e.transition)}`}))).subscribe(this.logger.log)),this.subscription.add(this.logger.log$.subscribe(this.events.log$))}initDebugTelemetry(){var e;const t=(e=this.providerContainer)===null||e===void 0?void 0:e.providerOutput;P(this.providerContainer),P(t),jS(),this.experimental.enableDebugTelemetry$.next(this.tuning.enableTelemetryAtStart),[this.experimental.enableDebugTelemetry$.subscribe(i=>YS(i)),this.providerContainer.current$.subscribe(({type:i})=>ms("provider",i)),t.duration$.subscribe(i=>ms("duration",i)),t.availableVideoTracks$.pipe(re(i=>!!i.length),ge()).subscribe(i=>ms("tracks",i)),this.events.fatalError$.subscribe(new rt("fatalError")),this.events.managedError$.subscribe(new rt("managedError")),t.position$.subscribe(new rt("position")),t.currentVideoTrack$.pipe(w(i=>i==null?void 0:i.quality)).subscribe(new rt("quality")),this.info.currentBuffer$.subscribe(new rt("buffer")),t.isBuffering$.subscribe(new rt("isBuffering"))].forEach(i=>this.subscription.add(i)),ms("codecs",pT())}initWakeLock(){if(!window.navigator.wakeLock||!this.tuning.enableWakeLock)return;let e;const t=()=>{e==null||e.release(),e=void 0},i=()=>ue(this,void 0,void 0,function*(){t(),e=yield window.navigator.wakeLock.request("screen").catch(r=>{r instanceof DOMException&&r.name==="NotAllowedError"||this.events.managedError$.next({id:"WakeLock",category:L.DOM,message:String(r)})})});this.subscription.add(V(B(document,"visibilitychange"),B(document,"fullscreenchange"),this.desiredState.playbackState.stateChangeEnded$).subscribe(()=>{const r=document.visibilityState==="visible",a=this.desiredState.playbackState.getState()===p.PLAYING,n=!!e&&!(e!=null&&e.released);r&&a?n||i():t()})).add(this.events.willDestruct$.subscribe(t))}}const LT=`@vkontakte/videoplayer-core@${Rl}`;export{$e as ChromecastState,Mi as HttpConnectionType,BT as Observable,p as PlaybackState,xT as Player,LT as SDK_VERSION,NT as Subject,FT as Subscription,At as Surface,Rl as VERSION,UT as ValueSubject,y as VideoFormat,VT as VideoQuality};
|