@vkontakte/videoplayer-core 2.0.102-beta.3 → 2.0.103-dev.c555938f.0
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 +4 -4
- package/es2015.esm.js +4 -4
- package/es2018.cjs.js +4 -4
- package/es2018.esm.js +4 -4
- package/esnext.cjs.js +4 -4
- package/esnext.esm.js +4 -4
- package/evergreen.esm.js +4 -4
- package/package.json +2 -2
package/es2015.esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-core v2.0.
|
|
3
|
-
* Tue,
|
|
4
|
-
* https://st.mycdn.me/static/vkontakte-videoplayer/2-0-
|
|
2
|
+
* @vkontakte/videoplayer-core v2.0.103-dev.c555938f.0
|
|
3
|
+
* Tue, 28 May 2024 09:13:35 GMT
|
|
4
|
+
* https://st.mycdn.me/static/vkontakte-videoplayer/2-0-103/doc/
|
|
5
5
|
*/
|
|
6
|
-
import{ValueSubject as y,Subject as D,Subscription as re,isNonNullable as R,ErrorCategory as I,isNullable as K,fromEvent as x,assertNever as H,merge as F,tap as Oi,map as $,observableFrom as He,filterChanged as pe,assertNonNullable as P,debounce as rt,getHighestQuality as Tu,timeout as Eu,getCurrentBrowser as Na,CurrentClientBrowser as yl,combine as Ve,once as _e,mapTo as _s,filter as fe,VideoQuality as Le,now as le,assertNotEmptyArray as $u,videoSizeToQuality as Mt,isInvariantQuality as Bt,isHigher as hi,isLower as $s,isHigherOrEqual as ua,isLowerOrEqual as Cs,interval as Ci,videoQualityToHeight as Au,abortable as Ce,getExponentialDelay as As,throttle as wu,Observable as Fa,observeElementSize as ku,isIOS as Pu,CurrentClientDevice as Ru,safeStorage as hr,fillWithDefault as _u,Logger as Cu}from"@vkontakte/videoplayer-shared/es2015.esm.js";import{Observable as FT,Subject as VT,Subscription as UT,ValueSubject as HT,VideoQuality as jT}from"@vkontakte/videoplayer-shared/es2015.esm.js";const Iu="2.0.102-beta.3";var p;(function(i){i.STOPPED="stopped",i.READY="ready",i.PLAYING="playing",i.PAUSED="paused"})(p||(p={}));var b;(function(i){i.MPEG="MPEG",i.DASH="DASH_SEP",i.DASH_SEP="DASH_SEP",i.DASH_SEP_VK="DASH_SEP",i.DASH_WEBM="DASH_WEBM",i.DASH_WEBM_AV1="DASH_WEBM_AV1",i.DASH_WEBM_VK="DASH_WEBM",i.DASH_ONDEMAND="DASH_ONDEMAND",i.DASH_ONDEMAND_VK="DASH_ONDEMAND",i.DASH_LIVE="DASH_LIVE",i.DASH_LIVE_CMAF="DASH_LIVE_CMAF",i.DASH_LIVE_WEBM="DASH_LIVE_WEBM",i.HLS="HLS",i.HLS_ONDEMAND="HLS_ONDEMAND",i.HLS_JS="HLS",i.HLS_LIVE="HLS_LIVE",i.HLS_LIVE_CMAF="HLS_LIVE_CMAF",i.WEB_RTC_LIVE="WEB_RTC_LIVE"})(b||(b={}));var Ae;(function(i){i.SCREEN="SCREEN",i.CHROMECAST="CHROMECAST"})(Ae||(Ae={}));var ye;(function(i){i.NOT_AVAILABLE="NOT_AVAILABLE",i.AVAILABLE="AVAILABLE",i.CONNECTING="CONNECTING",i.CONNECTED="CONNECTED"})(ye||(ye={}));var ca;(function(i){i.HTTP1="http1",i.HTTP2="http2",i.QUIC="quic"})(ca||(ca={}));var Y;(function(i){i.None="none",i.Requested="requested",i.Applying="applying"})(Y||(Y={}));var bt;(function(i){i.NONE="none",i.INLINE="inline",i.FULLSCREEN="fullscreen",i.SECOND_SCREEN="second_screen",i.PIP="pip"})(bt||(bt={}));function te(i,e,t,s){function r(a){return a instanceof t?a:new t(function(n){n(a)})}return new(t||(t=Promise))(function(a,n){function o(d){try{l(s.next(d))}catch(c){n(c)}}function u(d){try{l(s.throw(d))}catch(c){n(c)}}function l(d){d.done?a(d.value):r(d.value).then(o,u)}l((s=s.apply(i,e||[])).next())})}function M(i){return this instanceof M?(this.v=i,this):new M(i)}function Ie(i,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=t.apply(i,e||[]),r,a=[];return r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r;function n(h){s[h]&&(r[h]=function(f){return new Promise(function(m,v){a.push([h,f,m,v])>1||o(h,f)})})}function o(h,f){try{u(s[h](f))}catch(m){c(a[0][3],m)}}function u(h){h.value instanceof M?Promise.resolve(h.value.v).then(l,d):c(a[0][2],h)}function l(h){o("next",h)}function d(h){o("throw",h)}function c(h,f){h(f),a.shift(),a.length&&o(a[0][0],a[0][1])}}var Du=i=>new Promise((e,t)=>{const s=document.createElement("script");s.setAttribute("src",i),s.onload=()=>e,s.onerror=()=>t,document.body.appendChild(s)});class Lu{constructor(e){var t;this.connection$=new y(void 0),this.castState$=new y(ye.NOT_AVAILABLE),this.errorEvent$=new D,this.realCastState$=new y(ye.NOT_AVAILABLE),this.subscription=new re,this.params=e,this.log=this.params.dependencies.logger.createComponentLog("ChromecastInitializer");const s="chrome"in window;if(this.log({message:`[constructor] receiverApplicationId: ${this.params.receiverApplicationId}, isDisabled: ${this.params.isDisabled}, isSupported: ${s}`}),e.isDisabled||!s)return;const r=R((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||Du("https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1").catch(()=>this.errorEvent$.next({id:"ChromecastLoading",category:I.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 s,r,a;(a=(r=(s=cast.framework.CastContext.getInstance())===null||s===void 0?void 0:s.getCurrentSession())===null||r===void 0?void 0:r.getMediaSession())===null||a===void 0||a.stop(new chrome.cast.media.StopRequest,e,t)})}toggleConnection(){R(this.connection$.getValue())?this.disconnect():this.connect()}setVolume(e){const t=this.connection$.getValue();K(t)||(t.remotePlayer.volumeLevel=e,t.remotePlayerController.setVolumeLevel())}setMuted(e){const t=this.connection$.getValue();K(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),s=cast.framework.CastContext.getInstance();this.subscription.add(x(s,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=s.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(F(x(s,cast.framework.CastContextEventType.CAST_STATE_CHANGED).pipe(Oi(r=>{this.log({message:`[cast.framework.RemotePlayerEventType.CAST_STATE_CHANGED]: ${JSON.stringify(r)}`})}),$(r=>r.castState)),He([s.getCastState()])).pipe(pe(),$(xu),Oi(r=>{this.log({message:`realCastState$: ${r}`})})).subscribe(this.realCastState$)).add(this.realCastState$.subscribe(r=>{var a;const n=r===ye.CONNECTED,o=R(this.connection$.getValue());if(n&&!o){const u=s.getCurrentSession();P(u);const l=u.getCastDevice(),d=(a=u.getMediaSession())===null||a===void 0?void 0:a.media.contentId;(K(d)||d===this.contentId)&&(this.log({message:"connection created"}),this.connection$.next({remotePlayer:e,remotePlayerController:t,session:u,castDevice:l}))}else!n&&o&&(this.log({message:"connection destroyed"}),this.connection$.next(void 0));this.castState$.next(r===ye.CONNECTED?R(this.connection$.getValue())?ye.CONNECTED:ye.AVAILABLE:r)}))}initializeCastApi(){var e;let t,s,r;try{t=cast.framework.CastContext.getInstance(),s=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:s,autoJoinPolicy:r}),this.initListeners()}catch(a){this.errorEvent$.next({id:"ChromecastInitializer",category:I.EXTERNAL_API,message:"[initializeCastApi] failed",thrown:a})}}}const xu=i=>{switch(i){case cast.framework.CastState.NO_DEVICES_AVAILABLE:return ye.NOT_AVAILABLE;case cast.framework.CastState.NOT_CONNECTED:return ye.AVAILABLE;case cast.framework.CastState.CONNECTING:return ye.CONNECTING;case cast.framework.CastState.CONNECTED:return ye.CONNECTED;default:return H(i)}};var fr=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Vs(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var je=function(i){try{return!!i()}catch(e){return!0}},Ou=je,Us=!Ou(function(){var i=function(){}.bind();return typeof i!="function"||i.hasOwnProperty("prototype")}),Tl=Us,El=Function.prototype,ha=El.call,Mu=Tl&&El.bind.bind(ha,ha),Ge=Tl?Mu:function(i){return function(){return ha.apply(i,arguments)}},$l=Ge,Bu=$l({}.toString),Nu=$l("".slice),Vi=function(i){return Nu(Bu(i),8,-1)},Fu=Ge,Vu=je,Uu=Vi,pr=Object,Hu=Fu("".split),ju=Vu(function(){return!pr("z").propertyIsEnumerable(0)})?function(i){return Uu(i)=="String"?Hu(i,""):pr(i)}:pr,Ui=function(i){return i==null},Gu=Ui,Yu=TypeError,Va=function(i){if(Gu(i))throw Yu("Can't call method on "+i);return i},qu=ju,Wu=Va,Hi=function(i){return qu(Wu(i))},gi={},is=function(i){return i&&i.Math==Math&&i},Ee=is(typeof globalThis=="object"&&globalThis)||is(typeof window=="object"&&window)||is(typeof self=="object"&&self)||is(typeof fr=="object"&&fr)||function(){return this}()||fr||Function("return this")(),fa=typeof document=="object"&&document.all,zu=typeof fa=="undefined"&&fa!==void 0,Al={all:fa,IS_HTMLDDA:zu},wl=Al,Qu=wl.all,ge=wl.IS_HTMLDDA?function(i){return typeof i=="function"||i===Qu}:function(i){return typeof i=="function"},Ku=Ee,Ju=ge,_n=Ku.WeakMap,Xu=Ju(_n)&&/native code/.test(String(_n)),Cn=ge,kl=Al,Zu=kl.all,ft=kl.IS_HTMLDDA?function(i){return typeof i=="object"?i!==null:Cn(i)||i===Zu}:function(i){return typeof i=="object"?i!==null:Cn(i)},ec=je,$t=!ec(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),Vt={},tc=Ee,In=ft,pa=tc.document,ic=In(pa)&&In(pa.createElement),Ua=function(i){return ic?pa.createElement(i):{}},sc=$t,rc=je,ac=Ua,Pl=!sc&&!rc(function(){return Object.defineProperty(ac("div"),"a",{get:function(){return 7}}).a!=7}),nc=$t,oc=je,Rl=nc&&oc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),lc=ft,dc=String,uc=TypeError,pt=function(i){if(lc(i))return i;throw uc(dc(i)+" is not an object")},cc=Us,ss=Function.prototype.call,Oe=cc?ss.bind(ss):function(){return ss.apply(ss,arguments)},Ha={},vr=Ha,mr=Ee,hc=ge,Dn=function(i){return hc(i)?i:void 0},Ut=function(i,e){return arguments.length<2?Dn(vr[i])||Dn(mr[i]):vr[i]&&vr[i][e]||mr[i]&&mr[i][e]},fc=Ge,Hs=fc({}.isPrototypeOf),js=typeof navigator!="undefined"&&String(navigator.userAgent)||"",_l=Ee,gr=js,Ln=_l.process,xn=_l.Deno,On=Ln&&Ln.versions||xn&&xn.version,Mn=On&&On.v8,We,Is;Mn&&(We=Mn.split("."),Is=We[0]>0&&We[0]<4?1:+(We[0]+We[1]));!Is&&gr&&(We=gr.match(/Edge\/(\d+)/),(!We||We[1]>=74)&&(We=gr.match(/Chrome\/(\d+)/),We&&(Is=+We[1])));var Cl=Is,Bn=Cl,pc=je,vc=Ee,mc=vc.String,Il=!!Object.getOwnPropertySymbols&&!pc(function(){var i=Symbol();return!mc(i)||!(Object(i)instanceof Symbol)||!Symbol.sham&&Bn&&Bn<41}),gc=Il,Dl=gc&&!Symbol.sham&&typeof Symbol.iterator=="symbol",Sc=Ut,bc=ge,yc=Hs,Tc=Dl,Ec=Object,Ll=Tc?function(i){return typeof i=="symbol"}:function(i){var e=Sc("Symbol");return bc(e)&&yc(e.prototype,Ec(i))},$c=String,Gs=function(i){try{return $c(i)}catch(e){return"Object"}},Ac=ge,wc=Gs,kc=TypeError,Ht=function(i){if(Ac(i))return i;throw kc(wc(i)+" is not a function")},Pc=Ht,Rc=Ui,Ys=function(i,e){var t=i[e];return Rc(t)?void 0:Pc(t)},Sr=Oe,br=ge,yr=ft,_c=TypeError,Cc=function(i,e){var t,s;if(e==="string"&&br(t=i.toString)&&!yr(s=Sr(t,i))||br(t=i.valueOf)&&!yr(s=Sr(t,i))||e!=="string"&&br(t=i.toString)&&!yr(s=Sr(t,i)))return s;throw _c("Can't convert object to primitive value")},xl={exports:{}},Ic=!0,Nn=Ee,Dc=Object.defineProperty,Lc=function(i,e){try{Dc(Nn,i,{value:e,configurable:!0,writable:!0})}catch(t){Nn[i]=e}return e},xc=Ee,Oc=Lc,Fn="__core-js_shared__",Mc=xc[Fn]||Oc(Fn,{}),ja=Mc,Vn=ja;(xl.exports=function(i,e){return Vn[i]||(Vn[i]=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 Ol=xl.exports,Bc=Va,Nc=Object,qs=function(i){return Nc(Bc(i))},Fc=Ge,Vc=qs,Uc=Fc({}.hasOwnProperty),nt=Object.hasOwn||function(e,t){return Uc(Vc(e),t)},Hc=Ge,jc=0,Gc=Math.random(),Yc=Hc(1 .toString),Ml=function(i){return"Symbol("+(i===void 0?"":i)+")_"+Yc(++jc+Gc,36)},qc=Ee,Wc=Ol,Un=nt,zc=Ml,Qc=Il,Kc=Dl,li=qc.Symbol,Tr=Wc("wks"),Jc=Kc?li.for||li:li&&li.withoutSetter||zc,Pe=function(i){return Un(Tr,i)||(Tr[i]=Qc&&Un(li,i)?li[i]:Jc("Symbol."+i)),Tr[i]},Xc=Oe,Hn=ft,jn=Ll,Zc=Ys,eh=Cc,th=Pe,ih=TypeError,sh=th("toPrimitive"),rh=function(i,e){if(!Hn(i)||jn(i))return i;var t=Zc(i,sh),s;if(t){if(e===void 0&&(e="default"),s=Xc(t,i,e),!Hn(s)||jn(s))return s;throw ih("Can't convert object to primitive value")}return e===void 0&&(e="number"),eh(i,e)},ah=rh,nh=Ll,Ga=function(i){var e=ah(i,"string");return nh(e)?e:e+""},oh=$t,lh=Pl,dh=Rl,rs=pt,Gn=Ga,uh=TypeError,Er=Object.defineProperty,ch=Object.getOwnPropertyDescriptor,$r="enumerable",Ar="configurable",wr="writable";Vt.f=oh?dh?function(e,t,s){if(rs(e),t=Gn(t),rs(s),typeof e=="function"&&t==="prototype"&&"value"in s&&wr in s&&!s[wr]){var r=ch(e,t);r&&r[wr]&&(e[t]=s.value,s={configurable:Ar in s?s[Ar]:r[Ar],enumerable:$r in s?s[$r]:r[$r],writable:!1})}return Er(e,t,s)}:Er:function(e,t,s){if(rs(e),t=Gn(t),rs(s),lh)try{return Er(e,t,s)}catch(r){}if("get"in s||"set"in s)throw uh("Accessors not supported");return"value"in s&&(e[t]=s.value),e};var Ws=function(i,e){return{enumerable:!(i&1),configurable:!(i&2),writable:!(i&4),value:e}},hh=$t,fh=Vt,ph=Ws,ji=hh?function(i,e,t){return fh.f(i,e,ph(1,t))}:function(i,e,t){return i[e]=t,i},vh=Ol,mh=Ml,Yn=vh("keys"),Ya=function(i){return Yn[i]||(Yn[i]=mh(i))},qa={},gh=Xu,Bl=Ee,Sh=ft,bh=ji,kr=nt,Pr=ja,yh=Ya,Th=qa,qn="Object already initialized",va=Bl.TypeError,Eh=Bl.WeakMap,Ds,Mi,Ls,$h=function(i){return Ls(i)?Mi(i):Ds(i,{})},Ah=function(i){return function(e){var t;if(!Sh(e)||(t=Mi(e)).type!==i)throw va("Incompatible receiver, "+i+" required");return t}};if(gh||Pr.state){var Xe=Pr.state||(Pr.state=new Eh);Xe.get=Xe.get,Xe.has=Xe.has,Xe.set=Xe.set,Ds=function(i,e){if(Xe.has(i))throw va(qn);return e.facade=i,Xe.set(i,e),e},Mi=function(i){return Xe.get(i)||{}},Ls=function(i){return Xe.has(i)}}else{var ei=yh("state");Th[ei]=!0,Ds=function(i,e){if(kr(i,ei))throw va(qn);return e.facade=i,bh(i,ei,e),e},Mi=function(i){return kr(i,ei)?i[ei]:{}},Ls=function(i){return kr(i,ei)}}var Nl={set:Ds,get:Mi,has:Ls,enforce:$h,getterFor:Ah},wh=Us,Fl=Function.prototype,Wn=Fl.apply,zn=Fl.call,Vl=typeof Reflect=="object"&&Reflect.apply||(wh?zn.bind(Wn):function(){return zn.apply(Wn,arguments)}),kh=Vi,Ph=Ge,Ul=function(i){if(kh(i)==="Function")return Ph(i)},Wa={},Hl={},jl={}.propertyIsEnumerable,Gl=Object.getOwnPropertyDescriptor,Rh=Gl&&!jl.call({1:2},1);Hl.f=Rh?function(e){var t=Gl(this,e);return!!t&&t.enumerable}:jl;var _h=$t,Ch=Oe,Ih=Hl,Dh=Ws,Lh=Hi,xh=Ga,Oh=nt,Mh=Pl,Qn=Object.getOwnPropertyDescriptor;Wa.f=_h?Qn:function(e,t){if(e=Lh(e),t=xh(t),Mh)try{return Qn(e,t)}catch(s){}if(Oh(e,t))return Dh(!Ch(Ih.f,e,t),e[t])};var Bh=je,Nh=ge,Fh=/#|\.prototype\./,Gi=function(i,e){var t=Uh[Vh(i)];return t==jh?!0:t==Hh?!1:Nh(e)?Bh(e):!!e},Vh=Gi.normalize=function(i){return String(i).replace(Fh,".").toLowerCase()},Uh=Gi.data={},Hh=Gi.NATIVE="N",jh=Gi.POLYFILL="P",Yl=Gi,Kn=Ul,Gh=Ht,Yh=Us,qh=Kn(Kn.bind),zs=function(i,e){return Gh(i),e===void 0?i:Yh?qh(i,e):function(){return i.apply(e,arguments)}},as=Ee,Wh=Vl,zh=Ul,Qh=ge,Kh=Wa.f,Jh=Yl,ti=Ha,Xh=zs,ii=ji,Jn=nt,Zh=function(i){var e=function(t,s,r){if(this instanceof e){switch(arguments.length){case 0:return new i;case 1:return new i(t);case 2:return new i(t,s)}return new i(t,s,r)}return Wh(i,this,arguments)};return e.prototype=i.prototype,e},Qe=function(i,e){var t=i.target,s=i.global,r=i.stat,a=i.proto,n=s?as:r?as[t]:(as[t]||{}).prototype,o=s?ti:ti[t]||ii(ti,t,{})[t],u=o.prototype,l,d,c,h,f,m,v,g,S;for(h in e)l=Jh(s?h:t+(r?".":"#")+h,i.forced),d=!l&&n&&Jn(n,h),m=o[h],d&&(i.dontCallGetSet?(S=Kh(n,h),v=S&&S.value):v=n[h]),f=d&&v?v:e[h],!(d&&typeof m==typeof f)&&(i.bind&&d?g=Xh(f,as):i.wrap&&d?g=Zh(f):a&&Qh(f)?g=zh(f):g=f,(i.sham||f&&f.sham||m&&m.sham)&&ii(g,"sham",!0),ii(o,h,g),a&&(c=t+"Prototype",Jn(ti,c)||ii(ti,c,{}),ii(ti[c],h,f),i.real&&u&&(l||!u[h])&&ii(u,h,f)))},ma=$t,ef=nt,ql=Function.prototype,tf=ma&&Object.getOwnPropertyDescriptor,za=ef(ql,"name"),sf=za&&function(){}.name==="something",rf=za&&(!ma||ma&&tf(ql,"name").configurable),af={EXISTS:za,PROPER:sf,CONFIGURABLE:rf},Wl={},nf=Math.ceil,of=Math.floor,lf=Math.trunc||function(e){var t=+e;return(t>0?of:nf)(t)},df=lf,Qa=function(i){var e=+i;return e!==e||e===0?0:df(e)},uf=Qa,cf=Math.max,hf=Math.min,ff=function(i,e){var t=uf(i);return t<0?cf(t+e,0):hf(t,e)},pf=Qa,vf=Math.min,mf=function(i){return i>0?vf(pf(i),9007199254740991):0},gf=mf,Ka=function(i){return gf(i.length)},Sf=Hi,bf=ff,yf=Ka,Xn=function(i){return function(e,t,s){var r=Sf(e),a=yf(r),n=bf(s,a),o;if(i&&t!=t){for(;a>n;)if(o=r[n++],o!=o)return!0}else for(;a>n;n++)if((i||n in r)&&r[n]===t)return i||n||0;return!i&&-1}},Tf={includes:Xn(!0),indexOf:Xn(!1)},Ef=Ge,Rr=nt,$f=Hi,Af=Tf.indexOf,wf=qa,Zn=Ef([].push),kf=function(i,e){var t=$f(i),s=0,r=[],a;for(a in t)!Rr(wf,a)&&Rr(t,a)&&Zn(r,a);for(;e.length>s;)Rr(t,a=e[s++])&&(~Af(r,a)||Zn(r,a));return r},zl=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Pf=kf,Rf=zl,_f=Object.keys||function(e){return Pf(e,Rf)},Cf=$t,If=Rl,Df=Vt,Lf=pt,xf=Hi,Of=_f;Wl.f=Cf&&!If?Object.defineProperties:function(e,t){Lf(e);for(var s=xf(t),r=Of(t),a=r.length,n=0,o;a>n;)Df.f(e,o=r[n++],s[o]);return e};var Mf=Ut,Ql=Mf("document","documentElement"),Bf=pt,Nf=Wl,eo=zl,Ff=qa,Vf=Ql,Uf=Ua,Hf=Ya,to=">",io="<",ga="prototype",Sa="script",Kl=Hf("IE_PROTO"),_r=function(){},Jl=function(i){return io+Sa+to+i+io+"/"+Sa+to},so=function(i){i.write(Jl("")),i.close();var e=i.parentWindow.Object;return i=null,e},jf=function(){var i=Uf("iframe"),e="java"+Sa+":",t;return i.style.display="none",Vf.appendChild(i),i.src=String(e),t=i.contentWindow.document,t.open(),t.write(Jl("document.F=Object")),t.close(),t.F},ns,ws=function(){try{ns=new ActiveXObject("htmlfile")}catch(e){}ws=typeof document!="undefined"?document.domain&&ns?so(ns):jf():so(ns);for(var i=eo.length;i--;)delete ws[ga][eo[i]];return ws()};Ff[Kl]=!0;var Xl=Object.create||function(e,t){var s;return e!==null?(_r[ga]=Bf(e),s=new _r,_r[ga]=null,s[Kl]=e):s=ws(),t===void 0?s:Nf.f(s,t)},Gf=je,Yf=!Gf(function(){function i(){}return i.prototype.constructor=null,Object.getPrototypeOf(new i)!==i.prototype}),qf=nt,Wf=ge,zf=qs,Qf=Ya,Kf=Yf,ro=Qf("IE_PROTO"),ba=Object,Jf=ba.prototype,Zl=Kf?ba.getPrototypeOf:function(i){var e=zf(i);if(qf(e,ro))return e[ro];var t=e.constructor;return Wf(t)&&e instanceof t?t.prototype:e instanceof ba?Jf:null},Xf=ji,Ja=function(i,e,t,s){return s&&s.enumerable?i[e]=t:Xf(i,e,t),i},Zf=je,ep=ge,tp=ft,ip=Xl,ao=Zl,sp=Ja,rp=Pe,ya=rp("iterator"),ed=!1,ct,Cr,Ir;[].keys&&(Ir=[].keys(),"next"in Ir?(Cr=ao(ao(Ir)),Cr!==Object.prototype&&(ct=Cr)):ed=!0);var ap=!tp(ct)||Zf(function(){var i={};return ct[ya].call(i)!==i});ap?ct={}:ct=ip(ct);ep(ct[ya])||sp(ct,ya,function(){return this});var td={IteratorPrototype:ct,BUGGY_SAFARI_ITERATORS:ed},np=Pe,op=np("toStringTag"),id={};id[op]="z";var Xa=String(id)==="[object z]",lp=Xa,dp=ge,ks=Vi,up=Pe,cp=up("toStringTag"),hp=Object,fp=ks(function(){return arguments}())=="Arguments",pp=function(i,e){try{return i[e]}catch(t){}},Yi=lp?ks:function(i){var e,t,s;return i===void 0?"Undefined":i===null?"Null":typeof(t=pp(e=hp(i),cp))=="string"?t:fp?ks(e):(s=ks(e))=="Object"&&dp(e.callee)?"Arguments":s},vp=Xa,mp=Yi,gp=vp?{}.toString:function(){return"[object "+mp(this)+"]"},Sp=Xa,bp=Vt.f,yp=ji,Tp=nt,Ep=gp,$p=Pe,no=$p("toStringTag"),Za=function(i,e,t,s){if(i){var r=t?i:i.prototype;Tp(r,no)||bp(r,no,{configurable:!0,value:e}),s&&!Sp&&yp(r,"toString",Ep)}},Ap=td.IteratorPrototype,wp=Xl,kp=Ws,Pp=Za,Rp=gi,_p=function(){return this},Cp=function(i,e,t,s){var r=e+" Iterator";return i.prototype=wp(Ap,{next:kp(+!s,t)}),Pp(i,r,!1,!0),Rp[r]=_p,i},Ip=Qe,Dp=Oe,sd=af,Lp=Cp,xp=Zl,Op=Za,oo=Ja,Mp=Pe,lo=gi,rd=td,Bp=sd.PROPER;sd.CONFIGURABLE;rd.IteratorPrototype;var os=rd.BUGGY_SAFARI_ITERATORS,Dr=Mp("iterator"),uo="keys",ls="values",co="entries",Np=function(){return this},Fp=function(i,e,t,s,r,a,n){Lp(t,e,s);var o=function(S){if(S===r&&h)return h;if(!os&&S in d)return d[S];switch(S){case uo:return function(){return new t(this,S)};case ls:return function(){return new t(this,S)};case co:return function(){return new t(this,S)}}return function(){return new t(this)}},u=e+" Iterator",l=!1,d=i.prototype,c=d[Dr]||d["@@iterator"]||r&&d[r],h=!os&&c||o(r),f=e=="Array"&&d.entries||c,m,v,g;if(f&&(m=xp(f.call(new i)),m!==Object.prototype&&m.next&&(Op(m,u,!0,!0),lo[u]=Np)),Bp&&r==ls&&c&&c.name!==ls&&(l=!0,h=function(){return Dp(c,this)}),r)if(v={values:o(ls),keys:a?h:o(uo),entries:o(co)},n)for(g in v)(os||l||!(g in d))&&oo(d,g,v[g]);else Ip({target:e,proto:!0,forced:os||l},v);return n&&d[Dr]!==h&&oo(d,Dr,h,{name:r}),lo[e]=h,v},Vp=function(i,e){return{value:i,done:e}},Up=Hi,ho=gi,ad=Nl;Vt.f;var Hp=Fp,ds=Vp,nd="Array Iterator",jp=ad.set,Gp=ad.getterFor(nd);Hp(Array,"Array",function(i,e){jp(this,{type:nd,target:Up(i),index:0,kind:e})},function(){var i=Gp(this),e=i.target,t=i.kind,s=i.index++;return!e||s>=e.length?(i.target=void 0,ds(void 0,!0)):t=="keys"?ds(s,!1):t=="values"?ds(e[s],!1):ds([s,e[s]],!1)},"values");ho.Arguments=ho.Array;var Yp=Pe,qp=gi,Wp=Yp("iterator"),zp=Array.prototype,Qp=function(i){return i!==void 0&&(qp.Array===i||zp[Wp]===i)},Kp=Yi,fo=Ys,Jp=Ui,Xp=gi,Zp=Pe,ev=Zp("iterator"),od=function(i){if(!Jp(i))return fo(i,ev)||fo(i,"@@iterator")||Xp[Kp(i)]},tv=Oe,iv=Ht,sv=pt,rv=Gs,av=od,nv=TypeError,ov=function(i,e){var t=arguments.length<2?av(i):e;if(iv(t))return sv(tv(t,i));throw nv(rv(i)+" is not iterable")},lv=Oe,po=pt,dv=Ys,uv=function(i,e,t){var s,r;po(i);try{if(s=dv(i,"return"),!s){if(e==="throw")throw t;return t}s=lv(s,i)}catch(a){r=!0,s=a}if(e==="throw")throw t;if(r)throw s;return po(s),t},cv=zs,hv=Oe,fv=pt,pv=Gs,vv=Qp,mv=Ka,vo=Hs,gv=ov,Sv=od,mo=uv,bv=TypeError,Ps=function(i,e){this.stopped=i,this.result=e},go=Ps.prototype,en=function(i,e,t){var s=t&&t.that,r=!!(t&&t.AS_ENTRIES),a=!!(t&&t.IS_RECORD),n=!!(t&&t.IS_ITERATOR),o=!!(t&&t.INTERRUPTED),u=cv(e,s),l,d,c,h,f,m,v,g=function(E){return l&&mo(l,"normal",E),new Ps(!0,E)},S=function(E){return r?(fv(E),o?u(E[0],E[1],g):u(E[0],E[1])):o?u(E,g):u(E)};if(a)l=i.iterator;else if(n)l=i;else{if(d=Sv(i),!d)throw bv(pv(i)+" is not iterable");if(vv(d)){for(c=0,h=mv(i);h>c;c++)if(f=S(i[c]),f&&vo(go,f))return f;return new Ps(!1)}l=gv(i,d)}for(m=a?i.next:l.next;!(v=hv(m,l)).done;){try{f=S(v.value)}catch(E){mo(l,"throw",E)}if(typeof f=="object"&&f&&vo(go,f))return f}return new Ps(!1)},yv=Ga,Tv=Vt,Ev=Ws,$v=function(i,e,t){var s=yv(e);s in i?Tv.f(i,s,Ev(0,t)):i[s]=t},Av=Qe,wv=en,kv=$v;Av({target:"Object",stat:!0},{fromEntries:function(e){var t={};return wv(e,function(s,r){kv(t,s,r)},{AS_ENTRIES:!0}),t}});var Pv=Ha,Rv=Pv.Object.fromEntries,_v={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},Cv=_v,Iv=Ee,Dv=Yi,Lv=ji,So=gi,xv=Pe,bo=xv("toStringTag");for(var Lr in Cv){var yo=Iv[Lr],xr=yo&&yo.prototype;xr&&Dv(xr)!==bo&&Lv(xr,bo,Lr),So[Lr]=So.Array}var Ov=Rv,Mv=Ov,Bv=Mv,Nv=Bv,xs=Vs(Nv),Fv=Vi,Qs=typeof process!="undefined"&&Fv(process)=="process",Vv=Vt,Uv=function(i,e,t){return Vv.f(i,e,t)},Hv=Ut,jv=Uv,Gv=Pe,Yv=$t,To=Gv("species"),qv=function(i){var e=Hv(i);Yv&&e&&!e[To]&&jv(e,To,{configurable:!0,get:function(){return this}})},Wv=Hs,zv=TypeError,Qv=function(i,e){if(Wv(e,i))return i;throw zv("Incorrect invocation")},Kv=Ge,Jv=ge,Ta=ja,Xv=Kv(Function.toString);Jv(Ta.inspectSource)||(Ta.inspectSource=function(i){return Xv(i)});var ld=Ta.inspectSource,Zv=Ge,em=je,dd=ge,tm=Yi,im=Ut,sm=ld,ud=function(){},rm=[],cd=im("Reflect","construct"),tn=/^\s*(?:class|function)\b/,am=Zv(tn.exec),nm=!tn.exec(ud),ki=function(e){if(!dd(e))return!1;try{return cd(ud,rm,e),!0}catch(t){return!1}},hd=function(e){if(!dd(e))return!1;switch(tm(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return nm||!!am(tn,sm(e))}catch(t){return!0}};hd.sham=!0;var om=!cd||em(function(){var i;return ki(ki.call)||!ki(Object)||!ki(function(){i=!0})||i})?hd:ki,lm=om,dm=Gs,um=TypeError,cm=function(i){if(lm(i))return i;throw um(dm(i)+" is not a constructor")},Eo=pt,hm=cm,fm=Ui,pm=Pe,vm=pm("species"),fd=function(i,e){var t=Eo(i).constructor,s;return t===void 0||fm(s=Eo(t)[vm])?e:hm(s)},mm=Ge,gm=mm([].slice),Sm=TypeError,bm=function(i,e){if(i<e)throw Sm("Not enough arguments");return i},ym=js,pd=/(?:ipad|iphone|ipod).*applewebkit/i.test(ym),xe=Ee,Tm=Vl,Em=zs,$o=ge,$m=nt,vd=je,Ao=Ql,Am=gm,wo=Ua,wm=bm,km=pd,Pm=Qs,Ea=xe.setImmediate,$a=xe.clearImmediate,Rm=xe.process,Or=xe.Dispatch,_m=xe.Function,ko=xe.MessageChannel,Cm=xe.String,Mr=0,Ii={},Po="onreadystatechange",Bi,Ct,Br,Nr;vd(function(){Bi=xe.location});var sn=function(i){if($m(Ii,i)){var e=Ii[i];delete Ii[i],e()}},Fr=function(i){return function(){sn(i)}},Ro=function(i){sn(i.data)},_o=function(i){xe.postMessage(Cm(i),Bi.protocol+"//"+Bi.host)};(!Ea||!$a)&&(Ea=function(e){wm(arguments.length,1);var t=$o(e)?e:_m(e),s=Am(arguments,1);return Ii[++Mr]=function(){Tm(t,void 0,s)},Ct(Mr),Mr},$a=function(e){delete Ii[e]},Pm?Ct=function(i){Rm.nextTick(Fr(i))}:Or&&Or.now?Ct=function(i){Or.now(Fr(i))}:ko&&!km?(Br=new ko,Nr=Br.port2,Br.port1.onmessage=Ro,Ct=Em(Nr.postMessage,Nr)):xe.addEventListener&&$o(xe.postMessage)&&!xe.importScripts&&Bi&&Bi.protocol!=="file:"&&!vd(_o)?(Ct=_o,xe.addEventListener("message",Ro,!1)):Po in wo("script")?Ct=function(i){Ao.appendChild(wo("script"))[Po]=function(){Ao.removeChild(this),sn(i)}}:Ct=function(i){setTimeout(Fr(i),0)});var md={set:Ea,clear:$a},gd=function(){this.head=null,this.tail=null};gd.prototype={add:function(i){var e={item:i,next:null},t=this.tail;t?t.next=e:this.head=e,this.tail=e},get:function(){var i=this.head;if(i){var e=this.head=i.next;return e===null&&(this.tail=null),i.item}}};var Sd=gd,Im=js,Dm=/ipad|iphone|ipod/i.test(Im)&&typeof Pebble!="undefined",Lm=js,xm=/web0s(?!.*chrome)/i.test(Lm),Nt=Ee,Co=zs,Om=Wa.f,Vr=md.set,Mm=Sd,Bm=pd,Nm=Dm,Fm=xm,Ur=Qs,Io=Nt.MutationObserver||Nt.WebKitMutationObserver,Do=Nt.document,Lo=Nt.process,us=Nt.Promise,xo=Om(Nt,"queueMicrotask"),Aa=xo&&xo.value,si,Hr,jr,cs,Oo;if(!Aa){var hs=new Mm,fs=function(){var i,e;for(Ur&&(i=Lo.domain)&&i.exit();e=hs.get();)try{e()}catch(t){throw hs.head&&si(),t}i&&i.enter()};!Bm&&!Ur&&!Fm&&Io&&Do?(Hr=!0,jr=Do.createTextNode(""),new Io(fs).observe(jr,{characterData:!0}),si=function(){jr.data=Hr=!Hr}):!Nm&&us&&us.resolve?(cs=us.resolve(void 0),cs.constructor=us,Oo=Co(cs.then,cs),si=function(){Oo(fs)}):Ur?si=function(){Lo.nextTick(fs)}:(Vr=Co(Vr,Nt),si=function(){Vr(fs)}),Aa=function(i){hs.head||si(),hs.add(i)}}var Vm=Aa,Um=function(i,e){try{arguments.length==1?console.error(i):console.error(i,e)}catch(t){}},rn=function(i){try{return{error:!1,value:i()}}catch(e){return{error:!0,value:e}}},Hm=Ee,Si=Hm.Promise,bd=typeof Deno=="object"&&Deno&&typeof Deno.version=="object",jm=bd,Gm=Qs,Ym=!jm&&!Gm&&typeof window=="object"&&typeof document=="object",qm=Ee,Di=Si,Wm=ge,zm=Yl,Qm=ld,Km=Pe,Jm=Ym,Xm=bd,Gr=Cl,Mo=Di&&Di.prototype,Zm=Km("species"),wa=!1,yd=Wm(qm.PromiseRejectionEvent),eg=zm("Promise",function(){var i=Qm(Di),e=i!==String(Di);if(!e&&Gr===66||!(Mo.catch&&Mo.finally))return!0;if(!Gr||Gr<51||!/native code/.test(i)){var t=new Di(function(a){a(1)}),s=function(a){a(function(){},function(){})},r=t.constructor={};if(r[Zm]=s,wa=t.then(function(){})instanceof s,!wa)return!0}return!e&&(Jm||Xm)&&!yd}),qi={CONSTRUCTOR:eg,REJECTION_EVENT:yd,SUBCLASSING:wa},bi={},Bo=Ht,tg=TypeError,ig=function(i){var e,t;this.promise=new i(function(s,r){if(e!==void 0||t!==void 0)throw tg("Bad Promise constructor");e=s,t=r}),this.resolve=Bo(e),this.reject=Bo(t)};bi.f=function(i){return new ig(i)};var sg=Qe,Os=Qs,Et=Ee,Wi=Oe,rg=Ja,ag=Za,ng=qv,og=Ht,ka=ge,lg=ft,dg=Qv,ug=fd,Td=md.set,an=Vm,cg=Um,hg=rn,fg=Sd,Ed=Nl,Pa=Si,nn=qi,$d=bi,Ks="Promise",Ad=nn.CONSTRUCTOR,pg=nn.REJECTION_EVENT;nn.SUBCLASSING;var Yr=Ed.getterFor(Ks),vg=Ed.set,mg=Pa&&Pa.prototype,di=Pa,qr=mg,wd=Et.TypeError,Ra=Et.document,on=Et.process,_a=$d.f,gg=_a,Sg=!!(Ra&&Ra.createEvent&&Et.dispatchEvent),kd="unhandledrejection",bg="rejectionhandled",No=0,Pd=1,yg=2,ln=1,Rd=2,ps,Fo,Tg,_d=function(i){var e;return lg(i)&&ka(e=i.then)?e:!1},Cd=function(i,e){var t=e.value,s=e.state==Pd,r=s?i.ok:i.fail,a=i.resolve,n=i.reject,o=i.domain,u,l,d;try{r?(s||(e.rejection===Rd&&$g(e),e.rejection=ln),r===!0?u=t:(o&&o.enter(),u=r(t),o&&(o.exit(),d=!0)),u===i.promise?n(wd("Promise-chain cycle")):(l=_d(u))?Wi(l,u,a,n):a(u)):n(t)}catch(c){o&&!d&&o.exit(),n(c)}},Id=function(i,e){i.notified||(i.notified=!0,an(function(){for(var t=i.reactions,s;s=t.get();)Cd(s,i);i.notified=!1,e&&!i.rejection&&Eg(i)}))},Dd=function(i,e,t){var s,r;Sg?(s=Ra.createEvent("Event"),s.promise=e,s.reason=t,s.initEvent(i,!1,!0),Et.dispatchEvent(s)):s={promise:e,reason:t},!pg&&(r=Et["on"+i])?r(s):i===kd&&cg("Unhandled promise rejection",t)},Eg=function(i){Wi(Td,Et,function(){var e=i.facade,t=i.value,s=Vo(i),r;if(s&&(r=hg(function(){Os?on.emit("unhandledRejection",t,e):Dd(kd,e,t)}),i.rejection=Os||Vo(i)?Rd:ln,r.error))throw r.value})},Vo=function(i){return i.rejection!==ln&&!i.parent},$g=function(i){Wi(Td,Et,function(){var e=i.facade;Os?on.emit("rejectionHandled",e):Dd(bg,e,i.value)})},ui=function(i,e,t){return function(s){i(e,s,t)}},fi=function(i,e,t){i.done||(i.done=!0,t&&(i=t),i.value=e,i.state=yg,Id(i,!0))},Ca=function(i,e,t){if(!i.done){i.done=!0,t&&(i=t);try{if(i.facade===e)throw wd("Promise can't be resolved itself");var s=_d(e);s?an(function(){var r={done:!1};try{Wi(s,e,ui(Ca,r,i),ui(fi,r,i))}catch(a){fi(r,a,i)}}):(i.value=e,i.state=Pd,Id(i,!1))}catch(r){fi({done:!1},r,i)}}};Ad&&(di=function(e){dg(this,qr),og(e),Wi(ps,this);var t=Yr(this);try{e(ui(Ca,t),ui(fi,t))}catch(s){fi(t,s)}},qr=di.prototype,ps=function(e){vg(this,{type:Ks,done:!1,notified:!1,parent:!1,reactions:new fg,rejection:!1,state:No,value:void 0})},ps.prototype=rg(qr,"then",function(e,t){var s=Yr(this),r=_a(ug(this,di));return s.parent=!0,r.ok=ka(e)?e:!0,r.fail=ka(t)&&t,r.domain=Os?on.domain:void 0,s.state==No?s.reactions.add(r):an(function(){Cd(r,s)}),r.promise}),Fo=function(){var i=new ps,e=Yr(i);this.promise=i,this.resolve=ui(Ca,e),this.reject=ui(fi,e)},$d.f=_a=function(i){return i===di||i===Tg?new Fo(i):gg(i)});sg({global:!0,constructor:!0,wrap:!0,forced:Ad},{Promise:di});ag(di,Ks,!1,!0);ng(Ks);var Ag=Pe,Ld=Ag("iterator"),xd=!1;try{var wg=0,Uo={next:function(){return{done:!!wg++}},return:function(){xd=!0}};Uo[Ld]=function(){return this},Array.from(Uo,function(){throw 2})}catch(i){}var kg=function(i,e){if(!e&&!xd)return!1;var t=!1;try{var s={};s[Ld]=function(){return{next:function(){return{done:t=!0}}}},i(s)}catch(r){}return t},Pg=Si,Rg=kg,_g=qi.CONSTRUCTOR,Od=_g||!Rg(function(i){Pg.all(i).then(void 0,function(){})}),Cg=Qe,Ig=Oe,Dg=Ht,Lg=bi,xg=rn,Og=en,Mg=Od;Cg({target:"Promise",stat:!0,forced:Mg},{all:function(e){var t=this,s=Lg.f(t),r=s.resolve,a=s.reject,n=xg(function(){var o=Dg(t.resolve),u=[],l=0,d=1;Og(e,function(c){var h=l++,f=!1;d++,Ig(o,t,c).then(function(m){f||(f=!0,u[h]=m,--d||r(u))},a)}),--d||r(u)});return n.error&&a(n.value),s.promise}});var Bg=Qe,Ng=qi.CONSTRUCTOR,Ho=Si;Ho&&Ho.prototype;Bg({target:"Promise",proto:!0,forced:Ng,real:!0},{catch:function(i){return this.then(void 0,i)}});var Fg=Qe,Vg=Oe,Ug=Ht,Hg=bi,jg=rn,Gg=en,Yg=Od;Fg({target:"Promise",stat:!0,forced:Yg},{race:function(e){var t=this,s=Hg.f(t),r=s.reject,a=jg(function(){var n=Ug(t.resolve);Gg(e,function(o){Vg(n,t,o).then(s.resolve,r)})});return a.error&&r(a.value),s.promise}});var qg=Qe,Wg=Oe,zg=bi,Qg=qi.CONSTRUCTOR;qg({target:"Promise",stat:!0,forced:Qg},{reject:function(e){var t=zg.f(this);return Wg(t.reject,void 0,e),t.promise}});var Kg=pt,Jg=ft,Xg=bi,Md=function(i,e){if(Kg(i),Jg(e)&&e.constructor===i)return e;var t=Xg.f(i),s=t.resolve;return s(e),t.promise},Zg=Qe,eS=Ut,tS=Ic,iS=Si,sS=qi.CONSTRUCTOR,rS=Md,aS=eS("Promise"),nS=!sS;Zg({target:"Promise",stat:!0,forced:tS},{resolve:function(e){return rS(nS&&this===aS?iS:this,e)}});var oS=Qe,Ia=Si,lS=je,dS=Ut,uS=ge,cS=fd,jo=Md,hS=Ia&&Ia.prototype,fS=!!Ia&&lS(function(){hS.finally.call({then:function(){}},function(){})});oS({target:"Promise",proto:!0,real:!0,forced:fS},{finally:function(i){var e=cS(this,dS("Promise")),t=uS(i);return this.then(t?function(s){return jo(e,i()).then(function(){return s})}:i,t?function(s){return jo(e,i()).then(function(){throw s})}:i)}});var pS=Ut,dn=pS,vS=dn,mS=vS("Promise","finally"),gS=mS,SS=gS,bS=SS,yS=bS,un=Vs(yS),Se;(function(i){i[i.OFFSET_P=0]="OFFSET_P",i[i.PLAYBACK_SHIFT=1]="PLAYBACK_SHIFT",i[i.DASH_CMAF_OFFSET_P=2]="DASH_CMAF_OFFSET_P"})(Se||(Se={}));var ze=(i,e=0,t=Se.OFFSET_P)=>{switch(t){case Se.OFFSET_P:return i.replace("_offset_p",e===0?"":"_"+e.toFixed(0));case Se.PLAYBACK_SHIFT:{if(e===0)return i;const s=new URL(i);return s.searchParams.append("playback_shift",e.toFixed(0)),s.toString()}case Se.DASH_CMAF_OFFSET_P:{const s=new URL(i);return!s.searchParams.get("offset_p")&&e===0?i:(s.searchParams.set("offset_p",e.toFixed(0)),s.toString())}default:H(t)}return i};const Go=(i,e)=>{var t;switch(e){case Se.OFFSET_P:return NaN;case Se.PLAYBACK_SHIFT:{const s=new URL(i);return Number(s.searchParams.get("playback_shift"))}case Se.DASH_CMAF_OFFSET_P:{const s=new URL(i);return Number((t=s.searchParams.get("offset_p"))!==null&&t!==void 0?t:0)}default:H(e)}};var O=(i,e,t=!1)=>{const s=i.getTransition();(t||!s||s.to===e)&&i.setState(e)};class he{constructor(e){this.transitionStarted$=new D,this.transitionEnded$=new D,this.transitionUpdated$=new D,this.forceChanged$=new D,this.stateChangeStarted$=F(this.transitionStarted$,this.transitionUpdated$),this.stateChangeEnded$=F(this.transitionEnded$,this.forceChanged$),this.state=e,this.prevState=void 0}setState(e){const t=this.transition,s=this.state;this.transition=void 0,this.prevState=s,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:s,to:e,canceledTransition:t})}startTransitionTo(e){const t=this.transition,s=this.state;s===e||R(t)&&t.to===e||(this.prevState=s,this.state=e,t?(this.transition={from:t.from,to:e,canceledTransition:t},this.transitionUpdated$.next(this.transition)):(this.transition={from:s,to:e},this.transitionStarted$.next(this.transition)))}getTransition(){return this.transition}getState(){return this.state}getPrevState(){return this.prevState}}const TS=i=>{switch(i){case b.MPEG:case b.DASH_SEP:case b.DASH_ONDEMAND:case b.DASH_WEBM:case b.DASH_WEBM_AV1:case b.HLS:case b.HLS_ONDEMAND:return!1;case b.DASH_LIVE:case b.DASH_LIVE_CMAF:case b.HLS_LIVE:case b.HLS_LIVE_CMAF:case b.DASH_LIVE_WEBM:case b.WEB_RTC_LIVE:return!0;default:return H(i)}};var U;(function(i){i.STOPPED="stopped",i.READY="ready",i.PLAYING="playing",i.PAUSED="paused"})(U||(U={}));const ES=5,$S=5,AS=500,Yo=7e3;class wS{constructor(e){this.subscription=new re,this.loadMediaTimeoutSubscription=new re,this.videoState=new he(U.STOPPED),this.syncPlayback=()=>{const s=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: ${s}; videoTransition: ${JSON.stringify(r)}; desiredPlaybackState: ${a}; desiredPlaybackStateTransition: ${this.params.desiredState.playbackState.getTransition()}; seekState: ${JSON.stringify(o)};`}),a===p.STOPPED){s!==U.STOPPED&&(this.videoState.startTransitionTo(U.STOPPED),this.stop());return}if(!r){if((n==null?void 0:n.to)!==p.PAUSED&&o.state===Y.Requested&&s!==U.STOPPED){this.seek(o.position/1e3);return}switch(a){case p.READY:{switch(s){case U.PLAYING:case U.PAUSED:case U.READY:break;case U.STOPPED:this.videoState.startTransitionTo(U.READY),this.prepare();break;default:H(s)}break}case p.PLAYING:{switch(s){case U.PLAYING:break;case U.PAUSED:this.videoState.startTransitionTo(U.PLAYING),this.params.connection.remotePlayerController.playOrPause();break;case U.READY:this.videoState.startTransitionTo(U.PLAYING),this.params.connection.remotePlayerController.playOrPause();break;case U.STOPPED:this.videoState.startTransitionTo(U.READY),this.prepare();break;default:H(s)}break}case p.PAUSED:{switch(s){case U.PLAYING:this.videoState.startTransitionTo(U.PAUSED),this.params.connection.remotePlayerController.playOrPause();break;case U.PAUSED:break;case U.READY:this.videoState.startTransitionTo(U.PAUSED),this.videoState.setState(U.PAUSED);break;case U.STOPPED:this.videoState.startTransitionTo(U.READY),this.prepare();break;default:H(s)}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(TS(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 re;this.subscription.add(e),this.subscription.add(F(this.videoState.stateChangeStarted$.pipe($(r=>`stateChangeStarted$ ${JSON.stringify(r)}`)),this.videoState.stateChangeEnded$.pipe($(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 D;e.add(r.pipe(rt(AS)).subscribe(()=>{this.params.output.seekedEvent$.next()}));let a=NaN;e.add(x(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===Y.Applying||Math.abs(o-a)>ES)&&r.next(o),a=o})),e.add(x(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.DURATION_CHANGED).subscribe(n=>{this.logRemoteEvent(n),this.params.output.duration$.next(n.value)}))}t(x(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED),r=>{this.logRemoteEvent(r),r.value?this.handleRemoteReady():(this.handleRemoteStop(),e.unsubscribe())}),t(x(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED),r=>{this.logRemoteEvent(r),r.value?this.handleRemotePause():this.handleRemotePlay()}),t(x(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<$S&&this.params.output.endedEvent$.next(),this.handleRemoteStop(),O(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(x(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED),r=>{this.logRemoteEvent(r),this.handleRemoteVolumeChange({volume:r.value})}),t(x(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED),r=>{this.logRemoteEvent(r),this.handleRemoteVolumeChange({muted:r.value})});const s=F(this.params.desiredState.playbackState.stateChangeStarted$,this.params.desiredState.seekState.stateChangeEnded$,this.videoState.stateChangeEnded$,He(["init"])).pipe(rt(0));t(s,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(U.PAUSED),O(this.params.desiredState.playbackState,p.PAUSED)):(this.videoState.setState(U.PLAYING),O(this.params.desiredState.playbackState,p.PLAYING));const s=this.params.output.isLive$.getValue();this.params.output.duration$.next(s?0:t.duration),this.params.output.position$.next(s?0:t.currentTime),this.params.desiredState.seekState.setState({state:Y.None})}}prepare(){const e=this.params.format;this.log({message:`[prepare] format: ${e}`});const t=this.createMediaInfo(e),s=this.createLoadRequest(t);this.loadMedia(s)}handleRemotePause(){const e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)===U.PAUSED||e===U.PLAYING)&&(this.videoState.setState(U.PAUSED),O(this.params.desiredState.playbackState,p.PAUSED))}handleRemotePlay(){const e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)===U.PLAYING||e===U.PAUSED)&&(this.videoState.setState(U.PLAYING),O(this.params.desiredState.playbackState,p.PLAYING))}handleRemoteReady(){var e;const t=this.videoState.getTransition();(t==null?void 0:t.to)===U.READY&&this.videoState.setState(U.READY),((e=this.params.desiredState.playbackState.getTransition())===null||e===void 0?void 0:e.to)===p.READY&&O(this.params.desiredState.playbackState,p.READY)}handleRemoteStop(){this.videoState.getState()!==U.STOPPED&&this.videoState.setState(U.STOPPED)}handleRemoteVolumeChange(e){var t,s;const r=this.params.output.volume$.getValue(),a={volume:(t=e.volume)!==null&&t!==void 0?t:r.volume,muted:(s=e.muted)!==null&&s!==void 0?s: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:s}=this.params.connection;t.currentTime=e,s.seek()}stop(){const{remotePlayerController:e}=this.params.connection;e.stop()}createMediaInfo(e){var t;const s=this.params.source;let r,a,n;switch(e){case b.MPEG:{const d=s[e];P(d);const c=Tu(Object.keys(d));P(c);const h=d[c];P(h),r=h,a="video/mp4",n=chrome.cast.media.StreamType.BUFFERED;break}case b.HLS:case b.HLS_ONDEMAND:{const d=s[e];P(d),r=d.url,a="application/x-mpegurl",n=chrome.cast.media.StreamType.BUFFERED;break}case b.DASH_SEP:case b.DASH_ONDEMAND:case b.DASH_WEBM:case b.DASH_WEBM_AV1:{const d=s[e];P(d),r=d.url,a="application/dash+xml",n=chrome.cast.media.StreamType.BUFFERED;break}case b.DASH_LIVE_CMAF:{const d=s[e];P(d),r=d.url,a="application/dash+xml",n=chrome.cast.media.StreamType.LIVE;break}case b.HLS_LIVE:case b.HLS_LIVE_CMAF:{const d=s[e];P(d),r=ze(d.url),a="application/x-mpegurl",n=chrome.cast.media.StreamType.LIVE;break}case b.DASH_LIVE:case b.WEB_RTC_LIVE:{const d="Unsupported format for Chromecast",c=new Error(d);throw this.params.output.error$.next({id:"ChromecastProvider.createMediaInfo()",category:I.VIDEO_PIPELINE,message:d,thrown:c}),c}case b.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:l}=this.params.meta;return R(u)&&(o.metadata.title=u),R(l)&&(o.metadata.subtitle=l),o}createLoadRequest(e){const t=new chrome.cast.media.LoadRequest(e);t.autoplay=!1;const s=this.params.desiredState.seekState.getState();return s.state===Y.Applying||s.state===Y.Requested?t.currentTime=this.params.output.isLive$.getValue()?0:s.position/1e3:t.currentTime=0,t}loadMedia(e){const t=this.params.connection.session.loadMedia(e),s=new Promise((r,a)=>{this.loadMediaTimeoutSubscription.add(Eu(Yo).subscribe(()=>a(`timeout(${Yo})`)))});un(Promise.race([t,s]).then(()=>{this.log({message:`[loadMedia] completed, format: ${this.params.format}`}),this.params.desiredState.seekState.getState().state===Y.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:I.VIDEO_PIPELINE,message:a,thrown:r})}),()=>{this.loadMediaTimeoutSubscription.unsubscribe()})}logRemoteEvent(e){this.log({message:`[remoteEvent] ${JSON.stringify(e)}`})}}const cn=i=>{i.removeAttribute("src"),i.load()},kS=i=>{try{i.pause(),i.playbackRate=0,cn(i),i.remove()}catch(e){console.error(e)}};class PS{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 Da=window.WeakMap?new WeakMap:new PS,jt=i=>{let e=i.querySelector("video");const t=!!e;return e?cn(e):(e=document.createElement("video"),i.appendChild(e)),Da.set(e,t),e.setAttribute("crossorigin","anonymous"),e.setAttribute("playsinline","playsinline"),e.controls=!1,e.setAttribute("poster","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),e},Gt=i=>{const e=Da.get(i);Da.delete(i),e?cn(i):kS(i)},dt=(i,e,t,{equal:s=(n,o)=>n===o,changed$:r,onError:a}={})=>{const n=i.getState(),o=e(),u=K(r),l=new re;return r&&l.add(r.subscribe(d=>{const c=i.getState();s(d,c)&&i.setState(d)},a)),s(o,n)||(t(n),u&&i.setState(n)),l.add(i.stateChangeStarted$.subscribe(d=>{t(d.to),u&&i.setState(d.to)},a)),l},zi=(i,e,t)=>dt(e,()=>i.loop,s=>{R(s)&&(i.loop=s)},{onError:t}),Yt=(i,e,t,s)=>dt(e,()=>({muted:i.muted,volume:i.volume}),r=>{R(r)&&(i.muted=r.muted,i.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:s}),yi=(i,e,t,s)=>dt(e,()=>i.playbackRate,r=>{R(r)&&(i.playbackRate=r)},{changed$:t,onError:s}),RS=i=>["__",i.language,i.label].join("|"),_S=(i,e)=>{if(i.id===e)return!0;const[t,s,r]=e.split("|");return i.language===s&&i.label===r};class At{constructor(){this.available$=new D,this.current$=new y(void 0),this.error$=new D,this.subscription=new re,this.externalTracks=new Map,this.internalTracks=new Map}connect(e,t,s){this.video=e,this.cueSettings=t.textTrackCuesSettings,this.subscribe();const r=a=>{this.error$.next({id:"TextTracksManager",category:I.WTF,message:"Generic HtmlVideoTextTrackManager error",thrown:a})};this.subscription.add(this.available$.subscribe(s.availableTextTracks$)),this.subscription.add(this.current$.subscribe(s.currentTextTrack$)),this.subscription.add(this.error$.subscribe(s.error$)),this.subscription.add(dt(t.internalTextTracks,()=>Object.values(this.internalTracks),a=>{R(a)&&this.setInternal(a)},{equal:(a,n)=>R(a)&&R(n)&&a.length===n.length&&a.every(({id:o},u)=>o===n[u].id),changed$:this.available$.pipe($(a=>a.filter(({type:n})=>n==="internal"))),onError:r})),this.subscription.add(dt(t.externalTextTracks,()=>Object.values(this.externalTracks),a=>{R(a)&&this.setExternal(a)},{equal:(a,n)=>R(a)&&R(n)&&a.length===n.length&&a.every(({id:o},u)=>o===n[u].id),changed$:this.available$.pipe($(a=>a.filter(({type:n})=>n==="external"))),onError:r})),this.subscription.add(dt(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(dt(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(x(e,"addtrack").subscribe(()=>{const s=this.current$.getValue();s&&this.select(s)})),this.subscription.add(F(x(e,"addtrack"),x(e,"removetrack"),He(["init"])).pipe($(()=>this.htmlTextTracksAsArray().map(s=>this.htmlTextTrackToITextTrack(s))),pe((s,r)=>s.length===r.length&&s.every(({id:a},n)=>a===r[n].id))).subscribe(this.available$)),this.subscription.add(F(x(e,"change"),He(["init"])).pipe($(()=>this.htmlTextTracksAsArray().find(({mode:s})=>s==="showing")),$(s=>s&&this.htmlTextTrackToITextTrack(s).id),pe()).subscribe(this.current$));const t=s=>{var r,a;return this.applyCueSettings((a=(r=s.target)===null||r===void 0?void 0:r.activeCues)!==null&&a!==void 0?a:null)};this.subscription.add(x(e,"addtrack").subscribe(s=>{var r,a;(r=s.track)===null||r===void 0||r.addEventListener("cuechange",t);const n=o=>{var u,l,d,c,h;const f=(l=(u=o.target)===null||u===void 0?void 0:u.cues)!==null&&l!==void 0?l:null;f&&f.length&&(this.applyCueSettings((c=(d=o.target)===null||d===void 0?void 0:d.cues)!==null&&c!==void 0?c:null),(h=o.target)===null||h===void 0||h.removeEventListener("cuechange",n))};(a=s.track)===null||a===void 0||a.addEventListener("cuechange",n)})),this.subscription.add(x(e,"removetrack").subscribe(s=>{var r;(r=s.track)===null||r===void 0||r.removeEventListener("cuechange",t)}))}applyCueSettings(e){if(!e||!e.length)return;const t=this.cueSettings.getState();for(const s of Array.from(e)){const r=s;R(t.align)&&(r.align=t.align),R(t.position)&&(r.position=t.position),R(t.size)&&(r.size=t.size),R(t.line)&&(r.line=t.line)}}htmlTextTracksAsArray(e=!1){P(this.video);const t=[...this.video.textTracks];return e?t:t.filter(At.isHealthyTrack)}htmlTextTrackToITextTrack(e){var t,s;const{language:r,label:a}=e,n=e.id?e.id:RS(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:(s=this.internalTracks.get(n))===null||s===void 0?void 0:s.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(s=>s.id===t)).forEach(([,t])=>this.detach(t))}setInternal(e){const t=[...this.externalTracks];e.filter(({id:s,language:r,isAuto:a})=>!this.internalTracks.has(s)&&!t.some(([,n])=>n.language===r&&n.isAuto===a)).forEach(s=>this.attach(s)),Array.from(this.internalTracks).filter(([s])=>!e.find(r=>r.id===s)).forEach(([,s])=>this.detach(s))}select(e){P(this.video);for(const t of this.htmlTextTracksAsArray(!0))t.mode="showing";for(const t of this.htmlTextTracksAsArray(!0))(K(e)||!_S(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"),s=>s.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)}}class hn{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 Bd=i=>{var e;let t=i;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},qo=i=>{const e=Bd(i);return!!(e&&e.fullscreenElement&&e.fullscreenElement===i)},CS=i=>{const e=Bd(i);return!!(e&&e.pictureInPictureElement&&e.pictureInPictureElement===i)},IS=3;var DS=(i,e,t=IS)=>{let s=0,r=0;for(let a=0;a<i.length;a++){const n=i.start(a),o=i.end(a);if(n<=e&&e<=o){if(s=n,r=o,!t)return{from:s,to:r};for(let u=a-1;u>=0;u--)i.end(u)+t>=s&&(s=i.start(u));for(let u=a+1;u<i.length;u++)i.start(u)-t<=r&&(r=i.end(u))}}return{from:s,to:r}};const qt=i=>{const e=A=>x(i,A).pipe(_s(void 0)),s=F(...["waiting","pause","canplay","play","canplaythrough","playing","seeking","seeked","ended"].map(A=>x(i,A))).pipe($(A=>A.type==="ended"?i.readyState<2:i.readyState<3),pe()),r=F(x(i,"progress"),x(i,"timeupdate")).pipe($(()=>DS(i.buffered,i.currentTime))),n=Na().browser===yl.Safari?Ve({play:e("play").pipe(_e()),playing:e("playing")}).pipe(_s(void 0)):e("playing"),o=x(i,"volumechange").pipe($(()=>({muted:i.muted,volume:i.volume}))),u=x(i,"ratechange").pipe($(()=>i.playbackRate)),l=x(i,"error").pipe(fe(()=>!!(i.error||i.played.length)),$(()=>{var A;const w=i.error;return{id:w?`MediaError#${w.code}`:"HtmlVideoError",category:I.VIDEO_PIPELINE,message:w?w.message:"Error event from HTML video element",thrown:(A=i.error)!==null&&A!==void 0?A:void 0}})),d=x(i,"timeupdate").pipe($(()=>i.currentTime)),c=new D,h=.3;let f;d.subscribe(A=>{i.loop&&R(f)&&R(A)&&f>=i.duration-h&&A<=h&&c.next(f),f=A});const m=x(i,"enterpictureinpicture"),v=x(i,"leavepictureinpicture"),g=new y(CS(i));m.subscribe(()=>g.next(!0)),v.subscribe(()=>g.next(!1));const S=new y(qo(i));return x(i,"fullscreenchange").pipe($(()=>qo(i))).subscribe(S),{playing$:n,pause$:e("pause").pipe(fe(()=>!i.error)),canplay$:e("canplay"),ended$:e("ended"),looped$:c,error$:l,seeked$:e("seeked"),seeking$:e("seeking"),progress$:e("progress"),loadStart$:e("loadstart"),loadedMetadata$:e("loadedmetadata"),loadedData$:e("loadeddata"),timeUpdate$:d,durationChange$:x(i,"durationchange").pipe($(()=>i.duration)),isBuffering$:s,currentBuffer$:r,volumeState$:o,playbackRateState$:u,inPiP$:g,inFullscreen$:S}};var Js=i=>{switch(i){case"mobile":return Le.Q_144P;case"lowest":return Le.Q_240P;case"low":return Le.Q_360P;case"sd":case"medium":return Le.Q_480P;case"hd":case"high":return Le.Q_720P;case"fullhd":case"full":return Le.Q_1080P;case"quadhd":case"quad":return Le.Q_1440P;case"ultrahd":case"ultra":return Le.Q_2160P}},LS=Qe,xS=qs,OS=Ka,MS=Qa;LS({target:"Array",proto:!0},{at:function(e){var t=xS(this),s=OS(t),r=MS(e),a=r>=0?r:s+r;return a<0||a>=s?void 0:t[a]}});var BS=dn,NS=BS("Array","at"),FS=NS,VS=FS,US=VS,HS=US,lt=Vs(HS);let fn=!1,ut={};const jS=i=>{fn=i},GS=()=>{ut={}},YS=i=>{i(ut)},vs=(i,e)=>{var t;fn&&(ut.meta=(t=ut.meta)!==null&&t!==void 0?t:{},ut.meta[i]=e)};class tt{constructor(e){this.name=e}next(e){var t,s;if(!fn)return;ut.series=(t=ut.series)!==null&&t!==void 0?t:{};const r=(s=ut.series[this.name])!==null&&s!==void 0?s:[];r.push([Date.now(),e]),ut.series[this.name]=r}}var xt;(function(i){i.FitsContainer="FitsContainer",i.FitsThroughput="FitsThroughput",i.Buffer="Buffer",i.DroppedFramesLimit="DroppedFramesLimit",i.FitsQualityLimits="FitsQualityLimits"})(xt||(xt={}));const qS=new tt("best_bitrate"),WS=(i,e,t)=>(e-t)*Math.pow(2,-10*i)+t;class zS{constructor(){this.history={}}recordSelection(e){this.history[e.id]=le()}recordSwitch(e){this.last=e}clear(){this.last=void 0,this.history={}}}const QS='Assertion "ABR Tracks is empty array" failed',Xs=(i,{container:e,throughput:t,tuning:s,limits:r,reserve:a=0,forwardBufferHealth:n,playbackRate:o,current:u,history:l,droppedVideoMaxQualityLimit:d,abrLogger:c})=>{var h,f,m,v,g;$u(i,QS);const S=s.usePixelRatio&&(h=window.devicePixelRatio)!==null&&h!==void 0?h:1,E=s.limitByContainer&&e&&e.width>0&&e.height>0&&{width:e.width*S*s.containerSizeFactor,height:e.height*S*s.containerSizeFactor},A=E&&Mt(E),w=s.considerPlaybackRate&&R(o)?o:1,k=i.filter(N=>!Bt(N.quality)).sort((N,C)=>hi(N.quality,C.quality)?-1:1),q=(f=lt(k,-1))===null||f===void 0?void 0:f.quality,W=(m=lt(k,0))===null||m===void 0?void 0:m.quality,J=K(r)||R(r.min)&&R(r.max)&&$s(r.max,r.min)||R(r.min)&&W&&hi(r.min,W)||R(r.max)&&q&&$s(r.max,q),G=w*WS(n!=null?n:.5,s.bitrateFactorAtEmptyBuffer,s.bitrateFactorAtFullBuffer),X={},B=k.filter(N=>(A?$s(N.quality,A):!0)?(R(t)&&isFinite(t)&&R(N.bitrate)?t-a>=N.bitrate*G:!0)?s.lazyQualitySwitch&&R(s.minBufferToSwitchUp)&&u&&!Bt(u.quality)&&(n!=null?n:0)<s.minBufferToSwitchUp&&hi(N.quality,u.quality)?(X[N.quality]=xt.Buffer,!1):!!d&&ua(N.quality,d)?(X[N.quality]=xt.DroppedFramesLimit,!1):J||(K(r.max)||Cs(N.quality,r.max))&&(K(r.min)||ua(N.quality,r.min))?!0:(X[N.quality]=xt.FitsQualityLimits,!1):(X[N.quality]=xt.FitsThroughput,!1):(X[N.quality]=xt.FitsContainer,!1))[0];B&&B.bitrate&&qS.next(B.bitrate);const L=(v=B!=null?B:k[Math.ceil((k.length-1)/2)])!==null&&v!==void 0?v:i[0];L.quality!==((g=l==null?void 0:l.last)===null||g===void 0?void 0:g.quality)&&c({message:`
|
|
6
|
+
import{ValueSubject as y,Subject as D,Subscription as re,isNonNullable as R,ErrorCategory as I,isNullable as K,fromEvent as x,assertNever as H,merge as F,tap as Oi,map as $,observableFrom as He,filterChanged as pe,assertNonNullable as P,debounce as rt,getHighestQuality as Tu,timeout as Eu,getCurrentBrowser as Na,CurrentClientBrowser as yl,combine as Ve,once as _e,mapTo as _s,filter as fe,VideoQuality as Le,now as le,assertNotEmptyArray as $u,videoSizeToQuality as Mt,isInvariantQuality as Bt,isHigher as hi,isLower as $s,isHigherOrEqual as ua,isLowerOrEqual as Cs,interval as Ci,videoQualityToHeight as Au,abortable as Ce,getExponentialDelay as As,throttle as wu,Observable as Fa,observeElementSize as ku,isIOS as Pu,CurrentClientDevice as Ru,safeStorage as hr,fillWithDefault as _u,Logger as Cu}from"@vkontakte/videoplayer-shared/es2015.esm.js";import{Observable as FT,Subject as VT,Subscription as UT,ValueSubject as HT,VideoQuality as jT}from"@vkontakte/videoplayer-shared/es2015.esm.js";const Iu="2.0.103-dev.c555938f.0";var p;(function(i){i.STOPPED="stopped",i.READY="ready",i.PLAYING="playing",i.PAUSED="paused"})(p||(p={}));var b;(function(i){i.MPEG="MPEG",i.DASH="DASH_SEP",i.DASH_SEP="DASH_SEP",i.DASH_SEP_VK="DASH_SEP",i.DASH_WEBM="DASH_WEBM",i.DASH_WEBM_AV1="DASH_WEBM_AV1",i.DASH_WEBM_VK="DASH_WEBM",i.DASH_ONDEMAND="DASH_ONDEMAND",i.DASH_ONDEMAND_VK="DASH_ONDEMAND",i.DASH_LIVE="DASH_LIVE",i.DASH_LIVE_CMAF="DASH_LIVE_CMAF",i.DASH_LIVE_WEBM="DASH_LIVE_WEBM",i.HLS="HLS",i.HLS_ONDEMAND="HLS_ONDEMAND",i.HLS_JS="HLS",i.HLS_LIVE="HLS_LIVE",i.HLS_LIVE_CMAF="HLS_LIVE_CMAF",i.WEB_RTC_LIVE="WEB_RTC_LIVE"})(b||(b={}));var Ae;(function(i){i.SCREEN="SCREEN",i.CHROMECAST="CHROMECAST"})(Ae||(Ae={}));var ye;(function(i){i.NOT_AVAILABLE="NOT_AVAILABLE",i.AVAILABLE="AVAILABLE",i.CONNECTING="CONNECTING",i.CONNECTED="CONNECTED"})(ye||(ye={}));var ca;(function(i){i.HTTP1="http1",i.HTTP2="http2",i.QUIC="quic"})(ca||(ca={}));var Y;(function(i){i.None="none",i.Requested="requested",i.Applying="applying"})(Y||(Y={}));var bt;(function(i){i.NONE="none",i.INLINE="inline",i.FULLSCREEN="fullscreen",i.SECOND_SCREEN="second_screen",i.PIP="pip"})(bt||(bt={}));function te(i,e,t,s){function r(a){return a instanceof t?a:new t(function(n){n(a)})}return new(t||(t=Promise))(function(a,n){function o(d){try{l(s.next(d))}catch(c){n(c)}}function u(d){try{l(s.throw(d))}catch(c){n(c)}}function l(d){d.done?a(d.value):r(d.value).then(o,u)}l((s=s.apply(i,e||[])).next())})}function M(i){return this instanceof M?(this.v=i,this):new M(i)}function Ie(i,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=t.apply(i,e||[]),r,a=[];return r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r;function n(h){s[h]&&(r[h]=function(f){return new Promise(function(m,v){a.push([h,f,m,v])>1||o(h,f)})})}function o(h,f){try{u(s[h](f))}catch(m){c(a[0][3],m)}}function u(h){h.value instanceof M?Promise.resolve(h.value.v).then(l,d):c(a[0][2],h)}function l(h){o("next",h)}function d(h){o("throw",h)}function c(h,f){h(f),a.shift(),a.length&&o(a[0][0],a[0][1])}}var Du=i=>new Promise((e,t)=>{const s=document.createElement("script");s.setAttribute("src",i),s.onload=()=>e,s.onerror=()=>t,document.body.appendChild(s)});class Lu{constructor(e){var t;this.connection$=new y(void 0),this.castState$=new y(ye.NOT_AVAILABLE),this.errorEvent$=new D,this.realCastState$=new y(ye.NOT_AVAILABLE),this.subscription=new re,this.params=e,this.log=this.params.dependencies.logger.createComponentLog("ChromecastInitializer");const s="chrome"in window;if(this.log({message:`[constructor] receiverApplicationId: ${this.params.receiverApplicationId}, isDisabled: ${this.params.isDisabled}, isSupported: ${s}`}),e.isDisabled||!s)return;const r=R((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||Du("https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1").catch(()=>this.errorEvent$.next({id:"ChromecastLoading",category:I.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 s,r,a;(a=(r=(s=cast.framework.CastContext.getInstance())===null||s===void 0?void 0:s.getCurrentSession())===null||r===void 0?void 0:r.getMediaSession())===null||a===void 0||a.stop(new chrome.cast.media.StopRequest,e,t)})}toggleConnection(){R(this.connection$.getValue())?this.disconnect():this.connect()}setVolume(e){const t=this.connection$.getValue();K(t)||(t.remotePlayer.volumeLevel=e,t.remotePlayerController.setVolumeLevel())}setMuted(e){const t=this.connection$.getValue();K(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),s=cast.framework.CastContext.getInstance();this.subscription.add(x(s,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=s.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(F(x(s,cast.framework.CastContextEventType.CAST_STATE_CHANGED).pipe(Oi(r=>{this.log({message:`[cast.framework.RemotePlayerEventType.CAST_STATE_CHANGED]: ${JSON.stringify(r)}`})}),$(r=>r.castState)),He([s.getCastState()])).pipe(pe(),$(xu),Oi(r=>{this.log({message:`realCastState$: ${r}`})})).subscribe(this.realCastState$)).add(this.realCastState$.subscribe(r=>{var a;const n=r===ye.CONNECTED,o=R(this.connection$.getValue());if(n&&!o){const u=s.getCurrentSession();P(u);const l=u.getCastDevice(),d=(a=u.getMediaSession())===null||a===void 0?void 0:a.media.contentId;(K(d)||d===this.contentId)&&(this.log({message:"connection created"}),this.connection$.next({remotePlayer:e,remotePlayerController:t,session:u,castDevice:l}))}else!n&&o&&(this.log({message:"connection destroyed"}),this.connection$.next(void 0));this.castState$.next(r===ye.CONNECTED?R(this.connection$.getValue())?ye.CONNECTED:ye.AVAILABLE:r)}))}initializeCastApi(){var e;let t,s,r;try{t=cast.framework.CastContext.getInstance(),s=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:s,autoJoinPolicy:r}),this.initListeners()}catch(a){this.errorEvent$.next({id:"ChromecastInitializer",category:I.EXTERNAL_API,message:"[initializeCastApi] failed",thrown:a})}}}const xu=i=>{switch(i){case cast.framework.CastState.NO_DEVICES_AVAILABLE:return ye.NOT_AVAILABLE;case cast.framework.CastState.NOT_CONNECTED:return ye.AVAILABLE;case cast.framework.CastState.CONNECTING:return ye.CONNECTING;case cast.framework.CastState.CONNECTED:return ye.CONNECTED;default:return H(i)}};var fr=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Vs(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var je=function(i){try{return!!i()}catch(e){return!0}},Ou=je,Us=!Ou(function(){var i=function(){}.bind();return typeof i!="function"||i.hasOwnProperty("prototype")}),Tl=Us,El=Function.prototype,ha=El.call,Mu=Tl&&El.bind.bind(ha,ha),Ge=Tl?Mu:function(i){return function(){return ha.apply(i,arguments)}},$l=Ge,Bu=$l({}.toString),Nu=$l("".slice),Vi=function(i){return Nu(Bu(i),8,-1)},Fu=Ge,Vu=je,Uu=Vi,pr=Object,Hu=Fu("".split),ju=Vu(function(){return!pr("z").propertyIsEnumerable(0)})?function(i){return Uu(i)=="String"?Hu(i,""):pr(i)}:pr,Ui=function(i){return i==null},Gu=Ui,Yu=TypeError,Va=function(i){if(Gu(i))throw Yu("Can't call method on "+i);return i},qu=ju,Wu=Va,Hi=function(i){return qu(Wu(i))},gi={},is=function(i){return i&&i.Math==Math&&i},Ee=is(typeof globalThis=="object"&&globalThis)||is(typeof window=="object"&&window)||is(typeof self=="object"&&self)||is(typeof fr=="object"&&fr)||function(){return this}()||fr||Function("return this")(),fa=typeof document=="object"&&document.all,zu=typeof fa=="undefined"&&fa!==void 0,Al={all:fa,IS_HTMLDDA:zu},wl=Al,Qu=wl.all,ge=wl.IS_HTMLDDA?function(i){return typeof i=="function"||i===Qu}:function(i){return typeof i=="function"},Ku=Ee,Ju=ge,_n=Ku.WeakMap,Xu=Ju(_n)&&/native code/.test(String(_n)),Cn=ge,kl=Al,Zu=kl.all,ft=kl.IS_HTMLDDA?function(i){return typeof i=="object"?i!==null:Cn(i)||i===Zu}:function(i){return typeof i=="object"?i!==null:Cn(i)},ec=je,$t=!ec(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),Vt={},tc=Ee,In=ft,pa=tc.document,ic=In(pa)&&In(pa.createElement),Ua=function(i){return ic?pa.createElement(i):{}},sc=$t,rc=je,ac=Ua,Pl=!sc&&!rc(function(){return Object.defineProperty(ac("div"),"a",{get:function(){return 7}}).a!=7}),nc=$t,oc=je,Rl=nc&&oc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),lc=ft,dc=String,uc=TypeError,pt=function(i){if(lc(i))return i;throw uc(dc(i)+" is not an object")},cc=Us,ss=Function.prototype.call,Oe=cc?ss.bind(ss):function(){return ss.apply(ss,arguments)},Ha={},vr=Ha,mr=Ee,hc=ge,Dn=function(i){return hc(i)?i:void 0},Ut=function(i,e){return arguments.length<2?Dn(vr[i])||Dn(mr[i]):vr[i]&&vr[i][e]||mr[i]&&mr[i][e]},fc=Ge,Hs=fc({}.isPrototypeOf),js=typeof navigator!="undefined"&&String(navigator.userAgent)||"",_l=Ee,gr=js,Ln=_l.process,xn=_l.Deno,On=Ln&&Ln.versions||xn&&xn.version,Mn=On&&On.v8,We,Is;Mn&&(We=Mn.split("."),Is=We[0]>0&&We[0]<4?1:+(We[0]+We[1]));!Is&&gr&&(We=gr.match(/Edge\/(\d+)/),(!We||We[1]>=74)&&(We=gr.match(/Chrome\/(\d+)/),We&&(Is=+We[1])));var Cl=Is,Bn=Cl,pc=je,vc=Ee,mc=vc.String,Il=!!Object.getOwnPropertySymbols&&!pc(function(){var i=Symbol();return!mc(i)||!(Object(i)instanceof Symbol)||!Symbol.sham&&Bn&&Bn<41}),gc=Il,Dl=gc&&!Symbol.sham&&typeof Symbol.iterator=="symbol",Sc=Ut,bc=ge,yc=Hs,Tc=Dl,Ec=Object,Ll=Tc?function(i){return typeof i=="symbol"}:function(i){var e=Sc("Symbol");return bc(e)&&yc(e.prototype,Ec(i))},$c=String,Gs=function(i){try{return $c(i)}catch(e){return"Object"}},Ac=ge,wc=Gs,kc=TypeError,Ht=function(i){if(Ac(i))return i;throw kc(wc(i)+" is not a function")},Pc=Ht,Rc=Ui,Ys=function(i,e){var t=i[e];return Rc(t)?void 0:Pc(t)},Sr=Oe,br=ge,yr=ft,_c=TypeError,Cc=function(i,e){var t,s;if(e==="string"&&br(t=i.toString)&&!yr(s=Sr(t,i))||br(t=i.valueOf)&&!yr(s=Sr(t,i))||e!=="string"&&br(t=i.toString)&&!yr(s=Sr(t,i)))return s;throw _c("Can't convert object to primitive value")},xl={exports:{}},Ic=!0,Nn=Ee,Dc=Object.defineProperty,Lc=function(i,e){try{Dc(Nn,i,{value:e,configurable:!0,writable:!0})}catch(t){Nn[i]=e}return e},xc=Ee,Oc=Lc,Fn="__core-js_shared__",Mc=xc[Fn]||Oc(Fn,{}),ja=Mc,Vn=ja;(xl.exports=function(i,e){return Vn[i]||(Vn[i]=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 Ol=xl.exports,Bc=Va,Nc=Object,qs=function(i){return Nc(Bc(i))},Fc=Ge,Vc=qs,Uc=Fc({}.hasOwnProperty),nt=Object.hasOwn||function(e,t){return Uc(Vc(e),t)},Hc=Ge,jc=0,Gc=Math.random(),Yc=Hc(1 .toString),Ml=function(i){return"Symbol("+(i===void 0?"":i)+")_"+Yc(++jc+Gc,36)},qc=Ee,Wc=Ol,Un=nt,zc=Ml,Qc=Il,Kc=Dl,li=qc.Symbol,Tr=Wc("wks"),Jc=Kc?li.for||li:li&&li.withoutSetter||zc,Pe=function(i){return Un(Tr,i)||(Tr[i]=Qc&&Un(li,i)?li[i]:Jc("Symbol."+i)),Tr[i]},Xc=Oe,Hn=ft,jn=Ll,Zc=Ys,eh=Cc,th=Pe,ih=TypeError,sh=th("toPrimitive"),rh=function(i,e){if(!Hn(i)||jn(i))return i;var t=Zc(i,sh),s;if(t){if(e===void 0&&(e="default"),s=Xc(t,i,e),!Hn(s)||jn(s))return s;throw ih("Can't convert object to primitive value")}return e===void 0&&(e="number"),eh(i,e)},ah=rh,nh=Ll,Ga=function(i){var e=ah(i,"string");return nh(e)?e:e+""},oh=$t,lh=Pl,dh=Rl,rs=pt,Gn=Ga,uh=TypeError,Er=Object.defineProperty,ch=Object.getOwnPropertyDescriptor,$r="enumerable",Ar="configurable",wr="writable";Vt.f=oh?dh?function(e,t,s){if(rs(e),t=Gn(t),rs(s),typeof e=="function"&&t==="prototype"&&"value"in s&&wr in s&&!s[wr]){var r=ch(e,t);r&&r[wr]&&(e[t]=s.value,s={configurable:Ar in s?s[Ar]:r[Ar],enumerable:$r in s?s[$r]:r[$r],writable:!1})}return Er(e,t,s)}:Er:function(e,t,s){if(rs(e),t=Gn(t),rs(s),lh)try{return Er(e,t,s)}catch(r){}if("get"in s||"set"in s)throw uh("Accessors not supported");return"value"in s&&(e[t]=s.value),e};var Ws=function(i,e){return{enumerable:!(i&1),configurable:!(i&2),writable:!(i&4),value:e}},hh=$t,fh=Vt,ph=Ws,ji=hh?function(i,e,t){return fh.f(i,e,ph(1,t))}:function(i,e,t){return i[e]=t,i},vh=Ol,mh=Ml,Yn=vh("keys"),Ya=function(i){return Yn[i]||(Yn[i]=mh(i))},qa={},gh=Xu,Bl=Ee,Sh=ft,bh=ji,kr=nt,Pr=ja,yh=Ya,Th=qa,qn="Object already initialized",va=Bl.TypeError,Eh=Bl.WeakMap,Ds,Mi,Ls,$h=function(i){return Ls(i)?Mi(i):Ds(i,{})},Ah=function(i){return function(e){var t;if(!Sh(e)||(t=Mi(e)).type!==i)throw va("Incompatible receiver, "+i+" required");return t}};if(gh||Pr.state){var Xe=Pr.state||(Pr.state=new Eh);Xe.get=Xe.get,Xe.has=Xe.has,Xe.set=Xe.set,Ds=function(i,e){if(Xe.has(i))throw va(qn);return e.facade=i,Xe.set(i,e),e},Mi=function(i){return Xe.get(i)||{}},Ls=function(i){return Xe.has(i)}}else{var ei=yh("state");Th[ei]=!0,Ds=function(i,e){if(kr(i,ei))throw va(qn);return e.facade=i,bh(i,ei,e),e},Mi=function(i){return kr(i,ei)?i[ei]:{}},Ls=function(i){return kr(i,ei)}}var Nl={set:Ds,get:Mi,has:Ls,enforce:$h,getterFor:Ah},wh=Us,Fl=Function.prototype,Wn=Fl.apply,zn=Fl.call,Vl=typeof Reflect=="object"&&Reflect.apply||(wh?zn.bind(Wn):function(){return zn.apply(Wn,arguments)}),kh=Vi,Ph=Ge,Ul=function(i){if(kh(i)==="Function")return Ph(i)},Wa={},Hl={},jl={}.propertyIsEnumerable,Gl=Object.getOwnPropertyDescriptor,Rh=Gl&&!jl.call({1:2},1);Hl.f=Rh?function(e){var t=Gl(this,e);return!!t&&t.enumerable}:jl;var _h=$t,Ch=Oe,Ih=Hl,Dh=Ws,Lh=Hi,xh=Ga,Oh=nt,Mh=Pl,Qn=Object.getOwnPropertyDescriptor;Wa.f=_h?Qn:function(e,t){if(e=Lh(e),t=xh(t),Mh)try{return Qn(e,t)}catch(s){}if(Oh(e,t))return Dh(!Ch(Ih.f,e,t),e[t])};var Bh=je,Nh=ge,Fh=/#|\.prototype\./,Gi=function(i,e){var t=Uh[Vh(i)];return t==jh?!0:t==Hh?!1:Nh(e)?Bh(e):!!e},Vh=Gi.normalize=function(i){return String(i).replace(Fh,".").toLowerCase()},Uh=Gi.data={},Hh=Gi.NATIVE="N",jh=Gi.POLYFILL="P",Yl=Gi,Kn=Ul,Gh=Ht,Yh=Us,qh=Kn(Kn.bind),zs=function(i,e){return Gh(i),e===void 0?i:Yh?qh(i,e):function(){return i.apply(e,arguments)}},as=Ee,Wh=Vl,zh=Ul,Qh=ge,Kh=Wa.f,Jh=Yl,ti=Ha,Xh=zs,ii=ji,Jn=nt,Zh=function(i){var e=function(t,s,r){if(this instanceof e){switch(arguments.length){case 0:return new i;case 1:return new i(t);case 2:return new i(t,s)}return new i(t,s,r)}return Wh(i,this,arguments)};return e.prototype=i.prototype,e},Qe=function(i,e){var t=i.target,s=i.global,r=i.stat,a=i.proto,n=s?as:r?as[t]:(as[t]||{}).prototype,o=s?ti:ti[t]||ii(ti,t,{})[t],u=o.prototype,l,d,c,h,f,m,v,g,S;for(h in e)l=Jh(s?h:t+(r?".":"#")+h,i.forced),d=!l&&n&&Jn(n,h),m=o[h],d&&(i.dontCallGetSet?(S=Kh(n,h),v=S&&S.value):v=n[h]),f=d&&v?v:e[h],!(d&&typeof m==typeof f)&&(i.bind&&d?g=Xh(f,as):i.wrap&&d?g=Zh(f):a&&Qh(f)?g=zh(f):g=f,(i.sham||f&&f.sham||m&&m.sham)&&ii(g,"sham",!0),ii(o,h,g),a&&(c=t+"Prototype",Jn(ti,c)||ii(ti,c,{}),ii(ti[c],h,f),i.real&&u&&(l||!u[h])&&ii(u,h,f)))},ma=$t,ef=nt,ql=Function.prototype,tf=ma&&Object.getOwnPropertyDescriptor,za=ef(ql,"name"),sf=za&&function(){}.name==="something",rf=za&&(!ma||ma&&tf(ql,"name").configurable),af={EXISTS:za,PROPER:sf,CONFIGURABLE:rf},Wl={},nf=Math.ceil,of=Math.floor,lf=Math.trunc||function(e){var t=+e;return(t>0?of:nf)(t)},df=lf,Qa=function(i){var e=+i;return e!==e||e===0?0:df(e)},uf=Qa,cf=Math.max,hf=Math.min,ff=function(i,e){var t=uf(i);return t<0?cf(t+e,0):hf(t,e)},pf=Qa,vf=Math.min,mf=function(i){return i>0?vf(pf(i),9007199254740991):0},gf=mf,Ka=function(i){return gf(i.length)},Sf=Hi,bf=ff,yf=Ka,Xn=function(i){return function(e,t,s){var r=Sf(e),a=yf(r),n=bf(s,a),o;if(i&&t!=t){for(;a>n;)if(o=r[n++],o!=o)return!0}else for(;a>n;n++)if((i||n in r)&&r[n]===t)return i||n||0;return!i&&-1}},Tf={includes:Xn(!0),indexOf:Xn(!1)},Ef=Ge,Rr=nt,$f=Hi,Af=Tf.indexOf,wf=qa,Zn=Ef([].push),kf=function(i,e){var t=$f(i),s=0,r=[],a;for(a in t)!Rr(wf,a)&&Rr(t,a)&&Zn(r,a);for(;e.length>s;)Rr(t,a=e[s++])&&(~Af(r,a)||Zn(r,a));return r},zl=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Pf=kf,Rf=zl,_f=Object.keys||function(e){return Pf(e,Rf)},Cf=$t,If=Rl,Df=Vt,Lf=pt,xf=Hi,Of=_f;Wl.f=Cf&&!If?Object.defineProperties:function(e,t){Lf(e);for(var s=xf(t),r=Of(t),a=r.length,n=0,o;a>n;)Df.f(e,o=r[n++],s[o]);return e};var Mf=Ut,Ql=Mf("document","documentElement"),Bf=pt,Nf=Wl,eo=zl,Ff=qa,Vf=Ql,Uf=Ua,Hf=Ya,to=">",io="<",ga="prototype",Sa="script",Kl=Hf("IE_PROTO"),_r=function(){},Jl=function(i){return io+Sa+to+i+io+"/"+Sa+to},so=function(i){i.write(Jl("")),i.close();var e=i.parentWindow.Object;return i=null,e},jf=function(){var i=Uf("iframe"),e="java"+Sa+":",t;return i.style.display="none",Vf.appendChild(i),i.src=String(e),t=i.contentWindow.document,t.open(),t.write(Jl("document.F=Object")),t.close(),t.F},ns,ws=function(){try{ns=new ActiveXObject("htmlfile")}catch(e){}ws=typeof document!="undefined"?document.domain&&ns?so(ns):jf():so(ns);for(var i=eo.length;i--;)delete ws[ga][eo[i]];return ws()};Ff[Kl]=!0;var Xl=Object.create||function(e,t){var s;return e!==null?(_r[ga]=Bf(e),s=new _r,_r[ga]=null,s[Kl]=e):s=ws(),t===void 0?s:Nf.f(s,t)},Gf=je,Yf=!Gf(function(){function i(){}return i.prototype.constructor=null,Object.getPrototypeOf(new i)!==i.prototype}),qf=nt,Wf=ge,zf=qs,Qf=Ya,Kf=Yf,ro=Qf("IE_PROTO"),ba=Object,Jf=ba.prototype,Zl=Kf?ba.getPrototypeOf:function(i){var e=zf(i);if(qf(e,ro))return e[ro];var t=e.constructor;return Wf(t)&&e instanceof t?t.prototype:e instanceof ba?Jf:null},Xf=ji,Ja=function(i,e,t,s){return s&&s.enumerable?i[e]=t:Xf(i,e,t),i},Zf=je,ep=ge,tp=ft,ip=Xl,ao=Zl,sp=Ja,rp=Pe,ya=rp("iterator"),ed=!1,ct,Cr,Ir;[].keys&&(Ir=[].keys(),"next"in Ir?(Cr=ao(ao(Ir)),Cr!==Object.prototype&&(ct=Cr)):ed=!0);var ap=!tp(ct)||Zf(function(){var i={};return ct[ya].call(i)!==i});ap?ct={}:ct=ip(ct);ep(ct[ya])||sp(ct,ya,function(){return this});var td={IteratorPrototype:ct,BUGGY_SAFARI_ITERATORS:ed},np=Pe,op=np("toStringTag"),id={};id[op]="z";var Xa=String(id)==="[object z]",lp=Xa,dp=ge,ks=Vi,up=Pe,cp=up("toStringTag"),hp=Object,fp=ks(function(){return arguments}())=="Arguments",pp=function(i,e){try{return i[e]}catch(t){}},Yi=lp?ks:function(i){var e,t,s;return i===void 0?"Undefined":i===null?"Null":typeof(t=pp(e=hp(i),cp))=="string"?t:fp?ks(e):(s=ks(e))=="Object"&&dp(e.callee)?"Arguments":s},vp=Xa,mp=Yi,gp=vp?{}.toString:function(){return"[object "+mp(this)+"]"},Sp=Xa,bp=Vt.f,yp=ji,Tp=nt,Ep=gp,$p=Pe,no=$p("toStringTag"),Za=function(i,e,t,s){if(i){var r=t?i:i.prototype;Tp(r,no)||bp(r,no,{configurable:!0,value:e}),s&&!Sp&&yp(r,"toString",Ep)}},Ap=td.IteratorPrototype,wp=Xl,kp=Ws,Pp=Za,Rp=gi,_p=function(){return this},Cp=function(i,e,t,s){var r=e+" Iterator";return i.prototype=wp(Ap,{next:kp(+!s,t)}),Pp(i,r,!1,!0),Rp[r]=_p,i},Ip=Qe,Dp=Oe,sd=af,Lp=Cp,xp=Zl,Op=Za,oo=Ja,Mp=Pe,lo=gi,rd=td,Bp=sd.PROPER;sd.CONFIGURABLE;rd.IteratorPrototype;var os=rd.BUGGY_SAFARI_ITERATORS,Dr=Mp("iterator"),uo="keys",ls="values",co="entries",Np=function(){return this},Fp=function(i,e,t,s,r,a,n){Lp(t,e,s);var o=function(S){if(S===r&&h)return h;if(!os&&S in d)return d[S];switch(S){case uo:return function(){return new t(this,S)};case ls:return function(){return new t(this,S)};case co:return function(){return new t(this,S)}}return function(){return new t(this)}},u=e+" Iterator",l=!1,d=i.prototype,c=d[Dr]||d["@@iterator"]||r&&d[r],h=!os&&c||o(r),f=e=="Array"&&d.entries||c,m,v,g;if(f&&(m=xp(f.call(new i)),m!==Object.prototype&&m.next&&(Op(m,u,!0,!0),lo[u]=Np)),Bp&&r==ls&&c&&c.name!==ls&&(l=!0,h=function(){return Dp(c,this)}),r)if(v={values:o(ls),keys:a?h:o(uo),entries:o(co)},n)for(g in v)(os||l||!(g in d))&&oo(d,g,v[g]);else Ip({target:e,proto:!0,forced:os||l},v);return n&&d[Dr]!==h&&oo(d,Dr,h,{name:r}),lo[e]=h,v},Vp=function(i,e){return{value:i,done:e}},Up=Hi,ho=gi,ad=Nl;Vt.f;var Hp=Fp,ds=Vp,nd="Array Iterator",jp=ad.set,Gp=ad.getterFor(nd);Hp(Array,"Array",function(i,e){jp(this,{type:nd,target:Up(i),index:0,kind:e})},function(){var i=Gp(this),e=i.target,t=i.kind,s=i.index++;return!e||s>=e.length?(i.target=void 0,ds(void 0,!0)):t=="keys"?ds(s,!1):t=="values"?ds(e[s],!1):ds([s,e[s]],!1)},"values");ho.Arguments=ho.Array;var Yp=Pe,qp=gi,Wp=Yp("iterator"),zp=Array.prototype,Qp=function(i){return i!==void 0&&(qp.Array===i||zp[Wp]===i)},Kp=Yi,fo=Ys,Jp=Ui,Xp=gi,Zp=Pe,ev=Zp("iterator"),od=function(i){if(!Jp(i))return fo(i,ev)||fo(i,"@@iterator")||Xp[Kp(i)]},tv=Oe,iv=Ht,sv=pt,rv=Gs,av=od,nv=TypeError,ov=function(i,e){var t=arguments.length<2?av(i):e;if(iv(t))return sv(tv(t,i));throw nv(rv(i)+" is not iterable")},lv=Oe,po=pt,dv=Ys,uv=function(i,e,t){var s,r;po(i);try{if(s=dv(i,"return"),!s){if(e==="throw")throw t;return t}s=lv(s,i)}catch(a){r=!0,s=a}if(e==="throw")throw t;if(r)throw s;return po(s),t},cv=zs,hv=Oe,fv=pt,pv=Gs,vv=Qp,mv=Ka,vo=Hs,gv=ov,Sv=od,mo=uv,bv=TypeError,Ps=function(i,e){this.stopped=i,this.result=e},go=Ps.prototype,en=function(i,e,t){var s=t&&t.that,r=!!(t&&t.AS_ENTRIES),a=!!(t&&t.IS_RECORD),n=!!(t&&t.IS_ITERATOR),o=!!(t&&t.INTERRUPTED),u=cv(e,s),l,d,c,h,f,m,v,g=function(E){return l&&mo(l,"normal",E),new Ps(!0,E)},S=function(E){return r?(fv(E),o?u(E[0],E[1],g):u(E[0],E[1])):o?u(E,g):u(E)};if(a)l=i.iterator;else if(n)l=i;else{if(d=Sv(i),!d)throw bv(pv(i)+" is not iterable");if(vv(d)){for(c=0,h=mv(i);h>c;c++)if(f=S(i[c]),f&&vo(go,f))return f;return new Ps(!1)}l=gv(i,d)}for(m=a?i.next:l.next;!(v=hv(m,l)).done;){try{f=S(v.value)}catch(E){mo(l,"throw",E)}if(typeof f=="object"&&f&&vo(go,f))return f}return new Ps(!1)},yv=Ga,Tv=Vt,Ev=Ws,$v=function(i,e,t){var s=yv(e);s in i?Tv.f(i,s,Ev(0,t)):i[s]=t},Av=Qe,wv=en,kv=$v;Av({target:"Object",stat:!0},{fromEntries:function(e){var t={};return wv(e,function(s,r){kv(t,s,r)},{AS_ENTRIES:!0}),t}});var Pv=Ha,Rv=Pv.Object.fromEntries,_v={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},Cv=_v,Iv=Ee,Dv=Yi,Lv=ji,So=gi,xv=Pe,bo=xv("toStringTag");for(var Lr in Cv){var yo=Iv[Lr],xr=yo&&yo.prototype;xr&&Dv(xr)!==bo&&Lv(xr,bo,Lr),So[Lr]=So.Array}var Ov=Rv,Mv=Ov,Bv=Mv,Nv=Bv,xs=Vs(Nv),Fv=Vi,Qs=typeof process!="undefined"&&Fv(process)=="process",Vv=Vt,Uv=function(i,e,t){return Vv.f(i,e,t)},Hv=Ut,jv=Uv,Gv=Pe,Yv=$t,To=Gv("species"),qv=function(i){var e=Hv(i);Yv&&e&&!e[To]&&jv(e,To,{configurable:!0,get:function(){return this}})},Wv=Hs,zv=TypeError,Qv=function(i,e){if(Wv(e,i))return i;throw zv("Incorrect invocation")},Kv=Ge,Jv=ge,Ta=ja,Xv=Kv(Function.toString);Jv(Ta.inspectSource)||(Ta.inspectSource=function(i){return Xv(i)});var ld=Ta.inspectSource,Zv=Ge,em=je,dd=ge,tm=Yi,im=Ut,sm=ld,ud=function(){},rm=[],cd=im("Reflect","construct"),tn=/^\s*(?:class|function)\b/,am=Zv(tn.exec),nm=!tn.exec(ud),ki=function(e){if(!dd(e))return!1;try{return cd(ud,rm,e),!0}catch(t){return!1}},hd=function(e){if(!dd(e))return!1;switch(tm(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return nm||!!am(tn,sm(e))}catch(t){return!0}};hd.sham=!0;var om=!cd||em(function(){var i;return ki(ki.call)||!ki(Object)||!ki(function(){i=!0})||i})?hd:ki,lm=om,dm=Gs,um=TypeError,cm=function(i){if(lm(i))return i;throw um(dm(i)+" is not a constructor")},Eo=pt,hm=cm,fm=Ui,pm=Pe,vm=pm("species"),fd=function(i,e){var t=Eo(i).constructor,s;return t===void 0||fm(s=Eo(t)[vm])?e:hm(s)},mm=Ge,gm=mm([].slice),Sm=TypeError,bm=function(i,e){if(i<e)throw Sm("Not enough arguments");return i},ym=js,pd=/(?:ipad|iphone|ipod).*applewebkit/i.test(ym),xe=Ee,Tm=Vl,Em=zs,$o=ge,$m=nt,vd=je,Ao=Ql,Am=gm,wo=Ua,wm=bm,km=pd,Pm=Qs,Ea=xe.setImmediate,$a=xe.clearImmediate,Rm=xe.process,Or=xe.Dispatch,_m=xe.Function,ko=xe.MessageChannel,Cm=xe.String,Mr=0,Ii={},Po="onreadystatechange",Bi,Ct,Br,Nr;vd(function(){Bi=xe.location});var sn=function(i){if($m(Ii,i)){var e=Ii[i];delete Ii[i],e()}},Fr=function(i){return function(){sn(i)}},Ro=function(i){sn(i.data)},_o=function(i){xe.postMessage(Cm(i),Bi.protocol+"//"+Bi.host)};(!Ea||!$a)&&(Ea=function(e){wm(arguments.length,1);var t=$o(e)?e:_m(e),s=Am(arguments,1);return Ii[++Mr]=function(){Tm(t,void 0,s)},Ct(Mr),Mr},$a=function(e){delete Ii[e]},Pm?Ct=function(i){Rm.nextTick(Fr(i))}:Or&&Or.now?Ct=function(i){Or.now(Fr(i))}:ko&&!km?(Br=new ko,Nr=Br.port2,Br.port1.onmessage=Ro,Ct=Em(Nr.postMessage,Nr)):xe.addEventListener&&$o(xe.postMessage)&&!xe.importScripts&&Bi&&Bi.protocol!=="file:"&&!vd(_o)?(Ct=_o,xe.addEventListener("message",Ro,!1)):Po in wo("script")?Ct=function(i){Ao.appendChild(wo("script"))[Po]=function(){Ao.removeChild(this),sn(i)}}:Ct=function(i){setTimeout(Fr(i),0)});var md={set:Ea,clear:$a},gd=function(){this.head=null,this.tail=null};gd.prototype={add:function(i){var e={item:i,next:null},t=this.tail;t?t.next=e:this.head=e,this.tail=e},get:function(){var i=this.head;if(i){var e=this.head=i.next;return e===null&&(this.tail=null),i.item}}};var Sd=gd,Im=js,Dm=/ipad|iphone|ipod/i.test(Im)&&typeof Pebble!="undefined",Lm=js,xm=/web0s(?!.*chrome)/i.test(Lm),Nt=Ee,Co=zs,Om=Wa.f,Vr=md.set,Mm=Sd,Bm=pd,Nm=Dm,Fm=xm,Ur=Qs,Io=Nt.MutationObserver||Nt.WebKitMutationObserver,Do=Nt.document,Lo=Nt.process,us=Nt.Promise,xo=Om(Nt,"queueMicrotask"),Aa=xo&&xo.value,si,Hr,jr,cs,Oo;if(!Aa){var hs=new Mm,fs=function(){var i,e;for(Ur&&(i=Lo.domain)&&i.exit();e=hs.get();)try{e()}catch(t){throw hs.head&&si(),t}i&&i.enter()};!Bm&&!Ur&&!Fm&&Io&&Do?(Hr=!0,jr=Do.createTextNode(""),new Io(fs).observe(jr,{characterData:!0}),si=function(){jr.data=Hr=!Hr}):!Nm&&us&&us.resolve?(cs=us.resolve(void 0),cs.constructor=us,Oo=Co(cs.then,cs),si=function(){Oo(fs)}):Ur?si=function(){Lo.nextTick(fs)}:(Vr=Co(Vr,Nt),si=function(){Vr(fs)}),Aa=function(i){hs.head||si(),hs.add(i)}}var Vm=Aa,Um=function(i,e){try{arguments.length==1?console.error(i):console.error(i,e)}catch(t){}},rn=function(i){try{return{error:!1,value:i()}}catch(e){return{error:!0,value:e}}},Hm=Ee,Si=Hm.Promise,bd=typeof Deno=="object"&&Deno&&typeof Deno.version=="object",jm=bd,Gm=Qs,Ym=!jm&&!Gm&&typeof window=="object"&&typeof document=="object",qm=Ee,Di=Si,Wm=ge,zm=Yl,Qm=ld,Km=Pe,Jm=Ym,Xm=bd,Gr=Cl,Mo=Di&&Di.prototype,Zm=Km("species"),wa=!1,yd=Wm(qm.PromiseRejectionEvent),eg=zm("Promise",function(){var i=Qm(Di),e=i!==String(Di);if(!e&&Gr===66||!(Mo.catch&&Mo.finally))return!0;if(!Gr||Gr<51||!/native code/.test(i)){var t=new Di(function(a){a(1)}),s=function(a){a(function(){},function(){})},r=t.constructor={};if(r[Zm]=s,wa=t.then(function(){})instanceof s,!wa)return!0}return!e&&(Jm||Xm)&&!yd}),qi={CONSTRUCTOR:eg,REJECTION_EVENT:yd,SUBCLASSING:wa},bi={},Bo=Ht,tg=TypeError,ig=function(i){var e,t;this.promise=new i(function(s,r){if(e!==void 0||t!==void 0)throw tg("Bad Promise constructor");e=s,t=r}),this.resolve=Bo(e),this.reject=Bo(t)};bi.f=function(i){return new ig(i)};var sg=Qe,Os=Qs,Et=Ee,Wi=Oe,rg=Ja,ag=Za,ng=qv,og=Ht,ka=ge,lg=ft,dg=Qv,ug=fd,Td=md.set,an=Vm,cg=Um,hg=rn,fg=Sd,Ed=Nl,Pa=Si,nn=qi,$d=bi,Ks="Promise",Ad=nn.CONSTRUCTOR,pg=nn.REJECTION_EVENT;nn.SUBCLASSING;var Yr=Ed.getterFor(Ks),vg=Ed.set,mg=Pa&&Pa.prototype,di=Pa,qr=mg,wd=Et.TypeError,Ra=Et.document,on=Et.process,_a=$d.f,gg=_a,Sg=!!(Ra&&Ra.createEvent&&Et.dispatchEvent),kd="unhandledrejection",bg="rejectionhandled",No=0,Pd=1,yg=2,ln=1,Rd=2,ps,Fo,Tg,_d=function(i){var e;return lg(i)&&ka(e=i.then)?e:!1},Cd=function(i,e){var t=e.value,s=e.state==Pd,r=s?i.ok:i.fail,a=i.resolve,n=i.reject,o=i.domain,u,l,d;try{r?(s||(e.rejection===Rd&&$g(e),e.rejection=ln),r===!0?u=t:(o&&o.enter(),u=r(t),o&&(o.exit(),d=!0)),u===i.promise?n(wd("Promise-chain cycle")):(l=_d(u))?Wi(l,u,a,n):a(u)):n(t)}catch(c){o&&!d&&o.exit(),n(c)}},Id=function(i,e){i.notified||(i.notified=!0,an(function(){for(var t=i.reactions,s;s=t.get();)Cd(s,i);i.notified=!1,e&&!i.rejection&&Eg(i)}))},Dd=function(i,e,t){var s,r;Sg?(s=Ra.createEvent("Event"),s.promise=e,s.reason=t,s.initEvent(i,!1,!0),Et.dispatchEvent(s)):s={promise:e,reason:t},!pg&&(r=Et["on"+i])?r(s):i===kd&&cg("Unhandled promise rejection",t)},Eg=function(i){Wi(Td,Et,function(){var e=i.facade,t=i.value,s=Vo(i),r;if(s&&(r=hg(function(){Os?on.emit("unhandledRejection",t,e):Dd(kd,e,t)}),i.rejection=Os||Vo(i)?Rd:ln,r.error))throw r.value})},Vo=function(i){return i.rejection!==ln&&!i.parent},$g=function(i){Wi(Td,Et,function(){var e=i.facade;Os?on.emit("rejectionHandled",e):Dd(bg,e,i.value)})},ui=function(i,e,t){return function(s){i(e,s,t)}},fi=function(i,e,t){i.done||(i.done=!0,t&&(i=t),i.value=e,i.state=yg,Id(i,!0))},Ca=function(i,e,t){if(!i.done){i.done=!0,t&&(i=t);try{if(i.facade===e)throw wd("Promise can't be resolved itself");var s=_d(e);s?an(function(){var r={done:!1};try{Wi(s,e,ui(Ca,r,i),ui(fi,r,i))}catch(a){fi(r,a,i)}}):(i.value=e,i.state=Pd,Id(i,!1))}catch(r){fi({done:!1},r,i)}}};Ad&&(di=function(e){dg(this,qr),og(e),Wi(ps,this);var t=Yr(this);try{e(ui(Ca,t),ui(fi,t))}catch(s){fi(t,s)}},qr=di.prototype,ps=function(e){vg(this,{type:Ks,done:!1,notified:!1,parent:!1,reactions:new fg,rejection:!1,state:No,value:void 0})},ps.prototype=rg(qr,"then",function(e,t){var s=Yr(this),r=_a(ug(this,di));return s.parent=!0,r.ok=ka(e)?e:!0,r.fail=ka(t)&&t,r.domain=Os?on.domain:void 0,s.state==No?s.reactions.add(r):an(function(){Cd(r,s)}),r.promise}),Fo=function(){var i=new ps,e=Yr(i);this.promise=i,this.resolve=ui(Ca,e),this.reject=ui(fi,e)},$d.f=_a=function(i){return i===di||i===Tg?new Fo(i):gg(i)});sg({global:!0,constructor:!0,wrap:!0,forced:Ad},{Promise:di});ag(di,Ks,!1,!0);ng(Ks);var Ag=Pe,Ld=Ag("iterator"),xd=!1;try{var wg=0,Uo={next:function(){return{done:!!wg++}},return:function(){xd=!0}};Uo[Ld]=function(){return this},Array.from(Uo,function(){throw 2})}catch(i){}var kg=function(i,e){if(!e&&!xd)return!1;var t=!1;try{var s={};s[Ld]=function(){return{next:function(){return{done:t=!0}}}},i(s)}catch(r){}return t},Pg=Si,Rg=kg,_g=qi.CONSTRUCTOR,Od=_g||!Rg(function(i){Pg.all(i).then(void 0,function(){})}),Cg=Qe,Ig=Oe,Dg=Ht,Lg=bi,xg=rn,Og=en,Mg=Od;Cg({target:"Promise",stat:!0,forced:Mg},{all:function(e){var t=this,s=Lg.f(t),r=s.resolve,a=s.reject,n=xg(function(){var o=Dg(t.resolve),u=[],l=0,d=1;Og(e,function(c){var h=l++,f=!1;d++,Ig(o,t,c).then(function(m){f||(f=!0,u[h]=m,--d||r(u))},a)}),--d||r(u)});return n.error&&a(n.value),s.promise}});var Bg=Qe,Ng=qi.CONSTRUCTOR,Ho=Si;Ho&&Ho.prototype;Bg({target:"Promise",proto:!0,forced:Ng,real:!0},{catch:function(i){return this.then(void 0,i)}});var Fg=Qe,Vg=Oe,Ug=Ht,Hg=bi,jg=rn,Gg=en,Yg=Od;Fg({target:"Promise",stat:!0,forced:Yg},{race:function(e){var t=this,s=Hg.f(t),r=s.reject,a=jg(function(){var n=Ug(t.resolve);Gg(e,function(o){Vg(n,t,o).then(s.resolve,r)})});return a.error&&r(a.value),s.promise}});var qg=Qe,Wg=Oe,zg=bi,Qg=qi.CONSTRUCTOR;qg({target:"Promise",stat:!0,forced:Qg},{reject:function(e){var t=zg.f(this);return Wg(t.reject,void 0,e),t.promise}});var Kg=pt,Jg=ft,Xg=bi,Md=function(i,e){if(Kg(i),Jg(e)&&e.constructor===i)return e;var t=Xg.f(i),s=t.resolve;return s(e),t.promise},Zg=Qe,eS=Ut,tS=Ic,iS=Si,sS=qi.CONSTRUCTOR,rS=Md,aS=eS("Promise"),nS=!sS;Zg({target:"Promise",stat:!0,forced:tS},{resolve:function(e){return rS(nS&&this===aS?iS:this,e)}});var oS=Qe,Ia=Si,lS=je,dS=Ut,uS=ge,cS=fd,jo=Md,hS=Ia&&Ia.prototype,fS=!!Ia&&lS(function(){hS.finally.call({then:function(){}},function(){})});oS({target:"Promise",proto:!0,real:!0,forced:fS},{finally:function(i){var e=cS(this,dS("Promise")),t=uS(i);return this.then(t?function(s){return jo(e,i()).then(function(){return s})}:i,t?function(s){return jo(e,i()).then(function(){throw s})}:i)}});var pS=Ut,dn=pS,vS=dn,mS=vS("Promise","finally"),gS=mS,SS=gS,bS=SS,yS=bS,un=Vs(yS),Se;(function(i){i[i.OFFSET_P=0]="OFFSET_P",i[i.PLAYBACK_SHIFT=1]="PLAYBACK_SHIFT",i[i.DASH_CMAF_OFFSET_P=2]="DASH_CMAF_OFFSET_P"})(Se||(Se={}));var ze=(i,e=0,t=Se.OFFSET_P)=>{switch(t){case Se.OFFSET_P:return i.replace("_offset_p",e===0?"":"_"+e.toFixed(0));case Se.PLAYBACK_SHIFT:{if(e===0)return i;const s=new URL(i);return s.searchParams.append("playback_shift",e.toFixed(0)),s.toString()}case Se.DASH_CMAF_OFFSET_P:{const s=new URL(i);return!s.searchParams.get("offset_p")&&e===0?i:(s.searchParams.set("offset_p",e.toFixed(0)),s.toString())}default:H(t)}return i};const Go=(i,e)=>{var t;switch(e){case Se.OFFSET_P:return NaN;case Se.PLAYBACK_SHIFT:{const s=new URL(i);return Number(s.searchParams.get("playback_shift"))}case Se.DASH_CMAF_OFFSET_P:{const s=new URL(i);return Number((t=s.searchParams.get("offset_p"))!==null&&t!==void 0?t:0)}default:H(e)}};var O=(i,e,t=!1)=>{const s=i.getTransition();(t||!s||s.to===e)&&i.setState(e)};class he{constructor(e){this.transitionStarted$=new D,this.transitionEnded$=new D,this.transitionUpdated$=new D,this.forceChanged$=new D,this.stateChangeStarted$=F(this.transitionStarted$,this.transitionUpdated$),this.stateChangeEnded$=F(this.transitionEnded$,this.forceChanged$),this.state=e,this.prevState=void 0}setState(e){const t=this.transition,s=this.state;this.transition=void 0,this.prevState=s,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:s,to:e,canceledTransition:t})}startTransitionTo(e){const t=this.transition,s=this.state;s===e||R(t)&&t.to===e||(this.prevState=s,this.state=e,t?(this.transition={from:t.from,to:e,canceledTransition:t},this.transitionUpdated$.next(this.transition)):(this.transition={from:s,to:e},this.transitionStarted$.next(this.transition)))}getTransition(){return this.transition}getState(){return this.state}getPrevState(){return this.prevState}}const TS=i=>{switch(i){case b.MPEG:case b.DASH_SEP:case b.DASH_ONDEMAND:case b.DASH_WEBM:case b.DASH_WEBM_AV1:case b.HLS:case b.HLS_ONDEMAND:return!1;case b.DASH_LIVE:case b.DASH_LIVE_CMAF:case b.HLS_LIVE:case b.HLS_LIVE_CMAF:case b.DASH_LIVE_WEBM:case b.WEB_RTC_LIVE:return!0;default:return H(i)}};var U;(function(i){i.STOPPED="stopped",i.READY="ready",i.PLAYING="playing",i.PAUSED="paused"})(U||(U={}));const ES=5,$S=5,AS=500,Yo=7e3;class wS{constructor(e){this.subscription=new re,this.loadMediaTimeoutSubscription=new re,this.videoState=new he(U.STOPPED),this.syncPlayback=()=>{const s=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: ${s}; videoTransition: ${JSON.stringify(r)}; desiredPlaybackState: ${a}; desiredPlaybackStateTransition: ${this.params.desiredState.playbackState.getTransition()}; seekState: ${JSON.stringify(o)};`}),a===p.STOPPED){s!==U.STOPPED&&(this.videoState.startTransitionTo(U.STOPPED),this.stop());return}if(!r){if((n==null?void 0:n.to)!==p.PAUSED&&o.state===Y.Requested&&s!==U.STOPPED){this.seek(o.position/1e3);return}switch(a){case p.READY:{switch(s){case U.PLAYING:case U.PAUSED:case U.READY:break;case U.STOPPED:this.videoState.startTransitionTo(U.READY),this.prepare();break;default:H(s)}break}case p.PLAYING:{switch(s){case U.PLAYING:break;case U.PAUSED:this.videoState.startTransitionTo(U.PLAYING),this.params.connection.remotePlayerController.playOrPause();break;case U.READY:this.videoState.startTransitionTo(U.PLAYING),this.params.connection.remotePlayerController.playOrPause();break;case U.STOPPED:this.videoState.startTransitionTo(U.READY),this.prepare();break;default:H(s)}break}case p.PAUSED:{switch(s){case U.PLAYING:this.videoState.startTransitionTo(U.PAUSED),this.params.connection.remotePlayerController.playOrPause();break;case U.PAUSED:break;case U.READY:this.videoState.startTransitionTo(U.PAUSED),this.videoState.setState(U.PAUSED);break;case U.STOPPED:this.videoState.startTransitionTo(U.READY),this.prepare();break;default:H(s)}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(TS(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 re;this.subscription.add(e),this.subscription.add(F(this.videoState.stateChangeStarted$.pipe($(r=>`stateChangeStarted$ ${JSON.stringify(r)}`)),this.videoState.stateChangeEnded$.pipe($(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 D;e.add(r.pipe(rt(AS)).subscribe(()=>{this.params.output.seekedEvent$.next()}));let a=NaN;e.add(x(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===Y.Applying||Math.abs(o-a)>ES)&&r.next(o),a=o})),e.add(x(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.DURATION_CHANGED).subscribe(n=>{this.logRemoteEvent(n),this.params.output.duration$.next(n.value)}))}t(x(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED),r=>{this.logRemoteEvent(r),r.value?this.handleRemoteReady():(this.handleRemoteStop(),e.unsubscribe())}),t(x(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED),r=>{this.logRemoteEvent(r),r.value?this.handleRemotePause():this.handleRemotePlay()}),t(x(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<$S&&this.params.output.endedEvent$.next(),this.handleRemoteStop(),O(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(x(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED),r=>{this.logRemoteEvent(r),this.handleRemoteVolumeChange({volume:r.value})}),t(x(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED),r=>{this.logRemoteEvent(r),this.handleRemoteVolumeChange({muted:r.value})});const s=F(this.params.desiredState.playbackState.stateChangeStarted$,this.params.desiredState.seekState.stateChangeEnded$,this.videoState.stateChangeEnded$,He(["init"])).pipe(rt(0));t(s,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(U.PAUSED),O(this.params.desiredState.playbackState,p.PAUSED)):(this.videoState.setState(U.PLAYING),O(this.params.desiredState.playbackState,p.PLAYING));const s=this.params.output.isLive$.getValue();this.params.output.duration$.next(s?0:t.duration),this.params.output.position$.next(s?0:t.currentTime),this.params.desiredState.seekState.setState({state:Y.None})}}prepare(){const e=this.params.format;this.log({message:`[prepare] format: ${e}`});const t=this.createMediaInfo(e),s=this.createLoadRequest(t);this.loadMedia(s)}handleRemotePause(){const e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)===U.PAUSED||e===U.PLAYING)&&(this.videoState.setState(U.PAUSED),O(this.params.desiredState.playbackState,p.PAUSED))}handleRemotePlay(){const e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)===U.PLAYING||e===U.PAUSED)&&(this.videoState.setState(U.PLAYING),O(this.params.desiredState.playbackState,p.PLAYING))}handleRemoteReady(){var e;const t=this.videoState.getTransition();(t==null?void 0:t.to)===U.READY&&this.videoState.setState(U.READY),((e=this.params.desiredState.playbackState.getTransition())===null||e===void 0?void 0:e.to)===p.READY&&O(this.params.desiredState.playbackState,p.READY)}handleRemoteStop(){this.videoState.getState()!==U.STOPPED&&this.videoState.setState(U.STOPPED)}handleRemoteVolumeChange(e){var t,s;const r=this.params.output.volume$.getValue(),a={volume:(t=e.volume)!==null&&t!==void 0?t:r.volume,muted:(s=e.muted)!==null&&s!==void 0?s: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:s}=this.params.connection;t.currentTime=e,s.seek()}stop(){const{remotePlayerController:e}=this.params.connection;e.stop()}createMediaInfo(e){var t;const s=this.params.source;let r,a,n;switch(e){case b.MPEG:{const d=s[e];P(d);const c=Tu(Object.keys(d));P(c);const h=d[c];P(h),r=h,a="video/mp4",n=chrome.cast.media.StreamType.BUFFERED;break}case b.HLS:case b.HLS_ONDEMAND:{const d=s[e];P(d),r=d.url,a="application/x-mpegurl",n=chrome.cast.media.StreamType.BUFFERED;break}case b.DASH_SEP:case b.DASH_ONDEMAND:case b.DASH_WEBM:case b.DASH_WEBM_AV1:{const d=s[e];P(d),r=d.url,a="application/dash+xml",n=chrome.cast.media.StreamType.BUFFERED;break}case b.DASH_LIVE_CMAF:{const d=s[e];P(d),r=d.url,a="application/dash+xml",n=chrome.cast.media.StreamType.LIVE;break}case b.HLS_LIVE:case b.HLS_LIVE_CMAF:{const d=s[e];P(d),r=ze(d.url),a="application/x-mpegurl",n=chrome.cast.media.StreamType.LIVE;break}case b.DASH_LIVE:case b.WEB_RTC_LIVE:{const d="Unsupported format for Chromecast",c=new Error(d);throw this.params.output.error$.next({id:"ChromecastProvider.createMediaInfo()",category:I.VIDEO_PIPELINE,message:d,thrown:c}),c}case b.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:l}=this.params.meta;return R(u)&&(o.metadata.title=u),R(l)&&(o.metadata.subtitle=l),o}createLoadRequest(e){const t=new chrome.cast.media.LoadRequest(e);t.autoplay=!1;const s=this.params.desiredState.seekState.getState();return s.state===Y.Applying||s.state===Y.Requested?t.currentTime=this.params.output.isLive$.getValue()?0:s.position/1e3:t.currentTime=0,t}loadMedia(e){const t=this.params.connection.session.loadMedia(e),s=new Promise((r,a)=>{this.loadMediaTimeoutSubscription.add(Eu(Yo).subscribe(()=>a(`timeout(${Yo})`)))});un(Promise.race([t,s]).then(()=>{this.log({message:`[loadMedia] completed, format: ${this.params.format}`}),this.params.desiredState.seekState.getState().state===Y.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:I.VIDEO_PIPELINE,message:a,thrown:r})}),()=>{this.loadMediaTimeoutSubscription.unsubscribe()})}logRemoteEvent(e){this.log({message:`[remoteEvent] ${JSON.stringify(e)}`})}}const cn=i=>{i.removeAttribute("src"),i.load()},kS=i=>{try{i.pause(),i.playbackRate=0,cn(i),i.remove()}catch(e){console.error(e)}};class PS{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 Da=window.WeakMap?new WeakMap:new PS,jt=i=>{let e=i.querySelector("video");const t=!!e;return e?cn(e):(e=document.createElement("video"),i.appendChild(e)),Da.set(e,t),e.setAttribute("crossorigin","anonymous"),e.setAttribute("playsinline","playsinline"),e.controls=!1,e.setAttribute("poster","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),e},Gt=i=>{const e=Da.get(i);Da.delete(i),e?cn(i):kS(i)},dt=(i,e,t,{equal:s=(n,o)=>n===o,changed$:r,onError:a}={})=>{const n=i.getState(),o=e(),u=K(r),l=new re;return r&&l.add(r.subscribe(d=>{const c=i.getState();s(d,c)&&i.setState(d)},a)),s(o,n)||(t(n),u&&i.setState(n)),l.add(i.stateChangeStarted$.subscribe(d=>{t(d.to),u&&i.setState(d.to)},a)),l},zi=(i,e,t)=>dt(e,()=>i.loop,s=>{R(s)&&(i.loop=s)},{onError:t}),Yt=(i,e,t,s)=>dt(e,()=>({muted:i.muted,volume:i.volume}),r=>{R(r)&&(i.muted=r.muted,i.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:s}),yi=(i,e,t,s)=>dt(e,()=>i.playbackRate,r=>{R(r)&&(i.playbackRate=r)},{changed$:t,onError:s}),RS=i=>["__",i.language,i.label].join("|"),_S=(i,e)=>{if(i.id===e)return!0;const[t,s,r]=e.split("|");return i.language===s&&i.label===r};class At{constructor(){this.available$=new D,this.current$=new y(void 0),this.error$=new D,this.subscription=new re,this.externalTracks=new Map,this.internalTracks=new Map}connect(e,t,s){this.video=e,this.cueSettings=t.textTrackCuesSettings,this.subscribe();const r=a=>{this.error$.next({id:"TextTracksManager",category:I.WTF,message:"Generic HtmlVideoTextTrackManager error",thrown:a})};this.subscription.add(this.available$.subscribe(s.availableTextTracks$)),this.subscription.add(this.current$.subscribe(s.currentTextTrack$)),this.subscription.add(this.error$.subscribe(s.error$)),this.subscription.add(dt(t.internalTextTracks,()=>Object.values(this.internalTracks),a=>{R(a)&&this.setInternal(a)},{equal:(a,n)=>R(a)&&R(n)&&a.length===n.length&&a.every(({id:o},u)=>o===n[u].id),changed$:this.available$.pipe($(a=>a.filter(({type:n})=>n==="internal"))),onError:r})),this.subscription.add(dt(t.externalTextTracks,()=>Object.values(this.externalTracks),a=>{R(a)&&this.setExternal(a)},{equal:(a,n)=>R(a)&&R(n)&&a.length===n.length&&a.every(({id:o},u)=>o===n[u].id),changed$:this.available$.pipe($(a=>a.filter(({type:n})=>n==="external"))),onError:r})),this.subscription.add(dt(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(dt(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(x(e,"addtrack").subscribe(()=>{const s=this.current$.getValue();s&&this.select(s)})),this.subscription.add(F(x(e,"addtrack"),x(e,"removetrack"),He(["init"])).pipe($(()=>this.htmlTextTracksAsArray().map(s=>this.htmlTextTrackToITextTrack(s))),pe((s,r)=>s.length===r.length&&s.every(({id:a},n)=>a===r[n].id))).subscribe(this.available$)),this.subscription.add(F(x(e,"change"),He(["init"])).pipe($(()=>this.htmlTextTracksAsArray().find(({mode:s})=>s==="showing")),$(s=>s&&this.htmlTextTrackToITextTrack(s).id),pe()).subscribe(this.current$));const t=s=>{var r,a;return this.applyCueSettings((a=(r=s.target)===null||r===void 0?void 0:r.activeCues)!==null&&a!==void 0?a:null)};this.subscription.add(x(e,"addtrack").subscribe(s=>{var r,a;(r=s.track)===null||r===void 0||r.addEventListener("cuechange",t);const n=o=>{var u,l,d,c,h;const f=(l=(u=o.target)===null||u===void 0?void 0:u.cues)!==null&&l!==void 0?l:null;f&&f.length&&(this.applyCueSettings((c=(d=o.target)===null||d===void 0?void 0:d.cues)!==null&&c!==void 0?c:null),(h=o.target)===null||h===void 0||h.removeEventListener("cuechange",n))};(a=s.track)===null||a===void 0||a.addEventListener("cuechange",n)})),this.subscription.add(x(e,"removetrack").subscribe(s=>{var r;(r=s.track)===null||r===void 0||r.removeEventListener("cuechange",t)}))}applyCueSettings(e){if(!e||!e.length)return;const t=this.cueSettings.getState();for(const s of Array.from(e)){const r=s;R(t.align)&&(r.align=t.align),R(t.position)&&(r.position=t.position),R(t.size)&&(r.size=t.size),R(t.line)&&(r.line=t.line)}}htmlTextTracksAsArray(e=!1){P(this.video);const t=[...this.video.textTracks];return e?t:t.filter(At.isHealthyTrack)}htmlTextTrackToITextTrack(e){var t,s;const{language:r,label:a}=e,n=e.id?e.id:RS(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:(s=this.internalTracks.get(n))===null||s===void 0?void 0:s.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(s=>s.id===t)).forEach(([,t])=>this.detach(t))}setInternal(e){const t=[...this.externalTracks];e.filter(({id:s,language:r,isAuto:a})=>!this.internalTracks.has(s)&&!t.some(([,n])=>n.language===r&&n.isAuto===a)).forEach(s=>this.attach(s)),Array.from(this.internalTracks).filter(([s])=>!e.find(r=>r.id===s)).forEach(([,s])=>this.detach(s))}select(e){P(this.video);for(const t of this.htmlTextTracksAsArray(!0))t.mode="showing";for(const t of this.htmlTextTracksAsArray(!0))(K(e)||!_S(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"),s=>s.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)}}class hn{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 Bd=i=>{var e;let t=i;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},qo=i=>{const e=Bd(i);return!!(e&&e.fullscreenElement&&e.fullscreenElement===i)},CS=i=>{const e=Bd(i);return!!(e&&e.pictureInPictureElement&&e.pictureInPictureElement===i)},IS=3;var DS=(i,e,t=IS)=>{let s=0,r=0;for(let a=0;a<i.length;a++){const n=i.start(a),o=i.end(a);if(n<=e&&e<=o){if(s=n,r=o,!t)return{from:s,to:r};for(let u=a-1;u>=0;u--)i.end(u)+t>=s&&(s=i.start(u));for(let u=a+1;u<i.length;u++)i.start(u)-t<=r&&(r=i.end(u))}}return{from:s,to:r}};const qt=i=>{const e=A=>x(i,A).pipe(_s(void 0)),s=F(...["waiting","pause","canplay","play","canplaythrough","playing","seeking","seeked","ended"].map(A=>x(i,A))).pipe($(A=>A.type==="ended"?i.readyState<2:i.readyState<3),pe()),r=F(x(i,"progress"),x(i,"timeupdate")).pipe($(()=>DS(i.buffered,i.currentTime))),n=Na().browser===yl.Safari?Ve({play:e("play").pipe(_e()),playing:e("playing")}).pipe(_s(void 0)):e("playing"),o=x(i,"volumechange").pipe($(()=>({muted:i.muted,volume:i.volume}))),u=x(i,"ratechange").pipe($(()=>i.playbackRate)),l=x(i,"error").pipe(fe(()=>!!(i.error||i.played.length)),$(()=>{var A;const w=i.error;return{id:w?`MediaError#${w.code}`:"HtmlVideoError",category:I.VIDEO_PIPELINE,message:w?w.message:"Error event from HTML video element",thrown:(A=i.error)!==null&&A!==void 0?A:void 0}})),d=x(i,"timeupdate").pipe($(()=>i.currentTime)),c=new D,h=.3;let f;d.subscribe(A=>{i.loop&&R(f)&&R(A)&&f>=i.duration-h&&A<=h&&c.next(f),f=A});const m=x(i,"enterpictureinpicture"),v=x(i,"leavepictureinpicture"),g=new y(CS(i));m.subscribe(()=>g.next(!0)),v.subscribe(()=>g.next(!1));const S=new y(qo(i));return x(i,"fullscreenchange").pipe($(()=>qo(i))).subscribe(S),{playing$:n,pause$:e("pause").pipe(fe(()=>!i.error)),canplay$:e("canplay"),ended$:e("ended"),looped$:c,error$:l,seeked$:e("seeked"),seeking$:e("seeking"),progress$:e("progress"),loadStart$:e("loadstart"),loadedMetadata$:e("loadedmetadata"),loadedData$:e("loadeddata"),timeUpdate$:d,durationChange$:x(i,"durationchange").pipe($(()=>i.duration)),isBuffering$:s,currentBuffer$:r,volumeState$:o,playbackRateState$:u,inPiP$:g,inFullscreen$:S}};var Js=i=>{switch(i){case"mobile":return Le.Q_144P;case"lowest":return Le.Q_240P;case"low":return Le.Q_360P;case"sd":case"medium":return Le.Q_480P;case"hd":case"high":return Le.Q_720P;case"fullhd":case"full":return Le.Q_1080P;case"quadhd":case"quad":return Le.Q_1440P;case"ultrahd":case"ultra":return Le.Q_2160P}},LS=Qe,xS=qs,OS=Ka,MS=Qa;LS({target:"Array",proto:!0},{at:function(e){var t=xS(this),s=OS(t),r=MS(e),a=r>=0?r:s+r;return a<0||a>=s?void 0:t[a]}});var BS=dn,NS=BS("Array","at"),FS=NS,VS=FS,US=VS,HS=US,lt=Vs(HS);let fn=!1,ut={};const jS=i=>{fn=i},GS=()=>{ut={}},YS=i=>{i(ut)},vs=(i,e)=>{var t;fn&&(ut.meta=(t=ut.meta)!==null&&t!==void 0?t:{},ut.meta[i]=e)};class tt{constructor(e){this.name=e}next(e){var t,s;if(!fn)return;ut.series=(t=ut.series)!==null&&t!==void 0?t:{};const r=(s=ut.series[this.name])!==null&&s!==void 0?s:[];r.push([Date.now(),e]),ut.series[this.name]=r}}var xt;(function(i){i.FitsContainer="FitsContainer",i.FitsThroughput="FitsThroughput",i.Buffer="Buffer",i.DroppedFramesLimit="DroppedFramesLimit",i.FitsQualityLimits="FitsQualityLimits"})(xt||(xt={}));const qS=new tt("best_bitrate"),WS=(i,e,t)=>(e-t)*Math.pow(2,-10*i)+t;class zS{constructor(){this.history={}}recordSelection(e){this.history[e.id]=le()}recordSwitch(e){this.last=e}clear(){this.last=void 0,this.history={}}}const QS='Assertion "ABR Tracks is empty array" failed',Xs=(i,{container:e,throughput:t,tuning:s,limits:r,reserve:a=0,forwardBufferHealth:n,playbackRate:o,current:u,history:l,droppedVideoMaxQualityLimit:d,abrLogger:c})=>{var h,f,m,v,g;$u(i,QS);const S=s.usePixelRatio&&(h=window.devicePixelRatio)!==null&&h!==void 0?h:1,E=s.limitByContainer&&e&&e.width>0&&e.height>0&&{width:e.width*S*s.containerSizeFactor,height:e.height*S*s.containerSizeFactor},A=E&&Mt(E),w=s.considerPlaybackRate&&R(o)?o:1,k=i.filter(N=>!Bt(N.quality)).sort((N,C)=>hi(N.quality,C.quality)?-1:1),q=(f=lt(k,-1))===null||f===void 0?void 0:f.quality,W=(m=lt(k,0))===null||m===void 0?void 0:m.quality,J=K(r)||R(r.min)&&R(r.max)&&$s(r.max,r.min)||R(r.min)&&W&&hi(r.min,W)||R(r.max)&&q&&$s(r.max,q),G=w*WS(n!=null?n:.5,s.bitrateFactorAtEmptyBuffer,s.bitrateFactorAtFullBuffer),X={},B=k.filter(N=>(A?$s(N.quality,A):!0)?(R(t)&&isFinite(t)&&R(N.bitrate)?t-a>=N.bitrate*G:!0)?s.lazyQualitySwitch&&R(s.minBufferToSwitchUp)&&u&&!Bt(u.quality)&&(n!=null?n:0)<s.minBufferToSwitchUp&&hi(N.quality,u.quality)?(X[N.quality]=xt.Buffer,!1):!!d&&ua(N.quality,d)?(X[N.quality]=xt.DroppedFramesLimit,!1):J||(K(r.max)||Cs(N.quality,r.max))&&(K(r.min)||ua(N.quality,r.min))?!0:(X[N.quality]=xt.FitsQualityLimits,!1):(X[N.quality]=xt.FitsThroughput,!1):(X[N.quality]=xt.FitsContainer,!1))[0];B&&B.bitrate&&qS.next(B.bitrate);const L=(v=B!=null?B:k[Math.ceil((k.length-1)/2)])!==null&&v!==void 0?v:i[0];L.quality!==((g=l==null?void 0:l.last)===null||g===void 0?void 0:g.quality)&&c({message:`
|
|
7
7
|
[available tracks]
|
|
8
8
|
${i.map(N=>`{ id: ${N.id}, quality: ${N.quality}, bitrate: ${N.bitrate} }`).join(`
|
|
9
9
|
`)}
|
package/es2018.cjs.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-core v2.0.
|
|
3
|
-
* Tue,
|
|
4
|
-
* https://st.mycdn.me/static/vkontakte-videoplayer/2-0-
|
|
2
|
+
* @vkontakte/videoplayer-core v2.0.103-dev.c555938f.0
|
|
3
|
+
* Tue, 28 May 2024 09:13:35 GMT
|
|
4
|
+
* https://st.mycdn.me/static/vkontakte-videoplayer/2-0-103/doc/
|
|
5
5
|
*/
|
|
6
|
-
"use strict";var Lo=Object.create;var _a=Object.defineProperty;var xo=Object.getOwnPropertyDescriptor;var _o=Object.getOwnPropertyNames;var Ro=Object.getPrototypeOf,Io=Object.prototype.hasOwnProperty;var No=(i,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of _o(e))!Io.call(i,a)&&a!==t&&_a(i,a,{get:()=>e[a],enumerable:!(s=xo(e,a))||s.enumerable});return i};var Oo=(i,e,t)=>(t=i!=null?Lo(Ro(i)):{},No(e||!i||!i.__esModule?_a(t,"default",{value:i,enumerable:!0}):t,i));var r=require("@vkontakte/videoplayer-shared/es2018.cjs.js");const en="2.0.102-beta.3";exports.PlaybackState=void 0;(function(i){i.STOPPED="stopped",i.READY="ready",i.PLAYING="playing",i.PAUSED="paused"})(exports.PlaybackState||(exports.PlaybackState={}));exports.VideoFormat=void 0;(function(i){i.MPEG="MPEG",i.DASH="DASH_SEP",i.DASH_SEP="DASH_SEP",i.DASH_SEP_VK="DASH_SEP",i.DASH_WEBM="DASH_WEBM",i.DASH_WEBM_AV1="DASH_WEBM_AV1",i.DASH_WEBM_VK="DASH_WEBM",i.DASH_ONDEMAND="DASH_ONDEMAND",i.DASH_ONDEMAND_VK="DASH_ONDEMAND",i.DASH_LIVE="DASH_LIVE",i.DASH_LIVE_CMAF="DASH_LIVE_CMAF",i.DASH_LIVE_WEBM="DASH_LIVE_WEBM",i.HLS="HLS",i.HLS_ONDEMAND="HLS_ONDEMAND",i.HLS_JS="HLS",i.HLS_LIVE="HLS_LIVE",i.HLS_LIVE_CMAF="HLS_LIVE_CMAF",i.WEB_RTC_LIVE="WEB_RTC_LIVE"})(exports.VideoFormat||(exports.VideoFormat={}));var ae;(function(i){i.SCREEN="SCREEN",i.CHROMECAST="CHROMECAST"})(ae||(ae={}));exports.ChromecastState=void 0;(function(i){i.NOT_AVAILABLE="NOT_AVAILABLE",i.AVAILABLE="AVAILABLE",i.CONNECTING="CONNECTING",i.CONNECTED="CONNECTED"})(exports.ChromecastState||(exports.ChromecastState={}));exports.HttpConnectionType=void 0;(function(i){i.HTTP1="http1",i.HTTP2="http2",i.QUIC="quic"})(exports.HttpConnectionType||(exports.HttpConnectionType={}));var I;(function(i){i.None="none",i.Requested="requested",i.Applying="applying"})(I||(I={}));exports.Surface=void 0;(function(i){i.NONE="none",i.INLINE="inline",i.FULLSCREEN="fullscreen",i.SECOND_SCREEN="second_screen",i.PIP="pip"})(exports.Surface||(exports.Surface={}));var Mo=i=>new Promise((e,t)=>{const s=document.createElement("script");s.setAttribute("src",i),s.onload=()=>e,s.onerror=()=>t,document.body.appendChild(s)});class Bo{constructor(e){var t;this.connection$=new r.ValueSubject(void 0),this.castState$=new r.ValueSubject(exports.ChromecastState.NOT_AVAILABLE),this.errorEvent$=new r.Subject,this.realCastState$=new r.ValueSubject(exports.ChromecastState.NOT_AVAILABLE),this.subscription=new r.Subscription,this.params=e,this.log=this.params.dependencies.logger.createComponentLog("ChromecastInitializer");const s="chrome"in window;if(this.log({message:`[constructor] receiverApplicationId: ${this.params.receiverApplicationId}, isDisabled: ${this.params.isDisabled}, isSupported: ${s}`}),e.isDisabled||!s)return;const a=r.isNonNullable((t=window.chrome)===null||t===void 0?void 0:t.cast),n=!!window.__onGCastApiAvailable;a?this.initializeCastApi():(window.__onGCastApiAvailable=o=>{delete window.__onGCastApiAvailable,o&&this.initializeCastApi()},n||Mo("https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1").catch(()=>this.errorEvent$.next({id:"ChromecastLoading",category:r.ErrorCategory.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 s,a,n;(n=(a=(s=cast.framework.CastContext.getInstance())===null||s===void 0?void 0:s.getCurrentSession())===null||a===void 0?void 0:a.getMediaSession())===null||n===void 0||n.stop(new chrome.cast.media.StopRequest,e,t)})}toggleConnection(){r.isNonNullable(this.connection$.getValue())?this.disconnect():this.connect()}setVolume(e){const t=this.connection$.getValue();r.isNullable(t)||(t.remotePlayer.volumeLevel=e,t.remotePlayerController.setVolumeLevel())}setMuted(e){const t=this.connection$.getValue();r.isNullable(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),s=cast.framework.CastContext.getInstance();this.subscription.add(r.fromEvent(s,cast.framework.CastContextEventType.SESSION_STATE_CHANGED).subscribe(a=>{var n,o;switch(a.sessionState){case cast.framework.SessionState.SESSION_STARTED:case cast.framework.SessionState.SESSION_STARTING:case cast.framework.SessionState.SESSION_RESUMED:this.contentId=(o=(n=s.getCurrentSession())===null||n===void 0?void 0:n.getMediaSession())===null||o===void 0?void 0:o.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 r.assertNever(a.sessionState)}})).add(r.merge(r.fromEvent(s,cast.framework.CastContextEventType.CAST_STATE_CHANGED).pipe(r.tap(a=>{this.log({message:`[cast.framework.RemotePlayerEventType.CAST_STATE_CHANGED]: ${JSON.stringify(a)}`})}),r.map(a=>a.castState)),r.observableFrom([s.getCastState()])).pipe(r.filterChanged(),r.map(Vo),r.tap(a=>{this.log({message:`realCastState$: ${a}`})})).subscribe(this.realCastState$)).add(this.realCastState$.subscribe(a=>{var n;const o=a===exports.ChromecastState.CONNECTED,l=r.isNonNullable(this.connection$.getValue());if(o&&!l){const c=s.getCurrentSession();r.assertNonNullable(c);const u=c.getCastDevice(),d=(n=c.getMediaSession())===null||n===void 0?void 0:n.media.contentId;(r.isNullable(d)||d===this.contentId)&&(this.log({message:"connection created"}),this.connection$.next({remotePlayer:e,remotePlayerController:t,session:c,castDevice:u}))}else!o&&l&&(this.log({message:"connection destroyed"}),this.connection$.next(void 0));this.castState$.next(a===exports.ChromecastState.CONNECTED?r.isNonNullable(this.connection$.getValue())?exports.ChromecastState.CONNECTED:exports.ChromecastState.AVAILABLE:a)}))}initializeCastApi(){var e;let t,s,a;try{t=cast.framework.CastContext.getInstance(),s=chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,a=chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}catch(n){return}try{t.setOptions({receiverApplicationId:(e=this.params.receiverApplicationId)!==null&&e!==void 0?e:s,autoJoinPolicy:a}),this.initListeners()}catch(n){this.errorEvent$.next({id:"ChromecastInitializer",category:r.ErrorCategory.EXTERNAL_API,message:"[initializeCastApi] failed",thrown:n})}}}const Vo=i=>{switch(i){case cast.framework.CastState.NO_DEVICES_AVAILABLE:return exports.ChromecastState.NOT_AVAILABLE;case cast.framework.CastState.NOT_CONNECTED:return exports.ChromecastState.AVAILABLE;case cast.framework.CastState.CONNECTING:return exports.ChromecastState.CONNECTING;case cast.framework.CastState.CONNECTED:return exports.ChromecastState.CONNECTED;default:return r.assertNever(i)}};var es=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function ea(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Oe=function(i){try{return!!i()}catch(e){return!0}},Fo=Oe,xi=!Fo(function(){var i=function(){}.bind();return typeof i!="function"||i.hasOwnProperty("prototype")}),tn=xi,sn=Function.prototype,Vs=sn.call,Uo=tn&&sn.bind.bind(Vs,Vs),Me=tn?Uo:function(i){return function(){return Vs.apply(i,arguments)}},an=Me,jo=an({}.toString),Ho=an("".slice),_i=function(i){return Ho(jo(i),8,-1)},Go=Me,Yo=Oe,qo=_i,ts=Object,zo=Go("".split),Wo=Yo(function(){return!ts("z").propertyIsEnumerable(0)})?function(i){return qo(i)=="String"?zo(i,""):ts(i)}:ts,Ri=function(i){return i==null},Qo=Ri,Ko=TypeError,ta=function(i){if(Qo(i))throw Ko("Can't call method on "+i);return i},Jo=Wo,Xo=ta,qt=function(i){return Jo(Xo(i))},Lt={},si=function(i){return i&&i.Math==Math&&i},ge=si(typeof globalThis=="object"&&globalThis)||si(typeof window=="object"&&window)||si(typeof self=="object"&&self)||si(typeof es=="object"&&es)||function(){return this}()||es||Function("return this")(),Fs=typeof document=="object"&&document.all,Zo=typeof Fs=="undefined"&&Fs!==void 0,rn={all:Fs,IS_HTMLDDA:Zo},nn=rn,el=nn.all,pe=nn.IS_HTMLDDA?function(i){return typeof i=="function"||i===el}:function(i){return typeof i=="function"},tl=ge,il=pe,Ra=tl.WeakMap,sl=il(Ra)&&/native code/.test(String(Ra)),Ia=pe,on=rn,al=on.all,at=on.IS_HTMLDDA?function(i){return typeof i=="object"?i!==null:Ia(i)||i===al}:function(i){return typeof i=="object"?i!==null:Ia(i)},rl=Oe,rt=!rl(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),xt={},nl=ge,Na=at,Us=nl.document,ol=Na(Us)&&Na(Us.createElement),ln=function(i){return ol?Us.createElement(i):{}},ll=rt,ul=Oe,dl=ln,un=!ll&&!ul(function(){return Object.defineProperty(dl("div"),"a",{get:function(){return 7}}).a!=7}),cl=rt,hl=Oe,dn=cl&&hl(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),fl=at,pl=String,ml=TypeError,nt=function(i){if(fl(i))return i;throw ml(pl(i)+" is not an object")},vl=xi,ai=Function.prototype.call,Be=vl?ai.bind(ai):function(){return ai.apply(ai,arguments)},ia={},is=ia,ss=ge,Sl=pe,Oa=function(i){return Sl(i)?i:void 0},sa=function(i,e){return arguments.length<2?Oa(is[i])||Oa(ss[i]):is[i]&&is[i][e]||ss[i]&&ss[i][e]},bl=Me,aa=bl({}.isPrototypeOf),gl=typeof navigator!="undefined"&&String(navigator.userAgent)||"",cn=ge,as=gl,Ma=cn.process,Ba=cn.Deno,Va=Ma&&Ma.versions||Ba&&Ba.version,Fa=Va&&Va.v8,Se,$i;Fa&&(Se=Fa.split("."),$i=Se[0]>0&&Se[0]<4?1:+(Se[0]+Se[1]));!$i&&as&&(Se=as.match(/Edge\/(\d+)/),(!Se||Se[1]>=74)&&(Se=as.match(/Chrome\/(\d+)/),Se&&($i=+Se[1])));var yl=$i,Ua=yl,Tl=Oe,El=ge,$l=El.String,hn=!!Object.getOwnPropertySymbols&&!Tl(function(){var i=Symbol();return!$l(i)||!(Object(i)instanceof Symbol)||!Symbol.sham&&Ua&&Ua<41}),kl=hn,fn=kl&&!Symbol.sham&&typeof Symbol.iterator=="symbol",Al=sa,wl=pe,Pl=aa,Cl=fn,Dl=Object,pn=Cl?function(i){return typeof i=="symbol"}:function(i){var e=Al("Symbol");return wl(e)&&Pl(e.prototype,Dl(i))},Ll=String,ra=function(i){try{return Ll(i)}catch(e){return"Object"}},xl=pe,_l=ra,Rl=TypeError,na=function(i){if(xl(i))return i;throw Rl(_l(i)+" is not a function")},Il=na,Nl=Ri,Ii=function(i,e){var t=i[e];return Nl(t)?void 0:Il(t)},rs=Be,ns=pe,os=at,Ol=TypeError,Ml=function(i,e){var t,s;if(e==="string"&&ns(t=i.toString)&&!os(s=rs(t,i))||ns(t=i.valueOf)&&!os(s=rs(t,i))||e!=="string"&&ns(t=i.toString)&&!os(s=rs(t,i)))return s;throw Ol("Can't convert object to primitive value")},mn={exports:{}},ja=ge,Bl=Object.defineProperty,Vl=function(i,e){try{Bl(ja,i,{value:e,configurable:!0,writable:!0})}catch(t){ja[i]=e}return e},Fl=ge,Ul=Vl,Ha="__core-js_shared__",jl=Fl[Ha]||Ul(Ha,{}),vn=jl,Ga=vn;(mn.exports=function(i,e){return Ga[i]||(Ga[i]=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 Sn=mn.exports,Hl=ta,Gl=Object,Ni=function(i){return Gl(Hl(i))},Yl=Me,ql=Ni,zl=Yl({}.hasOwnProperty),Ve=Object.hasOwn||function(e,t){return zl(ql(e),t)},Wl=Me,Ql=0,Kl=Math.random(),Jl=Wl(1 .toString),bn=function(i){return"Symbol("+(i===void 0?"":i)+")_"+Jl(++Ql+Kl,36)},Xl=ge,Zl=Sn,Ya=Ve,eu=bn,tu=hn,iu=fn,At=Xl.Symbol,ls=Zl("wks"),su=iu?At.for||At:At&&At.withoutSetter||eu,ye=function(i){return Ya(ls,i)||(ls[i]=tu&&Ya(At,i)?At[i]:su("Symbol."+i)),ls[i]},au=Be,qa=at,za=pn,ru=Ii,nu=Ml,ou=ye,lu=TypeError,uu=ou("toPrimitive"),du=function(i,e){if(!qa(i)||za(i))return i;var t=ru(i,uu),s;if(t){if(e===void 0&&(e="default"),s=au(t,i,e),!qa(s)||za(s))return s;throw lu("Can't convert object to primitive value")}return e===void 0&&(e="number"),nu(i,e)},cu=du,hu=pn,oa=function(i){var e=cu(i,"string");return hu(e)?e:e+""},fu=rt,pu=un,mu=dn,ri=nt,Wa=oa,vu=TypeError,us=Object.defineProperty,Su=Object.getOwnPropertyDescriptor,ds="enumerable",cs="configurable",hs="writable";xt.f=fu?mu?function(e,t,s){if(ri(e),t=Wa(t),ri(s),typeof e=="function"&&t==="prototype"&&"value"in s&&hs in s&&!s[hs]){var a=Su(e,t);a&&a[hs]&&(e[t]=s.value,s={configurable:cs in s?s[cs]:a[cs],enumerable:ds in s?s[ds]:a[ds],writable:!1})}return us(e,t,s)}:us:function(e,t,s){if(ri(e),t=Wa(t),ri(s),pu)try{return us(e,t,s)}catch(a){}if("get"in s||"set"in s)throw vu("Accessors not supported");return"value"in s&&(e[t]=s.value),e};var Oi=function(i,e){return{enumerable:!(i&1),configurable:!(i&2),writable:!(i&4),value:e}},bu=rt,gu=xt,yu=Oi,zt=bu?function(i,e,t){return gu.f(i,e,yu(1,t))}:function(i,e,t){return i[e]=t,i},Tu=Sn,Eu=bn,Qa=Tu("keys"),la=function(i){return Qa[i]||(Qa[i]=Eu(i))},ua={},$u=sl,gn=ge,ku=at,Au=zt,fs=Ve,ps=vn,wu=la,Pu=ua,Ka="Object already initialized",js=gn.TypeError,Cu=gn.WeakMap,ki,Ht,Ai,Du=function(i){return Ai(i)?Ht(i):ki(i,{})},Lu=function(i){return function(e){var t;if(!ku(e)||(t=Ht(e)).type!==i)throw js("Incompatible receiver, "+i+" required");return t}};if($u||ps.state){var $e=ps.state||(ps.state=new Cu);$e.get=$e.get,$e.has=$e.has,$e.set=$e.set,ki=function(i,e){if($e.has(i))throw js(Ka);return e.facade=i,$e.set(i,e),e},Ht=function(i){return $e.get(i)||{}},Ai=function(i){return $e.has(i)}}else{var bt=wu("state");Pu[bt]=!0,ki=function(i,e){if(fs(i,bt))throw js(Ka);return e.facade=i,Au(i,bt,e),e},Ht=function(i){return fs(i,bt)?i[bt]:{}},Ai=function(i){return fs(i,bt)}}var xu={set:ki,get:Ht,has:Ai,enforce:Du,getterFor:Lu},_u=xi,yn=Function.prototype,Ja=yn.apply,Xa=yn.call,Ru=typeof Reflect=="object"&&Reflect.apply||(_u?Xa.bind(Ja):function(){return Xa.apply(Ja,arguments)}),Iu=_i,Nu=Me,Tn=function(i){if(Iu(i)==="Function")return Nu(i)},En={},$n={},kn={}.propertyIsEnumerable,An=Object.getOwnPropertyDescriptor,Ou=An&&!kn.call({1:2},1);$n.f=Ou?function(e){var t=An(this,e);return!!t&&t.enumerable}:kn;var Mu=rt,Bu=Be,Vu=$n,Fu=Oi,Uu=qt,ju=oa,Hu=Ve,Gu=un,Za=Object.getOwnPropertyDescriptor;En.f=Mu?Za:function(e,t){if(e=Uu(e),t=ju(t),Gu)try{return Za(e,t)}catch(s){}if(Hu(e,t))return Fu(!Bu(Vu.f,e,t),e[t])};var Yu=Oe,qu=pe,zu=/#|\.prototype\./,Wt=function(i,e){var t=Qu[Wu(i)];return t==Ju?!0:t==Ku?!1:qu(e)?Yu(e):!!e},Wu=Wt.normalize=function(i){return String(i).replace(zu,".").toLowerCase()},Qu=Wt.data={},Ku=Wt.NATIVE="N",Ju=Wt.POLYFILL="P",Xu=Wt,er=Tn,Zu=na,ed=xi,td=er(er.bind),wn=function(i,e){return Zu(i),e===void 0?i:ed?td(i,e):function(){return i.apply(e,arguments)}},ni=ge,id=Ru,sd=Tn,ad=pe,rd=En.f,nd=Xu,gt=ia,od=wn,yt=zt,tr=Ve,ld=function(i){var e=function(t,s,a){if(this instanceof e){switch(arguments.length){case 0:return new i;case 1:return new i(t);case 2:return new i(t,s)}return new i(t,s,a)}return id(i,this,arguments)};return e.prototype=i.prototype,e},Mi=function(i,e){var t=i.target,s=i.global,a=i.stat,n=i.proto,o=s?ni:a?ni[t]:(ni[t]||{}).prototype,l=s?gt:gt[t]||yt(gt,t,{})[t],c=l.prototype,u,d,h,f,p,S,m,v,b;for(f in e)u=nd(s?f:t+(a?".":"#")+f,i.forced),d=!u&&o&&tr(o,f),S=l[f],d&&(i.dontCallGetSet?(b=rd(o,f),m=b&&b.value):m=o[f]),p=d&&m?m:e[f],!(d&&typeof S==typeof p)&&(i.bind&&d?v=od(p,ni):i.wrap&&d?v=ld(p):n&&ad(p)?v=sd(p):v=p,(i.sham||p&&p.sham||S&&S.sham)&&yt(v,"sham",!0),yt(l,f,v),n&&(h=t+"Prototype",tr(gt,h)||yt(gt,h,{}),yt(gt[h],f,p),i.real&&c&&(u||!c[f])&&yt(c,f,p)))},Hs=rt,ud=Ve,Pn=Function.prototype,dd=Hs&&Object.getOwnPropertyDescriptor,da=ud(Pn,"name"),cd=da&&function(){}.name==="something",hd=da&&(!Hs||Hs&&dd(Pn,"name").configurable),fd={EXISTS:da,PROPER:cd,CONFIGURABLE:hd},Cn={},pd=Math.ceil,md=Math.floor,vd=Math.trunc||function(e){var t=+e;return(t>0?md:pd)(t)},Sd=vd,ca=function(i){var e=+i;return e!==e||e===0?0:Sd(e)},bd=ca,gd=Math.max,yd=Math.min,Td=function(i,e){var t=bd(i);return t<0?gd(t+e,0):yd(t,e)},Ed=ca,$d=Math.min,kd=function(i){return i>0?$d(Ed(i),9007199254740991):0},Ad=kd,ha=function(i){return Ad(i.length)},wd=qt,Pd=Td,Cd=ha,ir=function(i){return function(e,t,s){var a=wd(e),n=Cd(a),o=Pd(s,n),l;if(i&&t!=t){for(;n>o;)if(l=a[o++],l!=l)return!0}else for(;n>o;o++)if((i||o in a)&&a[o]===t)return i||o||0;return!i&&-1}},Dd={includes:ir(!0),indexOf:ir(!1)},Ld=Me,ms=Ve,xd=qt,_d=Dd.indexOf,Rd=ua,sr=Ld([].push),Id=function(i,e){var t=xd(i),s=0,a=[],n;for(n in t)!ms(Rd,n)&&ms(t,n)&&sr(a,n);for(;e.length>s;)ms(t,n=e[s++])&&(~_d(a,n)||sr(a,n));return a},Dn=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Nd=Id,Od=Dn,Md=Object.keys||function(e){return Nd(e,Od)},Bd=rt,Vd=dn,Fd=xt,Ud=nt,jd=qt,Hd=Md;Cn.f=Bd&&!Vd?Object.defineProperties:function(e,t){Ud(e);for(var s=jd(t),a=Hd(t),n=a.length,o=0,l;n>o;)Fd.f(e,l=a[o++],s[l]);return e};var Gd=sa,Yd=Gd("document","documentElement"),qd=nt,zd=Cn,ar=Dn,Wd=ua,Qd=Yd,Kd=ln,Jd=la,rr=">",nr="<",Gs="prototype",Ys="script",Ln=Jd("IE_PROTO"),vs=function(){},xn=function(i){return nr+Ys+rr+i+nr+"/"+Ys+rr},or=function(i){i.write(xn("")),i.close();var e=i.parentWindow.Object;return i=null,e},Xd=function(){var i=Kd("iframe"),e="java"+Ys+":",t;return i.style.display="none",Qd.appendChild(i),i.src=String(e),t=i.contentWindow.document,t.open(),t.write(xn("document.F=Object")),t.close(),t.F},oi,gi=function(){try{oi=new ActiveXObject("htmlfile")}catch(e){}gi=typeof document!="undefined"?document.domain&&oi?or(oi):Xd():or(oi);for(var i=ar.length;i--;)delete gi[Gs][ar[i]];return gi()};Wd[Ln]=!0;var _n=Object.create||function(e,t){var s;return e!==null?(vs[Gs]=qd(e),s=new vs,vs[Gs]=null,s[Ln]=e):s=gi(),t===void 0?s:zd.f(s,t)},Zd=Oe,ec=!Zd(function(){function i(){}return i.prototype.constructor=null,Object.getPrototypeOf(new i)!==i.prototype}),tc=Ve,ic=pe,sc=Ni,ac=la,rc=ec,lr=ac("IE_PROTO"),qs=Object,nc=qs.prototype,Rn=rc?qs.getPrototypeOf:function(i){var e=sc(i);if(tc(e,lr))return e[lr];var t=e.constructor;return ic(t)&&e instanceof t?t.prototype:e instanceof qs?nc:null},oc=zt,In=function(i,e,t,s){return s&&s.enumerable?i[e]=t:oc(i,e,t),i},lc=Oe,uc=pe,dc=at,cc=_n,ur=Rn,hc=In,fc=ye,zs=fc("iterator"),Nn=!1,Ie,Ss,bs;[].keys&&(bs=[].keys(),"next"in bs?(Ss=ur(ur(bs)),Ss!==Object.prototype&&(Ie=Ss)):Nn=!0);var pc=!dc(Ie)||lc(function(){var i={};return Ie[zs].call(i)!==i});pc?Ie={}:Ie=cc(Ie);uc(Ie[zs])||hc(Ie,zs,function(){return this});var On={IteratorPrototype:Ie,BUGGY_SAFARI_ITERATORS:Nn},mc=ye,vc=mc("toStringTag"),Mn={};Mn[vc]="z";var fa=String(Mn)==="[object z]",Sc=fa,bc=pe,yi=_i,gc=ye,yc=gc("toStringTag"),Tc=Object,Ec=yi(function(){return arguments}())=="Arguments",$c=function(i,e){try{return i[e]}catch(t){}},Bi=Sc?yi:function(i){var e,t,s;return i===void 0?"Undefined":i===null?"Null":typeof(t=$c(e=Tc(i),yc))=="string"?t:Ec?yi(e):(s=yi(e))=="Object"&&bc(e.callee)?"Arguments":s},kc=fa,Ac=Bi,wc=kc?{}.toString:function(){return"[object "+Ac(this)+"]"},Pc=fa,Cc=xt.f,Dc=zt,Lc=Ve,xc=wc,_c=ye,dr=_c("toStringTag"),Bn=function(i,e,t,s){if(i){var a=t?i:i.prototype;Lc(a,dr)||Cc(a,dr,{configurable:!0,value:e}),s&&!Pc&&Dc(a,"toString",xc)}},Rc=On.IteratorPrototype,Ic=_n,Nc=Oi,Oc=Bn,Mc=Lt,Bc=function(){return this},Vc=function(i,e,t,s){var a=e+" Iterator";return i.prototype=Ic(Rc,{next:Nc(+!s,t)}),Oc(i,a,!1,!0),Mc[a]=Bc,i},Fc=Mi,Uc=Be,Vn=fd,jc=Vc,Hc=Rn,Gc=Bn,cr=In,Yc=ye,hr=Lt,Fn=On,qc=Vn.PROPER;Vn.CONFIGURABLE;Fn.IteratorPrototype;var li=Fn.BUGGY_SAFARI_ITERATORS,gs=Yc("iterator"),fr="keys",ui="values",pr="entries",zc=function(){return this},Wc=function(i,e,t,s,a,n,o){jc(t,e,s);var l=function(b){if(b===a&&f)return f;if(!li&&b in d)return d[b];switch(b){case fr:return function(){return new t(this,b)};case ui:return function(){return new t(this,b)};case pr:return function(){return new t(this,b)}}return function(){return new t(this)}},c=e+" Iterator",u=!1,d=i.prototype,h=d[gs]||d["@@iterator"]||a&&d[a],f=!li&&h||l(a),p=e=="Array"&&d.entries||h,S,m,v;if(p&&(S=Hc(p.call(new i)),S!==Object.prototype&&S.next&&(Gc(S,c,!0,!0),hr[c]=zc)),qc&&a==ui&&h&&h.name!==ui&&(u=!0,f=function(){return Uc(h,this)}),a)if(m={values:l(ui),keys:n?f:l(fr),entries:l(pr)},o)for(v in m)(li||u||!(v in d))&&cr(d,v,m[v]);else Fc({target:e,proto:!0,forced:li||u},m);return o&&d[gs]!==f&&cr(d,gs,f,{name:a}),hr[e]=f,m},Qc=function(i,e){return{value:i,done:e}},Kc=qt,mr=Lt,Un=xu;xt.f;var Jc=Wc,di=Qc,jn="Array Iterator",Xc=Un.set,Zc=Un.getterFor(jn);Jc(Array,"Array",function(i,e){Xc(this,{type:jn,target:Kc(i),index:0,kind:e})},function(){var i=Zc(this),e=i.target,t=i.kind,s=i.index++;return!e||s>=e.length?(i.target=void 0,di(void 0,!0)):t=="keys"?di(s,!1):t=="values"?di(e[s],!1):di([s,e[s]],!1)},"values");mr.Arguments=mr.Array;var eh=ye,th=Lt,ih=eh("iterator"),sh=Array.prototype,ah=function(i){return i!==void 0&&(th.Array===i||sh[ih]===i)},rh=Bi,vr=Ii,nh=Ri,oh=Lt,lh=ye,uh=lh("iterator"),Hn=function(i){if(!nh(i))return vr(i,uh)||vr(i,"@@iterator")||oh[rh(i)]},dh=Be,ch=na,hh=nt,fh=ra,ph=Hn,mh=TypeError,vh=function(i,e){var t=arguments.length<2?ph(i):e;if(ch(t))return hh(dh(t,i));throw mh(fh(i)+" is not iterable")},Sh=Be,Sr=nt,bh=Ii,gh=function(i,e,t){var s,a;Sr(i);try{if(s=bh(i,"return"),!s){if(e==="throw")throw t;return t}s=Sh(s,i)}catch(n){a=!0,s=n}if(e==="throw")throw t;if(a)throw s;return Sr(s),t},yh=wn,Th=Be,Eh=nt,$h=ra,kh=ah,Ah=ha,br=aa,wh=vh,Ph=Hn,gr=gh,Ch=TypeError,Ti=function(i,e){this.stopped=i,this.result=e},yr=Ti.prototype,Dh=function(i,e,t){var s=t&&t.that,a=!!(t&&t.AS_ENTRIES),n=!!(t&&t.IS_RECORD),o=!!(t&&t.IS_ITERATOR),l=!!(t&&t.INTERRUPTED),c=yh(e,s),u,d,h,f,p,S,m,v=function(y){return u&&gr(u,"normal",y),new Ti(!0,y)},b=function(y){return a?(Eh(y),l?c(y[0],y[1],v):c(y[0],y[1])):l?c(y,v):c(y)};if(n)u=i.iterator;else if(o)u=i;else{if(d=Ph(i),!d)throw Ch($h(i)+" is not iterable");if(kh(d)){for(h=0,f=Ah(i);f>h;h++)if(p=b(i[h]),p&&br(yr,p))return p;return new Ti(!1)}u=wh(i,d)}for(S=n?i.next:u.next;!(m=Th(S,u)).done;){try{p=b(m.value)}catch(y){gr(u,"throw",y)}if(typeof p=="object"&&p&&br(yr,p))return p}return new Ti(!1)},Lh=oa,xh=xt,_h=Oi,Rh=function(i,e,t){var s=Lh(e);s in i?xh.f(i,s,_h(0,t)):i[s]=t},Ih=Mi,Nh=Dh,Oh=Rh;Ih({target:"Object",stat:!0},{fromEntries:function(e){var t={};return Nh(e,function(s,a){Oh(t,s,a)},{AS_ENTRIES:!0}),t}});var Mh=ia,Bh=Mh.Object.fromEntries,Vh={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},Fh=Vh,Uh=ge,jh=Bi,Hh=zt,Tr=Lt,Gh=ye,Er=Gh("toStringTag");for(var ys in Fh){var $r=Uh[ys],Ts=$r&&$r.prototype;Ts&&jh(Ts)!==Er&&Hh(Ts,Er,ys),Tr[ys]=Tr.Array}var Yh=Bh,qh=Yh,zh=qh,Wh=zh,wi=ea(Wh),ee;(function(i){i[i.OFFSET_P=0]="OFFSET_P",i[i.PLAYBACK_SHIFT=1]="PLAYBACK_SHIFT",i[i.DASH_CMAF_OFFSET_P=2]="DASH_CMAF_OFFSET_P"})(ee||(ee={}));var be=(i,e=0,t=ee.OFFSET_P)=>{switch(t){case ee.OFFSET_P:return i.replace("_offset_p",e===0?"":"_"+e.toFixed(0));case ee.PLAYBACK_SHIFT:{if(e===0)return i;const s=new URL(i);return s.searchParams.append("playback_shift",e.toFixed(0)),s.toString()}case ee.DASH_CMAF_OFFSET_P:{const s=new URL(i);return!s.searchParams.get("offset_p")&&e===0?i:(s.searchParams.set("offset_p",e.toFixed(0)),s.toString())}default:r.assertNever(t)}return i};const kr=(i,e)=>{var t;switch(e){case ee.OFFSET_P:return NaN;case ee.PLAYBACK_SHIFT:{const s=new URL(i);return Number(s.searchParams.get("playback_shift"))}case ee.DASH_CMAF_OFFSET_P:{const s=new URL(i);return Number((t=s.searchParams.get("offset_p"))!==null&&t!==void 0?t:0)}default:r.assertNever(e)}};var P=(i,e,t=!1)=>{const s=i.getTransition();(t||!s||s.to===e)&&i.setState(e)};class J{constructor(e){this.transitionStarted$=new r.Subject,this.transitionEnded$=new r.Subject,this.transitionUpdated$=new r.Subject,this.forceChanged$=new r.Subject,this.stateChangeStarted$=r.merge(this.transitionStarted$,this.transitionUpdated$),this.stateChangeEnded$=r.merge(this.transitionEnded$,this.forceChanged$),this.state=e,this.prevState=void 0}setState(e){const t=this.transition,s=this.state;this.transition=void 0,this.prevState=s,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:s,to:e,canceledTransition:t})}startTransitionTo(e){const t=this.transition,s=this.state;s===e||r.isNonNullable(t)&&t.to===e||(this.prevState=s,this.state=e,t?(this.transition={from:t.from,to:e,canceledTransition:t},this.transitionUpdated$.next(this.transition)):(this.transition={from:s,to:e},this.transitionStarted$.next(this.transition)))}getTransition(){return this.transition}getState(){return this.state}getPrevState(){return this.prevState}}const Qh=i=>{switch(i){case exports.VideoFormat.MPEG:case exports.VideoFormat.DASH_SEP:case exports.VideoFormat.DASH_ONDEMAND:case exports.VideoFormat.DASH_WEBM:case exports.VideoFormat.DASH_WEBM_AV1:case exports.VideoFormat.HLS:case exports.VideoFormat.HLS_ONDEMAND:return!1;case exports.VideoFormat.DASH_LIVE:case exports.VideoFormat.DASH_LIVE_CMAF:case exports.VideoFormat.HLS_LIVE:case exports.VideoFormat.HLS_LIVE_CMAF:case exports.VideoFormat.DASH_LIVE_WEBM:case exports.VideoFormat.WEB_RTC_LIVE:return!0;default:return r.assertNever(i)}};var x;(function(i){i.STOPPED="stopped",i.READY="ready",i.PLAYING="playing",i.PAUSED="paused"})(x||(x={}));const Kh=5,Jh=5,Xh=500,Ar=7e3;class Zh{constructor(e){this.subscription=new r.Subscription,this.loadMediaTimeoutSubscription=new r.Subscription,this.videoState=new J(x.STOPPED),this.syncPlayback=()=>{const s=this.videoState.getState(),a=this.videoState.getTransition(),n=this.params.desiredState.playbackState.getState(),o=this.params.desiredState.playbackState.getTransition(),l=this.params.desiredState.seekState.getState();if(this.log({message:`[syncPlayback] videoState: ${s}; videoTransition: ${JSON.stringify(a)}; desiredPlaybackState: ${n}; desiredPlaybackStateTransition: ${this.params.desiredState.playbackState.getTransition()}; seekState: ${JSON.stringify(l)};`}),n===exports.PlaybackState.STOPPED){s!==x.STOPPED&&(this.videoState.startTransitionTo(x.STOPPED),this.stop());return}if(!a){if((o==null?void 0:o.to)!==exports.PlaybackState.PAUSED&&l.state===I.Requested&&s!==x.STOPPED){this.seek(l.position/1e3);return}switch(n){case exports.PlaybackState.READY:{switch(s){case x.PLAYING:case x.PAUSED:case x.READY:break;case x.STOPPED:this.videoState.startTransitionTo(x.READY),this.prepare();break;default:r.assertNever(s)}break}case exports.PlaybackState.PLAYING:{switch(s){case x.PLAYING:break;case x.PAUSED:this.videoState.startTransitionTo(x.PLAYING),this.params.connection.remotePlayerController.playOrPause();break;case x.READY:this.videoState.startTransitionTo(x.PLAYING),this.params.connection.remotePlayerController.playOrPause();break;case x.STOPPED:this.videoState.startTransitionTo(x.READY),this.prepare();break;default:r.assertNever(s)}break}case exports.PlaybackState.PAUSED:{switch(s){case x.PLAYING:this.videoState.startTransitionTo(x.PAUSED),this.params.connection.remotePlayerController.playOrPause();break;case x.PAUSED:break;case x.READY:this.videoState.startTransitionTo(x.PAUSED),this.videoState.setState(x.PAUSED);break;case x.STOPPED:this.videoState.startTransitionTo(x.READY),this.prepare();break;default:r.assertNever(s)}break}default:r.assertNever(n)}}},this.params=e,this.log=this.params.dependencies.logger.createComponentLog("ChromecastProvider"),this.log({message:`constructor, format: ${e.format}`}),this.params.output.isLive$.next(Qh(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 r.Subscription;this.subscription.add(e),this.subscription.add(r.merge(this.videoState.stateChangeStarted$.pipe(r.map(a=>`stateChangeStarted$ ${JSON.stringify(a)}`)),this.videoState.stateChangeEnded$.pipe(r.map(a=>`stateChangeEnded$ ${JSON.stringify(a)}`))).subscribe(a=>this.log({message:`[videoState] ${a}`})));const t=(a,n)=>this.subscription.add(a.subscribe(n));if(this.params.output.isLive$.getValue())this.params.output.position$.next(0),this.params.output.duration$.next(0);else{const a=new r.Subject;e.add(a.pipe(r.debounce(Xh)).subscribe(()=>{this.params.output.seekedEvent$.next()}));let n=NaN;e.add(r.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED).subscribe(o=>{this.logRemoteEvent(o);const l=o.value;this.params.output.position$.next(l),(this.params.desiredState.seekState.getState().state===I.Applying||Math.abs(l-n)>Kh)&&a.next(l),n=l})),e.add(r.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.DURATION_CHANGED).subscribe(o=>{this.logRemoteEvent(o),this.params.output.duration$.next(o.value)}))}t(r.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED),a=>{this.logRemoteEvent(a),a.value?this.handleRemoteReady():(this.handleRemoteStop(),e.unsubscribe())}),t(r.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED),a=>{this.logRemoteEvent(a),a.value?this.handleRemotePause():this.handleRemotePlay()}),t(r.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED),a=>{this.logRemoteEvent(a);const{remotePlayer:n}=this.params.connection,o=a.value,l=this.params.output.isBuffering$.getValue(),c=o===chrome.cast.media.PlayerState.BUFFERING;switch(l!==c&&this.params.output.isBuffering$.next(c),o){case chrome.cast.media.PlayerState.IDLE:!this.params.output.isLive$.getValue()&&n.duration-n.currentTime<Jh&&this.params.output.endedEvent$.next(),this.handleRemoteStop(),P(this.params.desiredState.playbackState,exports.PlaybackState.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:r.assertNever(o)}}),t(r.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED),a=>{this.logRemoteEvent(a),this.handleRemoteVolumeChange({volume:a.value})}),t(r.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED),a=>{this.logRemoteEvent(a),this.handleRemoteVolumeChange({muted:a.value})});const s=r.merge(this.params.desiredState.playbackState.stateChangeStarted$,this.params.desiredState.seekState.stateChangeEnded$,this.videoState.stateChangeEnded$,r.observableFrom(["init"])).pipe(r.debounce(0));t(s,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(x.PAUSED),P(this.params.desiredState.playbackState,exports.PlaybackState.PAUSED)):(this.videoState.setState(x.PLAYING),P(this.params.desiredState.playbackState,exports.PlaybackState.PLAYING));const s=this.params.output.isLive$.getValue();this.params.output.duration$.next(s?0:t.duration),this.params.output.position$.next(s?0:t.currentTime),this.params.desiredState.seekState.setState({state:I.None})}}prepare(){const e=this.params.format;this.log({message:`[prepare] format: ${e}`});const t=this.createMediaInfo(e),s=this.createLoadRequest(t);this.loadMedia(s)}handleRemotePause(){const e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)===x.PAUSED||e===x.PLAYING)&&(this.videoState.setState(x.PAUSED),P(this.params.desiredState.playbackState,exports.PlaybackState.PAUSED))}handleRemotePlay(){const e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)===x.PLAYING||e===x.PAUSED)&&(this.videoState.setState(x.PLAYING),P(this.params.desiredState.playbackState,exports.PlaybackState.PLAYING))}handleRemoteReady(){var e;const t=this.videoState.getTransition();(t==null?void 0:t.to)===x.READY&&this.videoState.setState(x.READY),((e=this.params.desiredState.playbackState.getTransition())===null||e===void 0?void 0:e.to)===exports.PlaybackState.READY&&P(this.params.desiredState.playbackState,exports.PlaybackState.READY)}handleRemoteStop(){this.videoState.getState()!==x.STOPPED&&this.videoState.setState(x.STOPPED)}handleRemoteVolumeChange(e){var t,s;const a=this.params.output.volume$.getValue(),n={volume:(t=e.volume)!==null&&t!==void 0?t:a.volume,muted:(s=e.muted)!==null&&s!==void 0?s:a.muted};(n.volume!==a.volume||n.muted!==n.muted)&&this.params.output.volume$.next(n)}seek(e){this.params.output.willSeekEvent$.next();const{remotePlayer:t,remotePlayerController:s}=this.params.connection;t.currentTime=e,s.seek()}stop(){const{remotePlayerController:e}=this.params.connection;e.stop()}createMediaInfo(e){var t;const s=this.params.source;let a,n,o;switch(e){case exports.VideoFormat.MPEG:{const d=s[e];r.assertNonNullable(d);const h=r.getHighestQuality(Object.keys(d));r.assertNonNullable(h);const f=d[h];r.assertNonNullable(f),a=f,n="video/mp4",o=chrome.cast.media.StreamType.BUFFERED;break}case exports.VideoFormat.HLS:case exports.VideoFormat.HLS_ONDEMAND:{const d=s[e];r.assertNonNullable(d),a=d.url,n="application/x-mpegurl",o=chrome.cast.media.StreamType.BUFFERED;break}case exports.VideoFormat.DASH_SEP:case exports.VideoFormat.DASH_ONDEMAND:case exports.VideoFormat.DASH_WEBM:case exports.VideoFormat.DASH_WEBM_AV1:{const d=s[e];r.assertNonNullable(d),a=d.url,n="application/dash+xml",o=chrome.cast.media.StreamType.BUFFERED;break}case exports.VideoFormat.DASH_LIVE_CMAF:{const d=s[e];r.assertNonNullable(d),a=d.url,n="application/dash+xml",o=chrome.cast.media.StreamType.LIVE;break}case exports.VideoFormat.HLS_LIVE:case exports.VideoFormat.HLS_LIVE_CMAF:{const d=s[e];r.assertNonNullable(d),a=be(d.url),n="application/x-mpegurl",o=chrome.cast.media.StreamType.LIVE;break}case exports.VideoFormat.DASH_LIVE:case exports.VideoFormat.WEB_RTC_LIVE:{const d="Unsupported format for Chromecast",h=new Error(d);throw this.params.output.error$.next({id:"ChromecastProvider.createMediaInfo()",category:r.ErrorCategory.VIDEO_PIPELINE,message:d,thrown:h}),h}case exports.VideoFormat.DASH_LIVE_WEBM:throw new Error("DASH_LIVE_WEBM is no longer supported");default:return r.assertNever(e)}const l=new chrome.cast.media.MediaInfo((t=this.params.meta.videoId)!==null&&t!==void 0?t:a,n);l.contentUrl=a,l.streamType=o,l.metadata=new chrome.cast.media.GenericMediaMetadata;const{title:c,subtitle:u}=this.params.meta;return r.isNonNullable(c)&&(l.metadata.title=c),r.isNonNullable(u)&&(l.metadata.subtitle=u),l}createLoadRequest(e){const t=new chrome.cast.media.LoadRequest(e);t.autoplay=!1;const s=this.params.desiredState.seekState.getState();return s.state===I.Applying||s.state===I.Requested?t.currentTime=this.params.output.isLive$.getValue()?0:s.position/1e3:t.currentTime=0,t}loadMedia(e){const t=this.params.connection.session.loadMedia(e),s=new Promise((a,n)=>{this.loadMediaTimeoutSubscription.add(r.timeout(Ar).subscribe(()=>n(`timeout(${Ar})`)))});Promise.race([t,s]).then(()=>{this.log({message:`[loadMedia] completed, format: ${this.params.format}`}),this.params.desiredState.seekState.getState().state===I.Applying&&this.params.output.seekedEvent$.next(),this.handleRemoteReady()},a=>{const n=`[prepare] loadMedia failed, format: ${this.params.format}, reason: ${a}`;this.log({message:n}),this.params.output.error$.next({id:"ChromecastProvider.loadMedia",category:r.ErrorCategory.VIDEO_PIPELINE,message:n,thrown:a})}).finally(()=>{this.loadMediaTimeoutSubscription.unsubscribe()})}logRemoteEvent(e){this.log({message:`[remoteEvent] ${JSON.stringify(e)}`})}}const pa=i=>{i.removeAttribute("src"),i.load()},ef=i=>{try{i.pause(),i.playbackRate=0,pa(i),i.remove()}catch(e){console.error(e)}};class tf{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 Ws=window.WeakMap?new WeakMap:new tf,ot=i=>{let e=i.querySelector("video");const t=!!e;return e?pa(e):(e=document.createElement("video"),i.appendChild(e)),Ws.set(e,t),e.setAttribute("crossorigin","anonymous"),e.setAttribute("playsinline","playsinline"),e.controls=!1,e.setAttribute("poster","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),e},lt=i=>{const e=Ws.get(i);Ws.delete(i),e?pa(i):ef(i)},_e=(i,e,t,{equal:s=(o,l)=>o===l,changed$:a,onError:n}={})=>{const o=i.getState(),l=e(),c=r.isNullable(a),u=new r.Subscription;return a&&u.add(a.subscribe(d=>{const h=i.getState();s(d,h)&&i.setState(d)},n)),s(l,o)||(t(o),c&&i.setState(o)),u.add(i.stateChangeStarted$.subscribe(d=>{t(d.to),c&&i.setState(d.to)},n)),u},Qt=(i,e,t)=>_e(e,()=>i.loop,s=>{r.isNonNullable(s)&&(i.loop=s)},{onError:t}),ut=(i,e,t,s)=>_e(e,()=>({muted:i.muted,volume:i.volume}),a=>{r.isNonNullable(a)&&(i.muted=a.muted,i.volume=a.volume)},{equal:(a,n)=>a===n||(a==null?void 0:a.muted)===(n==null?void 0:n.muted)&&(a==null?void 0:a.volume)===(n==null?void 0:n.volume),changed$:t,onError:s}),_t=(i,e,t,s)=>_e(e,()=>i.playbackRate,a=>{r.isNonNullable(a)&&(i.playbackRate=a)},{changed$:t,onError:s}),sf=i=>["__",i.language,i.label].join("|"),af=(i,e)=>{if(i.id===e)return!0;const[t,s,a]=e.split("|");return i.language===s&&i.label===a};class qe{constructor(){this.available$=new r.Subject,this.current$=new r.ValueSubject(void 0),this.error$=new r.Subject,this.subscription=new r.Subscription,this.externalTracks=new Map,this.internalTracks=new Map}connect(e,t,s){this.video=e,this.cueSettings=t.textTrackCuesSettings,this.subscribe();const a=n=>{this.error$.next({id:"TextTracksManager",category:r.ErrorCategory.WTF,message:"Generic HtmlVideoTextTrackManager error",thrown:n})};this.subscription.add(this.available$.subscribe(s.availableTextTracks$)),this.subscription.add(this.current$.subscribe(s.currentTextTrack$)),this.subscription.add(this.error$.subscribe(s.error$)),this.subscription.add(_e(t.internalTextTracks,()=>Object.values(this.internalTracks),n=>{r.isNonNullable(n)&&this.setInternal(n)},{equal:(n,o)=>r.isNonNullable(n)&&r.isNonNullable(o)&&n.length===o.length&&n.every(({id:l},c)=>l===o[c].id),changed$:this.available$.pipe(r.map(n=>n.filter(({type:o})=>o==="internal"))),onError:a})),this.subscription.add(_e(t.externalTextTracks,()=>Object.values(this.externalTracks),n=>{r.isNonNullable(n)&&this.setExternal(n)},{equal:(n,o)=>r.isNonNullable(n)&&r.isNonNullable(o)&&n.length===o.length&&n.every(({id:l},c)=>l===o[c].id),changed$:this.available$.pipe(r.map(n=>n.filter(({type:o})=>o==="external"))),onError:a})),this.subscription.add(_e(t.currentTextTrack,()=>{if(this.video)return;const n=this.htmlTextTracksAsArray().find(({mode:o})=>o==="showing");return n&&this.htmlTextTrackToITextTrack(n).id},n=>this.select(n),{changed$:this.current$,onError:a})),this.subscription.add(_e(t.textTrackCuesSettings,()=>({}),()=>{if(this.video)for(const n of this.htmlTextTracksAsArray())this.applyCueSettings(n.cues),this.applyCueSettings(n.activeCues)}))}subscribe(){r.assertNonNullable(this.video);const{textTracks:e}=this.video;this.subscription.add(r.fromEvent(e,"addtrack").subscribe(()=>{const s=this.current$.getValue();s&&this.select(s)})),this.subscription.add(r.merge(r.fromEvent(e,"addtrack"),r.fromEvent(e,"removetrack"),r.observableFrom(["init"])).pipe(r.map(()=>this.htmlTextTracksAsArray().map(s=>this.htmlTextTrackToITextTrack(s))),r.filterChanged((s,a)=>s.length===a.length&&s.every(({id:n},o)=>n===a[o].id))).subscribe(this.available$)),this.subscription.add(r.merge(r.fromEvent(e,"change"),r.observableFrom(["init"])).pipe(r.map(()=>this.htmlTextTracksAsArray().find(({mode:s})=>s==="showing")),r.map(s=>s&&this.htmlTextTrackToITextTrack(s).id),r.filterChanged()).subscribe(this.current$));const t=s=>{var a,n;return this.applyCueSettings((n=(a=s.target)===null||a===void 0?void 0:a.activeCues)!==null&&n!==void 0?n:null)};this.subscription.add(r.fromEvent(e,"addtrack").subscribe(s=>{var a,n;(a=s.track)===null||a===void 0||a.addEventListener("cuechange",t);const o=l=>{var c,u,d,h,f;const p=(u=(c=l.target)===null||c===void 0?void 0:c.cues)!==null&&u!==void 0?u:null;p&&p.length&&(this.applyCueSettings((h=(d=l.target)===null||d===void 0?void 0:d.cues)!==null&&h!==void 0?h:null),(f=l.target)===null||f===void 0||f.removeEventListener("cuechange",o))};(n=s.track)===null||n===void 0||n.addEventListener("cuechange",o)})),this.subscription.add(r.fromEvent(e,"removetrack").subscribe(s=>{var a;(a=s.track)===null||a===void 0||a.removeEventListener("cuechange",t)}))}applyCueSettings(e){if(!e||!e.length)return;const t=this.cueSettings.getState();for(const s of Array.from(e)){const a=s;r.isNonNullable(t.align)&&(a.align=t.align),r.isNonNullable(t.position)&&(a.position=t.position),r.isNonNullable(t.size)&&(a.size=t.size),r.isNonNullable(t.line)&&(a.line=t.line)}}htmlTextTracksAsArray(e=!1){r.assertNonNullable(this.video);const t=[...this.video.textTracks];return e?t:t.filter(qe.isHealthyTrack)}htmlTextTrackToITextTrack(e){var t,s;const{language:a,label:n}=e,o=e.id?e.id:sf(e),l=this.externalTracks.has(o),c=o.includes("auto");return l?{id:o,type:"external",isAuto:c,language:a,label:n,url:(t=this.externalTracks.get(o))===null||t===void 0?void 0:t.url}:{id:o,type:"internal",isAuto:c,language:a,label:n,url:(s=this.internalTracks.get(o))===null||s===void 0?void 0:s.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(s=>s.id===t)).forEach(([,t])=>this.detach(t))}setInternal(e){const t=[...this.externalTracks];e.filter(({id:s,language:a,isAuto:n})=>!this.internalTracks.has(s)&&!t.some(([,o])=>o.language===a&&o.isAuto===n)).forEach(s=>this.attach(s)),Array.from(this.internalTracks).filter(([s])=>!e.find(a=>a.id===s)).forEach(([,s])=>this.detach(s))}select(e){r.assertNonNullable(this.video);for(const t of this.htmlTextTracksAsArray(!0))t.mode="showing";for(const t of this.htmlTextTracksAsArray(!0))(r.isNullable(e)||!af(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){r.assertNonNullable(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){r.assertNonNullable(this.video);const t=Array.prototype.find.call(this.video.getElementsByTagName("track"),s=>s.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)}}class ma{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 Gn=i=>{var e;let t=i;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},wr=i=>{const e=Gn(i);return!!(e&&e.fullscreenElement&&e.fullscreenElement===i)},rf=i=>{const e=Gn(i);return!!(e&&e.pictureInPictureElement&&e.pictureInPictureElement===i)},nf=3;var of=(i,e,t=nf)=>{let s=0,a=0;for(let n=0;n<i.length;n++){const o=i.start(n),l=i.end(n);if(o<=e&&e<=l){if(s=o,a=l,!t)return{from:s,to:a};for(let c=n-1;c>=0;c--)i.end(c)+t>=s&&(s=i.start(c));for(let c=n+1;c<i.length;c++)i.start(c)-t<=a&&(a=i.end(c))}}return{from:s,to:a}};const dt=i=>{const e=T=>r.fromEvent(i,T).pipe(r.mapTo(void 0)),t=["waiting","pause","canplay","play","canplaythrough","playing","seeking","seeked","ended"],s=r.merge(...t.map(T=>r.fromEvent(i,T))).pipe(r.map(T=>T.type==="ended"?i.readyState<2:i.readyState<3),r.filterChanged()),a=r.merge(r.fromEvent(i,"progress"),r.fromEvent(i,"timeupdate")).pipe(r.map(()=>of(i.buffered,i.currentTime))),o=r.getCurrentBrowser().browser===r.CurrentClientBrowser.Safari?r.combine({play:e("play").pipe(r.once()),playing:e("playing")}).pipe(r.mapTo(void 0)):e("playing"),l=r.fromEvent(i,"volumechange").pipe(r.map(()=>({muted:i.muted,volume:i.volume}))),c=r.fromEvent(i,"ratechange").pipe(r.map(()=>i.playbackRate)),u=r.fromEvent(i,"error").pipe(r.filter(()=>!!(i.error||i.played.length)),r.map(()=>{var T;const E=i.error;return{id:E?`MediaError#${E.code}`:"HtmlVideoError",category:r.ErrorCategory.VIDEO_PIPELINE,message:E?E.message:"Error event from HTML video element",thrown:(T=i.error)!==null&&T!==void 0?T:void 0}})),d=r.fromEvent(i,"timeupdate").pipe(r.map(()=>i.currentTime)),h=new r.Subject,f=.3;let p;d.subscribe(T=>{i.loop&&r.isNonNullable(p)&&r.isNonNullable(T)&&p>=i.duration-f&&T<=f&&h.next(p),p=T});const S=r.fromEvent(i,"enterpictureinpicture"),m=r.fromEvent(i,"leavepictureinpicture"),v=new r.ValueSubject(rf(i));S.subscribe(()=>v.next(!0)),m.subscribe(()=>v.next(!1));const b=new r.ValueSubject(wr(i));return r.fromEvent(i,"fullscreenchange").pipe(r.map(()=>wr(i))).subscribe(b),{playing$:o,pause$:e("pause").pipe(r.filter(()=>!i.error)),canplay$:e("canplay"),ended$:e("ended"),looped$:h,error$:u,seeked$:e("seeked"),seeking$:e("seeking"),progress$:e("progress"),loadStart$:e("loadstart"),loadedMetadata$:e("loadedmetadata"),loadedData$:e("loadeddata"),timeUpdate$:d,durationChange$:r.fromEvent(i,"durationchange").pipe(r.map(()=>i.duration)),isBuffering$:s,currentBuffer$:a,volumeState$:l,playbackRateState$:c,inPiP$:v,inFullscreen$:b}};var Vi=i=>{switch(i){case"mobile":return r.VideoQuality.Q_144P;case"lowest":return r.VideoQuality.Q_240P;case"low":return r.VideoQuality.Q_360P;case"sd":case"medium":return r.VideoQuality.Q_480P;case"hd":case"high":return r.VideoQuality.Q_720P;case"fullhd":case"full":return r.VideoQuality.Q_1080P;case"quadhd":case"quad":return r.VideoQuality.Q_1440P;case"ultrahd":case"ultra":return r.VideoQuality.Q_2160P}},lf=Mi,uf=Ni,df=ha,cf=ca;lf({target:"Array",proto:!0},{at:function(e){var t=uf(this),s=df(t),a=cf(e),n=a>=0?a:s+a;return n<0||n>=s?void 0:t[n]}});var hf=sa,Yn=hf,ff=Yn,pf=ff("Array","at"),mf=pf,vf=mf,Sf=vf,bf=Sf,xe=ea(bf);let va=!1,Re={};const gf=i=>{va=i},yf=()=>{Re={}},Tf=i=>{i(Re)},ci=(i,e)=>{var t;va&&(Re.meta=(t=Re.meta)!==null&&t!==void 0?t:{},Re.meta[i]=e)};class we{constructor(e){this.name=e}next(e){var t,s;if(!va)return;Re.series=(t=Re.series)!==null&&t!==void 0?t:{};const a=(s=Re.series[this.name])!==null&&s!==void 0?s:[];a.push([Date.now(),e]),Re.series[this.name]=a}}var tt;(function(i){i.FitsContainer="FitsContainer",i.FitsThroughput="FitsThroughput",i.Buffer="Buffer",i.DroppedFramesLimit="DroppedFramesLimit",i.FitsQualityLimits="FitsQualityLimits"})(tt||(tt={}));const Ef=new we("best_bitrate"),$f=(i,e,t)=>(e-t)*Math.pow(2,-10*i)+t;class kf{constructor(){this.history={}}recordSelection(e){this.history[e.id]=r.now()}recordSwitch(e){this.last=e}clear(){this.last=void 0,this.history={}}}const Af='Assertion "ABR Tracks is empty array" failed',Fi=(i,{container:e,throughput:t,tuning:s,limits:a,reserve:n=0,forwardBufferHealth:o,playbackRate:l,current:c,history:u,droppedVideoMaxQualityLimit:d,abrLogger:h})=>{var f,p,S,m,v;r.assertNotEmptyArray(i,Af);const b=s.usePixelRatio&&(f=window.devicePixelRatio)!==null&&f!==void 0?f:1,y=s.limitByContainer&&e&&e.width>0&&e.height>0&&{width:e.width*b*s.containerSizeFactor,height:e.height*b*s.containerSizeFactor},T=y&&r.videoSizeToQuality(y),E=s.considerPlaybackRate&&r.isNonNullable(l)?l:1,$=i.filter(D=>!r.isInvariantQuality(D.quality)).sort((D,A)=>r.isHigher(D.quality,A.quality)?-1:1),N=(p=xe($,-1))===null||p===void 0?void 0:p.quality,O=(S=xe($,0))===null||S===void 0?void 0:S.quality,V=r.isNullable(a)||r.isNonNullable(a.min)&&r.isNonNullable(a.max)&&r.isLower(a.max,a.min)||r.isNonNullable(a.min)&&O&&r.isHigher(a.min,O)||r.isNonNullable(a.max)&&N&&r.isLower(a.max,N),R=E*$f(o!=null?o:.5,s.bitrateFactorAtEmptyBuffer,s.bitrateFactorAtFullBuffer),F={},C=$.filter(D=>(T?r.isLower(D.quality,T):!0)?(r.isNonNullable(t)&&isFinite(t)&&r.isNonNullable(D.bitrate)?t-n>=D.bitrate*R:!0)?s.lazyQualitySwitch&&r.isNonNullable(s.minBufferToSwitchUp)&&c&&!r.isInvariantQuality(c.quality)&&(o!=null?o:0)<s.minBufferToSwitchUp&&r.isHigher(D.quality,c.quality)?(F[D.quality]=tt.Buffer,!1):!!d&&r.isHigherOrEqual(D.quality,d)?(F[D.quality]=tt.DroppedFramesLimit,!1):V||(r.isNullable(a.max)||r.isLowerOrEqual(D.quality,a.max))&&(r.isNullable(a.min)||r.isHigherOrEqual(D.quality,a.min))?!0:(F[D.quality]=tt.FitsQualityLimits,!1):(F[D.quality]=tt.FitsThroughput,!1):(F[D.quality]=tt.FitsContainer,!1))[0];C&&C.bitrate&&Ef.next(C.bitrate);const w=(m=C!=null?C:$[Math.ceil(($.length-1)/2)])!==null&&m!==void 0?m:i[0];w.quality!==((v=u==null?void 0:u.last)===null||v===void 0?void 0:v.quality)&&h({message:`
|
|
6
|
+
"use strict";var Lo=Object.create;var _a=Object.defineProperty;var xo=Object.getOwnPropertyDescriptor;var _o=Object.getOwnPropertyNames;var Ro=Object.getPrototypeOf,Io=Object.prototype.hasOwnProperty;var No=(i,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of _o(e))!Io.call(i,a)&&a!==t&&_a(i,a,{get:()=>e[a],enumerable:!(s=xo(e,a))||s.enumerable});return i};var Oo=(i,e,t)=>(t=i!=null?Lo(Ro(i)):{},No(e||!i||!i.__esModule?_a(t,"default",{value:i,enumerable:!0}):t,i));var r=require("@vkontakte/videoplayer-shared/es2018.cjs.js");const en="2.0.103-dev.c555938f.0";exports.PlaybackState=void 0;(function(i){i.STOPPED="stopped",i.READY="ready",i.PLAYING="playing",i.PAUSED="paused"})(exports.PlaybackState||(exports.PlaybackState={}));exports.VideoFormat=void 0;(function(i){i.MPEG="MPEG",i.DASH="DASH_SEP",i.DASH_SEP="DASH_SEP",i.DASH_SEP_VK="DASH_SEP",i.DASH_WEBM="DASH_WEBM",i.DASH_WEBM_AV1="DASH_WEBM_AV1",i.DASH_WEBM_VK="DASH_WEBM",i.DASH_ONDEMAND="DASH_ONDEMAND",i.DASH_ONDEMAND_VK="DASH_ONDEMAND",i.DASH_LIVE="DASH_LIVE",i.DASH_LIVE_CMAF="DASH_LIVE_CMAF",i.DASH_LIVE_WEBM="DASH_LIVE_WEBM",i.HLS="HLS",i.HLS_ONDEMAND="HLS_ONDEMAND",i.HLS_JS="HLS",i.HLS_LIVE="HLS_LIVE",i.HLS_LIVE_CMAF="HLS_LIVE_CMAF",i.WEB_RTC_LIVE="WEB_RTC_LIVE"})(exports.VideoFormat||(exports.VideoFormat={}));var ae;(function(i){i.SCREEN="SCREEN",i.CHROMECAST="CHROMECAST"})(ae||(ae={}));exports.ChromecastState=void 0;(function(i){i.NOT_AVAILABLE="NOT_AVAILABLE",i.AVAILABLE="AVAILABLE",i.CONNECTING="CONNECTING",i.CONNECTED="CONNECTED"})(exports.ChromecastState||(exports.ChromecastState={}));exports.HttpConnectionType=void 0;(function(i){i.HTTP1="http1",i.HTTP2="http2",i.QUIC="quic"})(exports.HttpConnectionType||(exports.HttpConnectionType={}));var I;(function(i){i.None="none",i.Requested="requested",i.Applying="applying"})(I||(I={}));exports.Surface=void 0;(function(i){i.NONE="none",i.INLINE="inline",i.FULLSCREEN="fullscreen",i.SECOND_SCREEN="second_screen",i.PIP="pip"})(exports.Surface||(exports.Surface={}));var Mo=i=>new Promise((e,t)=>{const s=document.createElement("script");s.setAttribute("src",i),s.onload=()=>e,s.onerror=()=>t,document.body.appendChild(s)});class Bo{constructor(e){var t;this.connection$=new r.ValueSubject(void 0),this.castState$=new r.ValueSubject(exports.ChromecastState.NOT_AVAILABLE),this.errorEvent$=new r.Subject,this.realCastState$=new r.ValueSubject(exports.ChromecastState.NOT_AVAILABLE),this.subscription=new r.Subscription,this.params=e,this.log=this.params.dependencies.logger.createComponentLog("ChromecastInitializer");const s="chrome"in window;if(this.log({message:`[constructor] receiverApplicationId: ${this.params.receiverApplicationId}, isDisabled: ${this.params.isDisabled}, isSupported: ${s}`}),e.isDisabled||!s)return;const a=r.isNonNullable((t=window.chrome)===null||t===void 0?void 0:t.cast),n=!!window.__onGCastApiAvailable;a?this.initializeCastApi():(window.__onGCastApiAvailable=o=>{delete window.__onGCastApiAvailable,o&&this.initializeCastApi()},n||Mo("https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1").catch(()=>this.errorEvent$.next({id:"ChromecastLoading",category:r.ErrorCategory.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 s,a,n;(n=(a=(s=cast.framework.CastContext.getInstance())===null||s===void 0?void 0:s.getCurrentSession())===null||a===void 0?void 0:a.getMediaSession())===null||n===void 0||n.stop(new chrome.cast.media.StopRequest,e,t)})}toggleConnection(){r.isNonNullable(this.connection$.getValue())?this.disconnect():this.connect()}setVolume(e){const t=this.connection$.getValue();r.isNullable(t)||(t.remotePlayer.volumeLevel=e,t.remotePlayerController.setVolumeLevel())}setMuted(e){const t=this.connection$.getValue();r.isNullable(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),s=cast.framework.CastContext.getInstance();this.subscription.add(r.fromEvent(s,cast.framework.CastContextEventType.SESSION_STATE_CHANGED).subscribe(a=>{var n,o;switch(a.sessionState){case cast.framework.SessionState.SESSION_STARTED:case cast.framework.SessionState.SESSION_STARTING:case cast.framework.SessionState.SESSION_RESUMED:this.contentId=(o=(n=s.getCurrentSession())===null||n===void 0?void 0:n.getMediaSession())===null||o===void 0?void 0:o.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 r.assertNever(a.sessionState)}})).add(r.merge(r.fromEvent(s,cast.framework.CastContextEventType.CAST_STATE_CHANGED).pipe(r.tap(a=>{this.log({message:`[cast.framework.RemotePlayerEventType.CAST_STATE_CHANGED]: ${JSON.stringify(a)}`})}),r.map(a=>a.castState)),r.observableFrom([s.getCastState()])).pipe(r.filterChanged(),r.map(Vo),r.tap(a=>{this.log({message:`realCastState$: ${a}`})})).subscribe(this.realCastState$)).add(this.realCastState$.subscribe(a=>{var n;const o=a===exports.ChromecastState.CONNECTED,l=r.isNonNullable(this.connection$.getValue());if(o&&!l){const c=s.getCurrentSession();r.assertNonNullable(c);const u=c.getCastDevice(),d=(n=c.getMediaSession())===null||n===void 0?void 0:n.media.contentId;(r.isNullable(d)||d===this.contentId)&&(this.log({message:"connection created"}),this.connection$.next({remotePlayer:e,remotePlayerController:t,session:c,castDevice:u}))}else!o&&l&&(this.log({message:"connection destroyed"}),this.connection$.next(void 0));this.castState$.next(a===exports.ChromecastState.CONNECTED?r.isNonNullable(this.connection$.getValue())?exports.ChromecastState.CONNECTED:exports.ChromecastState.AVAILABLE:a)}))}initializeCastApi(){var e;let t,s,a;try{t=cast.framework.CastContext.getInstance(),s=chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,a=chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}catch(n){return}try{t.setOptions({receiverApplicationId:(e=this.params.receiverApplicationId)!==null&&e!==void 0?e:s,autoJoinPolicy:a}),this.initListeners()}catch(n){this.errorEvent$.next({id:"ChromecastInitializer",category:r.ErrorCategory.EXTERNAL_API,message:"[initializeCastApi] failed",thrown:n})}}}const Vo=i=>{switch(i){case cast.framework.CastState.NO_DEVICES_AVAILABLE:return exports.ChromecastState.NOT_AVAILABLE;case cast.framework.CastState.NOT_CONNECTED:return exports.ChromecastState.AVAILABLE;case cast.framework.CastState.CONNECTING:return exports.ChromecastState.CONNECTING;case cast.framework.CastState.CONNECTED:return exports.ChromecastState.CONNECTED;default:return r.assertNever(i)}};var es=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function ea(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Oe=function(i){try{return!!i()}catch(e){return!0}},Fo=Oe,xi=!Fo(function(){var i=function(){}.bind();return typeof i!="function"||i.hasOwnProperty("prototype")}),tn=xi,sn=Function.prototype,Vs=sn.call,Uo=tn&&sn.bind.bind(Vs,Vs),Me=tn?Uo:function(i){return function(){return Vs.apply(i,arguments)}},an=Me,jo=an({}.toString),Ho=an("".slice),_i=function(i){return Ho(jo(i),8,-1)},Go=Me,Yo=Oe,qo=_i,ts=Object,zo=Go("".split),Wo=Yo(function(){return!ts("z").propertyIsEnumerable(0)})?function(i){return qo(i)=="String"?zo(i,""):ts(i)}:ts,Ri=function(i){return i==null},Qo=Ri,Ko=TypeError,ta=function(i){if(Qo(i))throw Ko("Can't call method on "+i);return i},Jo=Wo,Xo=ta,qt=function(i){return Jo(Xo(i))},Lt={},si=function(i){return i&&i.Math==Math&&i},ge=si(typeof globalThis=="object"&&globalThis)||si(typeof window=="object"&&window)||si(typeof self=="object"&&self)||si(typeof es=="object"&&es)||function(){return this}()||es||Function("return this")(),Fs=typeof document=="object"&&document.all,Zo=typeof Fs=="undefined"&&Fs!==void 0,rn={all:Fs,IS_HTMLDDA:Zo},nn=rn,el=nn.all,pe=nn.IS_HTMLDDA?function(i){return typeof i=="function"||i===el}:function(i){return typeof i=="function"},tl=ge,il=pe,Ra=tl.WeakMap,sl=il(Ra)&&/native code/.test(String(Ra)),Ia=pe,on=rn,al=on.all,at=on.IS_HTMLDDA?function(i){return typeof i=="object"?i!==null:Ia(i)||i===al}:function(i){return typeof i=="object"?i!==null:Ia(i)},rl=Oe,rt=!rl(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),xt={},nl=ge,Na=at,Us=nl.document,ol=Na(Us)&&Na(Us.createElement),ln=function(i){return ol?Us.createElement(i):{}},ll=rt,ul=Oe,dl=ln,un=!ll&&!ul(function(){return Object.defineProperty(dl("div"),"a",{get:function(){return 7}}).a!=7}),cl=rt,hl=Oe,dn=cl&&hl(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),fl=at,pl=String,ml=TypeError,nt=function(i){if(fl(i))return i;throw ml(pl(i)+" is not an object")},vl=xi,ai=Function.prototype.call,Be=vl?ai.bind(ai):function(){return ai.apply(ai,arguments)},ia={},is=ia,ss=ge,Sl=pe,Oa=function(i){return Sl(i)?i:void 0},sa=function(i,e){return arguments.length<2?Oa(is[i])||Oa(ss[i]):is[i]&&is[i][e]||ss[i]&&ss[i][e]},bl=Me,aa=bl({}.isPrototypeOf),gl=typeof navigator!="undefined"&&String(navigator.userAgent)||"",cn=ge,as=gl,Ma=cn.process,Ba=cn.Deno,Va=Ma&&Ma.versions||Ba&&Ba.version,Fa=Va&&Va.v8,Se,$i;Fa&&(Se=Fa.split("."),$i=Se[0]>0&&Se[0]<4?1:+(Se[0]+Se[1]));!$i&&as&&(Se=as.match(/Edge\/(\d+)/),(!Se||Se[1]>=74)&&(Se=as.match(/Chrome\/(\d+)/),Se&&($i=+Se[1])));var yl=$i,Ua=yl,Tl=Oe,El=ge,$l=El.String,hn=!!Object.getOwnPropertySymbols&&!Tl(function(){var i=Symbol();return!$l(i)||!(Object(i)instanceof Symbol)||!Symbol.sham&&Ua&&Ua<41}),kl=hn,fn=kl&&!Symbol.sham&&typeof Symbol.iterator=="symbol",Al=sa,wl=pe,Pl=aa,Cl=fn,Dl=Object,pn=Cl?function(i){return typeof i=="symbol"}:function(i){var e=Al("Symbol");return wl(e)&&Pl(e.prototype,Dl(i))},Ll=String,ra=function(i){try{return Ll(i)}catch(e){return"Object"}},xl=pe,_l=ra,Rl=TypeError,na=function(i){if(xl(i))return i;throw Rl(_l(i)+" is not a function")},Il=na,Nl=Ri,Ii=function(i,e){var t=i[e];return Nl(t)?void 0:Il(t)},rs=Be,ns=pe,os=at,Ol=TypeError,Ml=function(i,e){var t,s;if(e==="string"&&ns(t=i.toString)&&!os(s=rs(t,i))||ns(t=i.valueOf)&&!os(s=rs(t,i))||e!=="string"&&ns(t=i.toString)&&!os(s=rs(t,i)))return s;throw Ol("Can't convert object to primitive value")},mn={exports:{}},ja=ge,Bl=Object.defineProperty,Vl=function(i,e){try{Bl(ja,i,{value:e,configurable:!0,writable:!0})}catch(t){ja[i]=e}return e},Fl=ge,Ul=Vl,Ha="__core-js_shared__",jl=Fl[Ha]||Ul(Ha,{}),vn=jl,Ga=vn;(mn.exports=function(i,e){return Ga[i]||(Ga[i]=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 Sn=mn.exports,Hl=ta,Gl=Object,Ni=function(i){return Gl(Hl(i))},Yl=Me,ql=Ni,zl=Yl({}.hasOwnProperty),Ve=Object.hasOwn||function(e,t){return zl(ql(e),t)},Wl=Me,Ql=0,Kl=Math.random(),Jl=Wl(1 .toString),bn=function(i){return"Symbol("+(i===void 0?"":i)+")_"+Jl(++Ql+Kl,36)},Xl=ge,Zl=Sn,Ya=Ve,eu=bn,tu=hn,iu=fn,At=Xl.Symbol,ls=Zl("wks"),su=iu?At.for||At:At&&At.withoutSetter||eu,ye=function(i){return Ya(ls,i)||(ls[i]=tu&&Ya(At,i)?At[i]:su("Symbol."+i)),ls[i]},au=Be,qa=at,za=pn,ru=Ii,nu=Ml,ou=ye,lu=TypeError,uu=ou("toPrimitive"),du=function(i,e){if(!qa(i)||za(i))return i;var t=ru(i,uu),s;if(t){if(e===void 0&&(e="default"),s=au(t,i,e),!qa(s)||za(s))return s;throw lu("Can't convert object to primitive value")}return e===void 0&&(e="number"),nu(i,e)},cu=du,hu=pn,oa=function(i){var e=cu(i,"string");return hu(e)?e:e+""},fu=rt,pu=un,mu=dn,ri=nt,Wa=oa,vu=TypeError,us=Object.defineProperty,Su=Object.getOwnPropertyDescriptor,ds="enumerable",cs="configurable",hs="writable";xt.f=fu?mu?function(e,t,s){if(ri(e),t=Wa(t),ri(s),typeof e=="function"&&t==="prototype"&&"value"in s&&hs in s&&!s[hs]){var a=Su(e,t);a&&a[hs]&&(e[t]=s.value,s={configurable:cs in s?s[cs]:a[cs],enumerable:ds in s?s[ds]:a[ds],writable:!1})}return us(e,t,s)}:us:function(e,t,s){if(ri(e),t=Wa(t),ri(s),pu)try{return us(e,t,s)}catch(a){}if("get"in s||"set"in s)throw vu("Accessors not supported");return"value"in s&&(e[t]=s.value),e};var Oi=function(i,e){return{enumerable:!(i&1),configurable:!(i&2),writable:!(i&4),value:e}},bu=rt,gu=xt,yu=Oi,zt=bu?function(i,e,t){return gu.f(i,e,yu(1,t))}:function(i,e,t){return i[e]=t,i},Tu=Sn,Eu=bn,Qa=Tu("keys"),la=function(i){return Qa[i]||(Qa[i]=Eu(i))},ua={},$u=sl,gn=ge,ku=at,Au=zt,fs=Ve,ps=vn,wu=la,Pu=ua,Ka="Object already initialized",js=gn.TypeError,Cu=gn.WeakMap,ki,Ht,Ai,Du=function(i){return Ai(i)?Ht(i):ki(i,{})},Lu=function(i){return function(e){var t;if(!ku(e)||(t=Ht(e)).type!==i)throw js("Incompatible receiver, "+i+" required");return t}};if($u||ps.state){var $e=ps.state||(ps.state=new Cu);$e.get=$e.get,$e.has=$e.has,$e.set=$e.set,ki=function(i,e){if($e.has(i))throw js(Ka);return e.facade=i,$e.set(i,e),e},Ht=function(i){return $e.get(i)||{}},Ai=function(i){return $e.has(i)}}else{var bt=wu("state");Pu[bt]=!0,ki=function(i,e){if(fs(i,bt))throw js(Ka);return e.facade=i,Au(i,bt,e),e},Ht=function(i){return fs(i,bt)?i[bt]:{}},Ai=function(i){return fs(i,bt)}}var xu={set:ki,get:Ht,has:Ai,enforce:Du,getterFor:Lu},_u=xi,yn=Function.prototype,Ja=yn.apply,Xa=yn.call,Ru=typeof Reflect=="object"&&Reflect.apply||(_u?Xa.bind(Ja):function(){return Xa.apply(Ja,arguments)}),Iu=_i,Nu=Me,Tn=function(i){if(Iu(i)==="Function")return Nu(i)},En={},$n={},kn={}.propertyIsEnumerable,An=Object.getOwnPropertyDescriptor,Ou=An&&!kn.call({1:2},1);$n.f=Ou?function(e){var t=An(this,e);return!!t&&t.enumerable}:kn;var Mu=rt,Bu=Be,Vu=$n,Fu=Oi,Uu=qt,ju=oa,Hu=Ve,Gu=un,Za=Object.getOwnPropertyDescriptor;En.f=Mu?Za:function(e,t){if(e=Uu(e),t=ju(t),Gu)try{return Za(e,t)}catch(s){}if(Hu(e,t))return Fu(!Bu(Vu.f,e,t),e[t])};var Yu=Oe,qu=pe,zu=/#|\.prototype\./,Wt=function(i,e){var t=Qu[Wu(i)];return t==Ju?!0:t==Ku?!1:qu(e)?Yu(e):!!e},Wu=Wt.normalize=function(i){return String(i).replace(zu,".").toLowerCase()},Qu=Wt.data={},Ku=Wt.NATIVE="N",Ju=Wt.POLYFILL="P",Xu=Wt,er=Tn,Zu=na,ed=xi,td=er(er.bind),wn=function(i,e){return Zu(i),e===void 0?i:ed?td(i,e):function(){return i.apply(e,arguments)}},ni=ge,id=Ru,sd=Tn,ad=pe,rd=En.f,nd=Xu,gt=ia,od=wn,yt=zt,tr=Ve,ld=function(i){var e=function(t,s,a){if(this instanceof e){switch(arguments.length){case 0:return new i;case 1:return new i(t);case 2:return new i(t,s)}return new i(t,s,a)}return id(i,this,arguments)};return e.prototype=i.prototype,e},Mi=function(i,e){var t=i.target,s=i.global,a=i.stat,n=i.proto,o=s?ni:a?ni[t]:(ni[t]||{}).prototype,l=s?gt:gt[t]||yt(gt,t,{})[t],c=l.prototype,u,d,h,f,p,S,m,v,b;for(f in e)u=nd(s?f:t+(a?".":"#")+f,i.forced),d=!u&&o&&tr(o,f),S=l[f],d&&(i.dontCallGetSet?(b=rd(o,f),m=b&&b.value):m=o[f]),p=d&&m?m:e[f],!(d&&typeof S==typeof p)&&(i.bind&&d?v=od(p,ni):i.wrap&&d?v=ld(p):n&&ad(p)?v=sd(p):v=p,(i.sham||p&&p.sham||S&&S.sham)&&yt(v,"sham",!0),yt(l,f,v),n&&(h=t+"Prototype",tr(gt,h)||yt(gt,h,{}),yt(gt[h],f,p),i.real&&c&&(u||!c[f])&&yt(c,f,p)))},Hs=rt,ud=Ve,Pn=Function.prototype,dd=Hs&&Object.getOwnPropertyDescriptor,da=ud(Pn,"name"),cd=da&&function(){}.name==="something",hd=da&&(!Hs||Hs&&dd(Pn,"name").configurable),fd={EXISTS:da,PROPER:cd,CONFIGURABLE:hd},Cn={},pd=Math.ceil,md=Math.floor,vd=Math.trunc||function(e){var t=+e;return(t>0?md:pd)(t)},Sd=vd,ca=function(i){var e=+i;return e!==e||e===0?0:Sd(e)},bd=ca,gd=Math.max,yd=Math.min,Td=function(i,e){var t=bd(i);return t<0?gd(t+e,0):yd(t,e)},Ed=ca,$d=Math.min,kd=function(i){return i>0?$d(Ed(i),9007199254740991):0},Ad=kd,ha=function(i){return Ad(i.length)},wd=qt,Pd=Td,Cd=ha,ir=function(i){return function(e,t,s){var a=wd(e),n=Cd(a),o=Pd(s,n),l;if(i&&t!=t){for(;n>o;)if(l=a[o++],l!=l)return!0}else for(;n>o;o++)if((i||o in a)&&a[o]===t)return i||o||0;return!i&&-1}},Dd={includes:ir(!0),indexOf:ir(!1)},Ld=Me,ms=Ve,xd=qt,_d=Dd.indexOf,Rd=ua,sr=Ld([].push),Id=function(i,e){var t=xd(i),s=0,a=[],n;for(n in t)!ms(Rd,n)&&ms(t,n)&&sr(a,n);for(;e.length>s;)ms(t,n=e[s++])&&(~_d(a,n)||sr(a,n));return a},Dn=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Nd=Id,Od=Dn,Md=Object.keys||function(e){return Nd(e,Od)},Bd=rt,Vd=dn,Fd=xt,Ud=nt,jd=qt,Hd=Md;Cn.f=Bd&&!Vd?Object.defineProperties:function(e,t){Ud(e);for(var s=jd(t),a=Hd(t),n=a.length,o=0,l;n>o;)Fd.f(e,l=a[o++],s[l]);return e};var Gd=sa,Yd=Gd("document","documentElement"),qd=nt,zd=Cn,ar=Dn,Wd=ua,Qd=Yd,Kd=ln,Jd=la,rr=">",nr="<",Gs="prototype",Ys="script",Ln=Jd("IE_PROTO"),vs=function(){},xn=function(i){return nr+Ys+rr+i+nr+"/"+Ys+rr},or=function(i){i.write(xn("")),i.close();var e=i.parentWindow.Object;return i=null,e},Xd=function(){var i=Kd("iframe"),e="java"+Ys+":",t;return i.style.display="none",Qd.appendChild(i),i.src=String(e),t=i.contentWindow.document,t.open(),t.write(xn("document.F=Object")),t.close(),t.F},oi,gi=function(){try{oi=new ActiveXObject("htmlfile")}catch(e){}gi=typeof document!="undefined"?document.domain&&oi?or(oi):Xd():or(oi);for(var i=ar.length;i--;)delete gi[Gs][ar[i]];return gi()};Wd[Ln]=!0;var _n=Object.create||function(e,t){var s;return e!==null?(vs[Gs]=qd(e),s=new vs,vs[Gs]=null,s[Ln]=e):s=gi(),t===void 0?s:zd.f(s,t)},Zd=Oe,ec=!Zd(function(){function i(){}return i.prototype.constructor=null,Object.getPrototypeOf(new i)!==i.prototype}),tc=Ve,ic=pe,sc=Ni,ac=la,rc=ec,lr=ac("IE_PROTO"),qs=Object,nc=qs.prototype,Rn=rc?qs.getPrototypeOf:function(i){var e=sc(i);if(tc(e,lr))return e[lr];var t=e.constructor;return ic(t)&&e instanceof t?t.prototype:e instanceof qs?nc:null},oc=zt,In=function(i,e,t,s){return s&&s.enumerable?i[e]=t:oc(i,e,t),i},lc=Oe,uc=pe,dc=at,cc=_n,ur=Rn,hc=In,fc=ye,zs=fc("iterator"),Nn=!1,Ie,Ss,bs;[].keys&&(bs=[].keys(),"next"in bs?(Ss=ur(ur(bs)),Ss!==Object.prototype&&(Ie=Ss)):Nn=!0);var pc=!dc(Ie)||lc(function(){var i={};return Ie[zs].call(i)!==i});pc?Ie={}:Ie=cc(Ie);uc(Ie[zs])||hc(Ie,zs,function(){return this});var On={IteratorPrototype:Ie,BUGGY_SAFARI_ITERATORS:Nn},mc=ye,vc=mc("toStringTag"),Mn={};Mn[vc]="z";var fa=String(Mn)==="[object z]",Sc=fa,bc=pe,yi=_i,gc=ye,yc=gc("toStringTag"),Tc=Object,Ec=yi(function(){return arguments}())=="Arguments",$c=function(i,e){try{return i[e]}catch(t){}},Bi=Sc?yi:function(i){var e,t,s;return i===void 0?"Undefined":i===null?"Null":typeof(t=$c(e=Tc(i),yc))=="string"?t:Ec?yi(e):(s=yi(e))=="Object"&&bc(e.callee)?"Arguments":s},kc=fa,Ac=Bi,wc=kc?{}.toString:function(){return"[object "+Ac(this)+"]"},Pc=fa,Cc=xt.f,Dc=zt,Lc=Ve,xc=wc,_c=ye,dr=_c("toStringTag"),Bn=function(i,e,t,s){if(i){var a=t?i:i.prototype;Lc(a,dr)||Cc(a,dr,{configurable:!0,value:e}),s&&!Pc&&Dc(a,"toString",xc)}},Rc=On.IteratorPrototype,Ic=_n,Nc=Oi,Oc=Bn,Mc=Lt,Bc=function(){return this},Vc=function(i,e,t,s){var a=e+" Iterator";return i.prototype=Ic(Rc,{next:Nc(+!s,t)}),Oc(i,a,!1,!0),Mc[a]=Bc,i},Fc=Mi,Uc=Be,Vn=fd,jc=Vc,Hc=Rn,Gc=Bn,cr=In,Yc=ye,hr=Lt,Fn=On,qc=Vn.PROPER;Vn.CONFIGURABLE;Fn.IteratorPrototype;var li=Fn.BUGGY_SAFARI_ITERATORS,gs=Yc("iterator"),fr="keys",ui="values",pr="entries",zc=function(){return this},Wc=function(i,e,t,s,a,n,o){jc(t,e,s);var l=function(b){if(b===a&&f)return f;if(!li&&b in d)return d[b];switch(b){case fr:return function(){return new t(this,b)};case ui:return function(){return new t(this,b)};case pr:return function(){return new t(this,b)}}return function(){return new t(this)}},c=e+" Iterator",u=!1,d=i.prototype,h=d[gs]||d["@@iterator"]||a&&d[a],f=!li&&h||l(a),p=e=="Array"&&d.entries||h,S,m,v;if(p&&(S=Hc(p.call(new i)),S!==Object.prototype&&S.next&&(Gc(S,c,!0,!0),hr[c]=zc)),qc&&a==ui&&h&&h.name!==ui&&(u=!0,f=function(){return Uc(h,this)}),a)if(m={values:l(ui),keys:n?f:l(fr),entries:l(pr)},o)for(v in m)(li||u||!(v in d))&&cr(d,v,m[v]);else Fc({target:e,proto:!0,forced:li||u},m);return o&&d[gs]!==f&&cr(d,gs,f,{name:a}),hr[e]=f,m},Qc=function(i,e){return{value:i,done:e}},Kc=qt,mr=Lt,Un=xu;xt.f;var Jc=Wc,di=Qc,jn="Array Iterator",Xc=Un.set,Zc=Un.getterFor(jn);Jc(Array,"Array",function(i,e){Xc(this,{type:jn,target:Kc(i),index:0,kind:e})},function(){var i=Zc(this),e=i.target,t=i.kind,s=i.index++;return!e||s>=e.length?(i.target=void 0,di(void 0,!0)):t=="keys"?di(s,!1):t=="values"?di(e[s],!1):di([s,e[s]],!1)},"values");mr.Arguments=mr.Array;var eh=ye,th=Lt,ih=eh("iterator"),sh=Array.prototype,ah=function(i){return i!==void 0&&(th.Array===i||sh[ih]===i)},rh=Bi,vr=Ii,nh=Ri,oh=Lt,lh=ye,uh=lh("iterator"),Hn=function(i){if(!nh(i))return vr(i,uh)||vr(i,"@@iterator")||oh[rh(i)]},dh=Be,ch=na,hh=nt,fh=ra,ph=Hn,mh=TypeError,vh=function(i,e){var t=arguments.length<2?ph(i):e;if(ch(t))return hh(dh(t,i));throw mh(fh(i)+" is not iterable")},Sh=Be,Sr=nt,bh=Ii,gh=function(i,e,t){var s,a;Sr(i);try{if(s=bh(i,"return"),!s){if(e==="throw")throw t;return t}s=Sh(s,i)}catch(n){a=!0,s=n}if(e==="throw")throw t;if(a)throw s;return Sr(s),t},yh=wn,Th=Be,Eh=nt,$h=ra,kh=ah,Ah=ha,br=aa,wh=vh,Ph=Hn,gr=gh,Ch=TypeError,Ti=function(i,e){this.stopped=i,this.result=e},yr=Ti.prototype,Dh=function(i,e,t){var s=t&&t.that,a=!!(t&&t.AS_ENTRIES),n=!!(t&&t.IS_RECORD),o=!!(t&&t.IS_ITERATOR),l=!!(t&&t.INTERRUPTED),c=yh(e,s),u,d,h,f,p,S,m,v=function(y){return u&&gr(u,"normal",y),new Ti(!0,y)},b=function(y){return a?(Eh(y),l?c(y[0],y[1],v):c(y[0],y[1])):l?c(y,v):c(y)};if(n)u=i.iterator;else if(o)u=i;else{if(d=Ph(i),!d)throw Ch($h(i)+" is not iterable");if(kh(d)){for(h=0,f=Ah(i);f>h;h++)if(p=b(i[h]),p&&br(yr,p))return p;return new Ti(!1)}u=wh(i,d)}for(S=n?i.next:u.next;!(m=Th(S,u)).done;){try{p=b(m.value)}catch(y){gr(u,"throw",y)}if(typeof p=="object"&&p&&br(yr,p))return p}return new Ti(!1)},Lh=oa,xh=xt,_h=Oi,Rh=function(i,e,t){var s=Lh(e);s in i?xh.f(i,s,_h(0,t)):i[s]=t},Ih=Mi,Nh=Dh,Oh=Rh;Ih({target:"Object",stat:!0},{fromEntries:function(e){var t={};return Nh(e,function(s,a){Oh(t,s,a)},{AS_ENTRIES:!0}),t}});var Mh=ia,Bh=Mh.Object.fromEntries,Vh={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},Fh=Vh,Uh=ge,jh=Bi,Hh=zt,Tr=Lt,Gh=ye,Er=Gh("toStringTag");for(var ys in Fh){var $r=Uh[ys],Ts=$r&&$r.prototype;Ts&&jh(Ts)!==Er&&Hh(Ts,Er,ys),Tr[ys]=Tr.Array}var Yh=Bh,qh=Yh,zh=qh,Wh=zh,wi=ea(Wh),ee;(function(i){i[i.OFFSET_P=0]="OFFSET_P",i[i.PLAYBACK_SHIFT=1]="PLAYBACK_SHIFT",i[i.DASH_CMAF_OFFSET_P=2]="DASH_CMAF_OFFSET_P"})(ee||(ee={}));var be=(i,e=0,t=ee.OFFSET_P)=>{switch(t){case ee.OFFSET_P:return i.replace("_offset_p",e===0?"":"_"+e.toFixed(0));case ee.PLAYBACK_SHIFT:{if(e===0)return i;const s=new URL(i);return s.searchParams.append("playback_shift",e.toFixed(0)),s.toString()}case ee.DASH_CMAF_OFFSET_P:{const s=new URL(i);return!s.searchParams.get("offset_p")&&e===0?i:(s.searchParams.set("offset_p",e.toFixed(0)),s.toString())}default:r.assertNever(t)}return i};const kr=(i,e)=>{var t;switch(e){case ee.OFFSET_P:return NaN;case ee.PLAYBACK_SHIFT:{const s=new URL(i);return Number(s.searchParams.get("playback_shift"))}case ee.DASH_CMAF_OFFSET_P:{const s=new URL(i);return Number((t=s.searchParams.get("offset_p"))!==null&&t!==void 0?t:0)}default:r.assertNever(e)}};var P=(i,e,t=!1)=>{const s=i.getTransition();(t||!s||s.to===e)&&i.setState(e)};class J{constructor(e){this.transitionStarted$=new r.Subject,this.transitionEnded$=new r.Subject,this.transitionUpdated$=new r.Subject,this.forceChanged$=new r.Subject,this.stateChangeStarted$=r.merge(this.transitionStarted$,this.transitionUpdated$),this.stateChangeEnded$=r.merge(this.transitionEnded$,this.forceChanged$),this.state=e,this.prevState=void 0}setState(e){const t=this.transition,s=this.state;this.transition=void 0,this.prevState=s,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:s,to:e,canceledTransition:t})}startTransitionTo(e){const t=this.transition,s=this.state;s===e||r.isNonNullable(t)&&t.to===e||(this.prevState=s,this.state=e,t?(this.transition={from:t.from,to:e,canceledTransition:t},this.transitionUpdated$.next(this.transition)):(this.transition={from:s,to:e},this.transitionStarted$.next(this.transition)))}getTransition(){return this.transition}getState(){return this.state}getPrevState(){return this.prevState}}const Qh=i=>{switch(i){case exports.VideoFormat.MPEG:case exports.VideoFormat.DASH_SEP:case exports.VideoFormat.DASH_ONDEMAND:case exports.VideoFormat.DASH_WEBM:case exports.VideoFormat.DASH_WEBM_AV1:case exports.VideoFormat.HLS:case exports.VideoFormat.HLS_ONDEMAND:return!1;case exports.VideoFormat.DASH_LIVE:case exports.VideoFormat.DASH_LIVE_CMAF:case exports.VideoFormat.HLS_LIVE:case exports.VideoFormat.HLS_LIVE_CMAF:case exports.VideoFormat.DASH_LIVE_WEBM:case exports.VideoFormat.WEB_RTC_LIVE:return!0;default:return r.assertNever(i)}};var x;(function(i){i.STOPPED="stopped",i.READY="ready",i.PLAYING="playing",i.PAUSED="paused"})(x||(x={}));const Kh=5,Jh=5,Xh=500,Ar=7e3;class Zh{constructor(e){this.subscription=new r.Subscription,this.loadMediaTimeoutSubscription=new r.Subscription,this.videoState=new J(x.STOPPED),this.syncPlayback=()=>{const s=this.videoState.getState(),a=this.videoState.getTransition(),n=this.params.desiredState.playbackState.getState(),o=this.params.desiredState.playbackState.getTransition(),l=this.params.desiredState.seekState.getState();if(this.log({message:`[syncPlayback] videoState: ${s}; videoTransition: ${JSON.stringify(a)}; desiredPlaybackState: ${n}; desiredPlaybackStateTransition: ${this.params.desiredState.playbackState.getTransition()}; seekState: ${JSON.stringify(l)};`}),n===exports.PlaybackState.STOPPED){s!==x.STOPPED&&(this.videoState.startTransitionTo(x.STOPPED),this.stop());return}if(!a){if((o==null?void 0:o.to)!==exports.PlaybackState.PAUSED&&l.state===I.Requested&&s!==x.STOPPED){this.seek(l.position/1e3);return}switch(n){case exports.PlaybackState.READY:{switch(s){case x.PLAYING:case x.PAUSED:case x.READY:break;case x.STOPPED:this.videoState.startTransitionTo(x.READY),this.prepare();break;default:r.assertNever(s)}break}case exports.PlaybackState.PLAYING:{switch(s){case x.PLAYING:break;case x.PAUSED:this.videoState.startTransitionTo(x.PLAYING),this.params.connection.remotePlayerController.playOrPause();break;case x.READY:this.videoState.startTransitionTo(x.PLAYING),this.params.connection.remotePlayerController.playOrPause();break;case x.STOPPED:this.videoState.startTransitionTo(x.READY),this.prepare();break;default:r.assertNever(s)}break}case exports.PlaybackState.PAUSED:{switch(s){case x.PLAYING:this.videoState.startTransitionTo(x.PAUSED),this.params.connection.remotePlayerController.playOrPause();break;case x.PAUSED:break;case x.READY:this.videoState.startTransitionTo(x.PAUSED),this.videoState.setState(x.PAUSED);break;case x.STOPPED:this.videoState.startTransitionTo(x.READY),this.prepare();break;default:r.assertNever(s)}break}default:r.assertNever(n)}}},this.params=e,this.log=this.params.dependencies.logger.createComponentLog("ChromecastProvider"),this.log({message:`constructor, format: ${e.format}`}),this.params.output.isLive$.next(Qh(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 r.Subscription;this.subscription.add(e),this.subscription.add(r.merge(this.videoState.stateChangeStarted$.pipe(r.map(a=>`stateChangeStarted$ ${JSON.stringify(a)}`)),this.videoState.stateChangeEnded$.pipe(r.map(a=>`stateChangeEnded$ ${JSON.stringify(a)}`))).subscribe(a=>this.log({message:`[videoState] ${a}`})));const t=(a,n)=>this.subscription.add(a.subscribe(n));if(this.params.output.isLive$.getValue())this.params.output.position$.next(0),this.params.output.duration$.next(0);else{const a=new r.Subject;e.add(a.pipe(r.debounce(Xh)).subscribe(()=>{this.params.output.seekedEvent$.next()}));let n=NaN;e.add(r.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED).subscribe(o=>{this.logRemoteEvent(o);const l=o.value;this.params.output.position$.next(l),(this.params.desiredState.seekState.getState().state===I.Applying||Math.abs(l-n)>Kh)&&a.next(l),n=l})),e.add(r.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.DURATION_CHANGED).subscribe(o=>{this.logRemoteEvent(o),this.params.output.duration$.next(o.value)}))}t(r.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED),a=>{this.logRemoteEvent(a),a.value?this.handleRemoteReady():(this.handleRemoteStop(),e.unsubscribe())}),t(r.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED),a=>{this.logRemoteEvent(a),a.value?this.handleRemotePause():this.handleRemotePlay()}),t(r.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED),a=>{this.logRemoteEvent(a);const{remotePlayer:n}=this.params.connection,o=a.value,l=this.params.output.isBuffering$.getValue(),c=o===chrome.cast.media.PlayerState.BUFFERING;switch(l!==c&&this.params.output.isBuffering$.next(c),o){case chrome.cast.media.PlayerState.IDLE:!this.params.output.isLive$.getValue()&&n.duration-n.currentTime<Jh&&this.params.output.endedEvent$.next(),this.handleRemoteStop(),P(this.params.desiredState.playbackState,exports.PlaybackState.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:r.assertNever(o)}}),t(r.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED),a=>{this.logRemoteEvent(a),this.handleRemoteVolumeChange({volume:a.value})}),t(r.fromEvent(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED),a=>{this.logRemoteEvent(a),this.handleRemoteVolumeChange({muted:a.value})});const s=r.merge(this.params.desiredState.playbackState.stateChangeStarted$,this.params.desiredState.seekState.stateChangeEnded$,this.videoState.stateChangeEnded$,r.observableFrom(["init"])).pipe(r.debounce(0));t(s,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(x.PAUSED),P(this.params.desiredState.playbackState,exports.PlaybackState.PAUSED)):(this.videoState.setState(x.PLAYING),P(this.params.desiredState.playbackState,exports.PlaybackState.PLAYING));const s=this.params.output.isLive$.getValue();this.params.output.duration$.next(s?0:t.duration),this.params.output.position$.next(s?0:t.currentTime),this.params.desiredState.seekState.setState({state:I.None})}}prepare(){const e=this.params.format;this.log({message:`[prepare] format: ${e}`});const t=this.createMediaInfo(e),s=this.createLoadRequest(t);this.loadMedia(s)}handleRemotePause(){const e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)===x.PAUSED||e===x.PLAYING)&&(this.videoState.setState(x.PAUSED),P(this.params.desiredState.playbackState,exports.PlaybackState.PAUSED))}handleRemotePlay(){const e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)===x.PLAYING||e===x.PAUSED)&&(this.videoState.setState(x.PLAYING),P(this.params.desiredState.playbackState,exports.PlaybackState.PLAYING))}handleRemoteReady(){var e;const t=this.videoState.getTransition();(t==null?void 0:t.to)===x.READY&&this.videoState.setState(x.READY),((e=this.params.desiredState.playbackState.getTransition())===null||e===void 0?void 0:e.to)===exports.PlaybackState.READY&&P(this.params.desiredState.playbackState,exports.PlaybackState.READY)}handleRemoteStop(){this.videoState.getState()!==x.STOPPED&&this.videoState.setState(x.STOPPED)}handleRemoteVolumeChange(e){var t,s;const a=this.params.output.volume$.getValue(),n={volume:(t=e.volume)!==null&&t!==void 0?t:a.volume,muted:(s=e.muted)!==null&&s!==void 0?s:a.muted};(n.volume!==a.volume||n.muted!==n.muted)&&this.params.output.volume$.next(n)}seek(e){this.params.output.willSeekEvent$.next();const{remotePlayer:t,remotePlayerController:s}=this.params.connection;t.currentTime=e,s.seek()}stop(){const{remotePlayerController:e}=this.params.connection;e.stop()}createMediaInfo(e){var t;const s=this.params.source;let a,n,o;switch(e){case exports.VideoFormat.MPEG:{const d=s[e];r.assertNonNullable(d);const h=r.getHighestQuality(Object.keys(d));r.assertNonNullable(h);const f=d[h];r.assertNonNullable(f),a=f,n="video/mp4",o=chrome.cast.media.StreamType.BUFFERED;break}case exports.VideoFormat.HLS:case exports.VideoFormat.HLS_ONDEMAND:{const d=s[e];r.assertNonNullable(d),a=d.url,n="application/x-mpegurl",o=chrome.cast.media.StreamType.BUFFERED;break}case exports.VideoFormat.DASH_SEP:case exports.VideoFormat.DASH_ONDEMAND:case exports.VideoFormat.DASH_WEBM:case exports.VideoFormat.DASH_WEBM_AV1:{const d=s[e];r.assertNonNullable(d),a=d.url,n="application/dash+xml",o=chrome.cast.media.StreamType.BUFFERED;break}case exports.VideoFormat.DASH_LIVE_CMAF:{const d=s[e];r.assertNonNullable(d),a=d.url,n="application/dash+xml",o=chrome.cast.media.StreamType.LIVE;break}case exports.VideoFormat.HLS_LIVE:case exports.VideoFormat.HLS_LIVE_CMAF:{const d=s[e];r.assertNonNullable(d),a=be(d.url),n="application/x-mpegurl",o=chrome.cast.media.StreamType.LIVE;break}case exports.VideoFormat.DASH_LIVE:case exports.VideoFormat.WEB_RTC_LIVE:{const d="Unsupported format for Chromecast",h=new Error(d);throw this.params.output.error$.next({id:"ChromecastProvider.createMediaInfo()",category:r.ErrorCategory.VIDEO_PIPELINE,message:d,thrown:h}),h}case exports.VideoFormat.DASH_LIVE_WEBM:throw new Error("DASH_LIVE_WEBM is no longer supported");default:return r.assertNever(e)}const l=new chrome.cast.media.MediaInfo((t=this.params.meta.videoId)!==null&&t!==void 0?t:a,n);l.contentUrl=a,l.streamType=o,l.metadata=new chrome.cast.media.GenericMediaMetadata;const{title:c,subtitle:u}=this.params.meta;return r.isNonNullable(c)&&(l.metadata.title=c),r.isNonNullable(u)&&(l.metadata.subtitle=u),l}createLoadRequest(e){const t=new chrome.cast.media.LoadRequest(e);t.autoplay=!1;const s=this.params.desiredState.seekState.getState();return s.state===I.Applying||s.state===I.Requested?t.currentTime=this.params.output.isLive$.getValue()?0:s.position/1e3:t.currentTime=0,t}loadMedia(e){const t=this.params.connection.session.loadMedia(e),s=new Promise((a,n)=>{this.loadMediaTimeoutSubscription.add(r.timeout(Ar).subscribe(()=>n(`timeout(${Ar})`)))});Promise.race([t,s]).then(()=>{this.log({message:`[loadMedia] completed, format: ${this.params.format}`}),this.params.desiredState.seekState.getState().state===I.Applying&&this.params.output.seekedEvent$.next(),this.handleRemoteReady()},a=>{const n=`[prepare] loadMedia failed, format: ${this.params.format}, reason: ${a}`;this.log({message:n}),this.params.output.error$.next({id:"ChromecastProvider.loadMedia",category:r.ErrorCategory.VIDEO_PIPELINE,message:n,thrown:a})}).finally(()=>{this.loadMediaTimeoutSubscription.unsubscribe()})}logRemoteEvent(e){this.log({message:`[remoteEvent] ${JSON.stringify(e)}`})}}const pa=i=>{i.removeAttribute("src"),i.load()},ef=i=>{try{i.pause(),i.playbackRate=0,pa(i),i.remove()}catch(e){console.error(e)}};class tf{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 Ws=window.WeakMap?new WeakMap:new tf,ot=i=>{let e=i.querySelector("video");const t=!!e;return e?pa(e):(e=document.createElement("video"),i.appendChild(e)),Ws.set(e,t),e.setAttribute("crossorigin","anonymous"),e.setAttribute("playsinline","playsinline"),e.controls=!1,e.setAttribute("poster","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),e},lt=i=>{const e=Ws.get(i);Ws.delete(i),e?pa(i):ef(i)},_e=(i,e,t,{equal:s=(o,l)=>o===l,changed$:a,onError:n}={})=>{const o=i.getState(),l=e(),c=r.isNullable(a),u=new r.Subscription;return a&&u.add(a.subscribe(d=>{const h=i.getState();s(d,h)&&i.setState(d)},n)),s(l,o)||(t(o),c&&i.setState(o)),u.add(i.stateChangeStarted$.subscribe(d=>{t(d.to),c&&i.setState(d.to)},n)),u},Qt=(i,e,t)=>_e(e,()=>i.loop,s=>{r.isNonNullable(s)&&(i.loop=s)},{onError:t}),ut=(i,e,t,s)=>_e(e,()=>({muted:i.muted,volume:i.volume}),a=>{r.isNonNullable(a)&&(i.muted=a.muted,i.volume=a.volume)},{equal:(a,n)=>a===n||(a==null?void 0:a.muted)===(n==null?void 0:n.muted)&&(a==null?void 0:a.volume)===(n==null?void 0:n.volume),changed$:t,onError:s}),_t=(i,e,t,s)=>_e(e,()=>i.playbackRate,a=>{r.isNonNullable(a)&&(i.playbackRate=a)},{changed$:t,onError:s}),sf=i=>["__",i.language,i.label].join("|"),af=(i,e)=>{if(i.id===e)return!0;const[t,s,a]=e.split("|");return i.language===s&&i.label===a};class qe{constructor(){this.available$=new r.Subject,this.current$=new r.ValueSubject(void 0),this.error$=new r.Subject,this.subscription=new r.Subscription,this.externalTracks=new Map,this.internalTracks=new Map}connect(e,t,s){this.video=e,this.cueSettings=t.textTrackCuesSettings,this.subscribe();const a=n=>{this.error$.next({id:"TextTracksManager",category:r.ErrorCategory.WTF,message:"Generic HtmlVideoTextTrackManager error",thrown:n})};this.subscription.add(this.available$.subscribe(s.availableTextTracks$)),this.subscription.add(this.current$.subscribe(s.currentTextTrack$)),this.subscription.add(this.error$.subscribe(s.error$)),this.subscription.add(_e(t.internalTextTracks,()=>Object.values(this.internalTracks),n=>{r.isNonNullable(n)&&this.setInternal(n)},{equal:(n,o)=>r.isNonNullable(n)&&r.isNonNullable(o)&&n.length===o.length&&n.every(({id:l},c)=>l===o[c].id),changed$:this.available$.pipe(r.map(n=>n.filter(({type:o})=>o==="internal"))),onError:a})),this.subscription.add(_e(t.externalTextTracks,()=>Object.values(this.externalTracks),n=>{r.isNonNullable(n)&&this.setExternal(n)},{equal:(n,o)=>r.isNonNullable(n)&&r.isNonNullable(o)&&n.length===o.length&&n.every(({id:l},c)=>l===o[c].id),changed$:this.available$.pipe(r.map(n=>n.filter(({type:o})=>o==="external"))),onError:a})),this.subscription.add(_e(t.currentTextTrack,()=>{if(this.video)return;const n=this.htmlTextTracksAsArray().find(({mode:o})=>o==="showing");return n&&this.htmlTextTrackToITextTrack(n).id},n=>this.select(n),{changed$:this.current$,onError:a})),this.subscription.add(_e(t.textTrackCuesSettings,()=>({}),()=>{if(this.video)for(const n of this.htmlTextTracksAsArray())this.applyCueSettings(n.cues),this.applyCueSettings(n.activeCues)}))}subscribe(){r.assertNonNullable(this.video);const{textTracks:e}=this.video;this.subscription.add(r.fromEvent(e,"addtrack").subscribe(()=>{const s=this.current$.getValue();s&&this.select(s)})),this.subscription.add(r.merge(r.fromEvent(e,"addtrack"),r.fromEvent(e,"removetrack"),r.observableFrom(["init"])).pipe(r.map(()=>this.htmlTextTracksAsArray().map(s=>this.htmlTextTrackToITextTrack(s))),r.filterChanged((s,a)=>s.length===a.length&&s.every(({id:n},o)=>n===a[o].id))).subscribe(this.available$)),this.subscription.add(r.merge(r.fromEvent(e,"change"),r.observableFrom(["init"])).pipe(r.map(()=>this.htmlTextTracksAsArray().find(({mode:s})=>s==="showing")),r.map(s=>s&&this.htmlTextTrackToITextTrack(s).id),r.filterChanged()).subscribe(this.current$));const t=s=>{var a,n;return this.applyCueSettings((n=(a=s.target)===null||a===void 0?void 0:a.activeCues)!==null&&n!==void 0?n:null)};this.subscription.add(r.fromEvent(e,"addtrack").subscribe(s=>{var a,n;(a=s.track)===null||a===void 0||a.addEventListener("cuechange",t);const o=l=>{var c,u,d,h,f;const p=(u=(c=l.target)===null||c===void 0?void 0:c.cues)!==null&&u!==void 0?u:null;p&&p.length&&(this.applyCueSettings((h=(d=l.target)===null||d===void 0?void 0:d.cues)!==null&&h!==void 0?h:null),(f=l.target)===null||f===void 0||f.removeEventListener("cuechange",o))};(n=s.track)===null||n===void 0||n.addEventListener("cuechange",o)})),this.subscription.add(r.fromEvent(e,"removetrack").subscribe(s=>{var a;(a=s.track)===null||a===void 0||a.removeEventListener("cuechange",t)}))}applyCueSettings(e){if(!e||!e.length)return;const t=this.cueSettings.getState();for(const s of Array.from(e)){const a=s;r.isNonNullable(t.align)&&(a.align=t.align),r.isNonNullable(t.position)&&(a.position=t.position),r.isNonNullable(t.size)&&(a.size=t.size),r.isNonNullable(t.line)&&(a.line=t.line)}}htmlTextTracksAsArray(e=!1){r.assertNonNullable(this.video);const t=[...this.video.textTracks];return e?t:t.filter(qe.isHealthyTrack)}htmlTextTrackToITextTrack(e){var t,s;const{language:a,label:n}=e,o=e.id?e.id:sf(e),l=this.externalTracks.has(o),c=o.includes("auto");return l?{id:o,type:"external",isAuto:c,language:a,label:n,url:(t=this.externalTracks.get(o))===null||t===void 0?void 0:t.url}:{id:o,type:"internal",isAuto:c,language:a,label:n,url:(s=this.internalTracks.get(o))===null||s===void 0?void 0:s.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(s=>s.id===t)).forEach(([,t])=>this.detach(t))}setInternal(e){const t=[...this.externalTracks];e.filter(({id:s,language:a,isAuto:n})=>!this.internalTracks.has(s)&&!t.some(([,o])=>o.language===a&&o.isAuto===n)).forEach(s=>this.attach(s)),Array.from(this.internalTracks).filter(([s])=>!e.find(a=>a.id===s)).forEach(([,s])=>this.detach(s))}select(e){r.assertNonNullable(this.video);for(const t of this.htmlTextTracksAsArray(!0))t.mode="showing";for(const t of this.htmlTextTracksAsArray(!0))(r.isNullable(e)||!af(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){r.assertNonNullable(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){r.assertNonNullable(this.video);const t=Array.prototype.find.call(this.video.getElementsByTagName("track"),s=>s.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)}}class ma{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 Gn=i=>{var e;let t=i;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},wr=i=>{const e=Gn(i);return!!(e&&e.fullscreenElement&&e.fullscreenElement===i)},rf=i=>{const e=Gn(i);return!!(e&&e.pictureInPictureElement&&e.pictureInPictureElement===i)},nf=3;var of=(i,e,t=nf)=>{let s=0,a=0;for(let n=0;n<i.length;n++){const o=i.start(n),l=i.end(n);if(o<=e&&e<=l){if(s=o,a=l,!t)return{from:s,to:a};for(let c=n-1;c>=0;c--)i.end(c)+t>=s&&(s=i.start(c));for(let c=n+1;c<i.length;c++)i.start(c)-t<=a&&(a=i.end(c))}}return{from:s,to:a}};const dt=i=>{const e=T=>r.fromEvent(i,T).pipe(r.mapTo(void 0)),t=["waiting","pause","canplay","play","canplaythrough","playing","seeking","seeked","ended"],s=r.merge(...t.map(T=>r.fromEvent(i,T))).pipe(r.map(T=>T.type==="ended"?i.readyState<2:i.readyState<3),r.filterChanged()),a=r.merge(r.fromEvent(i,"progress"),r.fromEvent(i,"timeupdate")).pipe(r.map(()=>of(i.buffered,i.currentTime))),o=r.getCurrentBrowser().browser===r.CurrentClientBrowser.Safari?r.combine({play:e("play").pipe(r.once()),playing:e("playing")}).pipe(r.mapTo(void 0)):e("playing"),l=r.fromEvent(i,"volumechange").pipe(r.map(()=>({muted:i.muted,volume:i.volume}))),c=r.fromEvent(i,"ratechange").pipe(r.map(()=>i.playbackRate)),u=r.fromEvent(i,"error").pipe(r.filter(()=>!!(i.error||i.played.length)),r.map(()=>{var T;const E=i.error;return{id:E?`MediaError#${E.code}`:"HtmlVideoError",category:r.ErrorCategory.VIDEO_PIPELINE,message:E?E.message:"Error event from HTML video element",thrown:(T=i.error)!==null&&T!==void 0?T:void 0}})),d=r.fromEvent(i,"timeupdate").pipe(r.map(()=>i.currentTime)),h=new r.Subject,f=.3;let p;d.subscribe(T=>{i.loop&&r.isNonNullable(p)&&r.isNonNullable(T)&&p>=i.duration-f&&T<=f&&h.next(p),p=T});const S=r.fromEvent(i,"enterpictureinpicture"),m=r.fromEvent(i,"leavepictureinpicture"),v=new r.ValueSubject(rf(i));S.subscribe(()=>v.next(!0)),m.subscribe(()=>v.next(!1));const b=new r.ValueSubject(wr(i));return r.fromEvent(i,"fullscreenchange").pipe(r.map(()=>wr(i))).subscribe(b),{playing$:o,pause$:e("pause").pipe(r.filter(()=>!i.error)),canplay$:e("canplay"),ended$:e("ended"),looped$:h,error$:u,seeked$:e("seeked"),seeking$:e("seeking"),progress$:e("progress"),loadStart$:e("loadstart"),loadedMetadata$:e("loadedmetadata"),loadedData$:e("loadeddata"),timeUpdate$:d,durationChange$:r.fromEvent(i,"durationchange").pipe(r.map(()=>i.duration)),isBuffering$:s,currentBuffer$:a,volumeState$:l,playbackRateState$:c,inPiP$:v,inFullscreen$:b}};var Vi=i=>{switch(i){case"mobile":return r.VideoQuality.Q_144P;case"lowest":return r.VideoQuality.Q_240P;case"low":return r.VideoQuality.Q_360P;case"sd":case"medium":return r.VideoQuality.Q_480P;case"hd":case"high":return r.VideoQuality.Q_720P;case"fullhd":case"full":return r.VideoQuality.Q_1080P;case"quadhd":case"quad":return r.VideoQuality.Q_1440P;case"ultrahd":case"ultra":return r.VideoQuality.Q_2160P}},lf=Mi,uf=Ni,df=ha,cf=ca;lf({target:"Array",proto:!0},{at:function(e){var t=uf(this),s=df(t),a=cf(e),n=a>=0?a:s+a;return n<0||n>=s?void 0:t[n]}});var hf=sa,Yn=hf,ff=Yn,pf=ff("Array","at"),mf=pf,vf=mf,Sf=vf,bf=Sf,xe=ea(bf);let va=!1,Re={};const gf=i=>{va=i},yf=()=>{Re={}},Tf=i=>{i(Re)},ci=(i,e)=>{var t;va&&(Re.meta=(t=Re.meta)!==null&&t!==void 0?t:{},Re.meta[i]=e)};class we{constructor(e){this.name=e}next(e){var t,s;if(!va)return;Re.series=(t=Re.series)!==null&&t!==void 0?t:{};const a=(s=Re.series[this.name])!==null&&s!==void 0?s:[];a.push([Date.now(),e]),Re.series[this.name]=a}}var tt;(function(i){i.FitsContainer="FitsContainer",i.FitsThroughput="FitsThroughput",i.Buffer="Buffer",i.DroppedFramesLimit="DroppedFramesLimit",i.FitsQualityLimits="FitsQualityLimits"})(tt||(tt={}));const Ef=new we("best_bitrate"),$f=(i,e,t)=>(e-t)*Math.pow(2,-10*i)+t;class kf{constructor(){this.history={}}recordSelection(e){this.history[e.id]=r.now()}recordSwitch(e){this.last=e}clear(){this.last=void 0,this.history={}}}const Af='Assertion "ABR Tracks is empty array" failed',Fi=(i,{container:e,throughput:t,tuning:s,limits:a,reserve:n=0,forwardBufferHealth:o,playbackRate:l,current:c,history:u,droppedVideoMaxQualityLimit:d,abrLogger:h})=>{var f,p,S,m,v;r.assertNotEmptyArray(i,Af);const b=s.usePixelRatio&&(f=window.devicePixelRatio)!==null&&f!==void 0?f:1,y=s.limitByContainer&&e&&e.width>0&&e.height>0&&{width:e.width*b*s.containerSizeFactor,height:e.height*b*s.containerSizeFactor},T=y&&r.videoSizeToQuality(y),E=s.considerPlaybackRate&&r.isNonNullable(l)?l:1,$=i.filter(D=>!r.isInvariantQuality(D.quality)).sort((D,A)=>r.isHigher(D.quality,A.quality)?-1:1),N=(p=xe($,-1))===null||p===void 0?void 0:p.quality,O=(S=xe($,0))===null||S===void 0?void 0:S.quality,V=r.isNullable(a)||r.isNonNullable(a.min)&&r.isNonNullable(a.max)&&r.isLower(a.max,a.min)||r.isNonNullable(a.min)&&O&&r.isHigher(a.min,O)||r.isNonNullable(a.max)&&N&&r.isLower(a.max,N),R=E*$f(o!=null?o:.5,s.bitrateFactorAtEmptyBuffer,s.bitrateFactorAtFullBuffer),F={},C=$.filter(D=>(T?r.isLower(D.quality,T):!0)?(r.isNonNullable(t)&&isFinite(t)&&r.isNonNullable(D.bitrate)?t-n>=D.bitrate*R:!0)?s.lazyQualitySwitch&&r.isNonNullable(s.minBufferToSwitchUp)&&c&&!r.isInvariantQuality(c.quality)&&(o!=null?o:0)<s.minBufferToSwitchUp&&r.isHigher(D.quality,c.quality)?(F[D.quality]=tt.Buffer,!1):!!d&&r.isHigherOrEqual(D.quality,d)?(F[D.quality]=tt.DroppedFramesLimit,!1):V||(r.isNullable(a.max)||r.isLowerOrEqual(D.quality,a.max))&&(r.isNullable(a.min)||r.isHigherOrEqual(D.quality,a.min))?!0:(F[D.quality]=tt.FitsQualityLimits,!1):(F[D.quality]=tt.FitsThroughput,!1):(F[D.quality]=tt.FitsContainer,!1))[0];C&&C.bitrate&&Ef.next(C.bitrate);const w=(m=C!=null?C:$[Math.ceil(($.length-1)/2)])!==null&&m!==void 0?m:i[0];w.quality!==((v=u==null?void 0:u.last)===null||v===void 0?void 0:v.quality)&&h({message:`
|
|
7
7
|
[available tracks]
|
|
8
8
|
${i.map(D=>`{ id: ${D.id}, quality: ${D.quality}, bitrate: ${D.bitrate} }`).join(`
|
|
9
9
|
`)}
|