@vkontakte/videoplayer-core 2.0.165-dev.cd28586c7.0 → 2.0.165
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 +3 -3
- package/es2015.esm.js +4 -4
- package/esnext.cjs +3 -3
- package/esnext.esm.js +3 -3
- package/evergreen.esm.js +3 -3
- package/package.json +2 -2
package/es2015.esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-core v2.0.165
|
|
3
|
-
* Wed,
|
|
2
|
+
* @vkontakte/videoplayer-core v2.0.165
|
|
3
|
+
* Wed, 01 Jul 2026 15:19:47 GMT
|
|
4
4
|
* https://st.mycdn.me/static/vkontakte-videoplayer/2-0-165/doc/
|
|
5
5
|
*/
|
|
6
|
-
import{objectEntries as le}from"@vkontakte/videoplayer-shared/es2015";import{objectValues as ue}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as de}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as fe,assertNonNullable as pe,isNonNullable as me,ValueSubject as he,Subject as ge,Subscription as _e,merge as ve,observableFrom as ye,fromEvent as be,map as xe,tap as Se,filterChanged as Ce,isNullable as we,ErrorCategory as Te}from"@vkontakte/videoplayer-shared/es2015";import{assertNonNullable as ke,combine as Ae,debounce as je,ErrorCategory as Me,filter as Ne,filterChanged as Pe,isNonNullable as Fe,isNullable as Ie,map as Le,Subscription as Re,ValueSubject as ze}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as Be,assertNonNullable as Ve,ErrorCategory as He,getHighestQuality as Ue,isNonNullable as We}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as Ge}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as $e}from"@vkontakte/videoplayer-shared/es2015";import{isBrowserWindow as et,ValueSubject as tt}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as nt}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as rt}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as A}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as at,isBrowserWindow as ot}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as lt,isBrowserWindow as ut}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as ft,isBrowserWindow as pt}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as Dt,isBrowserWindow as Ot}from"@vkontakte/videoplayer-shared/es2015";import{assertNonNullable as It,ErrorCategory as Lt,filter as Rt,Subject as zt,Subscription as Bt,tap as Vt,ValueSubject as Ht,fromEvent as Ut,getWindow as Wt}from"@vkontakte/videoplayer-shared/es2015";import{ValueSubject as Jt,Subject as Yt,map as Xt,Subscription as Zt,combine as Qt,filterChanged as $t,assertNonNullable as en}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as nn}from"@vkontakte/videoplayer-shared/es2015";import{objectEntries as rn}from"@vkontakte/videoplayer-shared/es2015";import{objectFromEntries as an}from"@vkontakte/videoplayer-shared/es2015";import{promiseFinally as on}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as sn,Subject as cn,merge as ln}from"@vkontakte/videoplayer-shared/es2015";import"@vkontakte/videoplayer-shared/es2015";import{assertNever as fn,debounce as pn,ErrorCategory as mn,fromEvent as hn,map as gn,merge as _n,observableFrom as vn,Subject as yn,Subscription as bn,timeout as xn}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as Dn}from"@vkontakte/videoplayer-shared/es2015";import{clearVideoElement as On,fromEvent as kn,getWindow as An,Subscription as jn}from"@vkontakte/videoplayer-shared/es2015";import{clearVideoElement as Mn}from"@vkontakte/videoplayer-shared/es2015";import{objectValues as Kn}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as qn}from"@vkontakte/videoplayer-shared/es2015";import{assertNonNullable as Jn,isNonNullable as Yn,isNullable as Xn,fromEvent as Zn,merge as Qn,observableFrom as $n,filterChanged as er,map as tr,Subject as nr,Subscription as rr,ValueSubject as ir,ErrorCategory as ar}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as or,isNullable as sr,Subscription as cr}from"@vkontakte/videoplayer-shared/es2015";import{fromEvent as M,map as Sr,merge as Cr,filterChanged as wr,isNonNullable as Tr,Subject as Er,filter as Dr,mapTo as Or,combine as kr,once as Ar,shareReplay as N,throttle as jr,ErrorCategory as Mr,ValueSubject as Nr,Subscription as Pr}from"@vkontakte/videoplayer-shared/es2015";import{VideoQuality as zr}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as P}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as Vr}from"@vkontakte/videoplayer-shared/es2015";import{objectEntries as Hr}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as F,isNullable as Ur,now as Wr,isHigher as Gr,isHigherOrEqual as Kr,isInvariantQuality as qr,isLowerOrEqual as Jr,videoSizeToQuality as Yr,assertNotEmptyArray as Xr,assertNonNullable as Zr}from"@vkontakte/videoplayer-shared/es2015";import{isHigher as ai,isLower as oi,isNonNullable as si,isNullable as ci,videoHeightToQuality as li}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as Ni,assertNonNullable as Pi,combine as Fi,debounce as Ii,ErrorCategory as Li,filter as Ri,filterChanged as zi,isNonNullable as Bi,map as Vi,merge as Hi,observableFrom as Ui,once as Wi,Subscription as Gi,ValueSubject as Ki,videoQualityToHeight as qi,videoSizeToQuality as Ji}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as Yi}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as Qi,isNullable as $i,assertNonNullable as ea}from"@vkontakte/videoplayer-shared/es2015";import{objectValues as ta}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as na,assertNonNullable as ra,now as ia}from"@vkontakte/videoplayer-shared/es2015";import{objectValues as pa}from"@vkontakte/videoplayer-shared/es2015";import{Subject as ha}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as ga}from"@vkontakte/videoplayer-shared/es2015";import{objectEntries as va}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as ya}from"@vkontakte/videoplayer-shared/es2015";import{objectEntries as Oa}from"@vkontakte/videoplayer-shared/es2015";import{debounce as ka,filter as Aa,fromEvent as ja,interval as Ma,isHigher as Na,isInvariantQuality as Pa,isLower as Fa,merge as Ia,Subject as La,Subscription as Ra}from"@vkontakte/videoplayer-shared/es2015";import{map as Va,Observable as Ha}from"@vkontakte/videoplayer-shared/es2015";import{fromEvent as Ua}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as Ka}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as qa}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as Ja}from"@vkontakte/videoplayer-shared/es2015";import{filter as yo,filterChanged as bo,isNonNullable as xo}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as So,assertNonNullable as Co,debounce as wo,ErrorCategory as To,filter as Eo,filterChanged as Do,fromEvent as Oo,isNonNullable as ko,isNullable as Ao,map as jo,mapTo as Mo,merge as No,observableFrom as Po,once as Fo,Subscription as Io,throttle as Lo}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as Ro}from"@vkontakte/videoplayer-shared/es2015";import{videoSizeToQuality as zo}from"@vkontakte/videoplayer-shared/es2015";import{isNullable as Qo,now as $o,once as es,Subscription as ts,ValueSubject as ns,isNonNullable as rs,safeStorage as is,filterChanged as as}from"@vkontakte/videoplayer-shared/es2015";import{combine as ms,map as hs,observeElementSize as gs,Subscription as _s,ValueSubject as vs,noop as ys}from"@vkontakte/videoplayer-shared/es2015";import{filter as xs,map as Ss,once as Cs}from"@vkontakte/videoplayer-shared/es2015";import{filterChanged as Ts,isNonNullable as Es,isNullable as Ds,now as Os,once as ks,Subscription as As,ValueSubject as js}from"@vkontakte/videoplayer-shared/es2015";import{now as Ps}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as Is,now as Ls}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as Rs}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as zs}from"@vkontakte/videoplayer-shared/es2015";import{isLowerOrEqual as Bs,isNonNullable as Vs,isNullable as Hs}from"@vkontakte/videoplayer-shared/es2015";import{isInvariantQuality as ec,isNullable as tc,Subscription as nc,ValueSubject as rc}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as ic,isNonNullable as ac,isNullable as oc}from"@vkontakte/videoplayer-shared/es2015";import{objectValues as sc}from"@vkontakte/videoplayer-shared/es2015";import{Subscription as cc}from"@vkontakte/videoplayer-shared/es2015";import{Subscription as dc}from"@vkontakte/videoplayer-shared/es2015";import{isHigher as Cc,isInvariantQuality as wc,isNonNullable as Tc}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as Dc}from"@vkontakte/videoplayer-shared/es2015";import{isNullable as kc,timeout as Ac}from"@vkontakte/videoplayer-shared/es2015";import{isHigherOrEqual as Mc,isLowerOrEqual as Nc,isNonNullable as Pc,videoSizeToQuality as Fc}from"@vkontakte/videoplayer-shared/es2015";import{isHigherOrEqual as Lc,isNullable as Rc}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as Vc,isHigherOrEqual as Hc,isNonNullable as Uc}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as Gc}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as Kc}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as Yc,isLowerOrEqual as Xc,isNonNullable as Zc,isNullable as Qc}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as el}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as nl,now as rl}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as ol}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as hl}from"@vkontakte/videoplayer-shared/es2015";import{arrayFlatMap as xl}from"@vkontakte/videoplayer-shared/es2015";import{AbortControllerPolyfilled as Sl}from"@vkontakte/videoplayer-shared/es2015";import{stringTrimStart as Cl}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as wl}from"@vkontakte/videoplayer-shared/es2015";import{abortable as El,assertNonNullable as Dl,ErrorCategory as Ol,filter as kl,filterChanged as Al,flattenObject as jl,fromEvent as Ml,getTraceSubscriptionMethod as Nl,getWindow as Pl,interval as Fl,isNonNullable as Il,isNullable as Ll,map as Rl,merge as zl,now as Bl,Subject as Vl,Subscription as Hl,SubscriptionRemovable as Ul,ValueSubject as z}from"@vkontakte/videoplayer-shared/es2015";import{AbortControllerPolyfilled as Wl}from"@vkontakte/videoplayer-shared/es2015";import{fetchPolyfilled as Gl}from"@vkontakte/videoplayer-shared/es2015";import{abortable as Jl,assertNever as Yl,ErrorCategory as Xl,flattenObject as Zl,fromEvent as Ql,getWindow as $l,merge as eu,now as tu,Subject as nu,Subscription as ru,suppressAbort as iu,ValueSubject as au}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as su}from"@vkontakte/videoplayer-shared/es2015";import{devNull as mu,getWindow as hu}from"@vkontakte/videoplayer-shared/es2015";import{stringReplaceAll as Du}from"@vkontakte/videoplayer-shared/es2015";import{objectEntries as Ou}from"@vkontakte/videoplayer-shared/es2015";import{stringPadStart as ku}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as Au}from"@vkontakte/videoplayer-shared/es2015";import{objectValues as ju}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as Mu}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as Nu}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as Fu,isNullable as Iu}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as Lu}from"@vkontakte/videoplayer-shared/es2015";import{AbortControllerPolyfilled as Wu}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as Gu}from"@vkontakte/videoplayer-shared/es2015";import{requestIdleCallbackPolyfilled as Ku}from"@vkontakte/videoplayer-shared/es2015";import{abortable as qu,assertNonNullable as Ju,ErrorCategory as Yu,flattenObject as B,fromEvent as Xu,getExponentialDelay as Zu,getWindow as Qu,isAbortError as $u,isHigher as ed,isNonNullable as V,isNullable as H,once as td,Subject as nd,Subscription as rd,ValueSubject as id}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as ad}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as cd}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as zd}from"@vkontakte/videoplayer-shared/es2015";import{assertNonNullable as Bd,isNonNullable as Vd,isNullable as Hd}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as Ud}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as ef}from"@vkontakte/videoplayer-shared/es2015";import{videoSizeToQuality as tf}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as ff,getWindow as pf,isNonNullable as mf,isNullable as hf,now as gf,isAbortError as _f}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as yf,getWindow as bf,isAbortError as xf,isNullable as Sf,now as Cf}from"@vkontakte/videoplayer-shared/es2015";import{arrayFlatMap as Tf}from"@vkontakte/videoplayer-shared/es2015";import{assertNonNullable as Ef,ErrorCategory as Df,isNullable as Of,ValueSubject as kf}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as Mf,fromEvent as Nf,isNullable as Pf,Subject as Ff,Subscription as If,ValueSubject as Lf}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as Rf,ErrorCategory as zf,Subject as Bf}from"@vkontakte/videoplayer-shared/es2015";import{objectValues as qf}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as Jf,isHigher as Yf,isLower as Xf,isLowerOrEqual as Zf,VideoQuality as Qf}from"@vkontakte/videoplayer-shared/es2015";import{assertNonNullable as dp,combine as fp,ErrorCategory as pp,filter as mp,filterChanged as hp,fromEvent as gp,isNonNullable as _p,map as vp,merge as yp}from"@vkontakte/videoplayer-shared/es2015";import{combine as Sp,merge as Cp,filter as wp,filterChanged as Tp,isNullable as Ep,map as Dp,ValueSubject as Op,isNonNullable as kp}from"@vkontakte/videoplayer-shared/es2015";import{isNullable as Ap,ValueSubject as jp}from"@vkontakte/videoplayer-shared/es2015";import{assertNonNullable as Lp,combine as Rp,ErrorCategory as zp,filter as Bp,filterChanged as Vp,fromEvent as Hp,interval as Up,isNonNullable as Wp,isNullable as Gp,map as Kp,now as qp,throttle as Jp}from"@vkontakte/videoplayer-shared/es2015";import{isNullable as Xp,ValueSubject as Zp}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as tm,assertNonNullable as nm,combine as rm,debounce as im,ErrorCategory as am,filter as om,filterChanged as sm,fromEvent as cm,isNonNullable as lm,isNullable as um,map as dm,merge as fm,observableFrom as pm,once as mm,Subscription as hm,throttle as gm,timeout as _m}from"@vkontakte/videoplayer-shared/es2015";import{AbortControllerPolyfilled as vm}from"@vkontakte/videoplayer-shared/es2015";import{arrayFlatMap as ym}from"@vkontakte/videoplayer-shared/es2015";import{abortable as xm,assertNonNullable as Sm,combine as Cm,ErrorCategory as wm,filter as Tm,filterChanged as Em,flattenObject as Dm,fromEvent as Om,getTraceSubscriptionMethod as km,interval as Am,isNonNullable as jm,isNullable as Mm,map as Nm,merge as Pm,now as Fm,Subject as Im,Subscription as Lm,SubscriptionRemovable as Rm,tap as zm,throttle as Bm,ValueSubject as W}from"@vkontakte/videoplayer-shared/es2015";import{AbortControllerPolyfilled as Vm}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as Hm}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as Um}from"@vkontakte/videoplayer-shared/es2015";import{arrayFlatMap as Wm}from"@vkontakte/videoplayer-shared/es2015";import{cancelIdleCallbackPolyfilled as Gm}from"@vkontakte/videoplayer-shared/es2015";import{requestIdleCallbackPolyfilled as Km}from"@vkontakte/videoplayer-shared/es2015";import{promiseFinally as qm}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as Jm,ErrorCategory as Ym,Subject as Xm}from"@vkontakte/videoplayer-shared/es2015";import{abortable as nh,assertNonNullable as G,ErrorCategory as rh,fromEvent as ih,getExponentialDelay as ah,getWindow as oh,isHigher as sh,isNonNullable as ch,isNullable as K,now as lh,once as uh,Subject as dh,Subscription as fh,ValueSubject as ph,isAbortError as mh}from"@vkontakte/videoplayer-shared/es2015";import{AbortControllerPolyfilled as gh}from"@vkontakte/videoplayer-shared/es2015";import{fetchPolyfilled as _h}from"@vkontakte/videoplayer-shared/es2015";import{abortable as vh,assertNever as yh,fromEvent as bh,merge as xh,now as Sh,Subject as Ch,ValueSubject as wh,flattenObject as Th,ErrorCategory as Eh,SubscriptionRemovable as Dh,getWindow as Oh,suppressAbort as kh}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as Ah}from"@vkontakte/videoplayer-shared/es2015";import{devNull as Lh,getWindow as Rh}from"@vkontakte/videoplayer-shared/es2015";import{isNullable as Zh,ValueSubject as Qh}from"@vkontakte/videoplayer-shared/es2015";import{combine as ag,merge as og,filter as sg,filterChanged as cg,isNullable as lg,map as ug,ValueSubject as dg,isNonNullable as fg}from"@vkontakte/videoplayer-shared/es2015";import{fetchPolyfilled as mg}from"@vkontakte/videoplayer-shared/es2015";import{fetchPolyfilled as hg}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as vg,combine as yg,debounce as bg,ErrorCategory as xg,filter as Sg,filterChanged as Cg,isNonNullable as wg,isNullable as Tg,map as Eg,merge as Dg,observableFrom as Og,Subscription as kg,ValueSubject as Ag,VideoQuality as jg}from"@vkontakte/videoplayer-shared/es2015";import{objectFromEntries as Mg}from"@vkontakte/videoplayer-shared/es2015";import{fetchPolyfilled as Ng}from"@vkontakte/videoplayer-shared/es2015";import{videoSizeToQuality as Pg,getExponentialDelay as Fg}from"@vkontakte/videoplayer-shared/es2015";import{AbortControllerPolyfilled as Hg}from"@vkontakte/videoplayer-shared/es2015";import{fetchPolyfilled as Ug}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as Wg,Subscription as Gg,throttle as Kg,ValueSubject as qg,Subject as Jg,ErrorCategory as Yg}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as Qg,debounce as $g,ErrorCategory as e_,fromEvent as t_,isNonNullable as n_,isNullable as r_,map as i_,merge as a_,observableFrom as o_,Subscription as s_,ValueSubject as c_,VideoQuality as l_}from"@vkontakte/videoplayer-shared/es2015";import{objectEntries as d_}from"@vkontakte/videoplayer-shared/es2015";import{objectValues as f_}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as p_}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as m_,assertNonNullable as h_,debounce as g_,ErrorCategory as __,isHigherOrEqual as v_,isLowerOrEqual as y_,isNonNullable as b_,merge as x_,observableFrom as S_,Subscription as C_,map as w_}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as E_,debounce as D_,merge as O_,observableFrom as k_,Subscription as A_,map as j_,ValueSubject as M_,ErrorCategory as N_,VideoQuality as P_}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as F_}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as U_,assertNonNullable as W_,ErrorCategory as G_,filter as K_,isNonNullable as q_,isNullable as J_,map as Y_,merge as X_,once as Z_,Subject as q,Subscription as Q_,ValueSubject as J,flattenObject as $_,devNull as ev,getWindow as tv}from"@vkontakte/videoplayer-shared/es2015";import{Observable as nv,map as rv,Subscription as iv,Subject as av,now as ov,combine as sv}from"@vkontakte/videoplayer-shared/es2015";import{AbortControllerPolyfilled as lv}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as uv,Subscription as dv,combine as fv,filter as pv,once as mv}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as hv}from"@vkontakte/videoplayer-shared/es2015";import{fromEvent as bv,once as xv,combine as Sv,Subscription as Cv,ValueSubject as wv,map as Tv,filter as Ev,isNonNullable as Dv,now as Ov,safeStorage as kv,getWindow as Av}from"@vkontakte/videoplayer-shared/es2015";import{fillWithDefault as Vv,VideoQuality as Hv}from"@vkontakte/videoplayer-shared/es2015";import{assertNonNullable as Gv,combine as Kv,devNull as qv,ErrorCategory as Jv,filter as Y,filterChanged as X,flattenObject as Yv,fromEvent as Xv,getPlayerId as Zv,getTraceSubscriptionMethod as Qv,getWindow as $v,InternalsExposure as ey,isHigher as ty,isInvariantQuality as ny,isNonNullable as ry,isNullable as iy,Logger as ay,map as Z,mapTo as oy,merge as sy,now as cy,once as Q,Subject as $,Subscription as ly,tap as uy,throttle as dy,TracerFactory as fy,ValueSubject as py}from"@vkontakte/videoplayer-shared/es2015";import{merge as my,map as hy,filter as gy,isNonNullable as _y}from"@vkontakte/videoplayer-shared/es2015";import{filter as yy,once as by}from"@vkontakte/videoplayer-shared/es2015";import{requestIdleCallbackPolyfilled as Sy}from"@vkontakte/videoplayer-shared/es2015";import{objectEntries as Cy}from"@vkontakte/videoplayer-shared/es2015";import{cancelIdleCallbackPolyfilled as wy}from"@vkontakte/videoplayer-shared/es2015";import{devNull as Ty,getWindow as Ey}from"@vkontakte/videoplayer-shared/es2015";import{assertNonNullable as Ny}from"@vkontakte/videoplayer-shared/es2015";import{Subscription as Iy,Observable as Ly,Subject as Ry,ValueSubject as zy,VideoQuality as By}from"@vkontakte/videoplayer-shared/es2015";var _oxcMod79m539=function(){function e(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function t(t){return function(){var n=this,r=arguments;return new Promise(function(i,a){var o=t.apply(n,r);function s(t){e(o,i,a,s,c,`next`,t)}function c(t){e(o,i,a,s,c,`throw`,t)}s(void 0)})}}function n(e){"@babel/helpers - typeof";return n=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},n(e)}var r=n;function i(e,t){if(r(e)!=`object`||!e)return e;var n=e[Symbol._oxc_toPrimitive];if(n!==void 0){var i=n.call(e,t||`default`);if(r(i)!=`object`)return i;throw TypeError(`@@_oxc_toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var r=n,a=i;function o(e){var t=a(e,`string`);return r(t)==`symbol`?t:t+``}var s=o;function c(e,t,n){return(t=s(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var l=c;function u(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function d(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?u(Object(n),!0).forEach(function(t){l(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):u(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function f(e,t){this.v=e,this.k=t}var p=f;function m(e){return new p(e,0)}var p=f;function h(e){return function(){return new g(e.apply(this,arguments))}}function g(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof p;Promise.resolve(s?o.v:o).then(function(n){if(s){var c=t===`return`?`return`:`next`;if(!o.k||n.done)return r(c,n);n=e[c](n).value}i(a.done?`return`:`normal`,n)},function(e){r(`throw`,e)})}catch(e){i(`throw`,e)}}function i(e,i){switch(e){case`return`:t.resolve({value:i,done:!0});break;case`throw`:t.reject(i);break;default:t.resolve({value:i,done:!1})}(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(a,o){var s={key:e,arg:i,resolve:a,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,i))})},typeof e.return!=`function`&&(this.return=void 0)}g.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},g.prototype.next=function(e){return this._invoke(`next`,e)},g.prototype.throw=function(e){return this._invoke(`throw`,e)},g.prototype.return=function(e){return this._invoke(`return`,e)};function _(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}var v=_;function y(e,t){if(e==null)return{};var n,r,i=v(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.includes(n)||{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}const b=[`url`],x=[`url`],S=[`downloadingItems`],C=[`container`];var w=t,T=d,E=m,D=h,ee=y,te=`2.0.165-dev.cd28586c7.0`,ne;(e=>{e.STOPPED=`stopped`,e.READY=`ready`,e.PLAYING=`playing`,e.PAUSED=`paused`})(ne||={});var re;(e=>{e.MPEG=`MPEG`,e.DASH=`DASH`,e.DASH_SEP=`DASH_SEP`,e.DASH_SEP_VK=`DASH_SEP`,e.DASH_WEBM=`DASH_WEBM`,e.DASH_WEBM_AV1=`DASH_WEBM_AV1`,e.DASH_STREAMS=`DASH_STREAMS`,e.DASH_WEBM_VK=`DASH_WEBM`,e.DASH_ONDEMAND=`DASH_ONDEMAND`,e.DASH_ONDEMAND_VK=`DASH_ONDEMAND`,e.DASH_LIVE=`DASH_LIVE`,e.DASH_LIVE_CMAF=`DASH_LIVE_CMAF`,e.DASH_LIVE_WEBM=`DASH_LIVE_WEBM`,e.HLS=`HLS`,e.HLS_ONDEMAND=`HLS_ONDEMAND`,e.HLS_JS=`HLS`,e.HLS_FMP4=`HLS_FMP4`,e.HLS_LIVE=`HLS_LIVE`,e.HLS_LIVE_CMAF=`HLS_LIVE_CMAF`,e.WEB_RTC_LIVE=`WEB_RTC_LIVE`})(re||={});var ie;(e=>{e.AV1=`av1`,e.VP9=`vp9`,e.AVC1=`avc1`,e.HEV1=`hev1`})(ie||={});var ae;(e=>{e.NOT_AVAILABLE=`NOT_AVAILABLE`,e.AVAILABLE=`AVAILABLE`,e.CONNECTING=`CONNECTING`,e.CONNECTED=`CONNECTED`})(ae||={});var oe;(e=>{e.HTTP1=`http1`,e.HTTP2=`http2`,e.QUIC=`quic`})(oe||={});var se;(e=>{e.NONE=`none`,e.INLINE=`inline`,e.FULLSCREEN=`fullscreen`,e.SECOND_SCREEN=`second_screen`,e.PIP=`pip`,e.INVISIBLE=`invisible`})(se||={});var ce;(e=>{e.TRAFFIC_SAVING=`traffic_saving`,e.HIGH_QUALITY=`high_quality`,e.UNKNOWN=`unknown`})(ce||={});var Ee=e=>new Promise((t,n)=>{let r=document.createElement(`script`);r.setAttribute(`src`,e),r.onload=()=>t(),r.onerror=e=>n(e),document.body.appendChild(r)});class De{constructor(e){this.connection$=new he(void 0),this.castState$=new he(`NOT_AVAILABLE`),this.errorEvent$=new ge,this.contentId=void 0,this.realCastState$=new he(`NOT_AVAILABLE`),this.subscription=new _e,this.log=void 0,this.params=void 0,this.isDestroyed=!1,this.params=e,this.log=this.params.dependencies.logger.createComponentLog(`ChromecastInitializer`);let t=`chrome`in window;if(this.log({message:`[constructor] receiverApplicationId: ${this.params.receiverApplicationId}, isDisabled: ${this.params.isDisabled}, isSupported: ${t}`}),e.isDisabled||!t)return;let n=me(window.chrome?.cast),r=!!window.__onGCastApiAvailable;n?this.initializeCastApi():(window.__onGCastApiAvailable=e=>{delete window.__onGCastApiAvailable,e&&!this.isDestroyed&&this.initializeCastApi()},r||Ee(`https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1`).catch(()=>this.errorEvent$.next({id:`ChromecastLoading`,category:Te.NETWORK,message:`Script loading failed!`})))}connect(){cast.framework.CastContext.getInstance()?.requestSession()}disconnect(){var e;(e=cast.framework.CastContext.getInstance())==null||(e=e.getCurrentSession())==null||e.endSession(!0)}stopMedia(){return new Promise((e,t)=>{var n;(n=cast.framework.CastContext.getInstance())==null||(n=n.getCurrentSession())==null||(n=n.getMediaSession())==null||n.stop(new chrome.cast.media.StopRequest,e,t)})}toggleConnection(){me(this.connection$.getValue())?this.disconnect():this.connect()}setVolume(e){let t=this.connection$.getValue();we(t)||(t.remotePlayer.volumeLevel=e,t.remotePlayerController.setVolumeLevel())}setMuted(e){let t=this.connection$.getValue();we(t)||e!==t.remotePlayer.isMuted&&t.remotePlayerController.muteOrUnmute()}destroy(){this.isDestroyed=!0,this.subscription.unsubscribe()}initListeners(){let e=new cast.framework.RemotePlayer,t=new cast.framework.RemotePlayerController(e),n=cast.framework.CastContext.getInstance();this.subscription.add(be(n,cast.framework.CastContextEventType.SESSION_STATE_CHANGED).subscribe(e=>{switch(e.sessionState){case cast.framework.SessionState.SESSION_STARTED:case cast.framework.SessionState.SESSION_STARTING:case cast.framework.SessionState.SESSION_RESUMED:var t;this.contentId=(t=n.getCurrentSession())==null||(t=t.getMediaSession())==null||(t=t.media)==null?void 0:t.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 fe(e.sessionState)}})).add(ve(be(n,cast.framework.CastContextEventType.CAST_STATE_CHANGED).pipe(Se(e=>{this.log({message:`[cast.framework.RemotePlayerEventType.CAST_STATE_CHANGED]: ${JSON.stringify(e)}`})}),xe(e=>e.castState)),ye([n.getCastState()])).pipe(Ce(),xe(Oe),Se(e=>{this.log({message:`realCastState$: ${e}`})})).subscribe(this.realCastState$)).add(this.realCastState$.subscribe(r=>{let i=r===`CONNECTED`,a=me(this.connection$.getValue());if(i&&!a){var o;let r=n.getCurrentSession();pe(r);let i=r.getCastDevice(),a=(o=r.getMediaSession())==null||(o=o.media)==null?void 0:o.contentId;(we(a)||a===this.contentId)&&(this.log({message:`connection created`}),this.connection$.next({remotePlayer:e,remotePlayerController:t,session:r,castDevice:i}))}else!i&&a&&(this.log({message:`connection destroyed`}),this.connection$.next(void 0));this.castState$.next(r===`CONNECTED`?me(this.connection$.getValue())?`CONNECTED`:`AVAILABLE`:r)}))}initializeCastApi(){let e,t,n;try{e=cast.framework.CastContext.getInstance(),t=chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,n=chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}catch{return}try{e.setOptions({receiverApplicationId:this.params.receiverApplicationId??t,autoJoinPolicy:n}),this.initListeners()}catch(e){this.errorEvent$.next({id:`ChromecastInitializer`,category:Te.EXTERNAL_API,message:`[initializeCastApi] failed`,thrown:e})}}}var Oe=e=>{switch(e){case cast.framework.CastState.NO_DEVICES_AVAILABLE:return`NOT_AVAILABLE`;case cast.framework.CastState.NOT_CONNECTED:return`AVAILABLE`;case cast.framework.CastState.CONNECTING:return`CONNECTING`;case cast.framework.CastState.CONNECTED:return`CONNECTED`;default:return fe(e)}};var O=(e,t=0,n=0)=>{switch(n){case 0:return e.replace(`_offset_p`,t===0?``:`_`+t.toFixed(0));case 1:{if(t===0)return e;let n=new URL(e);return n.searchParams.append(`playback_shift`,t.toFixed(0)),n.toString()}case 2:{let n=new URL(e);return!n.searchParams.get(`offset_p`)&&t===0?e:(n.searchParams.set(`offset_p`,t.toFixed(0)),n.toString())}default:Ge(n)}return e},Ke=(e,t)=>{switch(t){case 0:return NaN;case 1:{let t=new URL(e);return Number(t.searchParams.get(`playback_shift`))}case 2:{let t=new URL(e);return Number(t.searchParams.get(`offset_p`)??0)}default:Ge(t)}},qe=e=>{let{source:t,format:n,meta:r,output:i}=e,a,o,s;switch(n){case`MPEG`:{let e=t[n];Ve(e);let r=Ue(Object.keys(e));Ve(r);let i=e[r];Ve(i),a=i,o=`video/mp4`,s=Je();break}case`HLS`:case`HLS_FMP4`:case`HLS_ONDEMAND`:{let e=t[n];Ve(e),a=e.url,o=`application/x-mpegurl`,s=Je();break}case`DASH_SEP`:case`DASH_ONDEMAND`:case`DASH_WEBM`:case`DASH_WEBM_AV1`:case`DASH_STREAMS`:{let e=t[n];Ve(e),a=e.url,o=`application/dash+xml`,s=Je();break}case`DASH_LIVE_CMAF`:{let e=t[n];Ve(e),a=e.url,o=`application/dash+xml`,s=Ye();break}case`HLS_LIVE`:case`HLS_LIVE_CMAF`:{let e=t[n];Ve(e),a=O(e.url),o=`application/x-mpegurl`,s=Ye();break}case`DASH_LIVE`:case`WEB_RTC_LIVE`:{let e=`Unsupported format for Chromecast`,t=Error(e);throw i.error$.next({id:`ChromecastProvider.createMediaInfo()`,category:He.VIDEO_PIPELINE,message:e,thrown:t}),t}case`DASH`:case`DASH_LIVE_WEBM`:throw Error(`${n} is no longer supported`);default:return Be(n)}let c=Xe(r.videoId??a,o);c.contentUrl=a,c.streamType=s,c.metadata=Ze();let{title:l,subtitle:u}=r;return We(l)&&(c.metadata.title=l),We(u)&&(c.metadata.subtitle=u),c};function Je(){var e;return((e=chrome.cast)==null||(e=e.media)==null||(e=e.StreamType)==null?void 0:e.BUFFERED)??`BUFFERED`}function Ye(){var e;return((e=chrome.cast)==null||(e=e.media)==null||(e=e.StreamType)==null?void 0:e.LIVE)??`LIVE`}function Xe(e,t){var n;return!((n=chrome.cast)==null||(n=n.media)==null)&&n.MediaInfo?new chrome.cast.media.MediaInfo(e,t):{contentId:e,contentType:t,metadata:{title:``,subtitle:``},streamType:Je()}}function Ze(){var e;return!((e=chrome.cast)==null||(e=e.media)==null)&&e.GenericMediaMetadata?new chrome.cast.media.GenericMediaMetadata:{images:[],metadataType:0,releaseDate:``,subtitle:``,title:``,releaseYear:1970,type:0}}var k=(e,t,n=!1)=>{let r=e.getTransition();(n||!r||r.to===t)&&e.setState(t)};class Qe{constructor(e){this.params=void 0,this.interval=0,this.startVideoPosition=void 0,this.startTs=void 0,this.params=e}start(e=0){clearInterval(this.interval),this.startVideoPosition=e,this.startTs=Date.now(),this.interval=window.setInterval(()=>{let e=(Date.now()-this.startTs)/1e3,t=this.startVideoPosition+e;this.params.output.position$.next(t)},1e3)}pause(){clearInterval(this.interval)}destroy(){clearInterval(this.interval)}}class it{constructor(){this._current=void 0,this._current_version=void 0,this._chromeVersion=void 0,this._firefoxVersion=void 0,this._safariVersion=void 0,this._operaVersion=void 0,this._edgeVersion=void 0,this._yandexVersion=void 0,this._isMiuiBrowser=!1}get current(){return this._current}get isChrome(){return this.current===`Chrome`}get isChromiumBased(){return nt([`Chrome`,`Chromium`,`Opera`,`Yandex`,`Edge`,`SamsungBrowser`],this.current)}get isFirefox(){return this.current===`Firefox`}get isSafari(){return this.current===`Safari`}get isOpera(){return this.current===`Opera`}get isEdge(){return this.current===`Edge`}get isYandex(){return this.current===`Yandex`}get isSamsungBrowser(){return this.current===`SamsungBrowser`}get currentVersion(){return this._current_version}get chromeVersion(){return this._chromeVersion}get firefoxVersion(){return this._firefoxVersion}get safariVersion(){return this._safariVersion}get operaVersion(){return this._operaVersion}get edgeVersion(){return this._edgeVersion}get yandexVersion(){return this._yandexVersion}get isMiuiBrowser(){return this._isMiuiBrowser}detect(){let{userAgent:e}=navigator;try{let t=/yabrowser/i.test(e)?`Yandex`:void 0,n=/samsungbrowser/i.test(e)?`SamsungBrowser`:void 0,r=/chrome|crios/i.test(e)?`Chrome`:void 0,i=/chromium/i.test(e)?`Chromium`:void 0,a=/firefox|fxios/i.test(e)?`Firefox`:void 0,o=/webkit|safari|khtml/i.test(e)?`Safari`:void 0,s=/opr\//i.test(e)?`Opera`:void 0,c=/edg/i.test(e)?`Edge`:void 0;this._isMiuiBrowser=/(XiaoMi)|(MiuiBrowser)/i.test(e),this._current=t||n||a||s||c||r||i||o||`Rest`}catch(e){console.error(e)}this.isChrome&&this.detectChromeVersion(),this.isFirefox&&this.detectFirefoxVersion(),this.isSafari&&this.detectSafariVersion(),this.isOpera&&this.detectOperaVersion(),this.isEdge&&this.detectEdgeVersion(),this.isYandex&&this.detectYandexVersion()}detectVersion(e){try{let{userAgent:t}=rt().navigator,n=t.match(e);if(!n)return;let r=n[1],i=parseInt(r,10);if(!isNaN(i))return this._current_version=i,i}catch(e){console.error(e)}}detectChromeVersion(){this._chromeVersion=this.detectVersion(/Chrome\/(\d+\.\d+)/)}detectFirefoxVersion(){this._firefoxVersion=this.detectVersion(/Firefox\/(\d+\.\d+)/)}detectSafariVersion(){this._safariVersion=this.detectVersion(/Version\/(\d+)/)}detectOperaVersion(){this._operaVersion=this.detectVersion(/OPR\/(\d+\.\d+)/)}detectEdgeVersion(){this._edgeVersion=this.detectVersion(/Edg\/(\d+\.\d+)/)}detectYandexVersion(){this._yandexVersion=this.detectVersion(/YaBrowser\/(\d+\.\d+\.\d+)/)}}var st=()=>{var e;return/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test(navigator.appVersion??navigator.userAgent)||((e=navigator)==null||(e=e.userAgentData)==null?void 0:e.mobile)};class ct{constructor(e){this._displayChecker=void 0,this._isMobile=void 0,this._current=void 0,this._iosVersion=void 0,this._highEntropyValues={},this._os={name:`Unknown`,version:`Unknown`,full:`Unknown`},this._details={vendor:`Unknown`,model:`Unknown`},this._displayChecker=e}get current(){return this._current}get os(){return this._os}get details(){return this._details}get isIOS(){return this._highEntropyValues.platform===`iOS`||A(this.os.name.toLowerCase(),`ios`)||A([`iPhone`,`iPad`,`iPod`],this.current)}get isMac(){return this._highEntropyValues.platform===`macOS`||A(this.os.name.toLowerCase(),`mac`)||this.current===`Mac`}get isApple(){return this.isIOS||this.isMac}get isIphoneOrOldIpad(){if(!this.isApple||!this._displayChecker.isTouch)return!1;let e=this.current===`iPad`||this._displayChecker.width>700,t=this._iosVersion;return!e||e&&!!t&&t<16}get isAndroid(){return this._highEntropyValues.platform===`Android`||A(this.os.name.toLowerCase(),`android`)||this.current===`Android`}get isWindows(){return A(this.os.name.toLowerCase(),`windows`)}get isLinux(){return A(this.os.name.toLowerCase(),`linux`)&&!this.isAndroid}get isMobile(){return this._highEntropyValues.mobile||this._isMobile}get iOSVersion(){return this._iosVersion}detect(){let e=at();if(!ot(e))return;let{userAgent:t}=e.navigator;try{this._isMobile=st()}catch(e){console.error(`DeviceChecker: calling isMobile error - `,e)}this.detectDevice(t),this.detectOS(t),this.detectDeviceDetails(t),this.detectHighEntropyValues(),this.isIOS&&this.detectIOSVersion()}detectHighEntropyValues(){var e=this;return w(function*(){let t=at();if(!ot(t))return;let{userAgentData:n}=t.navigator;if(n?.getHighEntropyValues){let t=yield n.getHighEntropyValues([`architecture`,`bitness`,`brands`,`mobile`,`platform`,`formFactor`,`model`,`platformVersion`,`wow64`]);e._highEntropyValues=t,t.platform&&(e._os.name=e.normalizeOSName(t.platform),t.platformVersion&&(e._os.version=e.normalizeOSVersion(t.platformVersion),e._os.full=`${e._os.name} ${e._os.version}`)),t.model&&(e._details.model=t.model)}})()}detectDevice(e){try{let t=/android/i.test(e)?`Android`:void 0,n=/iphone/i.test(e)?`iPhone`:void 0,r=/ipad/i.test(e)?`iPad`:void 0,i=/ipod/i.test(e)?`iPod`:void 0,a=/mac/i.test(e)?`Mac`:void 0,o=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(e)?`RestMobile`:void 0;this._current=t||n||r||i||o||a||`Desktop`}catch(e){console.error(`DeviceChecker: device detection error - `,e)}}detectOS(e){try{for(let[t,n]of[[/(windows nt) (6\.[23]); arm/i,[`Windows RT`]],[/(windows nt) (6\.3); arm/i,[`Windows RT 8.1`]],[/(windows (?:phone|mobile|iot))(?: os)?[/ ]?([\d.]+)/i,[`Windows Mobile`,2]],[/(windows)[/ ](xp|vista|7|8(\.1)?|10|11|2000|me)/i,[1,1]],[/windows nt ?([\d.]+)/i,[`Windows`,1]],[/(windows)[/ ](95|98|me|2000|xp|vista|7|8|8\.1|10|11)/i,[1,2]],[/(iphone os|cpu iphone os) ([\d_.]+)/i,[`iOS`,2]],[/(ipad os|cpu os) ([\d_.]+)/i,[`iPadOS`,2]],[/(ipod os|cpu ipod os) ([\d_.]+)/i,[`iOS`,2]],[/(?:ios|os) ([\d_.]+) like mac os x/i,[`iOS`,1]],[/cfnetwork\/.+darwin/i,[`iOS`]],[/(mac os x) ?([\d_.]+)/i,[`macOS`,2]],[/(macintosh|mac os)/i,[`macOS`]],[/(android) ([\d.]+)/i,[1,2]],[/(harmonyos)[/ ]?([\d.]*)/i,[`HarmonyOS`,2]],[/\b(ubuntu|debian|fedora|centos|arch|linux)(?:[-/ ]([\w.]+))?/i,[1,2]],[/(cros)\D*([\d.]+)/i,[`Chrome OS`,2]],[/(freebsd|openbsd|netbsd|dragonfly)[/ ]?([\w.]*)/i,[1,2]],[/(sunos|solaris)?([\d.]*)/i,[`Solaris`,2]],[/(aix)?([\d.]*)/i,[`AIX`,2]]]){let r=e.match(t);if(r){let t=n.length>0,i=n.length>1,a=`Unknown`,o=`Unknown`;if(t){let e=n[0];typeof e==`number`?e<r.length&&r[e]!==void 0&&(a=r[e]):a=e}if(i){let e=n[1];typeof e==`number`?e<r.length&&r[e]!==void 0&&(o=r[e]):e!==void 0&&(o=e)}else r[2]===void 0?r[1]!==void 0&&t&&typeof n[0]==`string`&&(o=r[1]):o=r[2];a=this.normalizeOSName(a),o=this.normalizeOSVersion(o,a),a===`iOS`&&/ipad/i.test(e)?a=`iPadOS`:a===`iPadOS`&&/ip(hone|od)/i.test(e)&&(a=`iOS`),this._os={name:a,version:o||`Unknown`,full:o&&o!==`Unknown`?`${a} ${o}`:a};break}}}catch(e){console.error(`DeviceChecker: OS detection error - `,e)}}normalizeOSName(e){if(!e)return`Unknown`;let t=e.toLowerCase();return A(t,`windows`)?`Windows`:A(t,`mac os`)||A(t,`macintosh`)?`macOS`:A(t,`iphone`)||A(t,`ios`)?`iOS`:A(t,`ipados`)?`iPadOS`:A(t,`android`)?`Android`:A(t,`harmonyos`)?`HarmonyOS`:A(t,`linux`)?`Linux`:A(t,`cros`)?`Chrome OS`:A(t,`freebsd`)?`FreeBSD`:A(t,`openbsd`)?`OpenBSD`:A(t,`solaris`)||A(t,`sunos`)?`Solaris`:A(t,`aix`)?`AIX`:e}normalizeOSVersion(e,t){if(!e)return`Unknown`;if(e!==`Unknown`&&(e=e.replace(/_/g,`.`),t===`Windows`)){let t=parseFloat(e);if(!isNaN(t)){if(t>=11)return`11`;if(t>=10)return`10`;if(t===6.3)return`8.1`;if(t===6.2)return`8`;if(t===6.1)return`7`;if(t===6)return`Vista`;if(t===5.1||t===5.2)return`XP`;if(t===5)return`2000`;if(t===4)return`NT 4.0`}}return e}detectDeviceDetails(e){try{for(let[t,n]of[[/(iphone)/i,[`Apple`,`iPhone`]],[/(ipad)/i,[`Apple`,`iPad`]],[/(ipod)/i,[`Apple`,`iPod`]],[/(macintosh)/i,[`Apple`,`Macintosh`]],[/(windows[\w\-_ ]*phone)/i,[`Microsoft`,0]],[/(windows nt|win64|win32|wow64)/i,[`Microsoft`,`PC`]],[/\b(sch-i[89]0\d|shw-m380s|sm-[ptxs]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i,[`Samsung`,1]],[/\b((?:s[cgp]h|gt|sm)-(?![lr])\w+|sc[g-]?\d+a?|galaxy nexus)/i,[`Samsung`,1]],[/samsung[- ]((?!sm-[lr]|browser)[-\w]+)/i,[`Samsung`,1]],[/sec-(sgh\w+)/i,[`Samsung`,1]],[/smart-tv.+(samsung)/i,[`Samsung`,`Smart TV`]],[/(samsung).*tizen/i,[`Samsung`,`Smart TV`]],[/(pixel (?:c|tablet|[0-9a-z ]+))/i,[`Google`,1]],[/(pixelbook(?: go)?)/i,[`Google`,1]],[/nexus [0-9]/i,[`Google`,0]],[/(redmi[-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,[`Xiaomi`,1]],[/\b(mi[\w\-_ ]+)(?: bui|\))/i,[`Xiaomi`,1]],[/\b(poco[\w ]+)(?: bui|\))/i,[`Xiaomi`,1]],[/\b(hm[-_ ]?note?[\w ]*)(?: bui|\))/i,[`Xiaomi`,1]],[/\b(?:xiao)?mi[\w\-_ ]+pad/i,[`Xiaomi`,0]],[/(?:huawei|honor) ?([-\w ]+)[;)]/i,[`Huawei`,1]],[/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][\dc][adnt]?)\b(?!.+d\/s)/i,[`Huawei`,1]],[/\b((?:ag[rs][2356]?k?|bah[234]?|bg[2o]|bt[kv]|cmr|cpn|db[ry]2?|jdn2|got|kob2?k?|mon|pce|scm|sht?|[tw]gr|vrd)-[ad]?[lw][0125][09]b?)/i,[`Huawei`,1]],[/(?:one)?(?:plus)? ?([a\d0]\d\d\d?)(?: b|\))/i,[`OnePlus`,1]],[/droid.+; (cph2[3-6]\d[13579]|((?:gm|hd)19|(?:ac|be|in|kb)20|(?:d[en]|eb|le|mt)21|ne22)[0-2]\d)(?: bui|\))/i,[`OnePlus`,1]],[/(oneplus)[-_ ]?([-\w]*)/i,[`OnePlus`,2]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i,[`Realme`,1]],[/(realme)[-_ ]?([-\w]*)/i,[`Realme`,2]],[/; (\w+) bui.+ oppo/i,[`OPPO`,1]],[/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i,[`OPPO`,1]],[/\b(opd2(\d{3}a?))(?: bui|\))/i,[`OPPO`,1]],[/(oppo)[-_ ]?([-\w]*)/i,[`OPPO`,2]],[/; vivo (\w+)(?: bui|\))/i,[`Vivo`,1]],[/\b(v[12]\d{3}\w?[at])(?: bui|;)/i,[`Vivo`,1]],[/(vivo)[-_ ]?([-\w]*)/i,[`Vivo`,2]],[/\bmot(?:orola)?[- ]([\w\s]+)(\)| bui)/i,[`Motorola`,1]],[/((?:moto(?! 360)[-\w() ]+|xt\d{3,4}[cgkosw+]?[-\d]*|nexus 6)(?= bui|\)))/i,[`Motorola`,1]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b/i,[`Motorola`,0]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i,[`Motorola`,0]],[/droid.+; ([a-z]?\d[0-2]{2}[a-z]{2}|[c-g]\d{4}|so[-gl]\w+|xq-[a-z]{2}\d\d)(?= bui|\))/i,[`Sony`,1]],[/sony tablet [ps]/i,[`Sony`,`Xperia Tablet`]],[/\b(?:sony)?sgp\w+(?: bui|\))/i,[`Sony`,0]],[/(sony)[-_ ]?([-\w]*)/i,[`Sony`,2]],[/\blg[-e;/ ]+(?!.*(?:browser|netcast|android tv|watch|webos))(\w+)/i,[`LG`,1]],[/\blg-?([\d\w]+) bui/i,[`LG`,1]],[/(lm(?:-?f100[nv]?|-[\w.]+)(?= bui|\))|nexus [45])/i,[`LG`,1]],[/((?=lg)?[vl]k-?\d{3}) bui/i,[`LG`,0]],[/(lg)[-_ ]?([-\w]*)/i,[`LG`,2]],[/(?:maemo|nokia).*(n900|lumia \d+|rm-\d+)/i,[`Nokia`,1]],[/nokia[-_ ]?(([-\w. ]*?))(?: bui|\)|;|\/)/i,[`Nokia`,1]],[/(nokia) (t[12][01])/i,[`Nokia`,2]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i,[`ASUS`,1]],[/(?:asus[-_ ])?(zenfone[\w\-_ ]*)/i,[`ASUS`,1]],[/(rog[\w\-_ ]*)/i,[`ASUS`,1]],[/(asus)[-_ ]?([-\w]*)/i,[`ASUS`,2]],[/lenovo[-_ ]?([-\w ]+?)(?: bui|\)|\/)/i,[`Lenovo`,1]],[/(ideatab[-\w ]+|602lv|d-42a|a101lv|a2109a|a3500-hv|s[56]000|pb-6505[my]|tb-?x?\d{3,4}(?:f[cu]|xu|[av])|yt\d?-[jx]?\d+[lfmx])(?: bui|;|\)|\/)/i,[`Lenovo`,1]],[/(thinkpad[\w\-_ ]*)/i,[`Lenovo`,0]],[/(kf[a-z]{2}[a-z]*)(?: bui|\))/i,[`Amazon`,1]],[/(alexa)webm/i,[`Amazon`,`Echo`]],[/(fire[\w\-_ ]*)/i,[`Amazon`,0]],[/(amazon)[-_ ]?([-\w]*)/i,[`Amazon`,2]],[/(?:blackberry|\(bb10;) (\w+)/i,[`BlackBerry`,1]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,[`BlackBerry`,1]],[/(playbook);[-\w),; ]+(rim)/i,[`BlackBerry`,1]],[/(microsoft); (lumia[\w ]+)/i,[`Microsoft`,2]],[/(surface duo)/i,[`Microsoft`,`Surface Duo`]],[/(surface[\w\-_ ]*)/i,[`Microsoft`,0]],[/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,[`ZTE`,2]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,[`HTC`,2]],[/(alcatel|tcl)[-_ ]?([-\w]*)/i,[1,2]],[/(meizu)[-_ ]?([-\w]*)/i,[`Meizu`,2]],[/(tecno)[-_ ]?([-\w]*)/i,[`Tecno`,2]],[/(infinix)[-_ ]?([-\w]*)/i,[`Infinix`,2]],[/(micromax)[-_ ]?([-\w]*)/i,[`Micromax`,2]],[/(lava)[-_ ]?([-\w]*)/i,[`Lava`,2]],[/(panasonic)[-_ ]?([-\w]*)/i,[`Panasonic`,2]],[/(sharp)\/?([-\w]*)/i,[`Sharp`,2]],[/(benq)[-_ ]?([-\w]*)/i,[`BenQ`,2]],[/(palm)[-_ ]?([-\w]*)/i,[`Palm`,2]],[/(vertu)[-_ ]?([-\w]*)/i,[`Vertu`,2]],[/(gionee)[-_ ]?([-\w]*)/i,[`Gionee`,2]],[/(doogee)[-_ ]?([-\w]*)/i,[`Doogee`,2]],[/(ulefone)[-_ ]?([-\w]*)/i,[`Ulefone`,2]],[/(blackview)[-_ ]?([-\w]*)/i,[`Blackview`,2]],[/(cubot)[-_ ]?([-\w]*)/i,[`Cubot`,2]],[/(umidigi)[-_ ]?([-\w]*)/i,[`UMIDIGI`,2]],[/(oukitel)[-_ ]?([-\w]*)/i,[`Oukitel`,2]],[/(fairphone)[-_ ]?([-\w]*)/i,[`Fairphone`,2]],[/(cat)[-_ ]?([-\w]*)/i,[`Cat`,2]],[/(energy)[-_ ]?([-\w]*)/i,[`Energizer`,2]],[/(land rover)[-_ ]?([-\w]*)/i,[`Land Rover`,2]],[/(shield[\w\-_ ]*)/i,[`Nvidia`,0]],[/(crkey)/i,[`Google`,`Chromecast`]],[/(roku)[\dx]*/i,[`Roku`,0]],[/(apple)[-_ ]?tv/i,[`Apple`,`TV`]],[/(amazon)[-_ ]?tv/i,[`Amazon`,`Fire TV`]],[/(google)[-_ ]?tv/i,[`Google`,`TV`]],[/(smart[\w\-_ ]*tv)/i,[0,`Smart TV`]],[/(playstation[\w\-_ ]*)/i,[`Sony`,0]],[/(nintendo[\w\-_ ]*)/i,[`Nintendo`,0]],[/(xbox[\w\-_ ]*)/i,[`Microsoft`,0]],[/(googlebot)/i,[`Google`,`Bot`]],[/(bingbot)/i,[`Microsoft`,`Bing Bot`]],[/(yandexbot)/i,[`Yandex`,`Bot`]],[/(slackbot)/i,[`Slack`,`Bot`]],[/(twitterbot)/i,[`Twitter`,`Bot`]],[/(facebookbot)/i,[`Facebook`,`Bot`]],[/(linkedinbot)/i,[`LinkedIn`,`Bot`]],[/(tesla)[-_ ]?([-\w]*)/i,[`Tesla`,2]],[/(raspberry[\w\-_ ]*)/i,[`Raspberry Pi`,0]]]){let r=e.match(t);if(r){let e=n[0],t=n[1],i=typeof e==`number`?r[e]===void 0?`Unknown`:this.normalizeVendorName(r[e]):this.normalizeVendorName(e),a=`Unknown`;typeof t==`number`?a=r[t]===void 0?`Unknown`:r[t]:t===void 0?r[1]===void 0?r[0]!==void 0&&(a=r[0]):a=r[1]:a=t,a=this.normalizeModelName(a,i),this.details.vendor=i,this.details.model=a;break}}}catch(e){console.error(`DeviceChecker: device details detection error - `,e)}}normalizeVendorName(e){return e?{apple:`Apple`,samsung:`Samsung`,google:`Google`,xiaomi:`Xiaomi`,huawei:`Huawei`,oneplus:`OnePlus`,oppo:`OPPO`,vivo:`Vivo`,realme:`Realme`,motorola:`Motorola`,sony:`Sony`,lg:`LG`,nokia:`Nokia`,asus:`ASUS`,lenovo:`Lenovo`,amazon:`Amazon`,blackberry:`BlackBerry`,microsoft:`Microsoft`,zte:`ZTE`,htc:`HTC`,alcatel:`Alcatel`,tcl:`TCL`,meizu:`Meizu`,tecno:`Tecno`,infinix:`Infinix`,micromax:`Micromax`,lava:`Lava`,panasonic:`Panasonic`,sharp:`Sharp`,benq:`BenQ`,palm:`Palm`,honor:`Honor`,nvidia:`NVIDIA`,roku:`Roku`}[e.toLowerCase()]||e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():`Unknown`}normalizeModelName(e,t){if(!e||e===`Unknown`)return e;if(e===`0`)return`Unknown`;let n=e.replace(/^build\//i,``).replace(/\s+bui$/i,``).replace(/\)$/,``).replace(/[;,)]/g,``).replace(/\s*\(.*?\)\s*/g,``).trim(),r=t.toLowerCase();return A(r,`samsung`)?n=n.replace(/^(sm-|gt-|sgh-|sch-)/i,``):A(r,`xiaomi`)?n=n.replace(/^(mi[\s\-_]*|redmi[\s\-_]*)/i,``):A(r,`oneplus`)?n=n.replace(/^oneplus[\s\-_]*/i,``):A(r,`google`)&&(n=n.replace(/^(pixel[\s\-_]*|nexus[\s\-_]*)/i,``)),n=n.replace(/_/g,` `).replace(/-/g,` `).replace(/\s+/g,` `).trim(),n?(n.length>0&&/^[a-z]/.test(n)&&(n=n.charAt(0).toUpperCase()+n.slice(1)),n):`Unknown`}detectIOSVersion(){try{let e=at();if(!ot(e))return;if(this._highEntropyValues.platformVersion){let e=this._highEntropyValues.platformVersion.split(`.`).slice(0,2).join(`.`);this._iosVersion=parseFloat(e);return}if(this._os.version!==`Unknown`){let e=this._os.version.split(`.`),t=e.length>=2?`${e[0]}.${e[1]}`:e[0];this._iosVersion=parseFloat(t);return}let t=e.navigator.userAgent.match(/OS (\d+(_\d+)?)/i);t?.[1]&&(this._iosVersion=parseFloat(t[1].replace(/_/g,`.`)))}catch(e){console.error(`DeviceChecker: iOS version detection error - `,e)}}}class dt{constructor(){this._maxTouchPoints=void 0,this._height=void 0,this._width=void 0,this._isHdr=void 0,this._pixelRatio=void 0,this._screenHeight=void 0,this._screenWidth=void 0,this._colorDepth=void 0}get isTouch(){return typeof this._maxTouchPoints==`number`?this._maxTouchPoints>1:`ontouchstart`in lt()}get maxTouchPoints(){return this._maxTouchPoints}get height(){return this._height}get width(){return this._width}get screenHeight(){return this._screenHeight}get screenWidth(){return this._screenWidth}get pixelRatio(){return this._pixelRatio}get isHDR(){return this._isHdr}get colorDepth(){return this._colorDepth}detect(){let e=lt();if(!ut(e))return;let{navigator:t,screen:n}=e,{maxTouchPoints:r}=t;try{this._maxTouchPoints=r??0,this._isHdr=!!e.matchMedia(`(dynamic-range: high)`)?.matches,this._colorDepth=n.colorDepth}catch(e){console.error(e)}try{this._pixelRatio=e.devicePixelRatio||1,this._height=n.height,this._width=n.width,this._height=n.height,this._screenHeight=this._height*this._pixelRatio,this._screenWidth=this._width*this._pixelRatio}catch(e){console.error(e)}}}var mt=()=>window.ManagedMediaSource||window.MediaSource,ht=()=>{var e;return!!(window.ManagedMediaSource&&!((e=window.ManagedSourceBuffer)==null||(e=e.prototype)==null)&&e.appendBuffer)},gt=()=>{var e;return!!(window.MediaSource&&!((e=window.SourceBuffer)==null||(e=e.prototype)==null)&&e.appendBuffer)},_t=()=>window.ManagedMediaSource?new ManagedMediaSource:new MediaSource,vt=ft().document?.createElement(`video`),yt=`video/mp4; codecs="avc1.42000a,mp4a.40.2"`,bt=`video/mp4; codecs="hev1.1.6.L93.B0"`,xt=`video/webm; codecs="vp09.00.10.08"`,St=`video/webm; codecs="av01.0.00M.08"`,Ct=`audio/mp4; codecs="mp4a.40.2"`,wt=`audio/webm; codecs="opus"`,Tt;(function(){var e=w(function*(){let e=ft();if(!pt(e)||!(`mediaCapabilities`in e.navigator))return;let t={type:`media-source`,video:{contentType:`video/webm`,width:1280,height:720,bitrate:1e6,framerate:30}},[n,r]=yield Promise.all([e.navigator.mediaCapabilities.decodingInfo(T(T({},t),{},{video:T(T({},t.video),{},{contentType:St})})),e.navigator.mediaCapabilities.decodingInfo(T(T({},t),{},{video:T(T({},t.video),{},{contentType:xt})}))]);Tt={DASH_WEBM_AV1:n,DASH_WEBM:r}});return function(){return e.apply(this,arguments)}})()().catch(e=>{console.log(vt),console.error(e)});class Et{constructor(e,t){this._video=void 0,this._deviceChecker=void 0,this._browserChecker=void 0,this._protocols=void 0,this._containers=void 0,this._codecs=void 0,this._nativeHlsSupported=void 0,this._deviceChecker=e,this._browserChecker=t}get protocols(){return this._protocols}get containers(){return this._containers}get codecs(){return this._codecs}get webmDecodingInfo(){return Tt}get supportedCodecs(){return Object.keys(this._codecs).filter(e=>this._codecs[e])}get nativeHlsSupported(){return this._nativeHlsSupported}detect(){let e=ft();if(!pt(e))return;let t=e.document;this._video=t.createElement(`video`);try{var n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_;this._protocols={mms:ht(),mse:gt(),hls:!!((n=this._video).canPlayType?.call(n,`application/x-mpegurl`)||(r=this._video).canPlayType?.call(r,`vnd.apple.mpegURL`)),webrtc:!!e.RTCPeerConnection,ws:!!e.WebSocket},this._containers={mp4:!!(i=this._video).canPlayType?.call(i,`video/mp4`),webm:!!(a=this._video).canPlayType?.call(a,`video/webm`),cmaf:!0};let t=!!(!((o=mt())==null||(s=o.isTypeSupported)==null)&&s.call(o,yt)),v=!!(!((c=mt())==null||(l=c.isTypeSupported)==null)&&l.call(c,bt)),y=!!(!((u=mt())==null||(d=u.isTypeSupported)==null)&&d.call(u,Ct));this._codecs={h264:t,h265:v,vp9:!!(!((f=mt())==null||(p=f.isTypeSupported)==null)&&p.call(f,xt)),av1:!!(!((m=mt())==null||(h=m.isTypeSupported)==null)&&h.call(m,St)),aac:y,opus:!!(!((g=mt())==null||(_=g.isTypeSupported)==null)&&_.call(g,wt)),mpeg:(t||v)&&y},this._nativeHlsSupported=this._protocols.hls&&this._containers.mp4}catch(e){console.error(e)}try{this.destroyVideoElement()}catch(e){console.error(`Error destroying video element:`,e)}}destroyVideoElement(){if(!this._video)return;if(this._video.pause(),this._video.currentTime=0,this._video.removeAttribute(`src`),this._video.src=``,this._video.load(),this._video.remove){this._video.remove(),this._video=null;return}this._video.parentNode&&this._video.parentNode.removeChild(this._video);let e=this._video.cloneNode(!1);this._video.parentNode?.replaceChild(e,this._video),this._video=null}}var kt=`audio/mpeg`;class At{constructor(){this._audio=void 0,this._containers=void 0,this._codecs=void 0}supportMp3(){return this._codecs.mp3&&this._containers.mpeg}detect(){let e=Dt();if(!Ot(e))return;let t=e.document;this._audio=t.createElement(`audio`);try{var n,r,i;this._containers={mpeg:!!(n=this._audio).canPlayType?.call(n,kt)},this._codecs={mp3:!!(!((r=mt())==null||(i=r.isTypeSupported)==null)&&i.call(r,kt))}}catch(e){console.error(e)}try{this.destroyAudioElement()}catch(e){console.error(`Error destroying audio element:`,e)}}destroyAudioElement(){if(!this._audio)return;if(this._audio.pause(),this._audio.currentTime=0,this._audio.removeAttribute(`src`),this._audio.src=``,this._audio.load(),this._audio.remove){this._audio.remove(),this._audio=null;return}this._audio.parentNode&&this._audio.parentNode.removeChild(this._audio);let e=this._audio.cloneNode(!1);this._audio.parentNode?.replaceChild(e,this._audio),this._audio=null}}class jt{constructor(){this.isInited$=new tt(!1),this._displayChecker=void 0,this._deviceChecker=void 0,this._browserChecker=void 0,this._videoChecker=void 0,this._audioChecker=void 0,this._displayChecker=new dt,this._deviceChecker=new ct(this._displayChecker),this._browserChecker=new it,this._videoChecker=new Et(this._deviceChecker,this._browserChecker),this._audioChecker=new At,this.detect()}get display(){return this._displayChecker}get device(){return this._deviceChecker}get browser(){return this._browserChecker}get video(){return this._videoChecker}get audio(){return this._audioChecker}detect(){var e=this;return w(function*(){et()&&(e._displayChecker.detect(),e._deviceChecker.detect(),e._browserChecker.detect(),e._videoChecker.detect(),e._audioChecker.detect(),e.isInited$.next(!0))})()}}var j=new jt,Mt=(e,t=!1)=>{let{containers:n,protocols:r,codecs:i,nativeHlsSupported:a}=j.video,{isMobile:o}=j.device,s=j.device.isMac&&j.browser.isSafari,c=t&&!o&&!s,l=(i.h264||i.h265)&&i.aac,u=r.mse||r.mms;return e.filter(e=>{switch(e){case`DASH_SEP`:return u&&n.mp4&&l;case`DASH_WEBM`:return u&&n.webm&&i.vp9&&i.opus;case`DASH_WEBM_AV1`:return u&&n.webm&&i.av1&&i.opus;case`DASH_STREAMS`:return u&&(n.mp4&&l||n.webm&&(i.vp9||i.av1)&&(i.opus||i.aac));case`DASH_LIVE`:return u&&n.mp4&&l;case`DASH_LIVE_CMAF`:return u&&n.mp4&&l&&n.cmaf;case`DASH_ONDEMAND`:return u&&n.mp4&&l;case`HLS`:case`HLS_ONDEMAND`:case`HLS_FMP4`:case`HLS_LIVE`:case`HLS_LIVE_CMAF`:return a&&!c;case`MPEG`:return n.mp4;case`DASH`:case`DASH_LIVE_WEBM`:return!1;case`WEB_RTC_LIVE`:return r.webrtc&&r.ws&&i.h264&&(n.mp4||n.webm);default:return $e(e)}})},Nt=e=>{switch(e){case`MPEG`:case`DASH`:case`DASH_SEP`:case`DASH_ONDEMAND`:case`DASH_WEBM`:case`DASH_WEBM_AV1`:case`DASH_STREAMS`:case`HLS`:case`HLS_FMP4`:case`HLS_ONDEMAND`:return!1;case`DASH_LIVE`:case`DASH_LIVE_CMAF`:case`HLS_LIVE`:case`HLS_LIVE_CMAF`:case`DASH_LIVE_WEBM`:case`WEB_RTC_LIVE`:return!0;default:return $e(e)}},Pt=(e,t=!1)=>Mt(Object.keys(e).filter(e=>!Nt(e)),t).length>0;class Ft{constructor(e){this.subscription=new Re,this.log=void 0,this.params=void 0,this.sessionId$=new ze(null),this.mediaSessionId$=new ze(null),this.contentId$=new ze(null),this.progressTicker=void 0,this.isMobile=st(),this.mobileVolumeState={muted:!1,volume:0},this.media=null,this.lastRequestedVolume=null,this.syncMediaState=e=>{if(Ie(e))return;this.media=e,this.mediaSessionId$.next(e.mediaSessionId??null);let t=e.media?.contentId;t&&this.contentId$.next(t),this.syncPlaybackState(e);let n=e.media?.duration;Fe(n)&&this.params.output.duration$.next(Math.max(0,n));let r=e.currentTime;if(Fe(r)){this.params.desiredState.seekState.getState().state===`applying`&&this.params.output.seekedEvent$.next(),this.params.output.position$.next(r);let t=this.params.output.isLive$.getValue();e.playerState===`PLAYING`&&!t?this.progressTicker.start(r):this.progressTicker.pause()}},this.params=e,this.progressTicker=new Qe(e),this.log=this.params.dependencies.logger.createComponentLog(`ChromecastPresentationApiProvider`),this.log({message:`constructor, format: ${e.format}`}),this.params.output.isLive$.next(Nt(e.format)),this.subscribe()}subscribe(){let e=e=>{this.params.output.error$.next({category:Me.WTF,id:`ChromecastPresentationApiProvider`,message:e?.message??`Unknown error`,thrown:e})};this.subscription.add(this.params.chromecastConnector.message$.pipe(Ne(e=>!!e)).subscribe(e=>{this.handleMessage(e)},e)),this.subscription.add(this.sessionId$.pipe(Ne(Fe),Pe(),je(0)).subscribe(()=>{this.loadMedia()},e));let t=this.contentId$.pipe(Pe(),Le(Boolean));this.subscription.add(Ae({seekState:this.params.desiredState.seekState.stateChangeEnded$,mediaLoaded:t}).pipe(Ne(({mediaLoaded:e})=>e)).subscribe(()=>{let e=this.params.desiredState.seekState.getState();e.state===`requested`&&this.seek(e.position/1e3)},e));let n=Ae({playbackState:this.params.desiredState.playbackState.stateChangeStarted$,mediaLoaded:t});this.subscription.add(n.pipe(Ne(({mediaLoaded:e})=>e),je(0)).subscribe(()=>{this.syncPlayback()},e)),this.subscription.add(n.pipe(Ne(({mediaLoaded:e,playbackState:{from:t,to:n}})=>!e&&t===`stopped`&&n===`playing`)).subscribe(()=>{this.loadMedia()},e)),this.subscription.add(Ae({volumeState:this.params.desiredState.volume.stateChangeStarted$.pipe(je(30)),mediaLoaded:t}).pipe(Ne(({mediaLoaded:e})=>e)).subscribe(({volumeState:e})=>{let{muted:t,volume:n}=e.to;this.setVolume(n,t)},e))}handleMessage(e){switch(e.type){case`new_session`:case`update_session`:{var t;this.sessionId$.next(e.message.sessionId);let n=(t=e.message)==null||(t=t.media)==null?void 0:t[0];this.syncMediaState(n);let r=e.message?.receiver.volume;this.syncVolumeState(r)}break;case`v2_message`:switch(e.message?.type){case`MEDIA_STATUS`:{var n;let t=(n=e.message)==null||(n=n.status)==null?void 0:n[0];this.syncMediaState(t);break}}break}}loadMedia(){let e=qe(this.params),t=this.media?.currentTime,n=this.params.desiredState.seekState.getState(),r=t??(n.state===`none`?0:n.position/1e3),i=this.params.desiredState.playbackState.getState()===`playing`;this.params.chromecastConnector.sendV2Message({type:`LOAD`,requestId:0,media:e,autoplay:i,currentTime:r,customData:null,activeTrackIds:null}),this.params.output.willSeekEvent$.next()}stop(){this.params.chromecastConnector.stopMedia()}play(){let e=this.mediaSessionId$.getValue();ke(e,`play on null mediaSessionId`),this.params.chromecastConnector.sendV2Message({type:`PLAY`,mediaSessionId:e,customData:null})}pause(){let e=this.mediaSessionId$.getValue();ke(e,`pause on null mediaSessionId`),this.params.chromecastConnector.sendV2Message({type:`PAUSE`,mediaSessionId:e,customData:null})}seek(e){let t=this.mediaSessionId$.getValue();ke(t,`seek on null mediaSessionId`),this.params.chromecastConnector.sendV2Message({type:`SEEK`,currentTime:e,mediaSessionId:t}),this.params.output.willSeekEvent$.next()}setVolume(e,t){let n=e,r=`[setVolume] volume: ${e}, muted: ${t}`;this.isMobile&&(n=this.mobileVolumeState.volume,r+=`, mobile next volume: ${n}`),this.log({message:r}),this.lastRequestedVolume={volume:n,muted:t},this.params.chromecastConnector.sendV2Message({type:`SET_VOLUME`,requestId:0,volume:{level:t?0:n,muted:t?!0:null}})}syncPlaybackState({playerState:e,idleReason:t}){let n=this.params.output.isBuffering$.getValue(),r=e===`BUFFERING`;switch(n!==r&&this.params.output.isBuffering$.next(r),e){case`PAUSED`:k(this.params.desiredState.playbackState,`paused`);break;case`PLAYING`:k(this.params.desiredState.playbackState,`playing`);break;case`IDLE`:t===`FINISHED`?(this.params.output.endedEvent$.next(),k(this.params.desiredState.playbackState,`stopped`),this.contentId$.next(null)):k(this.params.desiredState.playbackState,`ready`);break;case`BUFFERING`:break}}syncPlayback(){let e=this.params.desiredState.playbackState.getState();switch(this.log({message:`[syncPlayback] ${e}`}),e){case`ready`:break;case`playing`:this.play();break;case`paused`:this.pause();break;case`stopped`:this.stop();break}}syncVolumeState(e){if(Ie(e))return;let{level:t,muted:n}=e,r={muted:n??!1,volume:t??0};this.lastRequestedVolume&&=(n&&(r.volume=this.lastRequestedVolume.volume),this.lastRequestedVolume.muted&&!t&&!n&&(r.volume=this.lastRequestedVolume.volume,r.muted=!0),null);let i=`[syncVolumeState] volume: ${r.volume}, muted: ${r.muted}`;this.isMobile&&(this.mobileVolumeState.volume=r.volume,this.mobileVolumeState.muted=r.muted,r.volume=this.params.output.volume$.getValue().volume,i+=`, volume passed to state machine: ${r.volume}`),this.log({message:i}),this.params.output.volume$.next(r)}destroy(){this.progressTicker.destroy(),this.subscription.unsubscribe()}}var Gt=e=>({castDevice:{friendlyName:e},remotePlayer:{},remotePlayerController:{},session:{}}),Kt=()=>String(Date.now())+String(Math.floor(Math.random()*1e5));class qt{constructor(e){this.params=void 0,this.clientId=void 0,this.capabilities=[`WEB`],this.presentationRequest$=new Ht(null),this.log=void 0,this.sessionId$=new Ht(null),this.broadcastChannel=new BroadcastChannel(`vk_player_chromecast_events`),this.subscription=new Bt,this.subscriptionEvents=new Bt,this.isDestroyed=!1,this.sequenceNumber=0,this.presentationAvailable$=new Ht(!1),this.presentationConnection$=new Ht(null),this.message$=new Ht(null),this.friendlyName$=new Ht(null),this.errorEvent$=new zt,this.clientId=this.getClientId(),this.params=e,this.log=e.logger.createComponentLog(`ChromecastPresentationApiConnector`),this.log({message:`constructor`}),this.safeReinitPresentation(),this.subscribe()}destroy(){this.log({message:`destroy`}),this.subscription.unsubscribe(),this.subscriptionEvents.unsubscribe(),this.broadcastChannel.close(),this.isDestroyed=!0}disconnect(e=!0){this.log({message:`disconnect`}),e&&this.stopMedia(),this.presentationRequest$.next(null);let t=this.presentationConnection$.getValue();t&&t.close(),this.presentationConnection$.next(null),this.friendlyName$.next(null),this.resetSequenceNumber(),this.resetSubscriptionEvents()}stopMedia(){this.log({message:`stopMedia`}),this.sendV2Message({type:`STOP`})}reinitPresentation(e=!0){let t=this.createCastUrl(),n=new PresentationRequest(t);this.presentationRequest$.next(n),this.log({message:`PresentationRequest created`}),n.getAvailability().then(e=>{let t=()=>{this.log({message:`PresentationRequest presentation availability: ${e.value}`}),this.presentationAvailable$.next(e.value)};this.subscriptionEvents.add(Ut(e,`change`).subscribe(()=>{t()})),t()}).catch(()=>{this.presentationAvailable$.next(!0)}),Wt().navigator.presentation.defaultRequest=n,e&&n.reconnect(`auto-join`).then(e=>{this.log({message:`PresentationRequest reconnect success`}),this.handleConnection(e)}).catch(()=>{this.log({message:`PresentationRequest reconnect failed`})})}safeReinitPresentation(e){try{this.reinitPresentation(e)}catch(e){this.errorEvent$.next({category:Lt.WTF,id:`ChromecastPresentationApiConnector`,message:e?.message??`reinitPresentation error`,thrown:e})}}connect(){var e=this;return w(function*(){e.log({message:`connect`});try{e.presentationRequest$.getValue()||(e.log({message:`reinitPresentation`}),e.reinitPresentation(!1));let t=e.presentationRequest$.getValue();It(t,`connect with null presentationRequest`);let n=yield t.start();e.handleConnection(n)}catch(t){switch(t?.name){case`AbortError`:case`NotAllowedError`:break;default:e.errorEvent$.next({category:Lt.WTF,id:`ChromecastPresentationApiConnector`,message:t?.message??`connect error`,thrown:t});break}}})()}subscribe(){this.subscription.add(Ut(this.broadcastChannel,`message`).subscribe(e=>{this.log({message:`broadcast connection data: ${e.data}`}),e.data===`connection`&&this.disconnect(!1)})),this.subscription.add(this.presentationAvailable$.subscribe(e=>{this.log({message:`presentationAvailable$: ${e}`})})),this.subscription.add(this.presentationConnection$.pipe(Vt(e=>{this.log({message:`presentationConnection$: ${!!e}`})}),Rt(e=>!!e)).subscribe(e=>{let t=Ut(e,`message`).subscribe(e=>{let t=JSON.parse(e.data);t.clientId===this.clientId&&(this.log({message:`[onmessage] ${e.data}`}),this.handleMessage(t),this.message$.next(t))}),n=Ut(e,`connect`).subscribe(()=>{this.send(`client_connect`)}),r=Ut(e,`close`).subscribe(e=>{switch(e.reason){case`error`:this.errorEvent$.next({category:Lt.WTF,id:`ChromecastPresentationApiConnector`,message:`Session error`,thrown:e});break;case`closed`:break}});this.subscriptionEvents.add(t),this.subscriptionEvents.add(n),this.subscriptionEvents.add(r)}))}send(e){switch(e){case`client_connect`:{let e={type:`client_connect`,message:this.clientId,sequenceNumber:-1,timeoutMillis:0,clientId:this.clientId};this.safeSend(JSON.stringify(e));break}}}sendV2Message(e){let t=this.sessionId$.getValue();if(t){let n={type:`v2_message`,sequenceNumber:this.getSequenceNumber(),timeoutMillis:0,clientId:this.clientId,message:T(T({},e),{},{sessionId:t})};this.safeSend(JSON.stringify(n))}}safeSend(e){try{this.log({message:`[send] ${e}`});let t=this.presentationConnection$.getValue();t?.state===`connected`&&t?.send(e)}catch(t){this.errorEvent$.next({category:Lt.WTF,id:`ChromecastPresentationApiConnector`,message:`PresentationConnection send error`,data:{message:e},thrown:t})}}handleMessage(e){switch(e.type){case`new_session`:case`update_session`:this.sessionId$.next(e.message.sessionId),this.friendlyName$.next(e.message.receiver.friendlyName||`Chromecast Device`);break;case`receiver_action`:e.message?.action===`stop`&&this.disconnect();break}}createCastUrl(){return`cast:${this.params.appId}?clientId=${this.clientId}&autoJoinPolicy=tab_and_origin_scoped&defaultActionPolicy=create_session&launchTimeout=60000&supportedAppTypes=${this.capabilities}&appParams=%7B%22launchCheckerParams%22%3A%7B%7D%7D`}getSequenceNumber(){let e=this.sequenceNumber;return this.sequenceNumber=(this.sequenceNumber+1)%(2**53-1),e}resetSequenceNumber(){this.sequenceNumber=0}getClientId(){let e=`__vk_player_chromecast_id`;return Wt()[e]=Wt()[e]||Kt()}resetSubscriptionEvents(){this.subscriptionEvents.unsubscribe(),this.subscriptionEvents=new Bt}handleConnection(e){this.log({message:`connection available`}),this.isDestroyed?(this.log({message:`connected on already destroyed component`}),e.close()):(this.broadcastChannel.postMessage(`connection`),this.presentationConnection$.next(e))}}class tn{static isSupported(){return`chrome`in window&&`presentation`in navigator&&`BroadcastChannel`in window}constructor(e){this.subscription=new Zt,this.log=void 0,this.contentId=void 0,this.connection$=new Jt(void 0),this.castState$=new Jt(`NOT_AVAILABLE`),this.errorEvent$=new Yt,this.chromecastConnector=void 0;let t=tn.isSupported();this.log=e.dependencies.logger.createComponentLog(`ChromecastPresentationApiInitializer`),this.log({message:`[constructor] receiverApplicationId: ${e.receiverApplicationId}, isDisabled: ${e.isDisabled}, isSupported: ${t}`}),!(!t||e.isDisabled||!e.receiverApplicationId)&&(this.chromecastConnector=new qt({appId:e.receiverApplicationId,logger:e.dependencies.logger}),this.subscribe())}subscribe(){en(this.chromecastConnector,`subscribe with null chromecastConnector`),this.subscription.add(this.chromecastConnector.errorEvent$.subscribe(this.errorEvent$));let e=Qt({connection:this.chromecastConnector.presentationConnection$,available:this.chromecastConnector.presentationAvailable$,friendlyName:this.chromecastConnector.friendlyName$.pipe($t())});this.subscription.add(e.pipe(Xt(({connection:e,friendlyName:t})=>!!(e&&t)),$t()).subscribe(e=>{let t=this.chromecastConnector?.friendlyName$.getValue()??``;this.connection$.next(e?Gt(t):void 0)})).add(e.subscribe(({available:e,connection:t})=>{e?t?this.castState$.next(`CONNECTED`):this.castState$.next(`AVAILABLE`):this.castState$.next(`NOT_AVAILABLE`)}))}connect(){this.log({message:`connect`}),this.chromecastConnector?.connect()}disconnect(){this.log({message:`disconnect`}),this.chromecastConnector?.disconnect()}stopMedia(){var e=this;return w(function*(){e.log({message:`stopMedia`}),e.chromecastConnector?.stopMedia()})()}toggleConnection(){let e=!!this.chromecastConnector?.presentationConnection$.getValue();this.log({message:`toggleConnection: isConnected - ${e}`}),e?this.disconnect():this.connect()}setVolume(e){}setMuted(e){}destroy(){this.log({message:`destroy`}),this.chromecastConnector?.destroy(),this.subscription.unsubscribe()}}var un=(e,t)=>e===t;class dn{constructor(e,t=un){this.comparator=void 0,this.state=void 0,this.prevState=void 0,this.transition=void 0,this.transitionStarted$=new cn,this.transitionEnded$=new cn,this.transitionUpdated$=new cn,this.forceChanged$=new cn,this.stateChangeStarted$=ln(this.transitionStarted$,this.transitionUpdated$),this.stateChangeEnded$=ln(this.transitionEnded$,this.forceChanged$),this.comparator=t,this.state=e,this.prevState=void 0}setState(e){let t=this.transition,n=this.state;this.transition=void 0,this.prevState=n,this.state=e,t?this.comparator(t.to,e)?this.transitionEnded$.next(t):this.forceChanged$.next({from:t.from,to:e,canceledTransition:t}):this.forceChanged$.next({from:n,to:e,canceledTransition:t})}startTransitionTo(e){let t=this.transition,n=this.state;this.comparator(n,e)||sn(t)&&this.comparator(t.to,e)||(this.prevState=n,this.state=e,t?(this.transition={from:t.from,to:e,canceledTransition:t},this.transitionUpdated$.next(this.transition)):(this.transition={from:n,to:e},this.transitionStarted$.next(this.transition)))}getTransition(){return this.transition}getState(){return this.state}getPrevState(){return this.prevState}}var Sn=5,Cn=5,wn=500,Tn=7e3;class En{constructor(e){this.subscription=new bn,this.loadMediaTimeoutSubscription=new bn,this.videoState=new dn(`stopped`),this.params=void 0,this.log=void 0,this.syncPlayback=()=>{let e=this.videoState.getState(),t=this.videoState.getTransition(),n=this.params.desiredState.playbackState.getState(),r=this.params.desiredState.playbackState.getTransition(),i=this.params.desiredState.seekState.getState();if(this.log({message:`[syncPlayback] videoState: ${e}; videoTransition: ${JSON.stringify(t)}; desiredPlaybackState: ${n}; desiredPlaybackStateTransition: ${this.params.desiredState.playbackState.getTransition()}; seekState: ${JSON.stringify(i)};`}),n===`stopped`){e!==`stopped`&&(this.videoState.startTransitionTo(`stopped`),this.stop());return}if(!t){if(r?.to!==`paused`&&i.state===`requested`&&e!==`stopped`){this.seek(i.position/1e3);return}switch(n){case`ready`:switch(e){case`playing`:case`paused`:case`ready`:break;case`stopped`:this.videoState.startTransitionTo(`ready`),this.prepare();break;default:fn(e)}break;case`playing`:switch(e){case`playing`:break;case`paused`:this.videoState.startTransitionTo(`playing`),this.params.connection.remotePlayerController.playOrPause();break;case`ready`:this.videoState.startTransitionTo(`playing`),this.params.connection.remotePlayerController.playOrPause();break;case`stopped`:this.videoState.startTransitionTo(`ready`),this.prepare();break;default:fn(e)}break;case`paused`:switch(e){case`playing`:this.videoState.startTransitionTo(`paused`),this.params.connection.remotePlayerController.playOrPause();break;case`paused`:break;case`ready`:this.videoState.startTransitionTo(`paused`),this.videoState.setState(`paused`);break;case`stopped`:this.videoState.startTransitionTo(`ready`),this.prepare();break;default:fn(e)}break;default:fn(n)}}},this.params=e,this.log=this.params.dependencies.logger.createComponentLog(`ChromecastProvider`),this.log({message:`constructor, format: ${e.format}`}),this.params.output.isLive$.next(Nt(e.format)),this.params.output.isAudioAvailable$.next(!0),this.handleRemoteVolumeChange({volume:this.params.connection.remotePlayer.volumeLevel,muted:this.params.connection.remotePlayer.isMuted});let 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);let e=new bn;this.subscription.add(e),this.subscription.add(_n(this.videoState.stateChangeStarted$.pipe(gn(e=>`stateChangeStarted$ ${JSON.stringify(e)}`)),this.videoState.stateChangeEnded$.pipe(gn(e=>`stateChangeEnded$ ${JSON.stringify(e)}`))).subscribe(e=>this.log({message:`[videoState] ${e}`})));let t=(e,t)=>this.subscription.add(e.subscribe(t));if(this.params.output.isLive$.getValue())this.params.output.position$.next(0),this.params.output.duration$.next(0);else{let t=new yn;e.add(t.pipe(pn(wn)).subscribe(()=>{this.params.output.seekedEvent$.next()}));let n=NaN;e.add(hn(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED).subscribe(e=>{this.logRemoteEvent(e);let r=e.value;this.params.output.position$.next(r),(this.params.desiredState.seekState.getState().state===`applying`||Math.abs(r-n)>Sn)&&t.next(r),n=r})),e.add(hn(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.DURATION_CHANGED).subscribe(e=>{this.logRemoteEvent(e),this.params.output.duration$.next(e.value)}))}t(hn(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED),t=>{this.logRemoteEvent(t),t.value?this.handleRemoteReady():(this.handleRemoteStop(),e.unsubscribe())}),t(hn(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED),e=>{this.logRemoteEvent(e),e.value?this.handleRemotePause():this.handleRemotePlay()}),t(hn(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED),e=>{this.logRemoteEvent(e);let{remotePlayer:t}=this.params.connection,n=e.value,r=this.params.output.isBuffering$.getValue(),i=n===chrome.cast.media.PlayerState.BUFFERING;switch(r!==i&&this.params.output.isBuffering$.next(i),n){case chrome.cast.media.PlayerState.IDLE:!this.params.output.isLive$.getValue()&&t.duration-t.currentTime<Cn&&this.params.output.endedEvent$.next(),this.handleRemoteStop(),k(this.params.desiredState.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:fn(n)}}),t(hn(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED),e=>{this.logRemoteEvent(e),this.handleRemoteVolumeChange({volume:e.value})}),t(hn(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED),e=>{this.logRemoteEvent(e),this.handleRemoteVolumeChange({muted:e.value})}),t(_n(this.params.desiredState.playbackState.stateChangeStarted$,this.params.desiredState.seekState.stateChangeEnded$,this.videoState.stateChangeEnded$,vn([`init`])).pipe(pn(0)),this.syncPlayback)}restoreSession(e){this.log({message:`restoreSession`});let{remotePlayer:t}=this.params.connection;if(e.playerState!==chrome.cast.media.PlayerState.IDLE){t.isPaused?(this.videoState.setState(`paused`),k(this.params.desiredState.playbackState,`paused`)):(this.videoState.setState(`playing`),k(this.params.desiredState.playbackState,`playing`));let e=this.params.output.isLive$.getValue();this.params.output.duration$.next(e?0:t.duration),this.params.output.position$.next(e?0:t.currentTime),this.params.desiredState.seekState.setState({state:`none`})}}prepare(){let e=this.params.format;this.log({message:`[prepare] format: ${e}`});let t=qe(this.params),n=this.createLoadRequest(t);this.loadMedia(n)}handleRemotePause(){let e=this.videoState.getState();(this.videoState.getTransition()?.to===`paused`||e===`playing`)&&(this.videoState.setState(`paused`),k(this.params.desiredState.playbackState,`paused`))}handleRemotePlay(){let e=this.videoState.getState();(this.videoState.getTransition()?.to===`playing`||e===`paused`)&&(this.videoState.setState(`playing`),k(this.params.desiredState.playbackState,`playing`))}handleRemoteReady(){this.videoState.getTransition()?.to===`ready`&&this.videoState.setState(`ready`),this.params.desiredState.playbackState.getTransition()?.to===`ready`&&k(this.params.desiredState.playbackState,`ready`)}handleRemoteStop(){this.videoState.getState()!==`stopped`&&this.videoState.setState(`stopped`)}handleRemoteVolumeChange(e){let t=this.params.output.volume$.getValue(),n={volume:e.volume??t.volume,muted:e.muted??t.muted};(n.volume!==t.volume||n.muted!==n.muted)&&this.params.output.volume$.next(n)}seek(e){this.params.output.willSeekEvent$.next();let{remotePlayer:t,remotePlayerController:n}=this.params.connection;t.currentTime=e,n.seek()}stop(){let{remotePlayerController:e}=this.params.connection;e.stop()}createLoadRequest(e){let t=new chrome.cast.media.LoadRequest(e);t.autoplay=!1;let n=this.params.desiredState.seekState.getState();return n.state===`applying`||n.state===`requested`?t.currentTime=this.params.output.isLive$.getValue()?0:n.position/1e3:t.currentTime=0,t}loadMedia(e){let t=this.params.connection.session.loadMedia(e),n=new Promise((e,t)=>{this.loadMediaTimeoutSubscription.add(xn(Tn).subscribe(()=>t(`timeout(${Tn})`)))});on(Promise.race([t,n]).then(()=>{this.log({message:`[loadMedia] completed, format: ${this.params.format}`}),this.params.desiredState.seekState.getState().state===`applying`&&this.params.output.seekedEvent$.next(),this.handleRemoteReady()},e=>{let t=`[prepare] loadMedia failed, format: ${this.params.format}, reason: ${e}`;this.log({message:t}),this.params.output.error$.next({id:`ChromecastProvider.loadMedia`,category:mn.VIDEO_PIPELINE,message:t,thrown:e})}),()=>{this.loadMediaTimeoutSubscription.unsubscribe()})}logRemoteEvent(e){this.log({message:`[remoteEvent] ${JSON.stringify(e)}`})}}var Nn=(e,t)=>{try{e.pause(),e.playbackRate=0,Mn(e,t),e.remove()}catch(e){console.error(e)}},Pn=`__spvc`;class Fn{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)}}var In=An(),Ln=In.WeakMap?new In.WeakMap:new Fn,Rn=In.WeakMap?new In.WeakMap:new Map,zn=(e,t=20)=>{let n=0;return kn(e,`ratechange`).subscribe(r=>{n++,n>=t&&(e.currentTime=e.currentTime,n=0)})};function Bn(e){e.style.position=`fixed`,e.style.left=`100%`,e.setAttribute(`data-role`,`screen`),An().document.body.appendChild(e)}function Vn(e,t){e.style.position=``,e.style.left=``,t.appendChild(e)}var Hn=(e,{audioVideoSyncRate:t,disableYandexPiP:n,clearVideoElementInnerHTML:r,reuseOwnVideoElement:i})=>{let a,o=e.querySelector(`video`),s=!!o,c=An().document.querySelector(`body > video[data-role=screen]`)||void 0;i?In[Pn]=c:(c?.remove(),delete In[Pn]),o?(a=o,On(a,r)):c&&c===In[Pn]?(a=c,Vn(a,e)):(a=An().document.createElement(`video`),e.appendChild(a),i&&(In[Pn]=a)),Ln.set(a,s);let l=new jn;return l.add(zn(a,t)),Rn.set(a,l),a.setAttribute(`crossorigin`,`anonymous`),a.setAttribute(`playsinline`,`playsinline`),n&&a.setAttribute(`x-yandex-pip`,`false`),a.controls=!1,a.setAttribute(`poster`,`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=`),a},Un=e=>(e.setAttribute(`crossorigin`,`anonymous`),e.controls=!1,e),Wn=(e,t)=>{if(e instanceof HTMLAudioElement){Nn(e,!0);return}if(e instanceof HTMLVideoElement){Gn(e,t);return}};function Gn(e,{keepVideoElement:t,clearVideoElementInnerHTML:n,reuseOwnVideoElement:r}){Rn.get(e)?.unsubscribe(),Rn.delete(e);let i=Ln.get(e);Ln.delete(e),i||t?On(e,n):r?(On(e,n),Bn(e)):Nn(e,n)}var lr=(e,t,n,{equal:r=(e,t)=>e===t,changed$:i,onError:a}={})=>{let o=e.getState(),s=t(),c=sr(i),l=new cr;return i&&l.add(i.subscribe(t=>{r(t,e.getState())&&e.setState(t)},a)),r(s,o)||(n(o),c&&e.setState(o)),l.add(e.stateChangeStarted$.subscribe(t=>{n(t.to),c&&e.setState(t.to)},a)),l},ur=(e,t,n)=>lr(t,()=>e.loop,t=>{or(t)&&(e.loop=t)},{onError:n}),dr=(e,t,n,r,i)=>lr(t,()=>({muted:e.muted,volume:e.volume}),t=>{i?.skipVideoElVolumeSync$.getValue()||or(t)&&(e.muted=t.muted,e.volume=t.volume)},{equal:(e,t)=>e===t||e?.muted===t?.muted&&e?.volume===t?.volume,changed$:n,onError:r}),fr=(e,t,n,r)=>lr(t,()=>e.playbackRate,t=>{or(t)&&(e.playbackRate=t)},{changed$:n,onError:r}),pr=lr,mr=e=>[`__`,e.language,e.label].join(`|`),hr=(e,t)=>{if(e.id===t)return!0;let[n,r,i]=t.split(`|`);return e.language===r&&e.label===i};class gr{constructor(e){this.available$=new nr,this.current$=new ir(void 0),this.error$=new nr,this.video=void 0,this.cueSettings=void 0,this.subscription=new rr,this.externalTracks=new Map,this.internalTracks=new Map,this.baseURL=void 0,this.baseURL=e}connect(e,t,n){this.video=e,this.cueSettings=t.textTrackCuesSettings,this.subscribe();let r=e=>{this.error$.next({id:`TextTracksManager`,category:ar.WTF,message:`Generic HtmlVideoTextTrackManager error`,thrown:e})};this.subscription.add(this.available$.subscribe(n.availableTextTracks$)),this.subscription.add(this.current$.subscribe(n.currentTextTrack$)),this.subscription.add(this.error$.subscribe(n.error$)),this.subscription.add(pr(t.internalTextTracks,()=>Kn(this.internalTracks),e=>{Yn(e)&&this.setInternal(e)},{equal:(e,t)=>Yn(e)&&Yn(t)&&e.length===t.length&&e.every(({id:e},n)=>e===t[n].id),changed$:this.available$.pipe(tr(e=>e.filter(({type:e})=>e===`internal`))),onError:r})),this.subscription.add(pr(t.externalTextTracks,()=>Kn(this.externalTracks),e=>{Yn(e)&&this.setExternal(e)},{equal:(e,t)=>Yn(e)&&Yn(t)&&e.length===t.length&&e.every(({id:e},n)=>e===t[n].id),changed$:this.available$.pipe(tr(e=>e.filter(({type:e})=>e===`external`))),onError:r})),this.subscription.add(pr(t.currentTextTrack,()=>{if(this.video)return;let e=this.htmlTextTracksAsArray().find(({mode:e})=>e===`showing`);return e&&this.htmlTextTrackToITextTrack(e).id},e=>this.select(e),{changed$:this.current$,onError:r})),this.subscription.add(pr(t.textTrackCuesSettings,()=>({}),()=>{if(this.video)for(let e of this.htmlTextTracksAsArray())this.applyCueSettings(e.cues),this.applyCueSettings(e.activeCues)}))}subscribe(){Jn(this.video);let{textTracks:e}=this.video;this.subscription.add(Zn(e,`addtrack`).subscribe(()=>{let e=this.current$.getValue();e&&this.select(e)})),this.subscription.add(Qn(Zn(e,`addtrack`),Zn(e,`removetrack`),$n([`init`])).pipe(tr(()=>this.htmlTextTracksAsArray().map(e=>this.htmlTextTrackToITextTrack(e))),er((e,t)=>e.length===t.length&&e.every(({id:e},n)=>e===t[n].id))).subscribe(this.available$)),this.subscription.add(Qn(Zn(e,`change`),$n([`init`])).pipe(tr(()=>this.htmlTextTracksAsArray().find(({mode:e})=>e===`showing`)),tr(e=>e&&this.htmlTextTrackToITextTrack(e).id),er()).subscribe(this.current$));let t=e=>this.applyCueSettings(e.target?.activeCues??null);this.subscription.add(Zn(e,`addtrack`).subscribe(e=>{e.track?.addEventListener(`cuechange`,t);let n=e=>{let t=e.target?.cues??null;t&&t.length&&(this.applyCueSettings(e.target?.cues??null),e.target?.removeEventListener(`cuechange`,n))};e.track?.addEventListener(`cuechange`,n)})),this.subscription.add(Zn(e,`removetrack`).subscribe(e=>{e.track?.removeEventListener(`cuechange`,t)}))}applyCueSettings(e){if(!e||!e.length)return;let t=this.cueSettings.getState();for(let n of Array.from(e)){let e=n;Yn(t.align)&&(e.align=t.align),Yn(t.position)&&(e.position=t.position),Yn(t.size)&&(e.size=t.size),Yn(t.line)&&(e.line=t.line)}}htmlTextTracksAsArray(e=!1){Jn(this.video);let t=[...this.video.textTracks];return e?t:t.filter(gr.isHealthyTrack)}htmlTextTrackToITextTrack(e){let{language:t,label:n}=e,r=e.id?e.id:mr(e),i=this.externalTracks.has(r),a=(i?this.externalTracks.get(r)?.isAuto:this.internalTracks.get(r)?.isAuto)??qn(r,`auto`);return i?{id:r,type:`external`,isAuto:a,language:t,label:n,url:this.externalTracks.get(r)?.url}:{id:r,type:`internal`,isAuto:a,language:t,label:n,url:this.internalTracks.get(r)?.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(([,e])=>this.detach(e)),e.filter(({id:e})=>!this.externalTracks.has(e)).forEach(e=>this.attach(e)),Array.from(this.externalTracks).filter(([t])=>!e.find(e=>e.id===t)).forEach(([,e])=>this.detach(e))}setInternal(e){let t=[...this.externalTracks];e.filter(({id:e,language:n,isAuto:r})=>!this.internalTracks.has(e)&&!t.some(([,e])=>e.language===n&&e.isAuto===r)).forEach(e=>this.attach(e)),Array.from(this.internalTracks).filter(([t])=>!e.find(e=>e.id===t)).forEach(([,e])=>this.detach(e))}select(e){Jn(this.video);for(let e of this.htmlTextTracksAsArray(!0))e.mode=`showing`;for(let t of this.htmlTextTracksAsArray(!0))(Xn(e)||!hr(t,e))&&(t.mode=`disabled`)}destroy(){if(this.subscription.unsubscribe(),this.video)for(let e of Array.from(this.video.getElementsByTagName(`track`))){let t=e.getAttribute(`id`);t&&this.externalTracks.has(t)&&this.video.removeChild(e)}this.externalTracks.clear()}attach(e){Jn(this.video);let t=document.createElement(`track`);this.baseURL?t.setAttribute(`src`,new URL(e.url,this.baseURL).toString()):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){Jn(this.video);let t=Array.prototype.find.call(this.video.getElementsByTagName(`track`),t=>t.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)}}var _r=gr;class vr{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()}}var yr=e=>{let t=e;for(;!(t instanceof Document)&&!(t instanceof ShadowRoot)&&t!==null;)t=t?.parentNode;return t??void 0},br=e=>{let t=yr(e);return!!(t&&t.fullscreenElement&&t.fullscreenElement===e)},xr=e=>{let t=yr(e);return!!(t&&t.pictureInPictureElement&&t.pictureInPictureElement===e)};var Fr=3,Ir=(e,t,n=Fr)=>{let r=0,i=0;for(let a=0;a<e.length;a++){let o=e.start(a),s=e.end(a);if(o<=t&&t<=s){if(r=o,i=s,!n)return{from:r,to:i};for(let t=a-1;t>=0;t--)e.end(t)+n>=r&&(r=e.start(t));for(let t=a+1;t<e.length;t++)e.start(t)-n<=i&&(i=e.end(t))}}return{from:r,to:i}},Lr=e=>{let t=0;for(let n=0;n<e.length;n++)t+=e.end(n)-e.start(n);return t},Rr=e=>{let t=t=>M(e,t).pipe(Or(void 0),N(1)),n=new Pr,r=()=>n.unsubscribe(),i=Cr(M(e,`progress`),M(e,`timeupdate`)).pipe(Sr(()=>Ir(e.buffered,e.currentTime)),N(1)),a=j.browser.isSafari?kr({play:t(`play`).pipe(Ar()),playing:t(`playing`)}).pipe(Or(void 0),N(1)):t(`playing`),o=M(e,`volumechange`).pipe(Sr(()=>({muted:e.muted,volume:e.volume})),N(1)),s=M(e,`ratechange`).pipe(Sr(()=>e.playbackRate),N(1)),c=M(e,`error`).pipe(Dr(()=>!!(e.error||e.played.length)),Sr(()=>{let t=e.error;return{id:t?`MediaError#${t.code}`:`HtmlVideoError`,category:Mr.VIDEO_PIPELINE,message:t?t.message:`Error event from HTML video element`,thrown:e.error??void 0}}),N(1)),l=M(e,`timeupdate`).pipe(Sr(()=>e.currentTime),N(1)),u=Cr(M(e,`loadedmetadata`),M(e,`timeupdate`),M(e,`pause`),M(e,`seeked`),M(e,`ended`)).pipe(Sr(()=>Lr(e.played)),wr(),N(1)),d=[`waiting`,`seeking`,`seeked`,`timeupdate`],f=new Er,p=.3,m;n.add(Cr(...d.map(t=>M(e,t))).subscribe(t=>{let n=e.currentTime;e.loop&&Tr(m)&&Tr(n)&&m>=e.duration-p&&n<=p&&f.next(m),m=n}));let h=t(`pause`).pipe(Dr(()=>!e.error&&m!==e.duration),N(1)),g=M(e,`enterpictureinpicture`).pipe(N(1)),_=M(e,`leavepictureinpicture`).pipe(N(1)),v=new Nr(xr(e));n.add(g.subscribe(()=>v.next(!0))),n.add(_.subscribe(()=>v.next(!1)));let y=new Nr(br(e)),b=M(e,`fullscreenchange`).pipe(N(1));n.add(b.pipe(Sr(()=>br(e))).subscribe(y));let x=M(e,`timeupdate`).pipe(Sr(t=>e.duration-e.currentTime<.1),wr(),N(1)),S=Cr(x.pipe(Dr(t=>!e.loop&&t)),M(e,`ended`)).pipe(jr(1e3),Or(void 0),N(1)),C=Cr(...[`waiting`,`pause`,`canplay`,`play`,`canplaythrough`,`playing`,`seeking`,`seeked`,`ended`].map(t=>M(e,t)),x.pipe(Sr(e=>({type:e?`ended`:`unknown`})))).pipe(Sr(t=>j.browser.isFirefox&&t.type===`ended`?e.readyState<2:e.readyState<3),wr(),N(1));return{playing$:a,pause$:h,canplay$:t(`canplay`),ended$:S,looped$:f,error$:c,seeked$:t(`seeked`),seeking$:t(`seeking`),progress$:t(`progress`),loadStart$:t(`loadstart`),loadedMetadata$:t(`loadedmetadata`),loadedData$:t(`loadeddata`),timeUpdate$:l,durationChange$:M(e,`durationchange`).pipe(Sr(()=>e.duration),N(1)),playedTime$:u,isBuffering$:C,currentBuffer$:i,volumeState$:o,playbackRateState$:s,inPiP$:v,inFullscreen$:y,enterPip$:g,leavePip$:_,destroy:r}};var Br=e=>{switch(e){case`mobile`:return zr.Q_144P;case`lowest`:return zr.Q_240P;case`low`:return zr.Q_360P;case`sd`:case`medium`:return zr.Q_480P;case`hd`:case`high`:return zr.Q_720P;case`fullhd`:case`full`:return zr.Q_1080P;case`quadhd`:case`quad`:return zr.Q_1440P;case`ultrahd`:case`ultra`:return zr.Q_2160P}};var Qr=!1,$r={},ei=e=>{Qr=e},ti=()=>{$r={}},ni=e=>{e($r)},ri=(e,t)=>{Qr&&($r.meta=$r.meta??{},$r.meta[e]=t)};class ii{constructor(e){this.name=void 0,this.name=e}next(e){if(!Qr)return;$r.series=$r.series??{};let t=$r.series[this.name]??[];t.push([Date.now(),e]),$r.series[this.name]=t}}function ui(e,t,n){return!e.max&&e.min===t?`high_quality`:!e.min&&e.max===n?`traffic_saving`:`unknown`}function di(e,t,n){return ci(e)||si(e.min)&&si(e.max)&&oi(e.max,e.min)||si(e.min)&&si(t)&&ai(e.min,t)||si(e.max)&&si(n)&&oi(e.max,n)}function fi({limits:e,highestAvailableHeight:t,lowestAvailableHeight:n}){return di({max:e?.max?li(e.max):void 0,min:e?.min?li(e.min):void 0},t?li(t):void 0,n?li(n):void 0)}var pi=new ii(`best_bitrate`),mi=(e,t,n)=>(t-n)*2**(-10*e)+n,hi=e=>(t,n)=>e*(Number(t.bitrate)-Number(n.bitrate));class gi{constructor(){this.last=void 0,this.history={}}recordSelection(e){this.history[e.id]=Wr()}recordSwitch(e){this.last=e}clear(){this.last=void 0,this.history={}}}var _i=`Assertion "ABR Tracks is empty array" failed`,vi=new WeakMap,yi=new WeakMap,bi=new WeakMap,xi=(e,t,n,r)=>{let i=[...t].sort(hi(1)),a=[...n].sort(hi(1)),o=a.filter(t=>F(t.bitrate)&&F(e.bitrate)?e.bitrate/t.bitrate>r:!0),s=P(a,Math.round(a.length*i.indexOf(e)/(i.length+1)))??P(a,-1);return s&&Vr(o,s)?s:o.length?P(o,-1):P(a,0)},Si=(e,t,n,r)=>{let i=vi.get(t);i||(i=[...t].sort(hi(1)),vi.set(t,i));let a=vi.get(n);a||(a=[...n].sort(hi(1)),vi.set(n,a));let o=bi.get(e);o||(o=a.filter(t=>F(t.bitrate)&&F(e.bitrate)?e.bitrate/t.bitrate>r:!0),bi.set(e,o));let s=P(a,Math.round(a.length*i.indexOf(e)/(i.length+1)))??P(a,-1);return s&&Vr(o,s)?s:o.length?P(o,-1):P(a,0)},Ci=e=>`quality`in e,wi=(e,t,n,r)=>{var i;let a=F(r==null||(i=r.last)==null?void 0:i.bitrate)&&F(n?.bitrate)&&r.last.bitrate<n.bitrate?e.trackCooldownIncreaseQuality:e.trackCooldownDecreaseQuality,o=n&&r&&r.history[n.id]&&Wr()-r.history[n.id]<=a&&(!r.last||n.id!==r.last.id);if(n?.id&&r&&!o&&r.recordSelection(n),o&&r?.last){let e=r.last;return r?.recordSwitch(e),t({message:`
|
|
6
|
+
import{objectEntries as le}from"@vkontakte/videoplayer-shared/es2015";import{objectValues as ue}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as de}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as fe,assertNonNullable as pe,isNonNullable as me,ValueSubject as he,Subject as ge,Subscription as _e,merge as ve,observableFrom as ye,fromEvent as be,map as xe,tap as Se,filterChanged as Ce,isNullable as we,ErrorCategory as Te}from"@vkontakte/videoplayer-shared/es2015";import{assertNonNullable as ke,combine as Ae,debounce as je,ErrorCategory as Me,filter as Ne,filterChanged as Pe,isNonNullable as Fe,isNullable as Ie,map as Le,Subscription as Re,ValueSubject as ze}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as Be,assertNonNullable as Ve,ErrorCategory as He,getHighestQuality as Ue,isNonNullable as We}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as Ge}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as $e}from"@vkontakte/videoplayer-shared/es2015";import{isBrowserWindow as et,ValueSubject as tt}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as nt}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as rt}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as A}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as at,isBrowserWindow as ot}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as lt,isBrowserWindow as ut}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as ft,isBrowserWindow as pt}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as Dt,isBrowserWindow as Ot}from"@vkontakte/videoplayer-shared/es2015";import{assertNonNullable as It,ErrorCategory as Lt,filter as Rt,Subject as zt,Subscription as Bt,tap as Vt,ValueSubject as Ht,fromEvent as Ut,getWindow as Wt}from"@vkontakte/videoplayer-shared/es2015";import{ValueSubject as Jt,Subject as Yt,map as Xt,Subscription as Zt,combine as Qt,filterChanged as $t,assertNonNullable as en}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as nn}from"@vkontakte/videoplayer-shared/es2015";import{objectEntries as rn}from"@vkontakte/videoplayer-shared/es2015";import{objectFromEntries as an}from"@vkontakte/videoplayer-shared/es2015";import{promiseFinally as on}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as sn,Subject as cn,merge as ln}from"@vkontakte/videoplayer-shared/es2015";import"@vkontakte/videoplayer-shared/es2015";import{assertNever as fn,debounce as pn,ErrorCategory as mn,fromEvent as hn,map as gn,merge as _n,observableFrom as vn,Subject as yn,Subscription as bn,timeout as xn}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as Dn}from"@vkontakte/videoplayer-shared/es2015";import{clearVideoElement as On,fromEvent as kn,getWindow as An,Subscription as jn}from"@vkontakte/videoplayer-shared/es2015";import{clearVideoElement as Mn}from"@vkontakte/videoplayer-shared/es2015";import{objectValues as Kn}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as qn}from"@vkontakte/videoplayer-shared/es2015";import{assertNonNullable as Jn,isNonNullable as Yn,isNullable as Xn,fromEvent as Zn,merge as Qn,observableFrom as $n,filterChanged as er,map as tr,Subject as nr,Subscription as rr,ValueSubject as ir,ErrorCategory as ar}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as or,isNullable as sr,Subscription as cr}from"@vkontakte/videoplayer-shared/es2015";import{fromEvent as M,map as Sr,merge as Cr,filterChanged as wr,isNonNullable as Tr,Subject as Er,filter as Dr,mapTo as Or,combine as kr,once as Ar,shareReplay as N,throttle as jr,ErrorCategory as Mr,ValueSubject as Nr,Subscription as Pr}from"@vkontakte/videoplayer-shared/es2015";import{VideoQuality as zr}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as P}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as Vr}from"@vkontakte/videoplayer-shared/es2015";import{objectEntries as Hr}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as F,isNullable as Ur,now as Wr,isHigher as Gr,isHigherOrEqual as Kr,isInvariantQuality as qr,isLowerOrEqual as Jr,videoSizeToQuality as Yr,assertNotEmptyArray as Xr,assertNonNullable as Zr}from"@vkontakte/videoplayer-shared/es2015";import{isHigher as ai,isLower as oi,isNonNullable as si,isNullable as ci,videoHeightToQuality as li}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as Ni,assertNonNullable as Pi,combine as Fi,debounce as Ii,ErrorCategory as Li,filter as Ri,filterChanged as zi,isNonNullable as Bi,map as Vi,merge as Hi,observableFrom as Ui,once as Wi,Subscription as Gi,ValueSubject as Ki,videoQualityToHeight as qi,videoSizeToQuality as Ji}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as Yi}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as Qi,isNullable as $i,assertNonNullable as ea}from"@vkontakte/videoplayer-shared/es2015";import{objectValues as ta}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as na,assertNonNullable as ra,now as ia}from"@vkontakte/videoplayer-shared/es2015";import{objectValues as pa}from"@vkontakte/videoplayer-shared/es2015";import{Subject as ha}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as ga}from"@vkontakte/videoplayer-shared/es2015";import{objectEntries as va}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as ya}from"@vkontakte/videoplayer-shared/es2015";import{objectEntries as Oa}from"@vkontakte/videoplayer-shared/es2015";import{debounce as ka,filter as Aa,fromEvent as ja,interval as Ma,isHigher as Na,isInvariantQuality as Pa,isLower as Fa,merge as Ia,Subject as La,Subscription as Ra}from"@vkontakte/videoplayer-shared/es2015";import{map as Va,Observable as Ha}from"@vkontakte/videoplayer-shared/es2015";import{fromEvent as Ua}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as Ka}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as qa}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as Ja}from"@vkontakte/videoplayer-shared/es2015";import{filter as yo,filterChanged as bo,isNonNullable as xo}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as So,assertNonNullable as Co,debounce as wo,ErrorCategory as To,filter as Eo,filterChanged as Do,fromEvent as Oo,isNonNullable as ko,isNullable as Ao,map as jo,mapTo as Mo,merge as No,observableFrom as Po,once as Fo,Subscription as Io,throttle as Lo}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as Ro}from"@vkontakte/videoplayer-shared/es2015";import{videoSizeToQuality as zo}from"@vkontakte/videoplayer-shared/es2015";import{isNullable as Qo,now as $o,once as es,Subscription as ts,ValueSubject as ns,isNonNullable as rs,safeStorage as is,filterChanged as as}from"@vkontakte/videoplayer-shared/es2015";import{combine as ms,map as hs,observeElementSize as gs,Subscription as _s,ValueSubject as vs,noop as ys}from"@vkontakte/videoplayer-shared/es2015";import{filter as xs,map as Ss,once as Cs}from"@vkontakte/videoplayer-shared/es2015";import{filterChanged as Ts,isNonNullable as Es,isNullable as Ds,now as Os,once as ks,Subscription as As,ValueSubject as js}from"@vkontakte/videoplayer-shared/es2015";import{now as Ps}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as Is,now as Ls}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as Rs}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as zs}from"@vkontakte/videoplayer-shared/es2015";import{isLowerOrEqual as Bs,isNonNullable as Vs,isNullable as Hs}from"@vkontakte/videoplayer-shared/es2015";import{isInvariantQuality as ec,isNullable as tc,Subscription as nc,ValueSubject as rc}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as ic,isNonNullable as ac,isNullable as oc}from"@vkontakte/videoplayer-shared/es2015";import{objectValues as sc}from"@vkontakte/videoplayer-shared/es2015";import{Subscription as cc}from"@vkontakte/videoplayer-shared/es2015";import{Subscription as dc}from"@vkontakte/videoplayer-shared/es2015";import{isHigher as Cc,isInvariantQuality as wc,isNonNullable as Tc}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as Dc}from"@vkontakte/videoplayer-shared/es2015";import{isNullable as kc,timeout as Ac}from"@vkontakte/videoplayer-shared/es2015";import{isHigherOrEqual as Mc,isLowerOrEqual as Nc,isNonNullable as Pc,videoSizeToQuality as Fc}from"@vkontakte/videoplayer-shared/es2015";import{isHigherOrEqual as Lc,isNullable as Rc}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as Vc,isHigherOrEqual as Hc,isNonNullable as Uc}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as Gc}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as Kc}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as Yc,isLowerOrEqual as Xc,isNonNullable as Zc,isNullable as Qc}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as el}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as nl,now as rl}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as ol}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as hl}from"@vkontakte/videoplayer-shared/es2015";import{arrayFlatMap as xl}from"@vkontakte/videoplayer-shared/es2015";import{AbortControllerPolyfilled as Sl}from"@vkontakte/videoplayer-shared/es2015";import{stringTrimStart as Cl}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as wl}from"@vkontakte/videoplayer-shared/es2015";import{abortable as El,assertNonNullable as Dl,ErrorCategory as Ol,filter as kl,filterChanged as Al,flattenObject as jl,fromEvent as Ml,getTraceSubscriptionMethod as Nl,getWindow as Pl,interval as Fl,isNonNullable as Il,isNullable as Ll,map as Rl,merge as zl,now as Bl,Subject as Vl,Subscription as Hl,SubscriptionRemovable as Ul,ValueSubject as z}from"@vkontakte/videoplayer-shared/es2015";import{AbortControllerPolyfilled as Wl}from"@vkontakte/videoplayer-shared/es2015";import{fetchPolyfilled as Gl}from"@vkontakte/videoplayer-shared/es2015";import{abortable as Jl,assertNever as Yl,ErrorCategory as Xl,flattenObject as Zl,fromEvent as Ql,getWindow as $l,merge as eu,now as tu,Subject as nu,Subscription as ru,suppressAbort as iu,ValueSubject as au}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as su}from"@vkontakte/videoplayer-shared/es2015";import{devNull as mu,getWindow as hu}from"@vkontakte/videoplayer-shared/es2015";import{stringReplaceAll as Du}from"@vkontakte/videoplayer-shared/es2015";import{objectEntries as Ou}from"@vkontakte/videoplayer-shared/es2015";import{stringPadStart as ku}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as Au}from"@vkontakte/videoplayer-shared/es2015";import{objectValues as ju}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as Mu}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as Nu}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as Fu,isNullable as Iu}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as Lu}from"@vkontakte/videoplayer-shared/es2015";import{AbortControllerPolyfilled as Wu}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as Gu}from"@vkontakte/videoplayer-shared/es2015";import{requestIdleCallbackPolyfilled as Ku}from"@vkontakte/videoplayer-shared/es2015";import{abortable as qu,assertNonNullable as Ju,ErrorCategory as Yu,flattenObject as B,fromEvent as Xu,getExponentialDelay as Zu,getWindow as Qu,isAbortError as $u,isHigher as ed,isNonNullable as V,isNullable as H,once as td,Subject as nd,Subscription as rd,ValueSubject as id}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as ad}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as cd}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as zd}from"@vkontakte/videoplayer-shared/es2015";import{assertNonNullable as Bd,isNonNullable as Vd,isNullable as Hd}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as Ud}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as ef}from"@vkontakte/videoplayer-shared/es2015";import{videoSizeToQuality as tf}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as ff,getWindow as pf,isNonNullable as mf,isNullable as hf,now as gf,isAbortError as _f}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as yf,getWindow as bf,isAbortError as xf,isNullable as Sf,now as Cf}from"@vkontakte/videoplayer-shared/es2015";import{arrayFlatMap as Tf}from"@vkontakte/videoplayer-shared/es2015";import{assertNonNullable as Ef,ErrorCategory as Df,isNullable as Of,ValueSubject as kf}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as Mf,fromEvent as Nf,isNullable as Pf,Subject as Ff,Subscription as If,ValueSubject as Lf}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as Rf,ErrorCategory as zf,Subject as Bf}from"@vkontakte/videoplayer-shared/es2015";import{objectValues as qf}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as Jf,isHigher as Yf,isLower as Xf,isLowerOrEqual as Zf,VideoQuality as Qf}from"@vkontakte/videoplayer-shared/es2015";import{assertNonNullable as dp,combine as fp,ErrorCategory as pp,filter as mp,filterChanged as hp,fromEvent as gp,isNonNullable as _p,map as vp,merge as yp}from"@vkontakte/videoplayer-shared/es2015";import{combine as Sp,merge as Cp,filter as wp,filterChanged as Tp,isNullable as Ep,map as Dp,ValueSubject as Op,isNonNullable as kp}from"@vkontakte/videoplayer-shared/es2015";import{isNullable as Ap,ValueSubject as jp}from"@vkontakte/videoplayer-shared/es2015";import{assertNonNullable as Lp,combine as Rp,ErrorCategory as zp,filter as Bp,filterChanged as Vp,fromEvent as Hp,interval as Up,isNonNullable as Wp,isNullable as Gp,map as Kp,now as qp,throttle as Jp}from"@vkontakte/videoplayer-shared/es2015";import{isNullable as Xp,ValueSubject as Zp}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as tm,assertNonNullable as nm,combine as rm,debounce as im,ErrorCategory as am,filter as om,filterChanged as sm,fromEvent as cm,isNonNullable as lm,isNullable as um,map as dm,merge as fm,observableFrom as pm,once as mm,Subscription as hm,throttle as gm,timeout as _m}from"@vkontakte/videoplayer-shared/es2015";import{AbortControllerPolyfilled as vm}from"@vkontakte/videoplayer-shared/es2015";import{arrayFlatMap as ym}from"@vkontakte/videoplayer-shared/es2015";import{abortable as xm,assertNonNullable as Sm,combine as Cm,ErrorCategory as wm,filter as Tm,filterChanged as Em,flattenObject as Dm,fromEvent as Om,getTraceSubscriptionMethod as km,interval as Am,isNonNullable as jm,isNullable as Mm,map as Nm,merge as Pm,now as Fm,Subject as Im,Subscription as Lm,SubscriptionRemovable as Rm,tap as zm,throttle as Bm,ValueSubject as W}from"@vkontakte/videoplayer-shared/es2015";import{AbortControllerPolyfilled as Vm}from"@vkontakte/videoplayer-shared/es2015";import{arrayIncludes as Hm}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as Um}from"@vkontakte/videoplayer-shared/es2015";import{arrayFlatMap as Wm}from"@vkontakte/videoplayer-shared/es2015";import{cancelIdleCallbackPolyfilled as Gm}from"@vkontakte/videoplayer-shared/es2015";import{requestIdleCallbackPolyfilled as Km}from"@vkontakte/videoplayer-shared/es2015";import{promiseFinally as qm}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as Jm,ErrorCategory as Ym,Subject as Xm}from"@vkontakte/videoplayer-shared/es2015";import{abortable as nh,assertNonNullable as G,ErrorCategory as rh,fromEvent as ih,getExponentialDelay as ah,getWindow as oh,isHigher as sh,isNonNullable as ch,isNullable as K,now as lh,once as uh,Subject as dh,Subscription as fh,ValueSubject as ph,isAbortError as mh}from"@vkontakte/videoplayer-shared/es2015";import{AbortControllerPolyfilled as gh}from"@vkontakte/videoplayer-shared/es2015";import{fetchPolyfilled as _h}from"@vkontakte/videoplayer-shared/es2015";import{abortable as vh,assertNever as yh,fromEvent as bh,merge as xh,now as Sh,Subject as Ch,ValueSubject as wh,flattenObject as Th,ErrorCategory as Eh,SubscriptionRemovable as Dh,getWindow as Oh,suppressAbort as kh}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as Ah}from"@vkontakte/videoplayer-shared/es2015";import{devNull as Lh,getWindow as Rh}from"@vkontakte/videoplayer-shared/es2015";import{isNullable as Zh,ValueSubject as Qh}from"@vkontakte/videoplayer-shared/es2015";import{combine as ag,merge as og,filter as sg,filterChanged as cg,isNullable as lg,map as ug,ValueSubject as dg,isNonNullable as fg}from"@vkontakte/videoplayer-shared/es2015";import{fetchPolyfilled as mg}from"@vkontakte/videoplayer-shared/es2015";import{fetchPolyfilled as hg}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as vg,combine as yg,debounce as bg,ErrorCategory as xg,filter as Sg,filterChanged as Cg,isNonNullable as wg,isNullable as Tg,map as Eg,merge as Dg,observableFrom as Og,Subscription as kg,ValueSubject as Ag,VideoQuality as jg}from"@vkontakte/videoplayer-shared/es2015";import{objectFromEntries as Mg}from"@vkontakte/videoplayer-shared/es2015";import{fetchPolyfilled as Ng}from"@vkontakte/videoplayer-shared/es2015";import{videoSizeToQuality as Pg,getExponentialDelay as Fg}from"@vkontakte/videoplayer-shared/es2015";import{AbortControllerPolyfilled as Hg}from"@vkontakte/videoplayer-shared/es2015";import{fetchPolyfilled as Ug}from"@vkontakte/videoplayer-shared/es2015";import{isNonNullable as Wg,Subscription as Gg,throttle as Kg,ValueSubject as qg,Subject as Jg,ErrorCategory as Yg}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as Qg,debounce as $g,ErrorCategory as e_,fromEvent as t_,isNonNullable as n_,isNullable as r_,map as i_,merge as a_,observableFrom as o_,Subscription as s_,ValueSubject as c_,VideoQuality as l_}from"@vkontakte/videoplayer-shared/es2015";import{objectEntries as d_}from"@vkontakte/videoplayer-shared/es2015";import{objectValues as f_}from"@vkontakte/videoplayer-shared/es2015";import{arrayAt as p_}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as m_,assertNonNullable as h_,debounce as g_,ErrorCategory as __,isHigherOrEqual as v_,isLowerOrEqual as y_,isNonNullable as b_,merge as x_,observableFrom as S_,Subscription as C_,map as w_}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as E_,debounce as D_,merge as O_,observableFrom as k_,Subscription as A_,map as j_,ValueSubject as M_,ErrorCategory as N_,VideoQuality as P_}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as F_}from"@vkontakte/videoplayer-shared/es2015";import{assertNever as U_,assertNonNullable as W_,ErrorCategory as G_,filter as K_,isNonNullable as q_,isNullable as J_,map as Y_,merge as X_,once as Z_,Subject as q,Subscription as Q_,ValueSubject as J,flattenObject as $_,devNull as ev,getWindow as tv}from"@vkontakte/videoplayer-shared/es2015";import{Observable as nv,map as rv,Subscription as iv,Subject as av,now as ov,combine as sv}from"@vkontakte/videoplayer-shared/es2015";import{AbortControllerPolyfilled as lv}from"@vkontakte/videoplayer-shared/es2015";import{ErrorCategory as uv,Subscription as dv,combine as fv,filter as pv,once as mv}from"@vkontakte/videoplayer-shared/es2015";import{getWindow as hv}from"@vkontakte/videoplayer-shared/es2015";import{fromEvent as bv,once as xv,combine as Sv,Subscription as Cv,ValueSubject as wv,map as Tv,filter as Ev,isNonNullable as Dv,now as Ov,safeStorage as kv,getWindow as Av}from"@vkontakte/videoplayer-shared/es2015";import{fillWithDefault as Vv,VideoQuality as Hv}from"@vkontakte/videoplayer-shared/es2015";import{assertNonNullable as Gv,combine as Kv,devNull as qv,ErrorCategory as Jv,filter as Y,filterChanged as X,flattenObject as Yv,fromEvent as Xv,getPlayerId as Zv,getTraceSubscriptionMethod as Qv,getWindow as $v,InternalsExposure as ey,isHigher as ty,isInvariantQuality as ny,isNonNullable as ry,isNullable as iy,Logger as ay,map as Z,mapTo as oy,merge as sy,now as cy,once as Q,Subject as $,Subscription as ly,tap as uy,throttle as dy,TracerFactory as fy,ValueSubject as py}from"@vkontakte/videoplayer-shared/es2015";import{merge as my,map as hy,filter as gy,isNonNullable as _y}from"@vkontakte/videoplayer-shared/es2015";import{filter as yy,once as by}from"@vkontakte/videoplayer-shared/es2015";import{requestIdleCallbackPolyfilled as Sy}from"@vkontakte/videoplayer-shared/es2015";import{objectEntries as Cy}from"@vkontakte/videoplayer-shared/es2015";import{cancelIdleCallbackPolyfilled as wy}from"@vkontakte/videoplayer-shared/es2015";import{devNull as Ty,getWindow as Ey}from"@vkontakte/videoplayer-shared/es2015";import{assertNonNullable as Ny}from"@vkontakte/videoplayer-shared/es2015";import{Subscription as Iy,Observable as Ly,Subject as Ry,ValueSubject as zy,VideoQuality as By}from"@vkontakte/videoplayer-shared/es2015";var _oxcModiyy8hh=function(){function e(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function t(t){return function(){var n=this,r=arguments;return new Promise(function(i,a){var o=t.apply(n,r);function s(t){e(o,i,a,s,c,`next`,t)}function c(t){e(o,i,a,s,c,`throw`,t)}s(void 0)})}}function n(e){"@babel/helpers - typeof";return n=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},n(e)}var r=n;function i(e,t){if(r(e)!=`object`||!e)return e;var n=e[Symbol._oxc_toPrimitive];if(n!==void 0){var i=n.call(e,t||`default`);if(r(i)!=`object`)return i;throw TypeError(`@@_oxc_toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var r=n,a=i;function o(e){var t=a(e,`string`);return r(t)==`symbol`?t:t+``}var s=o;function c(e,t,n){return(t=s(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var l=c;function u(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function d(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?u(Object(n),!0).forEach(function(t){l(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):u(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function f(e,t){this.v=e,this.k=t}var p=f;function m(e){return new p(e,0)}var p=f;function h(e){return function(){return new g(e.apply(this,arguments))}}function g(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof p;Promise.resolve(s?o.v:o).then(function(n){if(s){var c=t===`return`?`return`:`next`;if(!o.k||n.done)return r(c,n);n=e[c](n).value}i(a.done?`return`:`normal`,n)},function(e){r(`throw`,e)})}catch(e){i(`throw`,e)}}function i(e,i){switch(e){case`return`:t.resolve({value:i,done:!0});break;case`throw`:t.reject(i);break;default:t.resolve({value:i,done:!1})}(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(a,o){var s={key:e,arg:i,resolve:a,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,i))})},typeof e.return!=`function`&&(this.return=void 0)}g.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},g.prototype.next=function(e){return this._invoke(`next`,e)},g.prototype.throw=function(e){return this._invoke(`throw`,e)},g.prototype.return=function(e){return this._invoke(`return`,e)};function _(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}var v=_;function y(e,t){if(e==null)return{};var n,r,i=v(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.includes(n)||{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}const b=[`url`],x=[`url`],S=[`downloadingItems`],C=[`container`];var w=t,T=d,E=m,D=h,ee=y,te=`2.0.165`,ne;(e=>{e.STOPPED=`stopped`,e.READY=`ready`,e.PLAYING=`playing`,e.PAUSED=`paused`})(ne||={});var re;(e=>{e.MPEG=`MPEG`,e.DASH=`DASH`,e.DASH_SEP=`DASH_SEP`,e.DASH_SEP_VK=`DASH_SEP`,e.DASH_WEBM=`DASH_WEBM`,e.DASH_WEBM_AV1=`DASH_WEBM_AV1`,e.DASH_STREAMS=`DASH_STREAMS`,e.DASH_WEBM_VK=`DASH_WEBM`,e.DASH_ONDEMAND=`DASH_ONDEMAND`,e.DASH_ONDEMAND_VK=`DASH_ONDEMAND`,e.DASH_LIVE=`DASH_LIVE`,e.DASH_LIVE_CMAF=`DASH_LIVE_CMAF`,e.DASH_LIVE_WEBM=`DASH_LIVE_WEBM`,e.HLS=`HLS`,e.HLS_ONDEMAND=`HLS_ONDEMAND`,e.HLS_JS=`HLS`,e.HLS_FMP4=`HLS_FMP4`,e.HLS_LIVE=`HLS_LIVE`,e.HLS_LIVE_CMAF=`HLS_LIVE_CMAF`,e.WEB_RTC_LIVE=`WEB_RTC_LIVE`})(re||={});var ie;(e=>{e.AV1=`av1`,e.VP9=`vp9`,e.AVC1=`avc1`,e.HEV1=`hev1`})(ie||={});var ae;(e=>{e.NOT_AVAILABLE=`NOT_AVAILABLE`,e.AVAILABLE=`AVAILABLE`,e.CONNECTING=`CONNECTING`,e.CONNECTED=`CONNECTED`})(ae||={});var oe;(e=>{e.HTTP1=`http1`,e.HTTP2=`http2`,e.QUIC=`quic`})(oe||={});var se;(e=>{e.NONE=`none`,e.INLINE=`inline`,e.FULLSCREEN=`fullscreen`,e.SECOND_SCREEN=`second_screen`,e.PIP=`pip`,e.INVISIBLE=`invisible`})(se||={});var ce;(e=>{e.TRAFFIC_SAVING=`traffic_saving`,e.HIGH_QUALITY=`high_quality`,e.UNKNOWN=`unknown`})(ce||={});var Ee=e=>new Promise((t,n)=>{let r=document.createElement(`script`);r.setAttribute(`src`,e),r.onload=()=>t(),r.onerror=e=>n(e),document.body.appendChild(r)});class De{constructor(e){this.connection$=new he(void 0),this.castState$=new he(`NOT_AVAILABLE`),this.errorEvent$=new ge,this.contentId=void 0,this.realCastState$=new he(`NOT_AVAILABLE`),this.subscription=new _e,this.log=void 0,this.params=void 0,this.isDestroyed=!1,this.params=e,this.log=this.params.dependencies.logger.createComponentLog(`ChromecastInitializer`);let t=`chrome`in window;if(this.log({message:`[constructor] receiverApplicationId: ${this.params.receiverApplicationId}, isDisabled: ${this.params.isDisabled}, isSupported: ${t}`}),e.isDisabled||!t)return;let n=me(window.chrome?.cast),r=!!window.__onGCastApiAvailable;n?this.initializeCastApi():(window.__onGCastApiAvailable=e=>{delete window.__onGCastApiAvailable,e&&!this.isDestroyed&&this.initializeCastApi()},r||Ee(`https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1`).catch(()=>this.errorEvent$.next({id:`ChromecastLoading`,category:Te.NETWORK,message:`Script loading failed!`})))}connect(){cast.framework.CastContext.getInstance()?.requestSession()}disconnect(){var e;(e=cast.framework.CastContext.getInstance())==null||(e=e.getCurrentSession())==null||e.endSession(!0)}stopMedia(){return new Promise((e,t)=>{var n;(n=cast.framework.CastContext.getInstance())==null||(n=n.getCurrentSession())==null||(n=n.getMediaSession())==null||n.stop(new chrome.cast.media.StopRequest,e,t)})}toggleConnection(){me(this.connection$.getValue())?this.disconnect():this.connect()}setVolume(e){let t=this.connection$.getValue();we(t)||(t.remotePlayer.volumeLevel=e,t.remotePlayerController.setVolumeLevel())}setMuted(e){let t=this.connection$.getValue();we(t)||e!==t.remotePlayer.isMuted&&t.remotePlayerController.muteOrUnmute()}destroy(){this.isDestroyed=!0,this.subscription.unsubscribe()}initListeners(){let e=new cast.framework.RemotePlayer,t=new cast.framework.RemotePlayerController(e),n=cast.framework.CastContext.getInstance();this.subscription.add(be(n,cast.framework.CastContextEventType.SESSION_STATE_CHANGED).subscribe(e=>{switch(e.sessionState){case cast.framework.SessionState.SESSION_STARTED:case cast.framework.SessionState.SESSION_STARTING:case cast.framework.SessionState.SESSION_RESUMED:var t;this.contentId=(t=n.getCurrentSession())==null||(t=t.getMediaSession())==null||(t=t.media)==null?void 0:t.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 fe(e.sessionState)}})).add(ve(be(n,cast.framework.CastContextEventType.CAST_STATE_CHANGED).pipe(Se(e=>{this.log({message:`[cast.framework.RemotePlayerEventType.CAST_STATE_CHANGED]: ${JSON.stringify(e)}`})}),xe(e=>e.castState)),ye([n.getCastState()])).pipe(Ce(),xe(Oe),Se(e=>{this.log({message:`realCastState$: ${e}`})})).subscribe(this.realCastState$)).add(this.realCastState$.subscribe(r=>{let i=r===`CONNECTED`,a=me(this.connection$.getValue());if(i&&!a){var o;let r=n.getCurrentSession();pe(r);let i=r.getCastDevice(),a=(o=r.getMediaSession())==null||(o=o.media)==null?void 0:o.contentId;(we(a)||a===this.contentId)&&(this.log({message:`connection created`}),this.connection$.next({remotePlayer:e,remotePlayerController:t,session:r,castDevice:i}))}else!i&&a&&(this.log({message:`connection destroyed`}),this.connection$.next(void 0));this.castState$.next(r===`CONNECTED`?me(this.connection$.getValue())?`CONNECTED`:`AVAILABLE`:r)}))}initializeCastApi(){let e,t,n;try{e=cast.framework.CastContext.getInstance(),t=chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,n=chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}catch{return}try{e.setOptions({receiverApplicationId:this.params.receiverApplicationId??t,autoJoinPolicy:n}),this.initListeners()}catch(e){this.errorEvent$.next({id:`ChromecastInitializer`,category:Te.EXTERNAL_API,message:`[initializeCastApi] failed`,thrown:e})}}}var Oe=e=>{switch(e){case cast.framework.CastState.NO_DEVICES_AVAILABLE:return`NOT_AVAILABLE`;case cast.framework.CastState.NOT_CONNECTED:return`AVAILABLE`;case cast.framework.CastState.CONNECTING:return`CONNECTING`;case cast.framework.CastState.CONNECTED:return`CONNECTED`;default:return fe(e)}};var O=(e,t=0,n=0)=>{switch(n){case 0:return e.replace(`_offset_p`,t===0?``:`_`+t.toFixed(0));case 1:{if(t===0)return e;let n=new URL(e);return n.searchParams.append(`playback_shift`,t.toFixed(0)),n.toString()}case 2:{let n=new URL(e);return!n.searchParams.get(`offset_p`)&&t===0?e:(n.searchParams.set(`offset_p`,t.toFixed(0)),n.toString())}default:Ge(n)}return e},Ke=(e,t)=>{switch(t){case 0:return NaN;case 1:{let t=new URL(e);return Number(t.searchParams.get(`playback_shift`))}case 2:{let t=new URL(e);return Number(t.searchParams.get(`offset_p`)??0)}default:Ge(t)}},qe=e=>{let{source:t,format:n,meta:r,output:i}=e,a,o,s;switch(n){case`MPEG`:{let e=t[n];Ve(e);let r=Ue(Object.keys(e));Ve(r);let i=e[r];Ve(i),a=i,o=`video/mp4`,s=Je();break}case`HLS`:case`HLS_FMP4`:case`HLS_ONDEMAND`:{let e=t[n];Ve(e),a=e.url,o=`application/x-mpegurl`,s=Je();break}case`DASH_SEP`:case`DASH_ONDEMAND`:case`DASH_WEBM`:case`DASH_WEBM_AV1`:case`DASH_STREAMS`:{let e=t[n];Ve(e),a=e.url,o=`application/dash+xml`,s=Je();break}case`DASH_LIVE_CMAF`:{let e=t[n];Ve(e),a=e.url,o=`application/dash+xml`,s=Ye();break}case`HLS_LIVE`:case`HLS_LIVE_CMAF`:{let e=t[n];Ve(e),a=O(e.url),o=`application/x-mpegurl`,s=Ye();break}case`DASH_LIVE`:case`WEB_RTC_LIVE`:{let e=`Unsupported format for Chromecast`,t=Error(e);throw i.error$.next({id:`ChromecastProvider.createMediaInfo()`,category:He.VIDEO_PIPELINE,message:e,thrown:t}),t}case`DASH`:case`DASH_LIVE_WEBM`:throw Error(`${n} is no longer supported`);default:return Be(n)}let c=Xe(r.videoId??a,o);c.contentUrl=a,c.streamType=s,c.metadata=Ze();let{title:l,subtitle:u}=r;return We(l)&&(c.metadata.title=l),We(u)&&(c.metadata.subtitle=u),c};function Je(){var e;return((e=chrome.cast)==null||(e=e.media)==null||(e=e.StreamType)==null?void 0:e.BUFFERED)??`BUFFERED`}function Ye(){var e;return((e=chrome.cast)==null||(e=e.media)==null||(e=e.StreamType)==null?void 0:e.LIVE)??`LIVE`}function Xe(e,t){var n;return!((n=chrome.cast)==null||(n=n.media)==null)&&n.MediaInfo?new chrome.cast.media.MediaInfo(e,t):{contentId:e,contentType:t,metadata:{title:``,subtitle:``},streamType:Je()}}function Ze(){var e;return!((e=chrome.cast)==null||(e=e.media)==null)&&e.GenericMediaMetadata?new chrome.cast.media.GenericMediaMetadata:{images:[],metadataType:0,releaseDate:``,subtitle:``,title:``,releaseYear:1970,type:0}}var k=(e,t,n=!1)=>{let r=e.getTransition();(n||!r||r.to===t)&&e.setState(t)};class Qe{constructor(e){this.params=void 0,this.interval=0,this.startVideoPosition=void 0,this.startTs=void 0,this.params=e}start(e=0){clearInterval(this.interval),this.startVideoPosition=e,this.startTs=Date.now(),this.interval=window.setInterval(()=>{let e=(Date.now()-this.startTs)/1e3,t=this.startVideoPosition+e;this.params.output.position$.next(t)},1e3)}pause(){clearInterval(this.interval)}destroy(){clearInterval(this.interval)}}class it{constructor(){this._current=void 0,this._current_version=void 0,this._chromeVersion=void 0,this._firefoxVersion=void 0,this._safariVersion=void 0,this._operaVersion=void 0,this._edgeVersion=void 0,this._yandexVersion=void 0,this._isMiuiBrowser=!1}get current(){return this._current}get isChrome(){return this.current===`Chrome`}get isChromiumBased(){return nt([`Chrome`,`Chromium`,`Opera`,`Yandex`,`Edge`,`SamsungBrowser`],this.current)}get isFirefox(){return this.current===`Firefox`}get isSafari(){return this.current===`Safari`}get isOpera(){return this.current===`Opera`}get isEdge(){return this.current===`Edge`}get isYandex(){return this.current===`Yandex`}get isSamsungBrowser(){return this.current===`SamsungBrowser`}get currentVersion(){return this._current_version}get chromeVersion(){return this._chromeVersion}get firefoxVersion(){return this._firefoxVersion}get safariVersion(){return this._safariVersion}get operaVersion(){return this._operaVersion}get edgeVersion(){return this._edgeVersion}get yandexVersion(){return this._yandexVersion}get isMiuiBrowser(){return this._isMiuiBrowser}detect(){let{userAgent:e}=navigator;try{let t=/yabrowser/i.test(e)?`Yandex`:void 0,n=/samsungbrowser/i.test(e)?`SamsungBrowser`:void 0,r=/chrome|crios/i.test(e)?`Chrome`:void 0,i=/chromium/i.test(e)?`Chromium`:void 0,a=/firefox|fxios/i.test(e)?`Firefox`:void 0,o=/webkit|safari|khtml/i.test(e)?`Safari`:void 0,s=/opr\//i.test(e)?`Opera`:void 0,c=/edg/i.test(e)?`Edge`:void 0;this._isMiuiBrowser=/(XiaoMi)|(MiuiBrowser)/i.test(e),this._current=t||n||a||s||c||r||i||o||`Rest`}catch(e){console.error(e)}this.isChrome&&this.detectChromeVersion(),this.isFirefox&&this.detectFirefoxVersion(),this.isSafari&&this.detectSafariVersion(),this.isOpera&&this.detectOperaVersion(),this.isEdge&&this.detectEdgeVersion(),this.isYandex&&this.detectYandexVersion()}detectVersion(e){try{let{userAgent:t}=rt().navigator,n=t.match(e);if(!n)return;let r=n[1],i=parseInt(r,10);if(!isNaN(i))return this._current_version=i,i}catch(e){console.error(e)}}detectChromeVersion(){this._chromeVersion=this.detectVersion(/Chrome\/(\d+\.\d+)/)}detectFirefoxVersion(){this._firefoxVersion=this.detectVersion(/Firefox\/(\d+\.\d+)/)}detectSafariVersion(){this._safariVersion=this.detectVersion(/Version\/(\d+)/)}detectOperaVersion(){this._operaVersion=this.detectVersion(/OPR\/(\d+\.\d+)/)}detectEdgeVersion(){this._edgeVersion=this.detectVersion(/Edg\/(\d+\.\d+)/)}detectYandexVersion(){this._yandexVersion=this.detectVersion(/YaBrowser\/(\d+\.\d+\.\d+)/)}}var st=()=>{var e;return/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test(navigator.appVersion??navigator.userAgent)||((e=navigator)==null||(e=e.userAgentData)==null?void 0:e.mobile)};class ct{constructor(e){this._displayChecker=void 0,this._isMobile=void 0,this._current=void 0,this._iosVersion=void 0,this._highEntropyValues={},this._os={name:`Unknown`,version:`Unknown`,full:`Unknown`},this._details={vendor:`Unknown`,model:`Unknown`},this._displayChecker=e}get current(){return this._current}get os(){return this._os}get details(){return this._details}get isIOS(){return this._highEntropyValues.platform===`iOS`||A(this.os.name.toLowerCase(),`ios`)||A([`iPhone`,`iPad`,`iPod`],this.current)}get isMac(){return this._highEntropyValues.platform===`macOS`||A(this.os.name.toLowerCase(),`mac`)||this.current===`Mac`}get isApple(){return this.isIOS||this.isMac}get isIphoneOrOldIpad(){if(!this.isApple||!this._displayChecker.isTouch)return!1;let e=this.current===`iPad`||this._displayChecker.width>700,t=this._iosVersion;return!e||e&&!!t&&t<16}get isAndroid(){return this._highEntropyValues.platform===`Android`||A(this.os.name.toLowerCase(),`android`)||this.current===`Android`}get isWindows(){return A(this.os.name.toLowerCase(),`windows`)}get isLinux(){return A(this.os.name.toLowerCase(),`linux`)&&!this.isAndroid}get isMobile(){return this._highEntropyValues.mobile||this._isMobile}get iOSVersion(){return this._iosVersion}detect(){let e=at();if(!ot(e))return;let{userAgent:t}=e.navigator;try{this._isMobile=st()}catch(e){console.error(`DeviceChecker: calling isMobile error - `,e)}this.detectDevice(t),this.detectOS(t),this.detectDeviceDetails(t),this.detectHighEntropyValues(),this.isIOS&&this.detectIOSVersion()}detectHighEntropyValues(){var e=this;return w(function*(){let t=at();if(!ot(t))return;let{userAgentData:n}=t.navigator;if(n?.getHighEntropyValues){let t=yield n.getHighEntropyValues([`architecture`,`bitness`,`brands`,`mobile`,`platform`,`formFactor`,`model`,`platformVersion`,`wow64`]);e._highEntropyValues=t,t.platform&&(e._os.name=e.normalizeOSName(t.platform),t.platformVersion&&(e._os.version=e.normalizeOSVersion(t.platformVersion),e._os.full=`${e._os.name} ${e._os.version}`)),t.model&&(e._details.model=t.model)}})()}detectDevice(e){try{let t=/android/i.test(e)?`Android`:void 0,n=/iphone/i.test(e)?`iPhone`:void 0,r=/ipad/i.test(e)?`iPad`:void 0,i=/ipod/i.test(e)?`iPod`:void 0,a=/mac/i.test(e)?`Mac`:void 0,o=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(e)?`RestMobile`:void 0;this._current=t||n||r||i||o||a||`Desktop`}catch(e){console.error(`DeviceChecker: device detection error - `,e)}}detectOS(e){try{for(let[t,n]of[[/(windows nt) (6\.[23]); arm/i,[`Windows RT`]],[/(windows nt) (6\.3); arm/i,[`Windows RT 8.1`]],[/(windows (?:phone|mobile|iot))(?: os)?[/ ]?([\d.]+)/i,[`Windows Mobile`,2]],[/(windows)[/ ](xp|vista|7|8(\.1)?|10|11|2000|me)/i,[1,1]],[/windows nt ?([\d.]+)/i,[`Windows`,1]],[/(windows)[/ ](95|98|me|2000|xp|vista|7|8|8\.1|10|11)/i,[1,2]],[/(iphone os|cpu iphone os) ([\d_.]+)/i,[`iOS`,2]],[/(ipad os|cpu os) ([\d_.]+)/i,[`iPadOS`,2]],[/(ipod os|cpu ipod os) ([\d_.]+)/i,[`iOS`,2]],[/(?:ios|os) ([\d_.]+) like mac os x/i,[`iOS`,1]],[/cfnetwork\/.+darwin/i,[`iOS`]],[/(mac os x) ?([\d_.]+)/i,[`macOS`,2]],[/(macintosh|mac os)/i,[`macOS`]],[/(android) ([\d.]+)/i,[1,2]],[/(harmonyos)[/ ]?([\d.]*)/i,[`HarmonyOS`,2]],[/\b(ubuntu|debian|fedora|centos|arch|linux)(?:[-/ ]([\w.]+))?/i,[1,2]],[/(cros)\D*([\d.]+)/i,[`Chrome OS`,2]],[/(freebsd|openbsd|netbsd|dragonfly)[/ ]?([\w.]*)/i,[1,2]],[/(sunos|solaris)?([\d.]*)/i,[`Solaris`,2]],[/(aix)?([\d.]*)/i,[`AIX`,2]]]){let r=e.match(t);if(r){let t=n.length>0,i=n.length>1,a=`Unknown`,o=`Unknown`;if(t){let e=n[0];typeof e==`number`?e<r.length&&r[e]!==void 0&&(a=r[e]):a=e}if(i){let e=n[1];typeof e==`number`?e<r.length&&r[e]!==void 0&&(o=r[e]):e!==void 0&&(o=e)}else r[2]===void 0?r[1]!==void 0&&t&&typeof n[0]==`string`&&(o=r[1]):o=r[2];a=this.normalizeOSName(a),o=this.normalizeOSVersion(o,a),a===`iOS`&&/ipad/i.test(e)?a=`iPadOS`:a===`iPadOS`&&/ip(hone|od)/i.test(e)&&(a=`iOS`),this._os={name:a,version:o||`Unknown`,full:o&&o!==`Unknown`?`${a} ${o}`:a};break}}}catch(e){console.error(`DeviceChecker: OS detection error - `,e)}}normalizeOSName(e){if(!e)return`Unknown`;let t=e.toLowerCase();return A(t,`windows`)?`Windows`:A(t,`mac os`)||A(t,`macintosh`)?`macOS`:A(t,`iphone`)||A(t,`ios`)?`iOS`:A(t,`ipados`)?`iPadOS`:A(t,`android`)?`Android`:A(t,`harmonyos`)?`HarmonyOS`:A(t,`linux`)?`Linux`:A(t,`cros`)?`Chrome OS`:A(t,`freebsd`)?`FreeBSD`:A(t,`openbsd`)?`OpenBSD`:A(t,`solaris`)||A(t,`sunos`)?`Solaris`:A(t,`aix`)?`AIX`:e}normalizeOSVersion(e,t){if(!e)return`Unknown`;if(e!==`Unknown`&&(e=e.replace(/_/g,`.`),t===`Windows`)){let t=parseFloat(e);if(!isNaN(t)){if(t>=11)return`11`;if(t>=10)return`10`;if(t===6.3)return`8.1`;if(t===6.2)return`8`;if(t===6.1)return`7`;if(t===6)return`Vista`;if(t===5.1||t===5.2)return`XP`;if(t===5)return`2000`;if(t===4)return`NT 4.0`}}return e}detectDeviceDetails(e){try{for(let[t,n]of[[/(iphone)/i,[`Apple`,`iPhone`]],[/(ipad)/i,[`Apple`,`iPad`]],[/(ipod)/i,[`Apple`,`iPod`]],[/(macintosh)/i,[`Apple`,`Macintosh`]],[/(windows[\w\-_ ]*phone)/i,[`Microsoft`,0]],[/(windows nt|win64|win32|wow64)/i,[`Microsoft`,`PC`]],[/\b(sch-i[89]0\d|shw-m380s|sm-[ptxs]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i,[`Samsung`,1]],[/\b((?:s[cgp]h|gt|sm)-(?![lr])\w+|sc[g-]?\d+a?|galaxy nexus)/i,[`Samsung`,1]],[/samsung[- ]((?!sm-[lr]|browser)[-\w]+)/i,[`Samsung`,1]],[/sec-(sgh\w+)/i,[`Samsung`,1]],[/smart-tv.+(samsung)/i,[`Samsung`,`Smart TV`]],[/(samsung).*tizen/i,[`Samsung`,`Smart TV`]],[/(pixel (?:c|tablet|[0-9a-z ]+))/i,[`Google`,1]],[/(pixelbook(?: go)?)/i,[`Google`,1]],[/nexus [0-9]/i,[`Google`,0]],[/(redmi[-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,[`Xiaomi`,1]],[/\b(mi[\w\-_ ]+)(?: bui|\))/i,[`Xiaomi`,1]],[/\b(poco[\w ]+)(?: bui|\))/i,[`Xiaomi`,1]],[/\b(hm[-_ ]?note?[\w ]*)(?: bui|\))/i,[`Xiaomi`,1]],[/\b(?:xiao)?mi[\w\-_ ]+pad/i,[`Xiaomi`,0]],[/(?:huawei|honor) ?([-\w ]+)[;)]/i,[`Huawei`,1]],[/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][\dc][adnt]?)\b(?!.+d\/s)/i,[`Huawei`,1]],[/\b((?:ag[rs][2356]?k?|bah[234]?|bg[2o]|bt[kv]|cmr|cpn|db[ry]2?|jdn2|got|kob2?k?|mon|pce|scm|sht?|[tw]gr|vrd)-[ad]?[lw][0125][09]b?)/i,[`Huawei`,1]],[/(?:one)?(?:plus)? ?([a\d0]\d\d\d?)(?: b|\))/i,[`OnePlus`,1]],[/droid.+; (cph2[3-6]\d[13579]|((?:gm|hd)19|(?:ac|be|in|kb)20|(?:d[en]|eb|le|mt)21|ne22)[0-2]\d)(?: bui|\))/i,[`OnePlus`,1]],[/(oneplus)[-_ ]?([-\w]*)/i,[`OnePlus`,2]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i,[`Realme`,1]],[/(realme)[-_ ]?([-\w]*)/i,[`Realme`,2]],[/; (\w+) bui.+ oppo/i,[`OPPO`,1]],[/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i,[`OPPO`,1]],[/\b(opd2(\d{3}a?))(?: bui|\))/i,[`OPPO`,1]],[/(oppo)[-_ ]?([-\w]*)/i,[`OPPO`,2]],[/; vivo (\w+)(?: bui|\))/i,[`Vivo`,1]],[/\b(v[12]\d{3}\w?[at])(?: bui|;)/i,[`Vivo`,1]],[/(vivo)[-_ ]?([-\w]*)/i,[`Vivo`,2]],[/\bmot(?:orola)?[- ]([\w\s]+)(\)| bui)/i,[`Motorola`,1]],[/((?:moto(?! 360)[-\w() ]+|xt\d{3,4}[cgkosw+]?[-\d]*|nexus 6)(?= bui|\)))/i,[`Motorola`,1]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b/i,[`Motorola`,0]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i,[`Motorola`,0]],[/droid.+; ([a-z]?\d[0-2]{2}[a-z]{2}|[c-g]\d{4}|so[-gl]\w+|xq-[a-z]{2}\d\d)(?= bui|\))/i,[`Sony`,1]],[/sony tablet [ps]/i,[`Sony`,`Xperia Tablet`]],[/\b(?:sony)?sgp\w+(?: bui|\))/i,[`Sony`,0]],[/(sony)[-_ ]?([-\w]*)/i,[`Sony`,2]],[/\blg[-e;/ ]+(?!.*(?:browser|netcast|android tv|watch|webos))(\w+)/i,[`LG`,1]],[/\blg-?([\d\w]+) bui/i,[`LG`,1]],[/(lm(?:-?f100[nv]?|-[\w.]+)(?= bui|\))|nexus [45])/i,[`LG`,1]],[/((?=lg)?[vl]k-?\d{3}) bui/i,[`LG`,0]],[/(lg)[-_ ]?([-\w]*)/i,[`LG`,2]],[/(?:maemo|nokia).*(n900|lumia \d+|rm-\d+)/i,[`Nokia`,1]],[/nokia[-_ ]?(([-\w. ]*?))(?: bui|\)|;|\/)/i,[`Nokia`,1]],[/(nokia) (t[12][01])/i,[`Nokia`,2]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i,[`ASUS`,1]],[/(?:asus[-_ ])?(zenfone[\w\-_ ]*)/i,[`ASUS`,1]],[/(rog[\w\-_ ]*)/i,[`ASUS`,1]],[/(asus)[-_ ]?([-\w]*)/i,[`ASUS`,2]],[/lenovo[-_ ]?([-\w ]+?)(?: bui|\)|\/)/i,[`Lenovo`,1]],[/(ideatab[-\w ]+|602lv|d-42a|a101lv|a2109a|a3500-hv|s[56]000|pb-6505[my]|tb-?x?\d{3,4}(?:f[cu]|xu|[av])|yt\d?-[jx]?\d+[lfmx])(?: bui|;|\)|\/)/i,[`Lenovo`,1]],[/(thinkpad[\w\-_ ]*)/i,[`Lenovo`,0]],[/(kf[a-z]{2}[a-z]*)(?: bui|\))/i,[`Amazon`,1]],[/(alexa)webm/i,[`Amazon`,`Echo`]],[/(fire[\w\-_ ]*)/i,[`Amazon`,0]],[/(amazon)[-_ ]?([-\w]*)/i,[`Amazon`,2]],[/(?:blackberry|\(bb10;) (\w+)/i,[`BlackBerry`,1]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,[`BlackBerry`,1]],[/(playbook);[-\w),; ]+(rim)/i,[`BlackBerry`,1]],[/(microsoft); (lumia[\w ]+)/i,[`Microsoft`,2]],[/(surface duo)/i,[`Microsoft`,`Surface Duo`]],[/(surface[\w\-_ ]*)/i,[`Microsoft`,0]],[/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,[`ZTE`,2]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,[`HTC`,2]],[/(alcatel|tcl)[-_ ]?([-\w]*)/i,[1,2]],[/(meizu)[-_ ]?([-\w]*)/i,[`Meizu`,2]],[/(tecno)[-_ ]?([-\w]*)/i,[`Tecno`,2]],[/(infinix)[-_ ]?([-\w]*)/i,[`Infinix`,2]],[/(micromax)[-_ ]?([-\w]*)/i,[`Micromax`,2]],[/(lava)[-_ ]?([-\w]*)/i,[`Lava`,2]],[/(panasonic)[-_ ]?([-\w]*)/i,[`Panasonic`,2]],[/(sharp)\/?([-\w]*)/i,[`Sharp`,2]],[/(benq)[-_ ]?([-\w]*)/i,[`BenQ`,2]],[/(palm)[-_ ]?([-\w]*)/i,[`Palm`,2]],[/(vertu)[-_ ]?([-\w]*)/i,[`Vertu`,2]],[/(gionee)[-_ ]?([-\w]*)/i,[`Gionee`,2]],[/(doogee)[-_ ]?([-\w]*)/i,[`Doogee`,2]],[/(ulefone)[-_ ]?([-\w]*)/i,[`Ulefone`,2]],[/(blackview)[-_ ]?([-\w]*)/i,[`Blackview`,2]],[/(cubot)[-_ ]?([-\w]*)/i,[`Cubot`,2]],[/(umidigi)[-_ ]?([-\w]*)/i,[`UMIDIGI`,2]],[/(oukitel)[-_ ]?([-\w]*)/i,[`Oukitel`,2]],[/(fairphone)[-_ ]?([-\w]*)/i,[`Fairphone`,2]],[/(cat)[-_ ]?([-\w]*)/i,[`Cat`,2]],[/(energy)[-_ ]?([-\w]*)/i,[`Energizer`,2]],[/(land rover)[-_ ]?([-\w]*)/i,[`Land Rover`,2]],[/(shield[\w\-_ ]*)/i,[`Nvidia`,0]],[/(crkey)/i,[`Google`,`Chromecast`]],[/(roku)[\dx]*/i,[`Roku`,0]],[/(apple)[-_ ]?tv/i,[`Apple`,`TV`]],[/(amazon)[-_ ]?tv/i,[`Amazon`,`Fire TV`]],[/(google)[-_ ]?tv/i,[`Google`,`TV`]],[/(smart[\w\-_ ]*tv)/i,[0,`Smart TV`]],[/(playstation[\w\-_ ]*)/i,[`Sony`,0]],[/(nintendo[\w\-_ ]*)/i,[`Nintendo`,0]],[/(xbox[\w\-_ ]*)/i,[`Microsoft`,0]],[/(googlebot)/i,[`Google`,`Bot`]],[/(bingbot)/i,[`Microsoft`,`Bing Bot`]],[/(yandexbot)/i,[`Yandex`,`Bot`]],[/(slackbot)/i,[`Slack`,`Bot`]],[/(twitterbot)/i,[`Twitter`,`Bot`]],[/(facebookbot)/i,[`Facebook`,`Bot`]],[/(linkedinbot)/i,[`LinkedIn`,`Bot`]],[/(tesla)[-_ ]?([-\w]*)/i,[`Tesla`,2]],[/(raspberry[\w\-_ ]*)/i,[`Raspberry Pi`,0]]]){let r=e.match(t);if(r){let e=n[0],t=n[1],i=typeof e==`number`?r[e]===void 0?`Unknown`:this.normalizeVendorName(r[e]):this.normalizeVendorName(e),a=`Unknown`;typeof t==`number`?a=r[t]===void 0?`Unknown`:r[t]:t===void 0?r[1]===void 0?r[0]!==void 0&&(a=r[0]):a=r[1]:a=t,a=this.normalizeModelName(a,i),this.details.vendor=i,this.details.model=a;break}}}catch(e){console.error(`DeviceChecker: device details detection error - `,e)}}normalizeVendorName(e){return e?{apple:`Apple`,samsung:`Samsung`,google:`Google`,xiaomi:`Xiaomi`,huawei:`Huawei`,oneplus:`OnePlus`,oppo:`OPPO`,vivo:`Vivo`,realme:`Realme`,motorola:`Motorola`,sony:`Sony`,lg:`LG`,nokia:`Nokia`,asus:`ASUS`,lenovo:`Lenovo`,amazon:`Amazon`,blackberry:`BlackBerry`,microsoft:`Microsoft`,zte:`ZTE`,htc:`HTC`,alcatel:`Alcatel`,tcl:`TCL`,meizu:`Meizu`,tecno:`Tecno`,infinix:`Infinix`,micromax:`Micromax`,lava:`Lava`,panasonic:`Panasonic`,sharp:`Sharp`,benq:`BenQ`,palm:`Palm`,honor:`Honor`,nvidia:`NVIDIA`,roku:`Roku`}[e.toLowerCase()]||e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():`Unknown`}normalizeModelName(e,t){if(!e||e===`Unknown`)return e;if(e===`0`)return`Unknown`;let n=e.replace(/^build\//i,``).replace(/\s+bui$/i,``).replace(/\)$/,``).replace(/[;,)]/g,``).replace(/\s*\(.*?\)\s*/g,``).trim(),r=t.toLowerCase();return A(r,`samsung`)?n=n.replace(/^(sm-|gt-|sgh-|sch-)/i,``):A(r,`xiaomi`)?n=n.replace(/^(mi[\s\-_]*|redmi[\s\-_]*)/i,``):A(r,`oneplus`)?n=n.replace(/^oneplus[\s\-_]*/i,``):A(r,`google`)&&(n=n.replace(/^(pixel[\s\-_]*|nexus[\s\-_]*)/i,``)),n=n.replace(/_/g,` `).replace(/-/g,` `).replace(/\s+/g,` `).trim(),n?(n.length>0&&/^[a-z]/.test(n)&&(n=n.charAt(0).toUpperCase()+n.slice(1)),n):`Unknown`}detectIOSVersion(){try{let e=at();if(!ot(e))return;if(this._highEntropyValues.platformVersion){let e=this._highEntropyValues.platformVersion.split(`.`).slice(0,2).join(`.`);this._iosVersion=parseFloat(e);return}if(this._os.version!==`Unknown`){let e=this._os.version.split(`.`),t=e.length>=2?`${e[0]}.${e[1]}`:e[0];this._iosVersion=parseFloat(t);return}let t=e.navigator.userAgent.match(/OS (\d+(_\d+)?)/i);t?.[1]&&(this._iosVersion=parseFloat(t[1].replace(/_/g,`.`)))}catch(e){console.error(`DeviceChecker: iOS version detection error - `,e)}}}class dt{constructor(){this._maxTouchPoints=void 0,this._height=void 0,this._width=void 0,this._isHdr=void 0,this._pixelRatio=void 0,this._screenHeight=void 0,this._screenWidth=void 0,this._colorDepth=void 0}get isTouch(){return typeof this._maxTouchPoints==`number`?this._maxTouchPoints>1:`ontouchstart`in lt()}get maxTouchPoints(){return this._maxTouchPoints}get height(){return this._height}get width(){return this._width}get screenHeight(){return this._screenHeight}get screenWidth(){return this._screenWidth}get pixelRatio(){return this._pixelRatio}get isHDR(){return this._isHdr}get colorDepth(){return this._colorDepth}detect(){let e=lt();if(!ut(e))return;let{navigator:t,screen:n}=e,{maxTouchPoints:r}=t;try{this._maxTouchPoints=r??0,this._isHdr=!!e.matchMedia(`(dynamic-range: high)`)?.matches,this._colorDepth=n.colorDepth}catch(e){console.error(e)}try{this._pixelRatio=e.devicePixelRatio||1,this._height=n.height,this._width=n.width,this._height=n.height,this._screenHeight=this._height*this._pixelRatio,this._screenWidth=this._width*this._pixelRatio}catch(e){console.error(e)}}}var mt=()=>window.ManagedMediaSource||window.MediaSource,ht=()=>{var e;return!!(window.ManagedMediaSource&&!((e=window.ManagedSourceBuffer)==null||(e=e.prototype)==null)&&e.appendBuffer)},gt=()=>{var e;return!!(window.MediaSource&&!((e=window.SourceBuffer)==null||(e=e.prototype)==null)&&e.appendBuffer)},_t=()=>window.ManagedMediaSource?new ManagedMediaSource:new MediaSource,vt=ft().document?.createElement(`video`),yt=`video/mp4; codecs="avc1.42000a,mp4a.40.2"`,bt=`video/mp4; codecs="hev1.1.6.L93.B0"`,xt=`video/webm; codecs="vp09.00.10.08"`,St=`video/webm; codecs="av01.0.00M.08"`,Ct=`audio/mp4; codecs="mp4a.40.2"`,wt=`audio/webm; codecs="opus"`,Tt;(function(){var e=w(function*(){let e=ft();if(!pt(e)||!(`mediaCapabilities`in e.navigator))return;let t={type:`media-source`,video:{contentType:`video/webm`,width:1280,height:720,bitrate:1e6,framerate:30}},[n,r]=yield Promise.all([e.navigator.mediaCapabilities.decodingInfo(T(T({},t),{},{video:T(T({},t.video),{},{contentType:St})})),e.navigator.mediaCapabilities.decodingInfo(T(T({},t),{},{video:T(T({},t.video),{},{contentType:xt})}))]);Tt={DASH_WEBM_AV1:n,DASH_WEBM:r}});return function(){return e.apply(this,arguments)}})()().catch(e=>{console.log(vt),console.error(e)});class Et{constructor(e,t){this._video=void 0,this._deviceChecker=void 0,this._browserChecker=void 0,this._protocols=void 0,this._containers=void 0,this._codecs=void 0,this._nativeHlsSupported=void 0,this._deviceChecker=e,this._browserChecker=t}get protocols(){return this._protocols}get containers(){return this._containers}get codecs(){return this._codecs}get webmDecodingInfo(){return Tt}get supportedCodecs(){return Object.keys(this._codecs).filter(e=>this._codecs[e])}get nativeHlsSupported(){return this._nativeHlsSupported}detect(){let e=ft();if(!pt(e))return;let t=e.document;this._video=t.createElement(`video`);try{var n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_;this._protocols={mms:ht(),mse:gt(),hls:!!((n=this._video).canPlayType?.call(n,`application/x-mpegurl`)||(r=this._video).canPlayType?.call(r,`vnd.apple.mpegURL`)),webrtc:!!e.RTCPeerConnection,ws:!!e.WebSocket},this._containers={mp4:!!(i=this._video).canPlayType?.call(i,`video/mp4`),webm:!!(a=this._video).canPlayType?.call(a,`video/webm`),cmaf:!0};let t=!!(!((o=mt())==null||(s=o.isTypeSupported)==null)&&s.call(o,yt)),v=!!(!((c=mt())==null||(l=c.isTypeSupported)==null)&&l.call(c,bt)),y=!!(!((u=mt())==null||(d=u.isTypeSupported)==null)&&d.call(u,Ct));this._codecs={h264:t,h265:v,vp9:!!(!((f=mt())==null||(p=f.isTypeSupported)==null)&&p.call(f,xt)),av1:!!(!((m=mt())==null||(h=m.isTypeSupported)==null)&&h.call(m,St)),aac:y,opus:!!(!((g=mt())==null||(_=g.isTypeSupported)==null)&&_.call(g,wt)),mpeg:(t||v)&&y},this._nativeHlsSupported=this._protocols.hls&&this._containers.mp4}catch(e){console.error(e)}try{this.destroyVideoElement()}catch(e){console.error(`Error destroying video element:`,e)}}destroyVideoElement(){if(!this._video)return;if(this._video.pause(),this._video.currentTime=0,this._video.removeAttribute(`src`),this._video.src=``,this._video.load(),this._video.remove){this._video.remove(),this._video=null;return}this._video.parentNode&&this._video.parentNode.removeChild(this._video);let e=this._video.cloneNode(!1);this._video.parentNode?.replaceChild(e,this._video),this._video=null}}var kt=`audio/mpeg`;class At{constructor(){this._audio=void 0,this._containers=void 0,this._codecs=void 0}supportMp3(){return this._codecs.mp3&&this._containers.mpeg}detect(){let e=Dt();if(!Ot(e))return;let t=e.document;this._audio=t.createElement(`audio`);try{var n,r,i;this._containers={mpeg:!!(n=this._audio).canPlayType?.call(n,kt)},this._codecs={mp3:!!(!((r=mt())==null||(i=r.isTypeSupported)==null)&&i.call(r,kt))}}catch(e){console.error(e)}try{this.destroyAudioElement()}catch(e){console.error(`Error destroying audio element:`,e)}}destroyAudioElement(){if(!this._audio)return;if(this._audio.pause(),this._audio.currentTime=0,this._audio.removeAttribute(`src`),this._audio.src=``,this._audio.load(),this._audio.remove){this._audio.remove(),this._audio=null;return}this._audio.parentNode&&this._audio.parentNode.removeChild(this._audio);let e=this._audio.cloneNode(!1);this._audio.parentNode?.replaceChild(e,this._audio),this._audio=null}}class jt{constructor(){this.isInited$=new tt(!1),this._displayChecker=void 0,this._deviceChecker=void 0,this._browserChecker=void 0,this._videoChecker=void 0,this._audioChecker=void 0,this._displayChecker=new dt,this._deviceChecker=new ct(this._displayChecker),this._browserChecker=new it,this._videoChecker=new Et(this._deviceChecker,this._browserChecker),this._audioChecker=new At,this.detect()}get display(){return this._displayChecker}get device(){return this._deviceChecker}get browser(){return this._browserChecker}get video(){return this._videoChecker}get audio(){return this._audioChecker}detect(){var e=this;return w(function*(){et()&&(e._displayChecker.detect(),e._deviceChecker.detect(),e._browserChecker.detect(),e._videoChecker.detect(),e._audioChecker.detect(),e.isInited$.next(!0))})()}}var j=new jt,Mt=(e,t=!1)=>{let{containers:n,protocols:r,codecs:i,nativeHlsSupported:a}=j.video,{isMobile:o}=j.device,s=j.device.isMac&&j.browser.isSafari,c=t&&!o&&!s,l=(i.h264||i.h265)&&i.aac,u=r.mse||r.mms;return e.filter(e=>{switch(e){case`DASH_SEP`:return u&&n.mp4&&l;case`DASH_WEBM`:return u&&n.webm&&i.vp9&&i.opus;case`DASH_WEBM_AV1`:return u&&n.webm&&i.av1&&i.opus;case`DASH_STREAMS`:return u&&(n.mp4&&l||n.webm&&(i.vp9||i.av1)&&(i.opus||i.aac));case`DASH_LIVE`:return u&&n.mp4&&l;case`DASH_LIVE_CMAF`:return u&&n.mp4&&l&&n.cmaf;case`DASH_ONDEMAND`:return u&&n.mp4&&l;case`HLS`:case`HLS_ONDEMAND`:case`HLS_FMP4`:case`HLS_LIVE`:case`HLS_LIVE_CMAF`:return a&&!c;case`MPEG`:return n.mp4;case`DASH`:case`DASH_LIVE_WEBM`:return!1;case`WEB_RTC_LIVE`:return r.webrtc&&r.ws&&i.h264&&(n.mp4||n.webm);default:return $e(e)}})},Nt=e=>{switch(e){case`MPEG`:case`DASH`:case`DASH_SEP`:case`DASH_ONDEMAND`:case`DASH_WEBM`:case`DASH_WEBM_AV1`:case`DASH_STREAMS`:case`HLS`:case`HLS_FMP4`:case`HLS_ONDEMAND`:return!1;case`DASH_LIVE`:case`DASH_LIVE_CMAF`:case`HLS_LIVE`:case`HLS_LIVE_CMAF`:case`DASH_LIVE_WEBM`:case`WEB_RTC_LIVE`:return!0;default:return $e(e)}},Pt=(e,t=!1)=>Mt(Object.keys(e).filter(e=>!Nt(e)),t).length>0;class Ft{constructor(e){this.subscription=new Re,this.log=void 0,this.params=void 0,this.sessionId$=new ze(null),this.mediaSessionId$=new ze(null),this.contentId$=new ze(null),this.progressTicker=void 0,this.isMobile=st(),this.mobileVolumeState={muted:!1,volume:0},this.media=null,this.lastRequestedVolume=null,this.syncMediaState=e=>{if(Ie(e))return;this.media=e,this.mediaSessionId$.next(e.mediaSessionId??null);let t=e.media?.contentId;t&&this.contentId$.next(t),this.syncPlaybackState(e);let n=e.media?.duration;Fe(n)&&this.params.output.duration$.next(Math.max(0,n));let r=e.currentTime;if(Fe(r)){this.params.desiredState.seekState.getState().state===`applying`&&this.params.output.seekedEvent$.next(),this.params.output.position$.next(r);let t=this.params.output.isLive$.getValue();e.playerState===`PLAYING`&&!t?this.progressTicker.start(r):this.progressTicker.pause()}},this.params=e,this.progressTicker=new Qe(e),this.log=this.params.dependencies.logger.createComponentLog(`ChromecastPresentationApiProvider`),this.log({message:`constructor, format: ${e.format}`}),this.params.output.isLive$.next(Nt(e.format)),this.subscribe()}subscribe(){let e=e=>{this.params.output.error$.next({category:Me.WTF,id:`ChromecastPresentationApiProvider`,message:e?.message??`Unknown error`,thrown:e})};this.subscription.add(this.params.chromecastConnector.message$.pipe(Ne(e=>!!e)).subscribe(e=>{this.handleMessage(e)},e)),this.subscription.add(this.sessionId$.pipe(Ne(Fe),Pe(),je(0)).subscribe(()=>{this.loadMedia()},e));let t=this.contentId$.pipe(Pe(),Le(Boolean));this.subscription.add(Ae({seekState:this.params.desiredState.seekState.stateChangeEnded$,mediaLoaded:t}).pipe(Ne(({mediaLoaded:e})=>e)).subscribe(()=>{let e=this.params.desiredState.seekState.getState();e.state===`requested`&&this.seek(e.position/1e3)},e));let n=Ae({playbackState:this.params.desiredState.playbackState.stateChangeStarted$,mediaLoaded:t});this.subscription.add(n.pipe(Ne(({mediaLoaded:e})=>e),je(0)).subscribe(()=>{this.syncPlayback()},e)),this.subscription.add(n.pipe(Ne(({mediaLoaded:e,playbackState:{from:t,to:n}})=>!e&&t===`stopped`&&n===`playing`)).subscribe(()=>{this.loadMedia()},e)),this.subscription.add(Ae({volumeState:this.params.desiredState.volume.stateChangeStarted$.pipe(je(30)),mediaLoaded:t}).pipe(Ne(({mediaLoaded:e})=>e)).subscribe(({volumeState:e})=>{let{muted:t,volume:n}=e.to;this.setVolume(n,t)},e))}handleMessage(e){switch(e.type){case`new_session`:case`update_session`:{var t;this.sessionId$.next(e.message.sessionId);let n=(t=e.message)==null||(t=t.media)==null?void 0:t[0];this.syncMediaState(n);let r=e.message?.receiver.volume;this.syncVolumeState(r)}break;case`v2_message`:switch(e.message?.type){case`MEDIA_STATUS`:{var n;let t=(n=e.message)==null||(n=n.status)==null?void 0:n[0];this.syncMediaState(t);break}}break}}loadMedia(){let e=qe(this.params),t=this.media?.currentTime,n=this.params.desiredState.seekState.getState(),r=t??(n.state===`none`?0:n.position/1e3),i=this.params.desiredState.playbackState.getState()===`playing`;this.params.chromecastConnector.sendV2Message({type:`LOAD`,requestId:0,media:e,autoplay:i,currentTime:r,customData:null,activeTrackIds:null}),this.params.output.willSeekEvent$.next()}stop(){this.params.chromecastConnector.stopMedia()}play(){let e=this.mediaSessionId$.getValue();ke(e,`play on null mediaSessionId`),this.params.chromecastConnector.sendV2Message({type:`PLAY`,mediaSessionId:e,customData:null})}pause(){let e=this.mediaSessionId$.getValue();ke(e,`pause on null mediaSessionId`),this.params.chromecastConnector.sendV2Message({type:`PAUSE`,mediaSessionId:e,customData:null})}seek(e){let t=this.mediaSessionId$.getValue();ke(t,`seek on null mediaSessionId`),this.params.chromecastConnector.sendV2Message({type:`SEEK`,currentTime:e,mediaSessionId:t}),this.params.output.willSeekEvent$.next()}setVolume(e,t){let n=e,r=`[setVolume] volume: ${e}, muted: ${t}`;this.isMobile&&(n=this.mobileVolumeState.volume,r+=`, mobile next volume: ${n}`),this.log({message:r}),this.lastRequestedVolume={volume:n,muted:t},this.params.chromecastConnector.sendV2Message({type:`SET_VOLUME`,requestId:0,volume:{level:t?0:n,muted:t?!0:null}})}syncPlaybackState({playerState:e,idleReason:t}){let n=this.params.output.isBuffering$.getValue(),r=e===`BUFFERING`;switch(n!==r&&this.params.output.isBuffering$.next(r),e){case`PAUSED`:k(this.params.desiredState.playbackState,`paused`);break;case`PLAYING`:k(this.params.desiredState.playbackState,`playing`);break;case`IDLE`:t===`FINISHED`?(this.params.output.endedEvent$.next(),k(this.params.desiredState.playbackState,`stopped`),this.contentId$.next(null)):k(this.params.desiredState.playbackState,`ready`);break;case`BUFFERING`:break}}syncPlayback(){let e=this.params.desiredState.playbackState.getState();switch(this.log({message:`[syncPlayback] ${e}`}),e){case`ready`:break;case`playing`:this.play();break;case`paused`:this.pause();break;case`stopped`:this.stop();break}}syncVolumeState(e){if(Ie(e))return;let{level:t,muted:n}=e,r={muted:n??!1,volume:t??0};this.lastRequestedVolume&&=(n&&(r.volume=this.lastRequestedVolume.volume),this.lastRequestedVolume.muted&&!t&&!n&&(r.volume=this.lastRequestedVolume.volume,r.muted=!0),null);let i=`[syncVolumeState] volume: ${r.volume}, muted: ${r.muted}`;this.isMobile&&(this.mobileVolumeState.volume=r.volume,this.mobileVolumeState.muted=r.muted,r.volume=this.params.output.volume$.getValue().volume,i+=`, volume passed to state machine: ${r.volume}`),this.log({message:i}),this.params.output.volume$.next(r)}destroy(){this.progressTicker.destroy(),this.subscription.unsubscribe()}}var Gt=e=>({castDevice:{friendlyName:e},remotePlayer:{},remotePlayerController:{},session:{}}),Kt=()=>String(Date.now())+String(Math.floor(Math.random()*1e5));class qt{constructor(e){this.params=void 0,this.clientId=void 0,this.capabilities=[`WEB`],this.presentationRequest$=new Ht(null),this.log=void 0,this.sessionId$=new Ht(null),this.broadcastChannel=new BroadcastChannel(`vk_player_chromecast_events`),this.subscription=new Bt,this.subscriptionEvents=new Bt,this.isDestroyed=!1,this.sequenceNumber=0,this.presentationAvailable$=new Ht(!1),this.presentationConnection$=new Ht(null),this.message$=new Ht(null),this.friendlyName$=new Ht(null),this.errorEvent$=new zt,this.clientId=this.getClientId(),this.params=e,this.log=e.logger.createComponentLog(`ChromecastPresentationApiConnector`),this.log({message:`constructor`}),this.safeReinitPresentation(),this.subscribe()}destroy(){this.log({message:`destroy`}),this.subscription.unsubscribe(),this.subscriptionEvents.unsubscribe(),this.broadcastChannel.close(),this.isDestroyed=!0}disconnect(e=!0){this.log({message:`disconnect`}),e&&this.stopMedia(),this.presentationRequest$.next(null);let t=this.presentationConnection$.getValue();t&&t.close(),this.presentationConnection$.next(null),this.friendlyName$.next(null),this.resetSequenceNumber(),this.resetSubscriptionEvents()}stopMedia(){this.log({message:`stopMedia`}),this.sendV2Message({type:`STOP`})}reinitPresentation(e=!0){let t=this.createCastUrl(),n=new PresentationRequest(t);this.presentationRequest$.next(n),this.log({message:`PresentationRequest created`}),n.getAvailability().then(e=>{let t=()=>{this.log({message:`PresentationRequest presentation availability: ${e.value}`}),this.presentationAvailable$.next(e.value)};this.subscriptionEvents.add(Ut(e,`change`).subscribe(()=>{t()})),t()}).catch(()=>{this.presentationAvailable$.next(!0)}),Wt().navigator.presentation.defaultRequest=n,e&&n.reconnect(`auto-join`).then(e=>{this.log({message:`PresentationRequest reconnect success`}),this.handleConnection(e)}).catch(()=>{this.log({message:`PresentationRequest reconnect failed`})})}safeReinitPresentation(e){try{this.reinitPresentation(e)}catch(e){this.errorEvent$.next({category:Lt.WTF,id:`ChromecastPresentationApiConnector`,message:e?.message??`reinitPresentation error`,thrown:e})}}connect(){var e=this;return w(function*(){e.log({message:`connect`});try{e.presentationRequest$.getValue()||(e.log({message:`reinitPresentation`}),e.reinitPresentation(!1));let t=e.presentationRequest$.getValue();It(t,`connect with null presentationRequest`);let n=yield t.start();e.handleConnection(n)}catch(t){switch(t?.name){case`AbortError`:case`NotAllowedError`:break;default:e.errorEvent$.next({category:Lt.WTF,id:`ChromecastPresentationApiConnector`,message:t?.message??`connect error`,thrown:t});break}}})()}subscribe(){this.subscription.add(Ut(this.broadcastChannel,`message`).subscribe(e=>{this.log({message:`broadcast connection data: ${e.data}`}),e.data===`connection`&&this.disconnect(!1)})),this.subscription.add(this.presentationAvailable$.subscribe(e=>{this.log({message:`presentationAvailable$: ${e}`})})),this.subscription.add(this.presentationConnection$.pipe(Vt(e=>{this.log({message:`presentationConnection$: ${!!e}`})}),Rt(e=>!!e)).subscribe(e=>{let t=Ut(e,`message`).subscribe(e=>{let t=JSON.parse(e.data);t.clientId===this.clientId&&(this.log({message:`[onmessage] ${e.data}`}),this.handleMessage(t),this.message$.next(t))}),n=Ut(e,`connect`).subscribe(()=>{this.send(`client_connect`)}),r=Ut(e,`close`).subscribe(e=>{switch(e.reason){case`error`:this.errorEvent$.next({category:Lt.WTF,id:`ChromecastPresentationApiConnector`,message:`Session error`,thrown:e});break;case`closed`:break}});this.subscriptionEvents.add(t),this.subscriptionEvents.add(n),this.subscriptionEvents.add(r)}))}send(e){switch(e){case`client_connect`:{let e={type:`client_connect`,message:this.clientId,sequenceNumber:-1,timeoutMillis:0,clientId:this.clientId};this.safeSend(JSON.stringify(e));break}}}sendV2Message(e){let t=this.sessionId$.getValue();if(t){let n={type:`v2_message`,sequenceNumber:this.getSequenceNumber(),timeoutMillis:0,clientId:this.clientId,message:T(T({},e),{},{sessionId:t})};this.safeSend(JSON.stringify(n))}}safeSend(e){try{this.log({message:`[send] ${e}`});let t=this.presentationConnection$.getValue();t?.state===`connected`&&t?.send(e)}catch(t){this.errorEvent$.next({category:Lt.WTF,id:`ChromecastPresentationApiConnector`,message:`PresentationConnection send error`,data:{message:e},thrown:t})}}handleMessage(e){switch(e.type){case`new_session`:case`update_session`:this.sessionId$.next(e.message.sessionId),this.friendlyName$.next(e.message.receiver.friendlyName||`Chromecast Device`);break;case`receiver_action`:e.message?.action===`stop`&&this.disconnect();break}}createCastUrl(){return`cast:${this.params.appId}?clientId=${this.clientId}&autoJoinPolicy=tab_and_origin_scoped&defaultActionPolicy=create_session&launchTimeout=60000&supportedAppTypes=${this.capabilities}&appParams=%7B%22launchCheckerParams%22%3A%7B%7D%7D`}getSequenceNumber(){let e=this.sequenceNumber;return this.sequenceNumber=(this.sequenceNumber+1)%(2**53-1),e}resetSequenceNumber(){this.sequenceNumber=0}getClientId(){let e=`__vk_player_chromecast_id`;return Wt()[e]=Wt()[e]||Kt()}resetSubscriptionEvents(){this.subscriptionEvents.unsubscribe(),this.subscriptionEvents=new Bt}handleConnection(e){this.log({message:`connection available`}),this.isDestroyed?(this.log({message:`connected on already destroyed component`}),e.close()):(this.broadcastChannel.postMessage(`connection`),this.presentationConnection$.next(e))}}class tn{static isSupported(){return`chrome`in window&&`presentation`in navigator&&`BroadcastChannel`in window}constructor(e){this.subscription=new Zt,this.log=void 0,this.contentId=void 0,this.connection$=new Jt(void 0),this.castState$=new Jt(`NOT_AVAILABLE`),this.errorEvent$=new Yt,this.chromecastConnector=void 0;let t=tn.isSupported();this.log=e.dependencies.logger.createComponentLog(`ChromecastPresentationApiInitializer`),this.log({message:`[constructor] receiverApplicationId: ${e.receiverApplicationId}, isDisabled: ${e.isDisabled}, isSupported: ${t}`}),!(!t||e.isDisabled||!e.receiverApplicationId)&&(this.chromecastConnector=new qt({appId:e.receiverApplicationId,logger:e.dependencies.logger}),this.subscribe())}subscribe(){en(this.chromecastConnector,`subscribe with null chromecastConnector`),this.subscription.add(this.chromecastConnector.errorEvent$.subscribe(this.errorEvent$));let e=Qt({connection:this.chromecastConnector.presentationConnection$,available:this.chromecastConnector.presentationAvailable$,friendlyName:this.chromecastConnector.friendlyName$.pipe($t())});this.subscription.add(e.pipe(Xt(({connection:e,friendlyName:t})=>!!(e&&t)),$t()).subscribe(e=>{let t=this.chromecastConnector?.friendlyName$.getValue()??``;this.connection$.next(e?Gt(t):void 0)})).add(e.subscribe(({available:e,connection:t})=>{e?t?this.castState$.next(`CONNECTED`):this.castState$.next(`AVAILABLE`):this.castState$.next(`NOT_AVAILABLE`)}))}connect(){this.log({message:`connect`}),this.chromecastConnector?.connect()}disconnect(){this.log({message:`disconnect`}),this.chromecastConnector?.disconnect()}stopMedia(){var e=this;return w(function*(){e.log({message:`stopMedia`}),e.chromecastConnector?.stopMedia()})()}toggleConnection(){let e=!!this.chromecastConnector?.presentationConnection$.getValue();this.log({message:`toggleConnection: isConnected - ${e}`}),e?this.disconnect():this.connect()}setVolume(e){}setMuted(e){}destroy(){this.log({message:`destroy`}),this.chromecastConnector?.destroy(),this.subscription.unsubscribe()}}var un=(e,t)=>e===t;class dn{constructor(e,t=un){this.comparator=void 0,this.state=void 0,this.prevState=void 0,this.transition=void 0,this.transitionStarted$=new cn,this.transitionEnded$=new cn,this.transitionUpdated$=new cn,this.forceChanged$=new cn,this.stateChangeStarted$=ln(this.transitionStarted$,this.transitionUpdated$),this.stateChangeEnded$=ln(this.transitionEnded$,this.forceChanged$),this.comparator=t,this.state=e,this.prevState=void 0}setState(e){let t=this.transition,n=this.state;this.transition=void 0,this.prevState=n,this.state=e,t?this.comparator(t.to,e)?this.transitionEnded$.next(t):this.forceChanged$.next({from:t.from,to:e,canceledTransition:t}):this.forceChanged$.next({from:n,to:e,canceledTransition:t})}startTransitionTo(e){let t=this.transition,n=this.state;this.comparator(n,e)||sn(t)&&this.comparator(t.to,e)||(this.prevState=n,this.state=e,t?(this.transition={from:t.from,to:e,canceledTransition:t},this.transitionUpdated$.next(this.transition)):(this.transition={from:n,to:e},this.transitionStarted$.next(this.transition)))}getTransition(){return this.transition}getState(){return this.state}getPrevState(){return this.prevState}}var Sn=5,Cn=5,wn=500,Tn=7e3;class En{constructor(e){this.subscription=new bn,this.loadMediaTimeoutSubscription=new bn,this.videoState=new dn(`stopped`),this.params=void 0,this.log=void 0,this.syncPlayback=()=>{let e=this.videoState.getState(),t=this.videoState.getTransition(),n=this.params.desiredState.playbackState.getState(),r=this.params.desiredState.playbackState.getTransition(),i=this.params.desiredState.seekState.getState();if(this.log({message:`[syncPlayback] videoState: ${e}; videoTransition: ${JSON.stringify(t)}; desiredPlaybackState: ${n}; desiredPlaybackStateTransition: ${this.params.desiredState.playbackState.getTransition()}; seekState: ${JSON.stringify(i)};`}),n===`stopped`){e!==`stopped`&&(this.videoState.startTransitionTo(`stopped`),this.stop());return}if(!t){if(r?.to!==`paused`&&i.state===`requested`&&e!==`stopped`){this.seek(i.position/1e3);return}switch(n){case`ready`:switch(e){case`playing`:case`paused`:case`ready`:break;case`stopped`:this.videoState.startTransitionTo(`ready`),this.prepare();break;default:fn(e)}break;case`playing`:switch(e){case`playing`:break;case`paused`:this.videoState.startTransitionTo(`playing`),this.params.connection.remotePlayerController.playOrPause();break;case`ready`:this.videoState.startTransitionTo(`playing`),this.params.connection.remotePlayerController.playOrPause();break;case`stopped`:this.videoState.startTransitionTo(`ready`),this.prepare();break;default:fn(e)}break;case`paused`:switch(e){case`playing`:this.videoState.startTransitionTo(`paused`),this.params.connection.remotePlayerController.playOrPause();break;case`paused`:break;case`ready`:this.videoState.startTransitionTo(`paused`),this.videoState.setState(`paused`);break;case`stopped`:this.videoState.startTransitionTo(`ready`),this.prepare();break;default:fn(e)}break;default:fn(n)}}},this.params=e,this.log=this.params.dependencies.logger.createComponentLog(`ChromecastProvider`),this.log({message:`constructor, format: ${e.format}`}),this.params.output.isLive$.next(Nt(e.format)),this.params.output.isAudioAvailable$.next(!0),this.handleRemoteVolumeChange({volume:this.params.connection.remotePlayer.volumeLevel,muted:this.params.connection.remotePlayer.isMuted});let 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);let e=new bn;this.subscription.add(e),this.subscription.add(_n(this.videoState.stateChangeStarted$.pipe(gn(e=>`stateChangeStarted$ ${JSON.stringify(e)}`)),this.videoState.stateChangeEnded$.pipe(gn(e=>`stateChangeEnded$ ${JSON.stringify(e)}`))).subscribe(e=>this.log({message:`[videoState] ${e}`})));let t=(e,t)=>this.subscription.add(e.subscribe(t));if(this.params.output.isLive$.getValue())this.params.output.position$.next(0),this.params.output.duration$.next(0);else{let t=new yn;e.add(t.pipe(pn(wn)).subscribe(()=>{this.params.output.seekedEvent$.next()}));let n=NaN;e.add(hn(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED).subscribe(e=>{this.logRemoteEvent(e);let r=e.value;this.params.output.position$.next(r),(this.params.desiredState.seekState.getState().state===`applying`||Math.abs(r-n)>Sn)&&t.next(r),n=r})),e.add(hn(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.DURATION_CHANGED).subscribe(e=>{this.logRemoteEvent(e),this.params.output.duration$.next(e.value)}))}t(hn(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED),t=>{this.logRemoteEvent(t),t.value?this.handleRemoteReady():(this.handleRemoteStop(),e.unsubscribe())}),t(hn(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED),e=>{this.logRemoteEvent(e),e.value?this.handleRemotePause():this.handleRemotePlay()}),t(hn(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED),e=>{this.logRemoteEvent(e);let{remotePlayer:t}=this.params.connection,n=e.value,r=this.params.output.isBuffering$.getValue(),i=n===chrome.cast.media.PlayerState.BUFFERING;switch(r!==i&&this.params.output.isBuffering$.next(i),n){case chrome.cast.media.PlayerState.IDLE:!this.params.output.isLive$.getValue()&&t.duration-t.currentTime<Cn&&this.params.output.endedEvent$.next(),this.handleRemoteStop(),k(this.params.desiredState.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:fn(n)}}),t(hn(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED),e=>{this.logRemoteEvent(e),this.handleRemoteVolumeChange({volume:e.value})}),t(hn(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED),e=>{this.logRemoteEvent(e),this.handleRemoteVolumeChange({muted:e.value})}),t(_n(this.params.desiredState.playbackState.stateChangeStarted$,this.params.desiredState.seekState.stateChangeEnded$,this.videoState.stateChangeEnded$,vn([`init`])).pipe(pn(0)),this.syncPlayback)}restoreSession(e){this.log({message:`restoreSession`});let{remotePlayer:t}=this.params.connection;if(e.playerState!==chrome.cast.media.PlayerState.IDLE){t.isPaused?(this.videoState.setState(`paused`),k(this.params.desiredState.playbackState,`paused`)):(this.videoState.setState(`playing`),k(this.params.desiredState.playbackState,`playing`));let e=this.params.output.isLive$.getValue();this.params.output.duration$.next(e?0:t.duration),this.params.output.position$.next(e?0:t.currentTime),this.params.desiredState.seekState.setState({state:`none`})}}prepare(){let e=this.params.format;this.log({message:`[prepare] format: ${e}`});let t=qe(this.params),n=this.createLoadRequest(t);this.loadMedia(n)}handleRemotePause(){let e=this.videoState.getState();(this.videoState.getTransition()?.to===`paused`||e===`playing`)&&(this.videoState.setState(`paused`),k(this.params.desiredState.playbackState,`paused`))}handleRemotePlay(){let e=this.videoState.getState();(this.videoState.getTransition()?.to===`playing`||e===`paused`)&&(this.videoState.setState(`playing`),k(this.params.desiredState.playbackState,`playing`))}handleRemoteReady(){this.videoState.getTransition()?.to===`ready`&&this.videoState.setState(`ready`),this.params.desiredState.playbackState.getTransition()?.to===`ready`&&k(this.params.desiredState.playbackState,`ready`)}handleRemoteStop(){this.videoState.getState()!==`stopped`&&this.videoState.setState(`stopped`)}handleRemoteVolumeChange(e){let t=this.params.output.volume$.getValue(),n={volume:e.volume??t.volume,muted:e.muted??t.muted};(n.volume!==t.volume||n.muted!==n.muted)&&this.params.output.volume$.next(n)}seek(e){this.params.output.willSeekEvent$.next();let{remotePlayer:t,remotePlayerController:n}=this.params.connection;t.currentTime=e,n.seek()}stop(){let{remotePlayerController:e}=this.params.connection;e.stop()}createLoadRequest(e){let t=new chrome.cast.media.LoadRequest(e);t.autoplay=!1;let n=this.params.desiredState.seekState.getState();return n.state===`applying`||n.state===`requested`?t.currentTime=this.params.output.isLive$.getValue()?0:n.position/1e3:t.currentTime=0,t}loadMedia(e){let t=this.params.connection.session.loadMedia(e),n=new Promise((e,t)=>{this.loadMediaTimeoutSubscription.add(xn(Tn).subscribe(()=>t(`timeout(${Tn})`)))});on(Promise.race([t,n]).then(()=>{this.log({message:`[loadMedia] completed, format: ${this.params.format}`}),this.params.desiredState.seekState.getState().state===`applying`&&this.params.output.seekedEvent$.next(),this.handleRemoteReady()},e=>{let t=`[prepare] loadMedia failed, format: ${this.params.format}, reason: ${e}`;this.log({message:t}),this.params.output.error$.next({id:`ChromecastProvider.loadMedia`,category:mn.VIDEO_PIPELINE,message:t,thrown:e})}),()=>{this.loadMediaTimeoutSubscription.unsubscribe()})}logRemoteEvent(e){this.log({message:`[remoteEvent] ${JSON.stringify(e)}`})}}var Nn=(e,t)=>{try{e.pause(),e.playbackRate=0,Mn(e,t),e.remove()}catch(e){console.error(e)}},Pn=`__spvc`;class Fn{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)}}var In=An(),Ln=In.WeakMap?new In.WeakMap:new Fn,Rn=In.WeakMap?new In.WeakMap:new Map,zn=(e,t=20)=>{let n=0;return kn(e,`ratechange`).subscribe(r=>{n++,n>=t&&(e.currentTime=e.currentTime,n=0)})};function Bn(e){e.style.position=`fixed`,e.style.left=`100%`,e.setAttribute(`data-role`,`screen`),An().document.body.appendChild(e)}function Vn(e,t){e.style.position=``,e.style.left=``,t.appendChild(e)}var Hn=(e,{audioVideoSyncRate:t,disableYandexPiP:n,clearVideoElementInnerHTML:r,reuseOwnVideoElement:i})=>{let a,o=e.querySelector(`video`),s=!!o,c=An().document.querySelector(`body > video[data-role=screen]`)||void 0;i?In[Pn]=c:(c?.remove(),delete In[Pn]),o?(a=o,On(a,r)):c&&c===In[Pn]?(a=c,Vn(a,e)):(a=An().document.createElement(`video`),e.appendChild(a),i&&(In[Pn]=a)),Ln.set(a,s);let l=new jn;return l.add(zn(a,t)),Rn.set(a,l),a.setAttribute(`crossorigin`,`anonymous`),a.setAttribute(`playsinline`,`playsinline`),n&&a.setAttribute(`x-yandex-pip`,`false`),a.controls=!1,a.setAttribute(`poster`,`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=`),a},Un=e=>(e.setAttribute(`crossorigin`,`anonymous`),e.controls=!1,e),Wn=(e,t)=>{if(e instanceof HTMLAudioElement){Nn(e,!0);return}if(e instanceof HTMLVideoElement){Gn(e,t);return}};function Gn(e,{keepVideoElement:t,clearVideoElementInnerHTML:n,reuseOwnVideoElement:r}){Rn.get(e)?.unsubscribe(),Rn.delete(e);let i=Ln.get(e);Ln.delete(e),i||t?On(e,n):r?(On(e,n),Bn(e)):Nn(e,n)}var lr=(e,t,n,{equal:r=(e,t)=>e===t,changed$:i,onError:a}={})=>{let o=e.getState(),s=t(),c=sr(i),l=new cr;return i&&l.add(i.subscribe(t=>{r(t,e.getState())&&e.setState(t)},a)),r(s,o)||(n(o),c&&e.setState(o)),l.add(e.stateChangeStarted$.subscribe(t=>{n(t.to),c&&e.setState(t.to)},a)),l},ur=(e,t,n)=>lr(t,()=>e.loop,t=>{or(t)&&(e.loop=t)},{onError:n}),dr=(e,t,n,r,i)=>lr(t,()=>({muted:e.muted,volume:e.volume}),t=>{i?.skipVideoElVolumeSync$.getValue()||or(t)&&(e.muted=t.muted,e.volume=t.volume)},{equal:(e,t)=>e===t||e?.muted===t?.muted&&e?.volume===t?.volume,changed$:n,onError:r}),fr=(e,t,n,r)=>lr(t,()=>e.playbackRate,t=>{or(t)&&(e.playbackRate=t)},{changed$:n,onError:r}),pr=lr,mr=e=>[`__`,e.language,e.label].join(`|`),hr=(e,t)=>{if(e.id===t)return!0;let[n,r,i]=t.split(`|`);return e.language===r&&e.label===i};class gr{constructor(e){this.available$=new nr,this.current$=new ir(void 0),this.error$=new nr,this.video=void 0,this.cueSettings=void 0,this.subscription=new rr,this.externalTracks=new Map,this.internalTracks=new Map,this.baseURL=void 0,this.baseURL=e}connect(e,t,n){this.video=e,this.cueSettings=t.textTrackCuesSettings,this.subscribe();let r=e=>{this.error$.next({id:`TextTracksManager`,category:ar.WTF,message:`Generic HtmlVideoTextTrackManager error`,thrown:e})};this.subscription.add(this.available$.subscribe(n.availableTextTracks$)),this.subscription.add(this.current$.subscribe(n.currentTextTrack$)),this.subscription.add(this.error$.subscribe(n.error$)),this.subscription.add(pr(t.internalTextTracks,()=>Kn(this.internalTracks),e=>{Yn(e)&&this.setInternal(e)},{equal:(e,t)=>Yn(e)&&Yn(t)&&e.length===t.length&&e.every(({id:e},n)=>e===t[n].id),changed$:this.available$.pipe(tr(e=>e.filter(({type:e})=>e===`internal`))),onError:r})),this.subscription.add(pr(t.externalTextTracks,()=>Kn(this.externalTracks),e=>{Yn(e)&&this.setExternal(e)},{equal:(e,t)=>Yn(e)&&Yn(t)&&e.length===t.length&&e.every(({id:e},n)=>e===t[n].id),changed$:this.available$.pipe(tr(e=>e.filter(({type:e})=>e===`external`))),onError:r})),this.subscription.add(pr(t.currentTextTrack,()=>{if(this.video)return;let e=this.htmlTextTracksAsArray().find(({mode:e})=>e===`showing`);return e&&this.htmlTextTrackToITextTrack(e).id},e=>this.select(e),{changed$:this.current$,onError:r})),this.subscription.add(pr(t.textTrackCuesSettings,()=>({}),()=>{if(this.video)for(let e of this.htmlTextTracksAsArray())this.applyCueSettings(e.cues),this.applyCueSettings(e.activeCues)}))}subscribe(){Jn(this.video);let{textTracks:e}=this.video;this.subscription.add(Zn(e,`addtrack`).subscribe(()=>{let e=this.current$.getValue();e&&this.select(e)})),this.subscription.add(Qn(Zn(e,`addtrack`),Zn(e,`removetrack`),$n([`init`])).pipe(tr(()=>this.htmlTextTracksAsArray().map(e=>this.htmlTextTrackToITextTrack(e))),er((e,t)=>e.length===t.length&&e.every(({id:e},n)=>e===t[n].id))).subscribe(this.available$)),this.subscription.add(Qn(Zn(e,`change`),$n([`init`])).pipe(tr(()=>this.htmlTextTracksAsArray().find(({mode:e})=>e===`showing`)),tr(e=>e&&this.htmlTextTrackToITextTrack(e).id),er()).subscribe(this.current$));let t=e=>this.applyCueSettings(e.target?.activeCues??null);this.subscription.add(Zn(e,`addtrack`).subscribe(e=>{e.track?.addEventListener(`cuechange`,t);let n=e=>{let t=e.target?.cues??null;t&&t.length&&(this.applyCueSettings(e.target?.cues??null),e.target?.removeEventListener(`cuechange`,n))};e.track?.addEventListener(`cuechange`,n)})),this.subscription.add(Zn(e,`removetrack`).subscribe(e=>{e.track?.removeEventListener(`cuechange`,t)}))}applyCueSettings(e){if(!e||!e.length)return;let t=this.cueSettings.getState();for(let n of Array.from(e)){let e=n;Yn(t.align)&&(e.align=t.align),Yn(t.position)&&(e.position=t.position),Yn(t.size)&&(e.size=t.size),Yn(t.line)&&(e.line=t.line)}}htmlTextTracksAsArray(e=!1){Jn(this.video);let t=[...this.video.textTracks];return e?t:t.filter(gr.isHealthyTrack)}htmlTextTrackToITextTrack(e){let{language:t,label:n}=e,r=e.id?e.id:mr(e),i=this.externalTracks.has(r),a=(i?this.externalTracks.get(r)?.isAuto:this.internalTracks.get(r)?.isAuto)??qn(r,`auto`);return i?{id:r,type:`external`,isAuto:a,language:t,label:n,url:this.externalTracks.get(r)?.url}:{id:r,type:`internal`,isAuto:a,language:t,label:n,url:this.internalTracks.get(r)?.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(([,e])=>this.detach(e)),e.filter(({id:e})=>!this.externalTracks.has(e)).forEach(e=>this.attach(e)),Array.from(this.externalTracks).filter(([t])=>!e.find(e=>e.id===t)).forEach(([,e])=>this.detach(e))}setInternal(e){let t=[...this.externalTracks];e.filter(({id:e,language:n,isAuto:r})=>!this.internalTracks.has(e)&&!t.some(([,e])=>e.language===n&&e.isAuto===r)).forEach(e=>this.attach(e)),Array.from(this.internalTracks).filter(([t])=>!e.find(e=>e.id===t)).forEach(([,e])=>this.detach(e))}select(e){Jn(this.video);for(let e of this.htmlTextTracksAsArray(!0))e.mode=`showing`;for(let t of this.htmlTextTracksAsArray(!0))(Xn(e)||!hr(t,e))&&(t.mode=`disabled`)}destroy(){if(this.subscription.unsubscribe(),this.video)for(let e of Array.from(this.video.getElementsByTagName(`track`))){let t=e.getAttribute(`id`);t&&this.externalTracks.has(t)&&this.video.removeChild(e)}this.externalTracks.clear()}attach(e){Jn(this.video);let t=document.createElement(`track`);this.baseURL?t.setAttribute(`src`,new URL(e.url,this.baseURL).toString()):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){Jn(this.video);let t=Array.prototype.find.call(this.video.getElementsByTagName(`track`),t=>t.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)}}var _r=gr;class vr{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()}}var yr=e=>{let t=e;for(;!(t instanceof Document)&&!(t instanceof ShadowRoot)&&t!==null;)t=t?.parentNode;return t??void 0},br=e=>{let t=yr(e);return!!(t&&t.fullscreenElement&&t.fullscreenElement===e)},xr=e=>{let t=yr(e);return!!(t&&t.pictureInPictureElement&&t.pictureInPictureElement===e)};var Fr=3,Ir=(e,t,n=Fr)=>{let r=0,i=0;for(let a=0;a<e.length;a++){let o=e.start(a),s=e.end(a);if(o<=t&&t<=s){if(r=o,i=s,!n)return{from:r,to:i};for(let t=a-1;t>=0;t--)e.end(t)+n>=r&&(r=e.start(t));for(let t=a+1;t<e.length;t++)e.start(t)-n<=i&&(i=e.end(t))}}return{from:r,to:i}},Lr=e=>{let t=0;for(let n=0;n<e.length;n++)t+=e.end(n)-e.start(n);return t},Rr=e=>{let t=t=>M(e,t).pipe(Or(void 0),N(1)),n=new Pr,r=()=>n.unsubscribe(),i=Cr(M(e,`progress`),M(e,`timeupdate`)).pipe(Sr(()=>Ir(e.buffered,e.currentTime)),N(1)),a=j.browser.isSafari?kr({play:t(`play`).pipe(Ar()),playing:t(`playing`)}).pipe(Or(void 0),N(1)):t(`playing`),o=M(e,`volumechange`).pipe(Sr(()=>({muted:e.muted,volume:e.volume})),N(1)),s=M(e,`ratechange`).pipe(Sr(()=>e.playbackRate),N(1)),c=M(e,`error`).pipe(Dr(()=>!!(e.error||e.played.length)),Sr(()=>{let t=e.error;return{id:t?`MediaError#${t.code}`:`HtmlVideoError`,category:Mr.VIDEO_PIPELINE,message:t?t.message:`Error event from HTML video element`,thrown:e.error??void 0}}),N(1)),l=M(e,`timeupdate`).pipe(Sr(()=>e.currentTime),N(1)),u=Cr(M(e,`loadedmetadata`),M(e,`timeupdate`),M(e,`pause`),M(e,`seeked`),M(e,`ended`)).pipe(Sr(()=>Lr(e.played)),wr(),N(1)),d=[`waiting`,`seeking`,`seeked`,`timeupdate`],f=new Er,p=.3,m;n.add(Cr(...d.map(t=>M(e,t))).subscribe(t=>{let n=e.currentTime;e.loop&&Tr(m)&&Tr(n)&&m>=e.duration-p&&n<=p&&f.next(m),m=n}));let h=t(`pause`).pipe(Dr(()=>!e.error&&m!==e.duration),N(1)),g=M(e,`enterpictureinpicture`).pipe(N(1)),_=M(e,`leavepictureinpicture`).pipe(N(1)),v=new Nr(xr(e));n.add(g.subscribe(()=>v.next(!0))),n.add(_.subscribe(()=>v.next(!1)));let y=new Nr(br(e)),b=M(e,`fullscreenchange`).pipe(N(1));n.add(b.pipe(Sr(()=>br(e))).subscribe(y));let x=M(e,`timeupdate`).pipe(Sr(t=>e.duration-e.currentTime<.1),wr(),N(1)),S=Cr(x.pipe(Dr(t=>!e.loop&&t)),M(e,`ended`)).pipe(jr(1e3),Or(void 0),N(1)),C=Cr(...[`waiting`,`pause`,`canplay`,`play`,`canplaythrough`,`playing`,`seeking`,`seeked`,`ended`].map(t=>M(e,t)),x.pipe(Sr(e=>({type:e?`ended`:`unknown`})))).pipe(Sr(t=>j.browser.isFirefox&&t.type===`ended`?e.readyState<2:e.readyState<3),wr(),N(1));return{playing$:a,pause$:h,canplay$:t(`canplay`),ended$:S,looped$:f,error$:c,seeked$:t(`seeked`),seeking$:t(`seeking`),progress$:t(`progress`),loadStart$:t(`loadstart`),loadedMetadata$:t(`loadedmetadata`),loadedData$:t(`loadeddata`),timeUpdate$:l,durationChange$:M(e,`durationchange`).pipe(Sr(()=>e.duration),N(1)),playedTime$:u,isBuffering$:C,currentBuffer$:i,volumeState$:o,playbackRateState$:s,inPiP$:v,inFullscreen$:y,enterPip$:g,leavePip$:_,destroy:r}};var Br=e=>{switch(e){case`mobile`:return zr.Q_144P;case`lowest`:return zr.Q_240P;case`low`:return zr.Q_360P;case`sd`:case`medium`:return zr.Q_480P;case`hd`:case`high`:return zr.Q_720P;case`fullhd`:case`full`:return zr.Q_1080P;case`quadhd`:case`quad`:return zr.Q_1440P;case`ultrahd`:case`ultra`:return zr.Q_2160P}};var Qr=!1,$r={},ei=e=>{Qr=e},ti=()=>{$r={}},ni=e=>{e($r)},ri=(e,t)=>{Qr&&($r.meta=$r.meta??{},$r.meta[e]=t)};class ii{constructor(e){this.name=void 0,this.name=e}next(e){if(!Qr)return;$r.series=$r.series??{};let t=$r.series[this.name]??[];t.push([Date.now(),e]),$r.series[this.name]=t}}function ui(e,t,n){return!e.max&&e.min===t?`high_quality`:!e.min&&e.max===n?`traffic_saving`:`unknown`}function di(e,t,n){return ci(e)||si(e.min)&&si(e.max)&&oi(e.max,e.min)||si(e.min)&&si(t)&&ai(e.min,t)||si(e.max)&&si(n)&&oi(e.max,n)}function fi({limits:e,highestAvailableHeight:t,lowestAvailableHeight:n}){return di({max:e?.max?li(e.max):void 0,min:e?.min?li(e.min):void 0},t?li(t):void 0,n?li(n):void 0)}var pi=new ii(`best_bitrate`),mi=(e,t,n)=>(t-n)*2**(-10*e)+n,hi=e=>(t,n)=>e*(Number(t.bitrate)-Number(n.bitrate));class gi{constructor(){this.last=void 0,this.history={}}recordSelection(e){this.history[e.id]=Wr()}recordSwitch(e){this.last=e}clear(){this.last=void 0,this.history={}}}var _i=`Assertion "ABR Tracks is empty array" failed`,vi=new WeakMap,yi=new WeakMap,bi=new WeakMap,xi=(e,t,n,r)=>{let i=[...t].sort(hi(1)),a=[...n].sort(hi(1)),o=a.filter(t=>F(t.bitrate)&&F(e.bitrate)?e.bitrate/t.bitrate>r:!0),s=P(a,Math.round(a.length*i.indexOf(e)/(i.length+1)))??P(a,-1);return s&&Vr(o,s)?s:o.length?P(o,-1):P(a,0)},Si=(e,t,n,r)=>{let i=vi.get(t);i||(i=[...t].sort(hi(1)),vi.set(t,i));let a=vi.get(n);a||(a=[...n].sort(hi(1)),vi.set(n,a));let o=bi.get(e);o||(o=a.filter(t=>F(t.bitrate)&&F(e.bitrate)?e.bitrate/t.bitrate>r:!0),bi.set(e,o));let s=P(a,Math.round(a.length*i.indexOf(e)/(i.length+1)))??P(a,-1);return s&&Vr(o,s)?s:o.length?P(o,-1):P(a,0)},Ci=e=>`quality`in e,wi=(e,t,n,r)=>{var i;let a=F(r==null||(i=r.last)==null?void 0:i.bitrate)&&F(n?.bitrate)&&r.last.bitrate<n.bitrate?e.trackCooldownIncreaseQuality:e.trackCooldownDecreaseQuality,o=n&&r&&r.history[n.id]&&Wr()-r.history[n.id]<=a&&(!r.last||n.id!==r.last.id);if(n?.id&&r&&!o&&r.recordSelection(n),o&&r?.last){let e=r.last;return r?.recordSwitch(e),t({message:`
|
|
7
7
|
[last ${Ci(e)?`video`:`audio`} selected] ${Ci(e)?e.quality:e.bitrate}
|
|
8
8
|
`}),e}return r?.recordSwitch(n),n},Ti=(e,t)=>Math.log(t)/Math.log(e),Ei=({tuning:e,container:t,limits:n,panelSize:r})=>{let i=e.containerSizeFactor;if(r)return{containerSizeLimit:r,containerSizeFactor:i};if(e.usePixelRatio&&j.display.pixelRatio){let t=j.display.pixelRatio;if(e.pixelRatioMultiplier)i*=e.pixelRatioMultiplier*(t-1)+1;else{let n=e.pixelRatioLogBase,[r=0,a=0,o=0]=e.pixelRatioLogCoefficients,s=Ti(n,r*t+a)+o;Number.isFinite(s)&&(i*=s)}}return F(n?.min)&&Kr(n.min,e.highQualityLimit)&&(i*=2),{containerSizeLimit:e.limitByContainer&&t&&t.width>0&&t.height>0?{width:t.width*i,height:t.height*i}:void 0,containerSizeFactor:i}},Di=new WeakMap,Oi=(e,{container:t,estimatedThroughput:n,tuning:r,limits:i,reserve:a=0,forwardBufferHealth:o,playbackRate:s,current:c,failedVideoTrack:l,history:u,visible:d,droppedVideoMaxQualityLimit:f,stallsVideoMaxQualityLimit:p,stallsPredictedThroughput:m,abrLogger:h,panelSize:g})=>{Xr(e,_i);let{containerSizeFactor:_,containerSizeLimit:v}=Ei({container:t,tuning:r,limits:i,panelSize:g}),y=r.considerPlaybackRate&&F(s)?s:1,b=Di.get(e);b||(b=e.filter(e=>!qr(e.quality)).sort((e,t)=>Gr(e.quality,t.quality)?-1:1),Di.set(e,b));let x=P(b,-1)?.quality,S=P(b,0)?.quality,C=di(i,S,x),w=y*mi(o??.5,r.bitrateFactorAtEmptyBuffer,r.bitrateFactorAtFullBuffer),T={},E=null;for(let e of b){if(e.tvDisabled){T[e.quality]=`TvDisabled`;continue}let t=!0;if(v)if(e.size)t=e.size.width<=v.width&&e.size.height<=v.height;else{let n=v&&Yr(v);t=n?Jr(e.quality,n):!0}if(!t){T[e.quality]=`FitsContainer`;continue}let s=m||n,u=F(s)&&isFinite(s)&&F(e.bitrate)?s-a>=e.bitrate*w:!0,h=i?.min===e.quality||F(i?.min)&&F(S)&&Gr(i.min,S)&&e.quality===S;if(!u&&!h){T[e.quality]=`FitsThroughput`;continue}if(F(l)&&l.quality===e.quality){T[e.quality]=`FailedVideoTrack`;continue}if(r.lazyQualitySwitch&&F(r.minBufferToSwitchUp)&&c&&!qr(c.quality)&&(o??0)<r.minBufferToSwitchUp&&Gr(e.quality,c.quality)){T[e.quality]=`Buffer`;continue}if(f&&Kr(e.quality,f)&&!h){T[e.quality]=`DroppedFramesLimit`;continue}if(p&&Kr(e.quality,p)&&!h){T[e.quality]=`StallsLimit`;continue}let g=C||(Ur(i?.max)||Jr(e.quality,i.max))&&(Ur(i?.min)||Kr(e.quality,i.min)),_=F(d)&&!d?Jr(e.quality,r.backgroundVideoQualityLimit):!0;if(!g||!_){T[e.quality]=`FitsQualityLimits`;continue}E||=e}E&&E.bitrate&&pi.next(E.bitrate);let D=E??P(b,-1)??e[0],ee=u?.last,te=wi(r,h,D,u);return F(u)&&te.quality!==ee?.quality&&h({message:`
|
|
9
9
|
[VIDEO TRACKS ABR]
|
|
@@ -257,4 +257,4 @@ import{objectEntries as le}from"@vkontakte/videoplayer-shared/es2015";import{obj
|
|
|
257
257
|
`,e.map(({time:e,data:t,stack:n})=>`${e}: ${JSON.stringify(t)}${n?`
|
|
258
258
|
`+n:``}`).join(`
|
|
259
259
|
`),`
|
|
260
|
-
===== DASH_LIVE DEBUG END ====`),n){let t=e.reduce((e,{time:t,data:n,stack:r})=>{let i=rn(n).map(([e,t])=>`${e}:${t}`).join(`,`);return e+=`${t}: ${i}${r?`: ${r}`:``};`,e},``);ev.push(`core`,{key:`vp_dash_live_debug`,strings:[t]})}};return e.add(this.providerError$.subscribe(e=>{e.id.startsWith(`ProviderHangup`)&&(R({m:`final.0`,e:e.id}),r())})).add(this.noAvailableProvidersError$.subscribe(()=>{R({m:`final.1`}),r()})),e.add(this.providerError$.subscribe(e=>{let{destination:r,type:i}=this.current$.getValue(),a={error:e,currentDestination:r};if(r===`CHROMECAST`)this.destroyProvider(),this.params.dependencies.chromecastInitializer.stopMedia().then(()=>this.switchToNextProvider(`CHROMECAST`),()=>this.params.dependencies.chromecastInitializer.disconnect());else{let o=this.params.tuning.dash.useFailoverHostsOnAllProviderCrash||e.category===G_.NETWORK,s=e.category===G_.FATAL,c=this.params.failoverHosts.length>0&&(this.failoverIndex===void 0||this.failoverIndex<this.params.failoverHosts.length-1),l=n<this.params.tuning.providerErrorLimit&&!s,u=this.videoCodecsIterator&&!this.videoCodecsIterator.isLast()&&this.params.tuning.dash.codecsPrioritizeEnabled,d=this.providerOutput.currentVideoTrack$.getValue();this.dashMaxTvVideoQuality=this.params.tuning.dash.dashMaxTvVideoQuality?np(e,i,d?.quality):null;let f=c&&!s&&(o&&t||!l);a=T(T({},a),{},{isNetworkError:o,isFatalError:s,haveFailoverHost:c,tryFailover:f,canReinitProvider:l}),this.currentFailedVideoTrack=this.params.tuning.dash.useNewFailoverLogic?d:null,this.params.tuning.dropUrlCacheWhenProviderCrashed&&!o&&Yh(),l?(n++,this.reinitProvider()):f?(this.failoverIndex=this.failoverIndex===void 0?0:this.failoverIndex+1,this.reinitProvider()):u?this.switchToNextVideoCodec():(n=0,this.switchToNextProvider(r??`SCREEN`))}e.traceAsLog?this.tracer.log(`providerInfo`,$_(a)):this.tracer.error(`providerError`,$_(a))})),e}}var jv=`vk_uvp_throughput`,Mv=`vk_uvp_rtt`,Nv=`one_video_throughput`,Pv=`one_video_rtt`,Fv=()=>{let{navigator:e}=Av();if(e)return e.connection},Iv=()=>{let e=Fv()?.downlink;if(Dv(e)&&e!==10)return e*1e3},Lv=()=>{let e=Fv()?.rtt;if(Dv(e)&&e!==3e3)return e},Rv=(e,t,n)=>{let r=n*8;return r/(r/e+t)};class zv{constructor(e){this.throughput=void 0,this.rtt=void 0,this.subscription=new Cv,this.tuningConfig=void 0,this.concurrentDownloads=new Set,this.throughput$=void 0,this.rtt$=void 0,this.rttAdjustedThroughput$=void 0,this.tuningConfig=e;let t=zv.loadStored(jv,Nv,e)||(e.useBrowserEstimation?Iv():void 0)||e.initialThroughput,n=zv.loadStored(Mv,Pv,e)??(e.useBrowserEstimation?Lv():void 0)??0;if(this.throughput$=new wv(t),this.rtt$=new wv(n),this.rttAdjustedThroughput$=new wv(Rv(t,n,e.rttPenaltyRequestSize)),this.throughput=Ip.getSmoothedValue(t,-1,e),this.rtt=Ip.getSmoothedValue(n,1,e),e.useBrowserEstimation){let e=()=>{let e=Iv();e&&this.throughput.next(e);let t=Lv();Dv(t)&&this.rtt.next(t)},t=Fv();t&&`onchange`in t&&this.subscription.add(bv(t,`change`).subscribe(e)),e()}this.subscription.add(this.throughput.smoothed$.subscribe(t=>{zv.writeStored(jv,Nv,t,e)})),this.subscription.add(this.rtt.smoothed$.subscribe(t=>{zv.writeStored(Mv,Pv,t,e)})),this.subscription.add(this.throughput.debounced$.pipe(Tv(e=>Math.round(e))).subscribe(this.throughput$)),this.subscription.add(this.rtt.debounced$.subscribe(this.rtt$)),this.subscription.add(Sv({throughput:this.throughput.smoothed$,rtt:this.rtt.smoothed$}).pipe(Tv(({throughput:t,rtt:n})=>Rv(t,n,e.rttPenaltyRequestSize)),Ev(t=>{let n=this.rttAdjustedThroughput$.getValue()||0;return Math.abs(t-n)/n>=e.changeThreshold})).subscribe(this.rttAdjustedThroughput$))}destroy(){this.concurrentDownloads.clear(),this.subscription.unsubscribe()}trackXHR(e){let t=0,n=Ov(),r=new Cv;switch(this.subscription.add(r),this.concurrentDownloads.add(e),e.readyState){case 4:break;case 3:case 2:r.add(bv(e,`progress`).pipe(xv()).subscribe(e=>{t=e.loaded,n=Ov()}));break;case 1:case 0:r.add(bv(e,`loadstart`).subscribe(()=>{t=0,n=Ov()}));break}r.add(bv(e,`loadend`).subscribe(i=>{if(e.status===200){let e=i.loaded,r=Ov(),a=e-t,o=r-n;this.addRawSpeed(a,o,1)}this.concurrentDownloads.delete(e),r.unsubscribe()}))}trackStream(e,t=!1){var n=this;let r=e.getReader();if(!r){e.cancel(`Could not get reader`);return}let i=0,a=Ov(),o=0,s=Ov(),c=t=>{this.concurrentDownloads.delete(e),r.releaseLock(),e.cancel(`Throughput Estimator error: ${t}`).catch(()=>{})},l=function(){var u=w(function*({done:u,value:d}){if(u)!t&&n.addRawSpeed(i,Ov()-a,1),n.concurrentDownloads.delete(e);else if(d){if(t){let e=Ov();if(e-s>n.tuningConfig.lowLatency.continuesByteSequenceInterval||e-a>n.tuningConfig.lowLatency.maxLastEvaluationTimeout){let e=s-a;e&&n.addRawSpeed(o,e,1,t),o=d.byteLength,a=Ov()}else o+=d.byteLength;s=Ov()}else i+=d.byteLength,o+=d.byteLength,o>=n.tuningConfig.streamMinSampleSize&&Ov()-s>=n.tuningConfig.streamMinSampleTime&&(n.addRawSpeed(o,Ov()-s,n.concurrentDownloads.size),o=0,s=Ov());yield r?.read().then(l,c)}});return function(e){return u.apply(this,arguments)}}();this.concurrentDownloads.add(e),r?.read().then(l,c)}addRawSpeed(e,t,n=1,r=!1){if(this.sanityCheck(e,t,r)){let r=e*8/t;this.throughput.next(r*n)}}addRawThroughput(e){this.throughput.next(e)}addRawRtt(e){this.rtt.next(e)}sanityCheck(e,t,n=!1){let r=e*8/t;return!(!r||!isFinite(r)||r>1e6||r<30||n&&e<1e4||!n&&e<10*1024&&(!this.tuningConfig.measureNonSegmentRequests||t<this.tuningConfig.smallSampleMinDuration+this.rtt$.getValue())||!n&&t<=this.tuningConfig.cacheThresholdSize)}get throughputVariance$(){return this.throughput.varianceCoefficient$}static loadStored(e,t,n){if(!n.useThroughputTtl){let e=kv.get(t);if(!Dv(e))return;let n=parseInt(e,10);return isNaN(n)?void 0:n}let r=kv.get(e)??kv.get(t);if(Dv(r))try{let e=JSON.parse(r);if(typeof e==`object`&&e&&typeof e.value==`number`)return zv.validateStored(e,n)}catch{}}static writeStored(e,t,n,r){if(!r.useThroughputTtl){kv.set(t,n.toFixed(0));return}let i=JSON.stringify({value:Math.round(n),timestamp:Date.now(),networkType:Fv()?.effectiveType});kv.set(e,i)}static validateStored(e,t){if(!t.useThroughputTtl)return e.value;if(Date.now()-e.timestamp>t.storedThroughputTtlMs)return;let n=Fv()?.effectiveType;if(!(n!==void 0&&e.networkType!==void 0&&n!==e.networkType))return e.value}}var Bv=zv;var Uv={keepVideoElement:!1,clearVideoElementInnerHTML:!1,allowPlayerReuse:!1,throughputEstimator:{type:`EmaAndMa`,emaAlphaSlow:.2,emaAlphaFast:.7,emaAlpha:.45,basisTrendChangeCount:10,changeThreshold:.05,useBrowserEstimation:!0,initialThroughput:5e3,measureNonSegmentRequests:!1,rttPenaltyRequestSize:1*1024*1024,streamMinSampleSize:10*1024,streamMinSampleTime:300,smallSampleMinDuration:100,cacheThresholdSize:20,deviationDepth:20,deviationFactor:.5,lowLatency:{continuesByteSequenceInterval:50,maxLastEvaluationTimeout:300},useThroughputTtl:!1,storedThroughputTtlMs:144e5},autoTrackSelection:{maxBitrateFactorAtEmptyBuffer:4,bitrateFactorAtEmptyBuffer:2.8,minBitrateFactorAtEmptyBuffer:1.5,bitrateAudioFactorAtEmptyBuffer:10,maxBitrateFactorAtFullBuffer:3,bitrateFactorAtFullBuffer:2,minBitrateFactorAtFullBuffer:1,bitrateAudioFactorAtFullBuffer:7,minVideoAudioRatio:5,minAvailableThroughputAudioRatio:5,usePixelRatio:!0,pixelRatioMultiplier:void 0,pixelRatioLogBase:3,pixelRatioLogCoefficients:[1,0,1],limitByContainer:!0,maxContainerSizeFactor:2,containerSizeFactor:1.3,minContainerSizeFactor:1,lazyQualitySwitch:!0,minBufferToSwitchUp:.4,considerPlaybackRate:!1,trackCooldownIncreaseQuality:15e3,trackCooldownDecreaseQuality:3e3,backgroundVideoQualityLimit:Hv.Q_4320P,activeVideoAreaThreshold:.1,highQualityLimit:Hv.Q_720P,trafficSavingLimit:Hv.Q_480P},stallsManager:{enabled:!1,ignoreDynamicAbrForShortVideo:!1,stallDurationNoDataBeforeQualityDecrease:500,stallDurationToBeCount:100,stallCountBeforeQualityDecrease:3,resetQualityRestrictionTimeout:1e4,ignoreStallsOnSeek:!0,stallsMetricsHistoryLength:20,maxPossibleStallDuration:3e4,minTvtToBeCounted:120,maxTvtToBeCounted:10800,significantTvt:600,targetStallsDurationPerTvt:1,deviationStallsDurationPerTvt:.5,criticalStallsDurationPerTvt:6,abrAdjustingSpeed:.1,emaAlpha:.6,useTotalStallsDurationPerTvt:!0,useAverageStallsDurationPerTvt:!0,useEmaStallsDurationPerTvt:!0},droppedFramesChecker:{enabled:!1,percentLimit:.1,checkTime:1e3,countLimit:3,tickCountAfterQualityChange:5,qualityUpWaitingTime:5e3,minQualityBanLimit:Hv.Q_480P},dash:{forwardBufferTarget:6e4,forwardBufferTargetAuto:6e4,forwardBufferTargetManual:5*6e4,forwardBufferTargetPreload:5e3,useDynamicBufferTarget:!1,audioBufferAheadOfVideoMs:1e4,seekBiasInTheEnd:2e3,maxSegmentDurationLeftToSelectNextSegment:3e3,minSafeBufferThreshold:.5,bufferPruningSafeZone:1e3,segmentRequestSize:1*1024*1024,maxVirtualBufferSize:250*1024*1024,virtualBufferPruneSize:100*1024*1024,representationSwitchForwardBufferGap:6e4,crashOnStallTimeout:25e3,crashOnStallTWithoutDataTimeout:5e3,restoreBufferBeforeCrashTimeout:1e3,enableSubSegmentBufferFeeding:!0,bufferEmptinessTolerance:100,virtualBufferEmptinessTolerance:100,useBufferQueueVerification:!1,useVirtualBufferImplicitSeek:!1,useNewRepresentationSwitch:!1,useDelayedRepresentationSwitch:!1,useSmartRepresentationSwitch:!1,seekStallExitPolicy:!1,mutexStallExitPolicy:!1,useFetchPriorityHints:!0,useAbortMSEFix:!1,enableBaseUrlSupport:!0,maxSegmentRetryCount:5,sourceOpenTimeout:1e3,vktvAbrThrottle:0,timeupdateEventTickThrottle:300,fetcherBufferOptimisation:!0,codecsPrioritizeEnabled:!1,usePersistentGaps:!1,abrThrottle:0,useVideoElementWaitingCurrentTimeReassign:!0,stallWatchdogInterval:100,liveUpdateInterval:1e3,liveStallReinitInterval:3e3,ignoreNetworkErrorsOnLoadInit:!1,bufferTolerance:100,minNativeBufferSize:5e3,removeTimeShiftFromSegment:500,tickMaintainInterval:100,minSafeBufferToPlay:0,useBufferHoldingOnlyOnStall:!0,useAbortResetNativeBufferMutex:!1,useNewAbr:!1,useAbrPhases:!1,abrVideoRules:[`fits_container_rule`,`throughput_rule`,`buffer_rule`,`stalls_rule`,`upper_limit_rule`,`lower_limit_rule`],abrAudioRules:[`throughput_rule`,`min_audio_for_video_rule`],useDynamicBirtateRule:!1,useNewFailoverLogic:!1,useFailoverHostsOnAllProviderCrash:!1,videoTrackBanAfterProviderFail:15e3,saveData3gQualityLimit:Hv.Q_240P,saveData2gQualityLimit:Hv.Q_144P,useConnectionDataUpperLimit:!1,abandon:{minElapsedMs:1500,bufferSafetyFactor:.8,minLoadedFraction:.15,minBufferToActivateMs:500},bola:{bufferTargetMs:3e4,minBufferMs:1e4,minBufferPerBitrateLevelMs:2e3,placeholderBufferDecay:.99,fallbackSegmentDurationMs:4e3,finiteThresholdMs:6e4,adaptiveBufferTargetK:.5,adaptiveBufferTargetMaxMs:6e4,trimDetectThresholdMs:1e4,antiCascadeDownshift:!0},insufficientBuffer:{thresholdMs:500,gracePeriodAfterPlaybackResetMs:1e3,budgetFactor:.5,fallbackSegmentDurationMs:6e3},dynamicBufferTarget:{maxMs:12e4,optimisticHeadroomLow:3.5,optimisticHeadroomHigh:6,weakThroughputLowKbps:1500,weakThroughputHighKbps:5e3,maxFactor:1.5},videoStreamRepresentaionsFilter:[],filterOnDemandQualityList:!1,dashMaxTvVideoQuality:!1,checkRepresentationCanPlayType:!1,downloadTime:{minLookaheadSegments:3,safetyFactor:1.3,bootstrapBufferMs:5e3,demandTolerance:3}},dashCmafLive:{externalStopControl:!1,keepSilentStallWatchdogWhenNotActive:!1,maxActiveLiveOffset:1e4,normalizedTargetMinBufferSize:6e4,normalizedLiveMinBufferSize:5e3,normalizedActualBufferOffset:1e4,offsetCalculationError:3e3,maxLiveDuration:7200,catchupLiveForMutedInactiveTab:!0,lowLatency:{maxTargetOffset:3e3,maxTargetOffsetDeviation:250,playbackCatchupSpeedup:.05,isActiveOnDefault:!1,bufferEstimator:{emaAlpha:.45,changeThreshold:.05,deviationDepth:20,deviationFactor:.5,extremumInterval:5}}},live:{minBuffer:3e3,minBufferSegments:3,lowLatencyMinBuffer:1e3,lowLatencyMinBufferSegments:1,isLiveCatchUpMode:!1,lowLatencyActiveLiveDelay:3e3,activeLiveDelay:5e3,maxPausedTime:5e3,catchupLiveForMutedInactiveTab:!1},downloadBackoff:{bufferThreshold:100,start:100,factor:2,max:3*1e3,random:.1},enableWakeLock:!0,enableTelemetryAtStart:!1,forceFormat:void 0,formatsToAvoid:[],disableChromecast:!1,chromecastReceiverId:`07A4434E`,chromecastPresentationApi:!1,useWebmBigRequest:!1,webmCodec:`vp9`,androidPreferredFormat:`dash`,iosPreferredFormat:`hls`,preferCMAF:!1,preferWebRTC:!1,preferMultiStream:!1,preferHDR:!1,bigRequestMinInitSize:50*1024,bigRequestMinDataSize:1*1024*1024,stripRangeHeader:!0,flushShortLoopedBuffers:!0,insufficientBufferRuleMargin:1e4,seekNearDurationBias:1,dashSeekInSegmentDurationThreshold:180*1e3,dashSeekInSegmentAlwaysSeekDelta:1e4,useDelayedPlaybackHangupWithData:!1,playbackHangupNoDataThreshold:5e3,endGapTolerance:300,stallIgnoreThreshold:33,stallHandlingStrategy:`exclude-threshold`,gapWatchdogInterval:50,requestQuick:!1,useHlsJs:!1,disableHlsOnDesktop:!1,useNativeHLSTextTracks:!1,useNewSwitchTo:!1,alwaysAbortPreviousSwitch:!1,useDashProviderVirtual:!1,useDashProviderVirtualMobile:!1,useNewAutoSelectVideoTrack:!1,useSafariEndlessRequestBugfix:!0,isAudioDisabled:!1,autoplayOnlyInActiveTab:!0,autoplayOnlyIfVisible:!0,dynamicImportTimeout:5e3,maxPlaybackTransitionInterval:2e4,providerErrorLimit:3,manifestRetryInterval:300,manifestRetryMaxInterval:1e4,manifestRetryMaxCount:10,audioVideoSyncRate:20,webrtc:{connectionRetryMaxNumber:3},spherical:{enabled:!1,fov:{x:135,y:76},rotationSpeed:45,maxYawAngle:175,rotationSpeedCorrection:10,degreeToPixelCorrection:5,speedFadeTime:2e3,speedFadeThreshold:50},useVolumeMultiplier:!1,ignoreAudioRendererError:!1,useEnableSubtitlesParam:!1,useHlsLiveNewTextManager:!1,exposeInternalsToGlobal:!1,hlsLiveNewTextManagerDownloadThreshold:4e3,disableYandexPiP:!1,asyncResolveClientChecker:!1,changePlaybackStateToPausedWhenEnded:!1,suppressExceptionsInObservables:!0,devNullLogEnabled:!1,collectingDecodingInfoEnabled:!1,sendDashLiveDebug:!1,logDashLiveDebug:!1,reuseOwnVideoElement:!1,handleExtendedNetworkErrorsSet:!1,useUrlCacheMechanism:!1,useDurationFromSegments:!0,dropUrlCacheWhenProviderCrashed:!1,ignoreForcePlayResultWhenProviderChanged:!1,hls:{filterOnDemandQualityList:!1},disableSubtitles:!1,audioOnly:!1},Wv=e=>Vv(e,Uv);var vy=({seekState:e,position$:t})=>my(e.stateChangeEnded$.pipe(hy(({to:e})=>e.state===`none`?void 0:(e.position??NaN)/1e3),gy(_y)),t.pipe(gy(()=>e.getState().state===`none`)));var xy=(e,t,n,r)=>{e!==void 0&&t.getState()===void 0&&t.getPrevState()===void 0&&n?.getValue().length===0?n.pipe(yy(e=>e.length>0),by()).subscribe(n=>{n.find(r)&&t.startTransitionTo(e)}):(e===void 0||n?.getValue().find(r))&&t.startTransitionTo(e)};var Dy=()=>{let e=`mediaCapabilities`in Ey().navigator?Oy:ky,t=Sy(w(function*(){let t=yield Promise.all(Cy(Ay).map(function(){var t=w(function*([t,n]){return{codec:t,supported:yield e(n)}});return function(e){return t.apply(this,arguments)}}())),n=[j.browser.current,...t.map(e=>JSON.stringify(e))].slice(0,16);return Ty.push(`core`,{key:`videoplayer_decoding_info`,strings:n}),t}));return()=>wy(t)},Oy=function(){var e=w(function*(e){if(!e)return Promise.resolve({supported:!1});let t={[`channels`in e?`audio`:`video`]:e};return yield Ey().navigator.mediaCapabilities.decodingInfo(T({type:`media-source`},t))});return function(t){return e.apply(this,arguments)}}(),ky=e=>{if(!e)return Promise.resolve({supported:!1});let t=Ey().document,n=`channels`in e?t.createElement(`audio`):t.createElement(`video`);return Promise.resolve({supported:n.canPlayType(e?.contentType??``)===`probably`})},Ay={H264:{contentType:`video/mp4; codecs="avc1.4D400C"`,width:720,height:720,bitrate:2886,framerate:30},H265:{contentType:`video/mp4; codecs="hvc1.1.6.L123.B0"`,width:720,height:720,bitrate:2886,framerate:30},VP8:{contentType:`video/webm; codecs="vp8"`,width:720,height:720,bitrate:2886,framerate:30},VP9:{contentType:`video/webm; codecs="vp09.00.10.08"`,width:720,height:720,bitrate:2886,framerate:30},AV1:{contentType:`video/mp4; codecs="av01.0.01M.08"`,width:720,height:720,bitrate:2886,framerate:30},OPUS:{contentType:`audio/ogg; codecs="opus"`,channels:`2`,bitrate:128e3},AAC_LC:{contentType:`audio/mp4; codecs="mp4a.40.2"`,channels:`2`,bitrate:128e3},AC3:{contentType:`audio/mp4; codecs="ac-3"`,channels:`6`,bitrate:128e3},EAC3:{contentType:`audio/mp4; codecs="ec-3"`,channels:`6`,bitrate:128e3},AAC_HE_V1:{contentType:`audio/mp4; codecs="mp4a.40.5"`,channels:`2`,bitrate:128e3},AAC_HE_V2:{contentType:`audio/mp4; codecs="mp4a.40.29"`,channels:`2`,bitrate:128e3},AAC_xHE:{contentType:`audio/mp4; codecs="mp4a.40.42"`,channels:`2`,bitrate:128e3}},jy={playbackState$:void 0,position$:0,duration$:1/0,playedTime$:0,muted$:!1,volume$:1,availableVideoStreams$:[],currentVideoStream$:void 0,availableVideoTracks$:[],availableQualities$:[],availableQualitiesFps$:{},currentQuality$:void 0,isAutoQualityEnabled$:!0,autoQualityLimitingAvailable$:!1,autoQualityLimits$:{},predefinedQualityLimitType$:`unknown`,availableAudioStreams$:[],currentAudioStream$:void 0,availableAudioTracks$:[],isAudioAvailable$:!0,currentPlaybackRate$:1,currentBuffer$:{start:0,end:0},currentNativeBuffer$:{start:0,end:0},isBuffering$:!0,isStalled$:!1,stallStartTime$:0,isEnded$:!1,isLooped$:!1,isLive$:void 0,isLiveEnded$:null,canPlayLiveTailBuffer$:!1,canChangePlaybackSpeed$:void 0,atLiveEdge$:void 0,atLiveDurationEdge$:void 0,liveTime$:void 0,liveBufferTime$:void 0,liveLatency$:void 0,currentFormat$:void 0,availableTextTracks$:[],currentTextTrack$:void 0,throughputEstimation$:void 0,rttEstimation$:void 0,videoBitrate$:void 0,hostname$:void 0,httpConnectionType$:void 0,httpConnectionReused$:void 0,httpConnectionMetrics$:void 0,httpDownloadMetrics$:void 0,surface$:`none`,chromecastState$:`NOT_AVAILABLE`,chromecastDeviceName$:void 0,intrinsicVideoSize$:void 0,availableSources$:void 0,is3DVideo$:!1,currentVideoSegmentLength$:0,currentAudioSegmentLength$:0},My={audioStream:void 0,autoVideoTrackLimits:{},autoVideoTrackSwitching:!0,cameraOrientation:{x:0,y:0},currentTextTrack:void 0,externalTextTracks:[],internalTextTracks:[],isLooped:!1,isLowLatency:!1,playbackRate:1,playbackState:`stopped`,seekState:{state:`none`},textTrackCuesSettings:{},videoTrack:void 0,videoStream:void 0,volume:{volume:1,muted:!1}};var Py=e=>{let t=typeof e.container==`string`?document.getElementById(e.container):e.container;return Ny(t,`Wrong container or containerId {${e.container}}`),t};class Fy{constructor(e={},t=fy.createRootTracer(`fake`),n){this.subscription=new ly,this.persistentSubscription=new ly,this.domContainer=null,this.providerContainer=void 0,this.chromecastInitializer=void 0,this.logger=new ay,this.tracer=void 0,this.abrLogger=this.logger.createComponentLog(`ABR`),this.config=void 0,this.tuning=void 0,this.throughputEstimator=void 0,this.internalsExposure=null,this.isPlaybackStarted=!1,this.suppressWillStop=!1,this.initedAt=void 0,this.hasLiveOffsetByPaused=new py(!1),this.hasLiveOffsetByPausedTimer=0,this.playerInitRequest=0,this.playerInited=new py(!1),this.explicitInitialQuality=void 0,this.wasSetStartedQuality=!1,this.desiredState=le(My).reduce((e,[t,n])=>(e[t]=new dn(n),e),{}),this.info=le(jy).reduce((e,[t,n])=>(e[t]=new py(n),e),{}),this.events={inited$:new $,ready$:new $,started$:new $,playing$:new $,paused$:new $,stopped$:new $,willReady$:new $,willStart$:new $,willResume$:new $,willPause$:new $,willStop$:new $,willDestruct$:new $,watchCoverageRecord$:new $,watchCoverageLive$:new $,managedError$:new $,fatalError$:new $,fetcherRecoverableError$:new $,ended$:new $,looped$:new $,seeked$:new $,willSeek$:new $,autoplaySoundProhibited$:new $,manifestRequested$:new $,firstBytesManifest$:new $,manifestReceived$:new $,firstBytesRequested$:new $,firstBytesReceived$:new $,firstBytes$:new $,loadedMetadata$:new $,firstFrame$:new $,canplay$:new $,log$:new $,fetcherError$:new $,severeStallOccured$:new $},this.experimental={element$:new py(void 0),enableDebugTelemetry$:new py(!1),dumpTelemetry:ni,getCurrentTime$:new py(null),skipVideoElVolumeSync$:new py(!1)},this.devNullLog=void 0,this.collectDecodingInfoDestroyCb=void 0,this.doInit=e=>{let{container:t}=e,n=ee(e,C);this.tracer.log(`initVideo`,Yv(n),!0),this.domContainer=Py(e),this.chromecastInitializer.contentId=e.meta?.videoId,this.providerContainer=new yv({sources:e.sources,meta:e.meta??{},failoverHosts:e.failoverHosts??[],container:this.domContainer,desiredState:this.desiredState,dependencies:{throughputEstimator:this.throughputEstimator,chromecastInitializer:this.chromecastInitializer,tracer:this.tracer,logger:this.logger,abrLogger:this.abrLogger},tuning:this.tuning,volumeMultiplier:e.volumeMultiplier,panelSize:e.panelSize,skipVideoElVolumeSync$:this.experimental.skipVideoElVolumeSync$,handleNetworkRecoverableErrorAsProviderError:e.handleNetworkRecoverableErrorAsProviderError}),this.initProviderContainerSubscription(this.providerContainer),this.initStartingVideoTrack(this.providerContainer),this.providerContainer.init(),this.setLiveLowLatency(this.tuning.dashCmafLive.lowLatency.isActiveOnDefault),this.initDebugTelemetry(),this.initWakeLock(),this.playerInited.next(!0),this.devNullLog&&this.tuning.devNullLogEnabled?(qv.subscribe(`core`,this.devNullLog),this.tuning.collectingDecodingInfoEnabled&&(this.collectDecodingInfoDestroyCb=Dy())):qv.destroy(`core`)},this.initLogs(),this.tuning=Wv(e),this.tracer=t,this.tuning.suppressExceptionsInObservables&&(ue(this.info).forEach(e=>e.setSuppressErrors(!0)),ue(this.events).forEach(e=>e.setSuppressErrors(!0)));let r={receiverApplicationId:this.tuning.chromecastReceiverId,isDisabled:this.tuning.disableChromecast,dependencies:{logger:this.logger}};if(this.chromecastInitializer=this.tuning.chromecastPresentationApi?new tn(r):new De(r),this.throughputEstimator=new Bv(this.tuning.throughputEstimator),e.exposeInternalsToGlobal&&(this.internalsExposure=new ey(`core`,Zv(n?.playerId)),this.internalsExposure.expose({player:this})),this.initChromecastSubscription(),this.initDesiredStateSubscriptions(),this.devNullLog=n?.onDevNullLog,qv.create(`core`),Proxy&&Reflect)return new Proxy(this,{get:(e,t,n)=>{let r=Reflect.get(e,t,n);return typeof r==`function`?(...n)=>{try{return r.apply(e,n)}catch(e){let r=n.map(e=>JSON.stringify(e,(e,t)=>{let n=typeof t;return de([`number`,`string`,`boolean`],n)?t:t===null?null:`<${n}>`})),i=`Player.${String(t)}`,a=`Exception calling ${i} (${r.join(`, `)})`;throw this.events.fatalError$.next({id:i,category:Jv.WTF,message:a,thrown:e}),e}}:r}})}resetDesiredState(){let e=(e,t)=>{e.setState(t)};Object.keys(this.desiredState).forEach(t=>{e(this.desiredState[t],My[t])})}reset(){this.subscription.unsubscribe(),this.providerContainer?.destroy(),this.providerContainer=void 0,$v().clearTimeout(this.hasLiveOffsetByPausedTimer),this.collectDecodingInfoDestroyCb?.call(this),this.playerInited.next(!1),this.resetDesiredState();let e=(e,t)=>{e.next(t)},t=[`muted$`,`volume$`];Object.keys(this.info).forEach(n=>{de(t,n)?e(this.info[n],this.info[n].getValue()):e(this.info[n],jy[n])})}initAudio(e){return this.initVideo(T(T({},e),{},{container:e.audioElement??document.createElement(`audio`)}))}initVideo(e){let t=$v();this.config=e,this.internalsExposure?.expose({config:e,logger:this.logger,tuning:this.tuning}),this.setMuted(this.tuning.isAudioDisabled);let n=()=>{this.tuning.autoplayOnlyIfVisible&&t.requestAnimationFrame?this.playerInitRequest=t.requestAnimationFrame(()=>this.doInit(e)):this.doInit(e)},r=()=>{this.tuning.asyncResolveClientChecker?j.isInited$.pipe(Y(e=>!!e),Q()).subscribe(()=>{console.log(`Core SDK async start`),n()}):n()};return this.isNotActiveTabCase()?(this.tracer.log(`request play from hidden tab`),Xv(t.document,`visibilitychange`).pipe(Q()).subscribe(r)):r(),this}destroy(e){let t=$v();this.tracer.log(`destroy`),t.clearTimeout(this.hasLiveOffsetByPausedTimer),this.playerInitRequest&&t.cancelAnimationFrame(this.playerInitRequest),this.events.willDestruct$.next(),this.suppressWillStop=e?.reportStop===!1,this.stop(),this.providerContainer?.destroy(),this.throughputEstimator.destroy(),this.chromecastInitializer.destroy(),this.subscription.unsubscribe(),this.persistentSubscription.unsubscribe(),this.tracer.end(),this.internalsExposure?.destroy(),qv.destroy(`core`),this.collectDecodingInfoDestroyCb?.call(this)}waitInit(e){this.playerInited.getValue()?e():this.subscription.add(this.playerInited.pipe(Y(e=>!!e),Q()).subscribe(e))}prepare(){return this.waitInit(()=>{let e=this.desiredState.playbackState;this.tracer.log(`prepare`,{currentPlayBackState:e.getState()}),e.getState()===`stopped`&&e.startTransitionTo(`ready`)}),this}play(){return this.waitInit(()=>{let e=this.desiredState.playbackState;this.tracer.log(`play`,{currentPlayBackState:e.getState()}),e.getState()!==`playing`&&e.startTransitionTo(`playing`)}),this}pause(){return this.waitInit(()=>{let e=this.desiredState.playbackState;this.tracer.log(`pause`,{currentPlayBackState:e.getState()}),e.getState()!==`paused`&&e.startTransitionTo(`paused`)}),this}stop(){return this.waitInit(()=>{let e=this.desiredState.playbackState;this.tracer.log(`stop`,{currentPlayBackState:e.getState()}),e.getState()!==`stopped`&&(e.startTransitionTo(`stopped`),this.tuning.allowPlayerReuse&&this.reset())}),this}seekTime(e,t=!0){return this.waitInit(()=>{let n=this.info.duration$.getValue(),r=this.info.isLive$.getValue(),i=e;e>=n&&!r&&(i=n-this.tuning.seekNearDurationBias),this.tracer.log(`seekTime`,{duration:n,isLive:r,time:e,calculatedTime:i,forcePrecise:t}),Number.isFinite(i)&&(this.events.willSeek$.next({from:this.getExactTime(),to:i}),this.desiredState.seekState.setState({state:`requested`,position:i*1e3,forcePrecise:t}))}),this}seekPercent(e){return this.waitInit(()=>{let t=this.info.duration$.getValue();this.tracer.log(`seekPercent`,{percent:e,duration:t}),isFinite(t)&&this.seekTime(Math.abs(t)*e,!1)}),this}setVolume(e,t,n=!1){return this.waitInit(()=>{this.experimental.skipVideoElVolumeSync$.next(n);let r=this.desiredState.volume,i=r.getTransition()?.to.muted??this.info.muted$.getValue(),a=t??(this.tuning.isAudioDisabled||i);this.tracer.log(`setVolume`,{volume:e,isAudioDisabled:this.tuning.isAudioDisabled,chromecastState:this.chromecastInitializer.castState$.getValue(),muted:a}),this.chromecastInitializer.castState$.getValue()===`CONNECTED`&&!(this.chromecastInitializer instanceof tn)?this.chromecastInitializer.setVolume(e):r.startTransitionTo({volume:e,muted:a})}),this}setMuted(e,t=!1,n=!1){return this.waitInit(()=>{this.experimental.skipVideoElVolumeSync$.next(n);let r=this.desiredState.volume,i=this.tuning.isAudioDisabled&&!t||e,a=r.getTransition()?.to.volume??this.info.volume$.getValue();this.tracer.log(`setMuted`,{isMuted:e,nextMuted:i,volume:a,isAudioDisabled:this.tuning.isAudioDisabled,chromecastState:this.chromecastInitializer.castState$.getValue()}),this.chromecastInitializer.castState$.getValue()===`CONNECTED`&&!(this.chromecastInitializer instanceof tn)?this.chromecastInitializer.setMuted(i):r.startTransitionTo({volume:a,muted:i})}),this}setVideoStream(e){return this.waitInit(()=>{this.desiredState.videoStream.startTransitionTo(e)}),this}setAudioStream(e){return this.waitInit(()=>{this.desiredState.audioStream.startTransitionTo(e)}),this}setQuality(e){return this.waitInit(()=>{Gv(this.providerContainer);let t=this.providerContainer.providerOutput.availableVideoTracks$.getValue();this.tracer.log(`setQuality`,{isDelayed:t.length===0,quality:e}),this.desiredState.videoTrack.getState()===void 0&&this.desiredState.videoTrack.getPrevState()===void 0&&t.length===0?this.wasSetStartedQuality?this.providerContainer.providerOutput.availableVideoTracks$.pipe(Y(e=>e.length>0),Q()).subscribe(t=>{this.setVideoTrackIdByQuality(t,e)}):this.explicitInitialQuality=e:t.length>0&&this.setVideoTrackIdByQuality(t,e)}),this}setAutoQuality(e){return this.waitInit(()=>{this.tracer.log(`setAutoQuality`,{enable:e}),this.desiredState.autoVideoTrackSwitching.startTransitionTo(e)}),this}setAutoQualityLimits(e){return this.waitInit(()=>{this.tracer.log(`setAutoQualityLimits`,Yv(e)),this.desiredState.autoVideoTrackLimits.startTransitionTo(e)}),this}setPredefinedQualityLimits(e){return this.waitInit(()=>{if(this.info.predefinedQualityLimitType$.getValue()===e)return this;let{highQualityLimit:t,trafficSavingLimit:n}=this.tuning.autoTrackSelection,r;switch(e){case`high_quality`:r={min:t,max:void 0};break;case`traffic_saving`:r={max:n,min:void 0};break;default:r={max:void 0,min:void 0}}this.setAutoQualityLimits(r)}),this}setPlaybackRate(e){return this.waitInit(()=>{this.tracer.log(`setPlaybackRate`,{playbackRate:e}),this.desiredState.playbackRate.startTransitionTo(e)}),this}setExternalTextTracks(e){return this.waitInit(()=>{e.length&&this.tracer.log(`setExternalTextTracks`,Yv(e)),this.desiredState.externalTextTracks.startTransitionTo(e.map(e=>T({type:`external`},e)))}),this}selectTextTrack(e){return this.waitInit(()=>{xy(e,this.desiredState.currentTextTrack,this.providerContainer?.providerOutput.availableTextTracks$,t=>t.id===e),this.tracer.log(`selectTextTrack`,{textTrackId:e})}),this}setTextTrackCueSettings(e){return this.waitInit(()=>{this.tracer.log(`setTextTrackCueSettings`,T({},e)),this.desiredState.textTrackCuesSettings.startTransitionTo(e)}),this}setLiveLowLatency(e){let t=this.info.isLive$.getValue(),n=this.desiredState.isLowLatency.getState();return!t||n===e?this:(this.tracer.log(`live switch to low latency `+e),this.desiredState.isLowLatency.setState(e),this.seekTime(0))}setLooped(e){return this.waitInit(()=>{this.tracer.log(`setLooped`,{isLooped:e}),this.desiredState.isLooped.startTransitionTo(e)}),this}toggleChromecast(){this.tracer.log(`toggleChromecast`),this.chromecastInitializer.toggleConnection()}startCameraManualRotation(e,t){return this.waitInit(()=>{let n=this.getScene3D();this.tracer.log(`startCameraManualRotation`,{isScene3DAvailable:!!n,mx:e,my:t}),n&&n.startCameraManualRotation(e,t)}),this}stopCameraManualRotation(e=!1){return this.waitInit(()=>{let t=this.getScene3D();this.tracer.log(`stopCameraManualRotation`,{isScene3DAvailable:!!t,immediate:e}),t&&t.stopCameraManualRotation(e)}),this}moveCameraFocusPX(e,t){return this.waitInit(()=>{let n=this.getScene3D();if(this.tracer.log(`moveCameraFocusPX`,{isScene3DAvailable:!!n,dxpx:e,dypx:t}),n){let r=n.getCameraRotation(),i=n.pixelToDegree({x:e,y:t});this.desiredState.cameraOrientation.setState({x:r.x+i.x,y:r.y+i.y})}}),this}holdCamera(){return this.waitInit(()=>{let e=this.getScene3D();e&&e.holdCamera()}),this}releaseCamera(){return this.waitInit(()=>{let e=this.getScene3D();e&&e.releaseCamera()}),this}getExactTime(){if(!this.providerContainer)return 0;let e=this.providerContainer.providerOutput.element$.getValue();if(iy(e))return this.info.position$.getValue();let t=this.desiredState.seekState.getState(),n=t.state===`none`?void 0:t.position;return ry(n)?n/1e3:e.currentTime}getExactLiveTime(){if(!this.providerContainer)return 0;let e=this.desiredState.seekState.getState(),t=e.state===`none`?void 0:e.position;return(ry(t)?t:this.info.liveTime$.getValue()??0)/1e3}getAllLogs(){return this.logger.getAllLogs()}getScene3D(){var e;let t=this.providerContainer?.current$.getValue();if(!(t==null||(e=t.provider)==null)&&e.scene3D)return t.provider.scene3D}setIntrinsicVideoSize(...e){let t={width:e.reduce((e,{width:t})=>e||t||0,0),height:e.reduce((e,{height:t})=>e||t||0,0)};t.width&&t.height&&this.info.intrinsicVideoSize$.next({width:t.width,height:t.height})}initDesiredStateSubscriptions(){this.persistentSubscription.add(sy(this.desiredState.playbackState.stateChangeStarted$,this.desiredState.playbackState.forceChanged$).pipe(Z(e=>e.to)).subscribe(this.info.playbackState$)).add(this.desiredState.isLooped.stateChangeEnded$.pipe(Z(e=>e.to)).subscribe(this.info.isLooped$)).add(this.desiredState.playbackRate.stateChangeEnded$.pipe(Z(e=>e.to)).subscribe(this.info.currentPlaybackRate$)).add(this.desiredState.autoVideoTrackSwitching.stateChangeEnded$.pipe(Z(e=>e.to)).subscribe(this.info.isAutoQualityEnabled$)).add(this.desiredState.autoVideoTrackLimits.stateChangeEnded$.pipe(Z(e=>e.to)).subscribe(e=>{this.info.autoQualityLimits$.next(e);let{highQualityLimit:t,trafficSavingLimit:n}=this.tuning.autoTrackSelection;this.info.predefinedQualityLimitType$.next(ui(e,t,n))})).add(sy(this.desiredState.playbackState.stateChangeStarted$,this.desiredState.playbackState.forceChanged$).pipe(Y(({from:e})=>e===`stopped`)).subscribe(()=>{this.initedAt=cy(),this.events.inited$.next()})).add(this.desiredState.playbackState.stateChangeEnded$.subscribe(e=>{switch(e.to){case`ready`:this.events.ready$.next();break;case`playing`:this.isPlaybackStarted||this.events.started$.next(),this.isPlaybackStarted=!0,this.events.playing$.next();break;case`paused`:this.events.paused$.next();break;case`stopped`:this.events.stopped$.next()}})).add(this.desiredState.playbackState.stateChangeStarted$.subscribe(e=>{switch(e.to){case`ready`:this.events.willReady$.next();break;case`paused`:this.events.willPause$.next();break;case`playing`:this.isPlaybackStarted?this.events.willResume$.next():this.events.willStart$.next();break;case`stopped`:this.suppressWillStop||this.events.willStop$.next();break;default:}}))}initProviderContainerSubscription(e){this.subscription.add(e.providerOutput.willSeekEvent$.subscribe(()=>{let e=this.desiredState.seekState.getState();this.tracer.log(`willSeekEvent`,Yv(e)),e.state===`requested`?this.desiredState.seekState.setState(T(T({},e),{},{state:`applying`})):this.events.managedError$.next({id:`WillSeekIn${e.state}`,category:Jv.WTF,message:`Received unexpeceted willSeek$`})})).add(e.providerOutput.soundProhibitedEvent$.pipe(Q()).subscribe(this.events.autoplaySoundProhibited$)).add(e.providerOutput.severeStallOccurred$.subscribe(this.events.severeStallOccured$)).add(e.providerOutput.seekedEvent$.subscribe(()=>{let e=this.desiredState.seekState.getState();this.tracer.log(`seekedEvent`,Yv(e)),e.state===`applying`&&(this.desiredState.seekState.setState({state:`none`}),this.events.seeked$.next())})).add(e.current$.pipe(Z(e=>e.type)).subscribe(this.info.currentFormat$)).add(e.current$.pipe(Z(e=>e.destination),X()).subscribe(()=>this.isPlaybackStarted=!1)).add(e.providerOutput.availableVideoStreams$.subscribe(this.info.availableVideoStreams$)).add(e.providerOutput.availableVideoTracks$.subscribe(this.info.availableVideoTracks$)).add(Kv({availableVideoTracks:e.providerOutput.availableVideoTracks$,currentVideoStream:e.providerOutput.currentVideoStream$}).pipe(Z(({availableVideoTracks:e,currentVideoStream:t})=>e.filter(e=>t?t.id===e.streamId:!0).map(({quality:e})=>e).sort((e,t)=>ny(e)?1:ny(t)?-1:ty(t,e)?1:-1))).subscribe(this.info.availableQualities$)).add(e.providerOutput.availableVideoTracks$.subscribe(e=>{let t={};for(let n of e)n.fps&&(t[n.quality]=n.fps);this.info.availableQualitiesFps$.next(t)})).add(e.providerOutput.availableAudioStreams$.subscribe(this.info.availableAudioStreams$)).add(e.providerOutput.currentVideoStream$.subscribe(this.info.currentVideoStream$)).add(e.providerOutput.currentAudioStream$.subscribe(this.info.currentAudioStream$)).add(e.providerOutput.availableAudioTracks$.subscribe(this.info.availableAudioTracks$)).add(e.providerOutput.isAudioAvailable$.pipe(X()).subscribe(this.info.isAudioAvailable$)).add(e.providerOutput.currentVideoTrack$.pipe(Y(e=>ry(e))).subscribe(e=>{this.info.currentQuality$.next(e?.quality),this.info.videoBitrate$.next(e?.bitrate)})).add(e.providerOutput.currentVideoSegmentLength$.pipe(X((e,t)=>Math.round(e)===Math.round(t))).subscribe(this.info.currentVideoSegmentLength$)).add(e.providerOutput.currentAudioSegmentLength$.pipe(X((e,t)=>Math.round(e)===Math.round(t))).subscribe(this.info.currentAudioSegmentLength$)).add(e.providerOutput.hostname$.pipe(X()).subscribe(this.info.hostname$)).add(e.providerOutput.httpConnectionType$.pipe(X()).subscribe(this.info.httpConnectionType$)).add(e.providerOutput.httpConnectionReused$.pipe(X()).subscribe(this.info.httpConnectionReused$)).add(e.providerOutput.httpConnectionMetrics$.pipe(X()).subscribe(this.info.httpConnectionMetrics$)).add(e.providerOutput.httpDownloadMetrics$.pipe(X()).subscribe(this.info.httpDownloadMetrics$)).add(e.providerOutput.currentTextTrack$.subscribe(this.info.currentTextTrack$)).add(e.providerOutput.availableTextTracks$.subscribe(this.info.availableTextTracks$)).add(e.providerOutput.autoVideoTrackLimitingAvailable$.subscribe(this.info.autoQualityLimitingAvailable$)).add(e.providerOutput.autoVideoTrackLimits$.subscribe(e=>{this.desiredState.autoVideoTrackLimits.setState(e??{})})).add(e.providerOutput.currentBuffer$.pipe(Z(e=>e?{start:e.from,end:e.to}:{start:0,end:0})).subscribe(this.info.currentBuffer$)).add(e.providerOutput.currentNativeBuffer$.pipe(Z(e=>e?{start:e.from,end:e.to}:{start:0,end:0})).subscribe(this.info.currentNativeBuffer$)).add(e.providerOutput.duration$.subscribe(this.info.duration$)).add(e.providerOutput.playedTime$.subscribe(this.info.playedTime$)).add(e.providerOutput.isBuffering$.subscribe(this.info.isBuffering$)).add(e.providerOutput.isLive$.subscribe(this.info.isLive$)).add(e.providerOutput.isLiveEnded$.pipe(uy(e=>e&&this.stop())).subscribe(this.info.isLiveEnded$)).add(e.providerOutput.canPlayLiveTailBuffer$.subscribe(this.info.canPlayLiveTailBuffer$)).add(e.providerOutput.canChangePlaybackSpeed$.subscribe(this.info.canChangePlaybackSpeed$)).add(e.providerOutput.liveTime$.pipe(X()).subscribe(this.info.liveTime$)).add(e.providerOutput.liveBufferTime$.subscribe(this.info.liveBufferTime$)).add(e.providerOutput.liveLatency$.subscribe(this.info.liveLatency$)).add(Kv({hasLiveOffsetByPaused:sy(this.desiredState.playbackState.stateChangeStarted$,this.desiredState.playbackState.forceChanged$).pipe(Z(e=>e.to),X(),Z(e=>e===`paused`)),isLowLatency:e.providerOutput.isLowLatency$}).subscribe(({hasLiveOffsetByPaused:e,isLowLatency:t})=>{let n=$v();if(n.clearTimeout(this.hasLiveOffsetByPausedTimer),e){this.hasLiveOffsetByPausedTimer=n.setTimeout(()=>{this.hasLiveOffsetByPaused.next(!0)},this.getActiveLiveDelay(t));return}this.hasLiveOffsetByPaused.next(!1)})).add(Kv({atLiveEdge:Kv({isLive:e.providerOutput.isLive$,isLowLatency:e.providerOutput.isLowLatency$,position:vy({seekState:this.desiredState.seekState,position$:e.providerOutput.position$})}).pipe(Z(({isLive:e,position:t,isLowLatency:n})=>{let r=this.getActiveLiveDelay(n);return e&&Math.abs(t)<r/1e3}),X(),uy(e=>e&&this.setPlaybackRate(1))),hasPausedTimeoutCase:this.hasLiveOffsetByPaused}).pipe(Z(({atLiveEdge:e,hasPausedTimeoutCase:t})=>e&&!t)).subscribe(this.info.atLiveEdge$)).add(Kv({isLive:e.providerOutput.isLive$,position:e.providerOutput.position$,duration:e.providerOutput.duration$}).pipe(Z(({isLive:e,position:t,duration:n})=>e&&(Math.abs(n)-Math.abs(t))*1e3<this.tuning.live.activeLiveDelay),X(),uy(e=>e&&this.setPlaybackRate(1))).subscribe(this.info.atLiveDurationEdge$)).add(e.providerOutput.volume$.pipe(Z(e=>e.muted),X()).subscribe(this.info.muted$)).add(e.providerOutput.volume$.pipe(Z(e=>e.volume),X()).subscribe(this.info.volume$)).add(vy({seekState:this.desiredState.seekState,position$:e.providerOutput.position$}).subscribe(this.info.position$)).add(e.providerOutput.seekedEvent$.subscribe(()=>{this.info.isEnded$.getValue()&&this.tuning.changePlaybackStateToPausedWhenEnded&&this.play()})).add(sy(e.providerOutput.endedEvent$.pipe(oy(!0)),e.providerOutput.seekedEvent$.pipe(oy(!1))).pipe(X()).subscribe(this.info.isEnded$)).add(e.providerOutput.endedEvent$.subscribe(this.events.ended$)).add(e.providerOutput.loopedEvent$.subscribe(this.events.looped$)).add(e.providerError$.subscribe(this.events.managedError$)).add(e.providerOutput.updateDurationError$.subscribe(this.events.managedError$)).add(e.providerOutput.fetcherRecoverableError$.subscribe(this.events.fetcherRecoverableError$)).add(e.providerOutput.fetcherError$.pipe(Y(e=>e.category===Jv.FATAL)).subscribe(this.events.fatalError$)).add(e.volumeMultiplierError$.subscribe(this.events.managedError$)).add(e.noAvailableProvidersError$.pipe(Z(({forced:e,input:t,supported:n})=>{let r,i;return e?(r=`NoForcedFormat`,i=`${e} was forced but failed or not available`):n.length?(r=`NoFormats`,i=`All formats failed`):t.length?(r=`NoSupportedFormats`,i=`No supported formats`):(r=`NoInputFormats`,i=`No formats supplied`),Gv(r),{id:r,category:Jv.VIDEO_PIPELINE,message:i}})).subscribe(this.events.fatalError$)).add(e.providerOutput.element$.subscribe(this.experimental.element$)).add(e.providerOutput.getCurrentTime$.subscribe(this.experimental.getCurrentTime$)).add(e.providerOutput.manifestRequested$.pipe(Q()).subscribe(this.events.manifestRequested$)).add(e.providerOutput.firstBytesManifest$.pipe(Q()).subscribe(this.events.firstBytesManifest$)).add(e.providerOutput.manifestReceived$.pipe(Q()).subscribe(this.events.manifestReceived$)).add(e.providerOutput.firstBytesRequested$.pipe(Q()).subscribe(this.events.firstBytesRequested$)).add(e.providerOutput.firstBytesReceived$.pipe(Q()).subscribe(this.events.firstBytesReceived$)).add(e.providerOutput.firstBytesEvent$.pipe(Q(),Z(e=>e??cy()-this.initedAt)).subscribe(this.events.firstBytes$)).add(e.providerOutput.loadedMetadataEvent$.subscribe(this.events.loadedMetadata$)).add(e.providerOutput.firstFrameEvent$.pipe(Q(),Z(()=>cy()-this.initedAt)).subscribe(this.events.firstFrame$)).add(e.providerOutput.canplay$.pipe(Q(),Z(()=>cy()-this.initedAt)).subscribe(this.events.canplay$)).add(this.throughputEstimator.throughput$.subscribe(this.info.throughputEstimation$)).add(this.throughputEstimator.rtt$.subscribe(this.info.rttEstimation$)).add(e.providerOutput.availableSources$.subscribe(this.info.availableSources$));let t=new py(!1);this.subscription.add(e.providerOutput.seekedEvent$.subscribe(()=>t.next(!1))).add(e.providerOutput.willSeekEvent$.subscribe(()=>t.next(!0)));let n=new py(!0);this.subscription.add(e.current$.subscribe(()=>n.next(!0))).add(this.desiredState.playbackState.stateChangeEnded$.pipe(Y(({to:e})=>e===`playing`),Q()).subscribe(()=>n.next(!1)));let r=0,i=0,a=sy(e.providerOutput.isBuffering$,t,n).pipe(Z(()=>{let r=e.providerOutput.isBuffering$.getValue(),i=t.getValue()||n.getValue();return r&&!i}),X());this.subscription.add(a.subscribe(e=>{let{stallIgnoreThreshold:t,stallHandlingStrategy:n}=this.tuning,a=$v();e?(i=cy(),n===`verbose`&&this.info.stallStartTime$.next(i),r=a.setTimeout(()=>{this.info.isStalled$.next(!0),i&&this.info.stallStartTime$.next(n===`exclude-threshold`?cy():i)},t)):(a.clearTimeout(r),this.info.isStalled$.next(!1),i=0,this.info.stallStartTime$.next(0))})),this.subscription.add(sy(e.providerOutput.canplay$,e.providerOutput.firstFrameEvent$,e.providerOutput.firstBytesEvent$).subscribe(()=>{let t=e.providerOutput.element$.getValue();this.setIntrinsicVideoSize({width:t?.videoWidth,height:t?.videoHeight})})).add(e.providerOutput.currentVideoTrack$.subscribe(t=>{var n,r;let i=e.providerOutput.element$.getValue();this.setIntrinsicVideoSize({width:t==null||(n=t.size)==null?void 0:n.width,height:t==null||(r=t.size)==null?void 0:r.height},{width:i?.videoWidth,height:i?.videoHeight})})).add(e.providerOutput.is3DVideo$.subscribe(this.info.is3DVideo$)),this.subscription.add(sy(e.providerOutput.inPiP$,e.providerOutput.inFullscreen$,e.providerOutput.element$,e.providerOutput.elementVisible$,this.chromecastInitializer.castState$).subscribe(()=>{let t=e.providerOutput.inPiP$.getValue(),n=e.providerOutput.inFullscreen$.getValue(),r=e.providerOutput.element$.getValue(),i=e.providerOutput.elementVisible$.getValue(),a=this.chromecastInitializer.castState$.getValue(),o;o=a===`CONNECTED`?`second_screen`:r?i?t?`pip`:n?`fullscreen`:`inline`:`invisible`:`none`,this.info.surface$.getValue()!==o&&this.info.surface$.next(o)}))}initChromecastSubscription(){this.subscription.add(this.chromecastInitializer.castState$.subscribe(this.info.chromecastState$)),this.subscription.add(this.chromecastInitializer.connection$.pipe(Z(e=>e?.castDevice.friendlyName)).subscribe(this.info.chromecastDeviceName$)),this.subscription.add(this.chromecastInitializer.errorEvent$.subscribe(this.events.managedError$))}initStartingVideoTrack(e){let t=new ly;this.subscription.add(t),this.subscription.add(e.current$.pipe(X((e,t)=>e.provider===t.provider)).subscribe(()=>{t.unsubscribe(),t.add(e.providerOutput.availableVideoTracks$.pipe(Y(e=>e.length>0),Q()).subscribe(e=>{this.setStartingVideoTrack(e)}))}))}setStartingVideoTrack(e){let t;this.wasSetStartedQuality=!0;let n=this.explicitInitialQuality??this.info.currentQuality$.getValue();n&&(t=e.find(({quality:e,tvDisabled:t})=>e===n&&!t),t||this.setAutoQuality(!0)),!t&&(t=Oi(e,{container:this.domContainer?.getBoundingClientRect(),panelSize:this.config.panelSize,estimatedThroughput:this.throughputEstimator.throughput$.getValue(),tuning:this.tuning.autoTrackSelection,limits:this.desiredState.autoVideoTrackLimits.getState(),playbackRate:this.info.currentPlaybackRate$.getValue(),forwardBufferHealth:0,abrLogger:this.abrLogger})),this.desiredState.videoTrack.startTransitionTo(t),this.info.currentQuality$.next(t.quality),this.info.videoBitrate$.next(t.bitrate)}initLogs(){this.persistentSubscription.add(sy(this.desiredState.videoTrack.stateChangeStarted$.pipe(Z(e=>({transition:e,entity:`quality`,type:`start`}))),this.desiredState.videoTrack.stateChangeEnded$.pipe(Z(e=>({transition:e,entity:`quality`,type:`end`}))),this.desiredState.autoVideoTrackSwitching.stateChangeStarted$.pipe(Z(e=>({transition:e,entity:`autoQualityEnabled`,type:`start`}))),this.desiredState.autoVideoTrackSwitching.stateChangeEnded$.pipe(Z(e=>({transition:e,entity:`autoQualityEnabled`,type:`end`}))),this.desiredState.seekState.stateChangeStarted$.pipe(Z(e=>({transition:e,entity:`seekState`,type:`start`}))),this.desiredState.seekState.stateChangeEnded$.pipe(Z(e=>({transition:e,entity:`seekState`,type:`end`}))),this.desiredState.playbackState.stateChangeStarted$.pipe(Z(e=>({transition:e,entity:`playbackState`,type:`start`}))),this.desiredState.playbackState.stateChangeEnded$.pipe(Z(e=>({transition:e,entity:`playbackState`,type:`end`})))).pipe(Z(e=>({component:`desiredState`,message:`[${e.entity} change] ${e.type}: ${JSON.stringify(e.transition)}`}))).subscribe(this.logger.log)),this.persistentSubscription.add(this.logger.log$.subscribe(this.events.log$))}initDebugTelemetry(){let e=this.providerContainer?.providerOutput;Gv(this.providerContainer),Gv(e),ti(),this.experimental.enableDebugTelemetry$.next(this.tuning.enableTelemetryAtStart),[this.experimental.enableDebugTelemetry$.subscribe(e=>ei(e)),this.providerContainer.current$.subscribe(({type:e})=>ri(`provider`,e)),e.duration$.subscribe(e=>ri(`duration`,e)),e.availableVideoTracks$.pipe(Y(e=>!!e.length),Q()).subscribe(e=>ri(`tracks`,e)),this.events.fatalError$.subscribe(new ii(`fatalError`)),this.events.managedError$.subscribe(new ii(`managedError`)),e.position$.subscribe(new ii(`position`)),e.currentVideoTrack$.pipe(Z(e=>e?.quality)).subscribe(new ii(`quality`)),this.info.currentBuffer$.subscribe(new ii(`buffer`)),e.isBuffering$.subscribe(new ii(`isBuffering`))].forEach(e=>this.subscription.add(e)),ri(`codecs`,j.video.supportedCodecs)}initTracerSubscription(){let e=Qv(this.tracer.log.bind(this.tracer)),t=Qv(this.tracer.error.bind(this.tracer));this.subscription.add(this.info.playbackState$.subscribe(e(`playbackState`))).add(this.info.isLooped$.subscribe(e(`isLooped`))).add(this.info.currentPlaybackRate$.pipe(X()).subscribe(e(`currentPlaybackRate`))).add(this.info.isAutoQualityEnabled$.subscribe(e(`isAutoQualityEnabled`))).add(this.info.autoQualityLimits$.subscribe(e(`autoQualityLimits`))).add(this.info.currentFormat$.subscribe(e(`currentFormat`))).add(this.info.availableQualities$.subscribe(e(`availableQualities`))).add(this.info.availableQualitiesFps$.subscribe(e(`availableQualitiesFps`))).add(this.info.availableAudioTracks$.subscribe(e(`availableAudioTracks`))).add(this.info.isAudioAvailable$.subscribe(e(`isAudioAvailable`))).add(Kv({currentQuality:this.info.currentQuality$,videoBitrate:this.info.videoBitrate$}).pipe(Y(({currentQuality:e,videoBitrate:t})=>!!e&&!!t),X((e,t)=>e.currentQuality===t.currentQuality)).subscribe(e(`currentVideoTrack`))).add(this.info.currentVideoSegmentLength$.pipe(Y(e=>e>0),X()).subscribe(e(`currentVideoSegmentLength`))).add(this.info.currentAudioSegmentLength$.pipe(Y(e=>e>0),X()).subscribe(e(`currentAudioSegmentLength`))).add(this.info.hostname$.subscribe(e(`hostname`))).add(this.info.currentTextTrack$.subscribe(e(`currentTextTrack`))).add(this.info.availableTextTracks$.subscribe(e(`availableTextTracks`))).add(this.info.autoQualityLimitingAvailable$.subscribe(e(`autoQualityLimitingAvailable`))).add(Kv({currentBuffer:this.info.currentBuffer$.pipe(Y(e=>e.end>0),X((e,t)=>e.end===t.end&&e.start===t.start)),position:this.info.position$.pipe(X())}).pipe(dy(1e3)).subscribe(e(`currentBufferAndPosition`))).add(this.info.duration$.pipe(X()).subscribe(e(`duration`))).add(this.info.isBuffering$.subscribe(e(`isBuffering`))).add(this.info.isLive$.pipe(X()).subscribe(e(`isLive`))).add(this.info.canChangePlaybackSpeed$.pipe(X()).subscribe(e(`canChangePlaybackSpeed`))).add(Kv({liveTime:this.info.liveTime$,liveBufferTime:this.info.liveBufferTime$,position:this.info.position$}).pipe(Y(({liveTime:e,liveBufferTime:t})=>!!e&&!!t),dy(1e3)).subscribe(e(`liveBufferAndPosition`))).add(this.info.atLiveEdge$.pipe(X(),Y(e=>e===!0)).subscribe(e(`atLiveEdge`))).add(this.info.atLiveDurationEdge$.pipe(X(),Y(e=>e===!0)).subscribe(e(`atLiveDurationEdge`))).add(this.info.muted$.pipe(X()).subscribe(e(`muted`))).add(this.info.volume$.pipe(X()).subscribe(e(`volume`))).add(this.info.isEnded$.pipe(X(),Y(e=>e===!0)).subscribe(e(`isEnded`))).add(this.info.availableSources$.subscribe(e(`availableSources`))).add(Kv({throughputEstimation:this.info.throughputEstimation$,rtt:this.info.rttEstimation$}).pipe(Y(({throughputEstimation:e,rtt:t})=>!!e&&!!t),dy(3e3)).subscribe(e(`throughputEstimation`))).add(this.info.isStalled$.subscribe(e(`isStalled`))).add(this.info.is3DVideo$.pipe(X(),Y(e=>e===!0)).subscribe(e(`is3DVideo`))).add(this.info.surface$.subscribe(e(`surface`))).add(this.events.ended$.subscribe(e(`ended`))).add(this.events.looped$.subscribe(e(`looped`))).add(this.events.managedError$.subscribe(t(`managedError`))).add(this.events.fatalError$.subscribe(t(`fatalError`))).add(this.events.firstBytes$.subscribe(e(`firstBytes`))).add(this.events.firstFrame$.subscribe(e(`firstFrame`))).add(this.events.canplay$.subscribe(e(`canplay`)))}initWakeLock(){var e=this;let t=$v();if(!t.navigator.wakeLock||!this.tuning.enableWakeLock)return;let n,r=()=>{n?.release(),n=void 0},i=function(){var t=w(function*(){r(),n=yield window.navigator.wakeLock.request(`screen`).catch(t=>{t instanceof DOMException&&t.name===`NotAllowedError`||e.events.managedError$.next({id:`WakeLock`,category:Jv.DOM,message:String(t)})})});return function(){return t.apply(this,arguments)}}();this.subscription.add(sy(Xv(t.document,`visibilitychange`),Xv(t.document,`fullscreenchange`),this.desiredState.playbackState.stateChangeEnded$).subscribe(()=>{let e=t.document.visibilityState===`visible`,a=this.desiredState.playbackState.getState()===`playing`,o=!!n&&!n?.released;e&&a?o||i():r()})).add(this.events.willDestruct$.subscribe(r))}setVideoTrackIdByQuality(e,t){let n=e.find(e=>e.quality===t);this.tracer.log(`setVideoTrackIdByQuality`,Yv({quality:t,availableTracks:Yv(e),track:Yv(n),isAutoQuality:!n})),n?n.tvDisabled?(this.setAutoQuality(!0),this.events.managedError$.next({id:`SetQualityTrackTvDisabled`,category:Jv.WTF,message:`Set quality was called on track with tvDisabled flag`})):this.desiredState.videoTrack.startTransitionTo(n):this.setAutoQuality(!0)}getActiveLiveDelay(e=!1){return e?this.tuning.live.lowLatencyActiveLiveDelay:this.tuning.live.activeLiveDelay}isNotActiveTabCase(){return $v().document.hidden&&this.tuning.autoplayOnlyInActiveTab&&!Wa()}}var Vy=`@vkontakte/videoplayer-core@${te}`;;return{st,j,Pt,Ya,By,re,ie,zy,te,se,Iy,Ry,Vy,ce,Fy,ne,Ly,oe,ae};}();var{st:_oxcMod79m539_st,j:_oxcMod79m539_j,Pt:_oxcMod79m539_Pt,Ya:_oxcMod79m539_Ya,By:_oxcMod79m539_By,re:_oxcMod79m539_re,ie:_oxcMod79m539_ie,zy:_oxcMod79m539_zy,te:_oxcMod79m539_te,se:_oxcMod79m539_se,Iy:_oxcMod79m539_Iy,Ry:_oxcMod79m539_Ry,Vy:_oxcMod79m539_Vy,ce:_oxcMod79m539_ce,Fy:_oxcMod79m539_Fy,ne:_oxcMod79m539_ne,Ly:_oxcMod79m539_Ly,oe:_oxcMod79m539_oe,ae:_oxcMod79m539_ae}=_oxcMod79m539;export{_oxcMod79m539_st as isMobile,_oxcMod79m539_j as clientChecker,_oxcMod79m539_Pt as areValidLiveRecordSources,_oxcMod79m539_Ya as WebmCodecStrategy,_oxcMod79m539_By as VideoQuality,_oxcMod79m539_re as VideoFormat,_oxcMod79m539_ie as VideoCodecName,_oxcMod79m539_zy as ValueSubject,_oxcMod79m539_te as VERSION,_oxcMod79m539_se as Surface,_oxcMod79m539_Iy as Subscription,_oxcMod79m539_Ry as Subject,_oxcMod79m539_Vy as SDK_VERSION,_oxcMod79m539_ce as PredefinedQualityLimits,_oxcMod79m539_Fy as Player,_oxcMod79m539_ne as PlaybackState,_oxcMod79m539_Ly as Observable,_oxcMod79m539_oe as HttpConnectionType,_oxcMod79m539_ae as ChromecastState};
|
|
260
|
+
===== DASH_LIVE DEBUG END ====`),n){let t=e.reduce((e,{time:t,data:n,stack:r})=>{let i=rn(n).map(([e,t])=>`${e}:${t}`).join(`,`);return e+=`${t}: ${i}${r?`: ${r}`:``};`,e},``);ev.push(`core`,{key:`vp_dash_live_debug`,strings:[t]})}};return e.add(this.providerError$.subscribe(e=>{e.id.startsWith(`ProviderHangup`)&&(R({m:`final.0`,e:e.id}),r())})).add(this.noAvailableProvidersError$.subscribe(()=>{R({m:`final.1`}),r()})),e.add(this.providerError$.subscribe(e=>{let{destination:r,type:i}=this.current$.getValue(),a={error:e,currentDestination:r};if(r===`CHROMECAST`)this.destroyProvider(),this.params.dependencies.chromecastInitializer.stopMedia().then(()=>this.switchToNextProvider(`CHROMECAST`),()=>this.params.dependencies.chromecastInitializer.disconnect());else{let o=this.params.tuning.dash.useFailoverHostsOnAllProviderCrash||e.category===G_.NETWORK,s=e.category===G_.FATAL,c=this.params.failoverHosts.length>0&&(this.failoverIndex===void 0||this.failoverIndex<this.params.failoverHosts.length-1),l=n<this.params.tuning.providerErrorLimit&&!s,u=this.videoCodecsIterator&&!this.videoCodecsIterator.isLast()&&this.params.tuning.dash.codecsPrioritizeEnabled,d=this.providerOutput.currentVideoTrack$.getValue();this.dashMaxTvVideoQuality=this.params.tuning.dash.dashMaxTvVideoQuality?np(e,i,d?.quality):null;let f=c&&!s&&(o&&t||!l);a=T(T({},a),{},{isNetworkError:o,isFatalError:s,haveFailoverHost:c,tryFailover:f,canReinitProvider:l}),this.currentFailedVideoTrack=this.params.tuning.dash.useNewFailoverLogic?d:null,this.params.tuning.dropUrlCacheWhenProviderCrashed&&!o&&Yh(),l?(n++,this.reinitProvider()):f?(this.failoverIndex=this.failoverIndex===void 0?0:this.failoverIndex+1,this.reinitProvider()):u?this.switchToNextVideoCodec():(n=0,this.switchToNextProvider(r??`SCREEN`))}e.traceAsLog?this.tracer.log(`providerInfo`,$_(a)):this.tracer.error(`providerError`,$_(a))})),e}}var jv=`vk_uvp_throughput`,Mv=`vk_uvp_rtt`,Nv=`one_video_throughput`,Pv=`one_video_rtt`,Fv=()=>{let{navigator:e}=Av();if(e)return e.connection},Iv=()=>{let e=Fv()?.downlink;if(Dv(e)&&e!==10)return e*1e3},Lv=()=>{let e=Fv()?.rtt;if(Dv(e)&&e!==3e3)return e},Rv=(e,t,n)=>{let r=n*8;return r/(r/e+t)};class zv{constructor(e){this.throughput=void 0,this.rtt=void 0,this.subscription=new Cv,this.tuningConfig=void 0,this.concurrentDownloads=new Set,this.throughput$=void 0,this.rtt$=void 0,this.rttAdjustedThroughput$=void 0,this.tuningConfig=e;let t=zv.loadStored(jv,Nv,e)||(e.useBrowserEstimation?Iv():void 0)||e.initialThroughput,n=zv.loadStored(Mv,Pv,e)??(e.useBrowserEstimation?Lv():void 0)??0;if(this.throughput$=new wv(t),this.rtt$=new wv(n),this.rttAdjustedThroughput$=new wv(Rv(t,n,e.rttPenaltyRequestSize)),this.throughput=Ip.getSmoothedValue(t,-1,e),this.rtt=Ip.getSmoothedValue(n,1,e),e.useBrowserEstimation){let e=()=>{let e=Iv();e&&this.throughput.next(e);let t=Lv();Dv(t)&&this.rtt.next(t)},t=Fv();t&&`onchange`in t&&this.subscription.add(bv(t,`change`).subscribe(e)),e()}this.subscription.add(this.throughput.smoothed$.subscribe(t=>{zv.writeStored(jv,Nv,t,e)})),this.subscription.add(this.rtt.smoothed$.subscribe(t=>{zv.writeStored(Mv,Pv,t,e)})),this.subscription.add(this.throughput.debounced$.pipe(Tv(e=>Math.round(e))).subscribe(this.throughput$)),this.subscription.add(this.rtt.debounced$.subscribe(this.rtt$)),this.subscription.add(Sv({throughput:this.throughput.smoothed$,rtt:this.rtt.smoothed$}).pipe(Tv(({throughput:t,rtt:n})=>Rv(t,n,e.rttPenaltyRequestSize)),Ev(t=>{let n=this.rttAdjustedThroughput$.getValue()||0;return Math.abs(t-n)/n>=e.changeThreshold})).subscribe(this.rttAdjustedThroughput$))}destroy(){this.concurrentDownloads.clear(),this.subscription.unsubscribe()}trackXHR(e){let t=0,n=Ov(),r=new Cv;switch(this.subscription.add(r),this.concurrentDownloads.add(e),e.readyState){case 4:break;case 3:case 2:r.add(bv(e,`progress`).pipe(xv()).subscribe(e=>{t=e.loaded,n=Ov()}));break;case 1:case 0:r.add(bv(e,`loadstart`).subscribe(()=>{t=0,n=Ov()}));break}r.add(bv(e,`loadend`).subscribe(i=>{if(e.status===200){let e=i.loaded,r=Ov(),a=e-t,o=r-n;this.addRawSpeed(a,o,1)}this.concurrentDownloads.delete(e),r.unsubscribe()}))}trackStream(e,t=!1){var n=this;let r=e.getReader();if(!r){e.cancel(`Could not get reader`);return}let i=0,a=Ov(),o=0,s=Ov(),c=t=>{this.concurrentDownloads.delete(e),r.releaseLock(),e.cancel(`Throughput Estimator error: ${t}`).catch(()=>{})},l=function(){var u=w(function*({done:u,value:d}){if(u)!t&&n.addRawSpeed(i,Ov()-a,1),n.concurrentDownloads.delete(e);else if(d){if(t){let e=Ov();if(e-s>n.tuningConfig.lowLatency.continuesByteSequenceInterval||e-a>n.tuningConfig.lowLatency.maxLastEvaluationTimeout){let e=s-a;e&&n.addRawSpeed(o,e,1,t),o=d.byteLength,a=Ov()}else o+=d.byteLength;s=Ov()}else i+=d.byteLength,o+=d.byteLength,o>=n.tuningConfig.streamMinSampleSize&&Ov()-s>=n.tuningConfig.streamMinSampleTime&&(n.addRawSpeed(o,Ov()-s,n.concurrentDownloads.size),o=0,s=Ov());yield r?.read().then(l,c)}});return function(e){return u.apply(this,arguments)}}();this.concurrentDownloads.add(e),r?.read().then(l,c)}addRawSpeed(e,t,n=1,r=!1){if(this.sanityCheck(e,t,r)){let r=e*8/t;this.throughput.next(r*n)}}addRawThroughput(e){this.throughput.next(e)}addRawRtt(e){this.rtt.next(e)}sanityCheck(e,t,n=!1){let r=e*8/t;return!(!r||!isFinite(r)||r>1e6||r<30||n&&e<1e4||!n&&e<10*1024&&(!this.tuningConfig.measureNonSegmentRequests||t<this.tuningConfig.smallSampleMinDuration+this.rtt$.getValue())||!n&&t<=this.tuningConfig.cacheThresholdSize)}get throughputVariance$(){return this.throughput.varianceCoefficient$}static loadStored(e,t,n){if(!n.useThroughputTtl){let e=kv.get(t);if(!Dv(e))return;let n=parseInt(e,10);return isNaN(n)?void 0:n}let r=kv.get(e)??kv.get(t);if(Dv(r))try{let e=JSON.parse(r);if(typeof e==`object`&&e&&typeof e.value==`number`)return zv.validateStored(e,n)}catch{}}static writeStored(e,t,n,r){if(!r.useThroughputTtl){kv.set(t,n.toFixed(0));return}let i=JSON.stringify({value:Math.round(n),timestamp:Date.now(),networkType:Fv()?.effectiveType});kv.set(e,i)}static validateStored(e,t){if(!t.useThroughputTtl)return e.value;if(Date.now()-e.timestamp>t.storedThroughputTtlMs)return;let n=Fv()?.effectiveType;if(!(n!==void 0&&e.networkType!==void 0&&n!==e.networkType))return e.value}}var Bv=zv;var Uv={keepVideoElement:!1,clearVideoElementInnerHTML:!1,allowPlayerReuse:!1,throughputEstimator:{type:`EmaAndMa`,emaAlphaSlow:.2,emaAlphaFast:.7,emaAlpha:.45,basisTrendChangeCount:10,changeThreshold:.05,useBrowserEstimation:!0,initialThroughput:5e3,measureNonSegmentRequests:!1,rttPenaltyRequestSize:1*1024*1024,streamMinSampleSize:10*1024,streamMinSampleTime:300,smallSampleMinDuration:100,cacheThresholdSize:20,deviationDepth:20,deviationFactor:.5,lowLatency:{continuesByteSequenceInterval:50,maxLastEvaluationTimeout:300},useThroughputTtl:!1,storedThroughputTtlMs:144e5},autoTrackSelection:{maxBitrateFactorAtEmptyBuffer:4,bitrateFactorAtEmptyBuffer:2.8,minBitrateFactorAtEmptyBuffer:1.5,bitrateAudioFactorAtEmptyBuffer:10,maxBitrateFactorAtFullBuffer:3,bitrateFactorAtFullBuffer:2,minBitrateFactorAtFullBuffer:1,bitrateAudioFactorAtFullBuffer:7,minVideoAudioRatio:5,minAvailableThroughputAudioRatio:5,usePixelRatio:!0,pixelRatioMultiplier:void 0,pixelRatioLogBase:3,pixelRatioLogCoefficients:[1,0,1],limitByContainer:!0,maxContainerSizeFactor:2,containerSizeFactor:1.3,minContainerSizeFactor:1,lazyQualitySwitch:!0,minBufferToSwitchUp:.4,considerPlaybackRate:!1,trackCooldownIncreaseQuality:15e3,trackCooldownDecreaseQuality:3e3,backgroundVideoQualityLimit:Hv.Q_4320P,activeVideoAreaThreshold:.1,highQualityLimit:Hv.Q_720P,trafficSavingLimit:Hv.Q_480P},stallsManager:{enabled:!1,ignoreDynamicAbrForShortVideo:!1,stallDurationNoDataBeforeQualityDecrease:500,stallDurationToBeCount:100,stallCountBeforeQualityDecrease:3,resetQualityRestrictionTimeout:1e4,ignoreStallsOnSeek:!0,stallsMetricsHistoryLength:20,maxPossibleStallDuration:3e4,minTvtToBeCounted:120,maxTvtToBeCounted:10800,significantTvt:600,targetStallsDurationPerTvt:1,deviationStallsDurationPerTvt:.5,criticalStallsDurationPerTvt:6,abrAdjustingSpeed:.1,emaAlpha:.6,useTotalStallsDurationPerTvt:!0,useAverageStallsDurationPerTvt:!0,useEmaStallsDurationPerTvt:!0},droppedFramesChecker:{enabled:!1,percentLimit:.1,checkTime:1e3,countLimit:3,tickCountAfterQualityChange:5,qualityUpWaitingTime:5e3,minQualityBanLimit:Hv.Q_480P},dash:{forwardBufferTarget:6e4,forwardBufferTargetAuto:6e4,forwardBufferTargetManual:5*6e4,forwardBufferTargetPreload:5e3,useDynamicBufferTarget:!1,audioBufferAheadOfVideoMs:1e4,seekBiasInTheEnd:2e3,maxSegmentDurationLeftToSelectNextSegment:3e3,minSafeBufferThreshold:.5,bufferPruningSafeZone:1e3,segmentRequestSize:1*1024*1024,maxVirtualBufferSize:250*1024*1024,virtualBufferPruneSize:100*1024*1024,representationSwitchForwardBufferGap:6e4,crashOnStallTimeout:25e3,crashOnStallTWithoutDataTimeout:5e3,restoreBufferBeforeCrashTimeout:1e3,enableSubSegmentBufferFeeding:!0,bufferEmptinessTolerance:100,virtualBufferEmptinessTolerance:100,useBufferQueueVerification:!1,useVirtualBufferImplicitSeek:!1,useNewRepresentationSwitch:!1,useDelayedRepresentationSwitch:!1,useSmartRepresentationSwitch:!1,seekStallExitPolicy:!1,mutexStallExitPolicy:!1,useFetchPriorityHints:!0,useAbortMSEFix:!1,enableBaseUrlSupport:!0,maxSegmentRetryCount:5,sourceOpenTimeout:1e3,vktvAbrThrottle:0,timeupdateEventTickThrottle:300,fetcherBufferOptimisation:!0,codecsPrioritizeEnabled:!1,usePersistentGaps:!1,abrThrottle:0,useVideoElementWaitingCurrentTimeReassign:!0,stallWatchdogInterval:100,liveUpdateInterval:1e3,liveStallReinitInterval:3e3,ignoreNetworkErrorsOnLoadInit:!1,bufferTolerance:100,minNativeBufferSize:5e3,removeTimeShiftFromSegment:500,tickMaintainInterval:100,minSafeBufferToPlay:0,useBufferHoldingOnlyOnStall:!0,useAbortResetNativeBufferMutex:!1,useNewAbr:!1,useAbrPhases:!1,abrVideoRules:[`fits_container_rule`,`throughput_rule`,`buffer_rule`,`stalls_rule`,`upper_limit_rule`,`lower_limit_rule`],abrAudioRules:[`throughput_rule`,`min_audio_for_video_rule`],useDynamicBirtateRule:!1,useNewFailoverLogic:!1,useFailoverHostsOnAllProviderCrash:!1,videoTrackBanAfterProviderFail:15e3,saveData3gQualityLimit:Hv.Q_240P,saveData2gQualityLimit:Hv.Q_144P,useConnectionDataUpperLimit:!1,abandon:{minElapsedMs:1500,bufferSafetyFactor:.8,minLoadedFraction:.15,minBufferToActivateMs:500},bola:{bufferTargetMs:3e4,minBufferMs:1e4,minBufferPerBitrateLevelMs:2e3,placeholderBufferDecay:.99,fallbackSegmentDurationMs:4e3,finiteThresholdMs:6e4,adaptiveBufferTargetK:.5,adaptiveBufferTargetMaxMs:6e4,trimDetectThresholdMs:1e4,antiCascadeDownshift:!0},insufficientBuffer:{thresholdMs:500,gracePeriodAfterPlaybackResetMs:1e3,budgetFactor:.5,fallbackSegmentDurationMs:6e3},dynamicBufferTarget:{maxMs:12e4,optimisticHeadroomLow:3.5,optimisticHeadroomHigh:6,weakThroughputLowKbps:1500,weakThroughputHighKbps:5e3,maxFactor:1.5},videoStreamRepresentaionsFilter:[],filterOnDemandQualityList:!1,dashMaxTvVideoQuality:!1,checkRepresentationCanPlayType:!1,downloadTime:{minLookaheadSegments:3,safetyFactor:1.3,bootstrapBufferMs:5e3,demandTolerance:3}},dashCmafLive:{externalStopControl:!1,keepSilentStallWatchdogWhenNotActive:!1,maxActiveLiveOffset:1e4,normalizedTargetMinBufferSize:6e4,normalizedLiveMinBufferSize:5e3,normalizedActualBufferOffset:1e4,offsetCalculationError:3e3,maxLiveDuration:7200,catchupLiveForMutedInactiveTab:!0,lowLatency:{maxTargetOffset:3e3,maxTargetOffsetDeviation:250,playbackCatchupSpeedup:.05,isActiveOnDefault:!1,bufferEstimator:{emaAlpha:.45,changeThreshold:.05,deviationDepth:20,deviationFactor:.5,extremumInterval:5}}},live:{minBuffer:3e3,minBufferSegments:3,lowLatencyMinBuffer:1e3,lowLatencyMinBufferSegments:1,isLiveCatchUpMode:!1,lowLatencyActiveLiveDelay:3e3,activeLiveDelay:5e3,maxPausedTime:5e3,catchupLiveForMutedInactiveTab:!1},downloadBackoff:{bufferThreshold:100,start:100,factor:2,max:3*1e3,random:.1},enableWakeLock:!0,enableTelemetryAtStart:!1,forceFormat:void 0,formatsToAvoid:[],disableChromecast:!1,chromecastReceiverId:`07A4434E`,chromecastPresentationApi:!1,useWebmBigRequest:!1,webmCodec:`vp9`,androidPreferredFormat:`dash`,iosPreferredFormat:`hls`,preferCMAF:!1,preferWebRTC:!1,preferMultiStream:!1,preferHDR:!1,bigRequestMinInitSize:50*1024,bigRequestMinDataSize:1*1024*1024,stripRangeHeader:!0,flushShortLoopedBuffers:!0,insufficientBufferRuleMargin:1e4,seekNearDurationBias:1,dashSeekInSegmentDurationThreshold:180*1e3,dashSeekInSegmentAlwaysSeekDelta:1e4,useDelayedPlaybackHangupWithData:!1,playbackHangupNoDataThreshold:5e3,endGapTolerance:300,stallIgnoreThreshold:33,stallHandlingStrategy:`exclude-threshold`,gapWatchdogInterval:50,requestQuick:!1,useHlsJs:!1,disableHlsOnDesktop:!1,useNativeHLSTextTracks:!1,useNewSwitchTo:!1,alwaysAbortPreviousSwitch:!1,useDashProviderVirtual:!1,useDashProviderVirtualMobile:!1,useNewAutoSelectVideoTrack:!1,useSafariEndlessRequestBugfix:!0,isAudioDisabled:!1,autoplayOnlyInActiveTab:!0,autoplayOnlyIfVisible:!0,dynamicImportTimeout:5e3,maxPlaybackTransitionInterval:2e4,providerErrorLimit:3,manifestRetryInterval:300,manifestRetryMaxInterval:1e4,manifestRetryMaxCount:10,audioVideoSyncRate:20,webrtc:{connectionRetryMaxNumber:3},spherical:{enabled:!1,fov:{x:135,y:76},rotationSpeed:45,maxYawAngle:175,rotationSpeedCorrection:10,degreeToPixelCorrection:5,speedFadeTime:2e3,speedFadeThreshold:50},useVolumeMultiplier:!1,ignoreAudioRendererError:!1,useEnableSubtitlesParam:!1,useHlsLiveNewTextManager:!1,exposeInternalsToGlobal:!1,hlsLiveNewTextManagerDownloadThreshold:4e3,disableYandexPiP:!1,asyncResolveClientChecker:!1,changePlaybackStateToPausedWhenEnded:!1,suppressExceptionsInObservables:!0,devNullLogEnabled:!1,collectingDecodingInfoEnabled:!1,sendDashLiveDebug:!1,logDashLiveDebug:!1,reuseOwnVideoElement:!1,handleExtendedNetworkErrorsSet:!1,useUrlCacheMechanism:!1,useDurationFromSegments:!0,dropUrlCacheWhenProviderCrashed:!1,ignoreForcePlayResultWhenProviderChanged:!1,hls:{filterOnDemandQualityList:!1},disableSubtitles:!1,audioOnly:!1},Wv=e=>Vv(e,Uv);var vy=({seekState:e,position$:t})=>my(e.stateChangeEnded$.pipe(hy(({to:e})=>e.state===`none`?void 0:(e.position??NaN)/1e3),gy(_y)),t.pipe(gy(()=>e.getState().state===`none`)));var xy=(e,t,n,r)=>{e!==void 0&&t.getState()===void 0&&t.getPrevState()===void 0&&n?.getValue().length===0?n.pipe(yy(e=>e.length>0),by()).subscribe(n=>{n.find(r)&&t.startTransitionTo(e)}):(e===void 0||n?.getValue().find(r))&&t.startTransitionTo(e)};var Dy=()=>{let e=`mediaCapabilities`in Ey().navigator?Oy:ky,t=Sy(w(function*(){let t=yield Promise.all(Cy(Ay).map(function(){var t=w(function*([t,n]){return{codec:t,supported:yield e(n)}});return function(e){return t.apply(this,arguments)}}())),n=[j.browser.current,...t.map(e=>JSON.stringify(e))].slice(0,16);return Ty.push(`core`,{key:`videoplayer_decoding_info`,strings:n}),t}));return()=>wy(t)},Oy=function(){var e=w(function*(e){if(!e)return Promise.resolve({supported:!1});let t={[`channels`in e?`audio`:`video`]:e};return yield Ey().navigator.mediaCapabilities.decodingInfo(T({type:`media-source`},t))});return function(t){return e.apply(this,arguments)}}(),ky=e=>{if(!e)return Promise.resolve({supported:!1});let t=Ey().document,n=`channels`in e?t.createElement(`audio`):t.createElement(`video`);return Promise.resolve({supported:n.canPlayType(e?.contentType??``)===`probably`})},Ay={H264:{contentType:`video/mp4; codecs="avc1.4D400C"`,width:720,height:720,bitrate:2886,framerate:30},H265:{contentType:`video/mp4; codecs="hvc1.1.6.L123.B0"`,width:720,height:720,bitrate:2886,framerate:30},VP8:{contentType:`video/webm; codecs="vp8"`,width:720,height:720,bitrate:2886,framerate:30},VP9:{contentType:`video/webm; codecs="vp09.00.10.08"`,width:720,height:720,bitrate:2886,framerate:30},AV1:{contentType:`video/mp4; codecs="av01.0.01M.08"`,width:720,height:720,bitrate:2886,framerate:30},OPUS:{contentType:`audio/ogg; codecs="opus"`,channels:`2`,bitrate:128e3},AAC_LC:{contentType:`audio/mp4; codecs="mp4a.40.2"`,channels:`2`,bitrate:128e3},AC3:{contentType:`audio/mp4; codecs="ac-3"`,channels:`6`,bitrate:128e3},EAC3:{contentType:`audio/mp4; codecs="ec-3"`,channels:`6`,bitrate:128e3},AAC_HE_V1:{contentType:`audio/mp4; codecs="mp4a.40.5"`,channels:`2`,bitrate:128e3},AAC_HE_V2:{contentType:`audio/mp4; codecs="mp4a.40.29"`,channels:`2`,bitrate:128e3},AAC_xHE:{contentType:`audio/mp4; codecs="mp4a.40.42"`,channels:`2`,bitrate:128e3}},jy={playbackState$:void 0,position$:0,duration$:1/0,playedTime$:0,muted$:!1,volume$:1,availableVideoStreams$:[],currentVideoStream$:void 0,availableVideoTracks$:[],availableQualities$:[],availableQualitiesFps$:{},currentQuality$:void 0,isAutoQualityEnabled$:!0,autoQualityLimitingAvailable$:!1,autoQualityLimits$:{},predefinedQualityLimitType$:`unknown`,availableAudioStreams$:[],currentAudioStream$:void 0,availableAudioTracks$:[],isAudioAvailable$:!0,currentPlaybackRate$:1,currentBuffer$:{start:0,end:0},currentNativeBuffer$:{start:0,end:0},isBuffering$:!0,isStalled$:!1,stallStartTime$:0,isEnded$:!1,isLooped$:!1,isLive$:void 0,isLiveEnded$:null,canPlayLiveTailBuffer$:!1,canChangePlaybackSpeed$:void 0,atLiveEdge$:void 0,atLiveDurationEdge$:void 0,liveTime$:void 0,liveBufferTime$:void 0,liveLatency$:void 0,currentFormat$:void 0,availableTextTracks$:[],currentTextTrack$:void 0,throughputEstimation$:void 0,rttEstimation$:void 0,videoBitrate$:void 0,hostname$:void 0,httpConnectionType$:void 0,httpConnectionReused$:void 0,httpConnectionMetrics$:void 0,httpDownloadMetrics$:void 0,surface$:`none`,chromecastState$:`NOT_AVAILABLE`,chromecastDeviceName$:void 0,intrinsicVideoSize$:void 0,availableSources$:void 0,is3DVideo$:!1,currentVideoSegmentLength$:0,currentAudioSegmentLength$:0},My={audioStream:void 0,autoVideoTrackLimits:{},autoVideoTrackSwitching:!0,cameraOrientation:{x:0,y:0},currentTextTrack:void 0,externalTextTracks:[],internalTextTracks:[],isLooped:!1,isLowLatency:!1,playbackRate:1,playbackState:`stopped`,seekState:{state:`none`},textTrackCuesSettings:{},videoTrack:void 0,videoStream:void 0,volume:{volume:1,muted:!1}};var Py=e=>{let t=typeof e.container==`string`?document.getElementById(e.container):e.container;return Ny(t,`Wrong container or containerId {${e.container}}`),t};class Fy{constructor(e={},t=fy.createRootTracer(`fake`),n){this.subscription=new ly,this.persistentSubscription=new ly,this.domContainer=null,this.providerContainer=void 0,this.chromecastInitializer=void 0,this.logger=new ay,this.tracer=void 0,this.abrLogger=this.logger.createComponentLog(`ABR`),this.config=void 0,this.tuning=void 0,this.throughputEstimator=void 0,this.internalsExposure=null,this.isPlaybackStarted=!1,this.suppressWillStop=!1,this.initedAt=void 0,this.hasLiveOffsetByPaused=new py(!1),this.hasLiveOffsetByPausedTimer=0,this.playerInitRequest=0,this.playerInited=new py(!1),this.explicitInitialQuality=void 0,this.wasSetStartedQuality=!1,this.desiredState=le(My).reduce((e,[t,n])=>(e[t]=new dn(n),e),{}),this.info=le(jy).reduce((e,[t,n])=>(e[t]=new py(n),e),{}),this.events={inited$:new $,ready$:new $,started$:new $,playing$:new $,paused$:new $,stopped$:new $,willReady$:new $,willStart$:new $,willResume$:new $,willPause$:new $,willStop$:new $,willDestruct$:new $,watchCoverageRecord$:new $,watchCoverageLive$:new $,managedError$:new $,fatalError$:new $,fetcherRecoverableError$:new $,ended$:new $,looped$:new $,seeked$:new $,willSeek$:new $,autoplaySoundProhibited$:new $,manifestRequested$:new $,firstBytesManifest$:new $,manifestReceived$:new $,firstBytesRequested$:new $,firstBytesReceived$:new $,firstBytes$:new $,loadedMetadata$:new $,firstFrame$:new $,canplay$:new $,log$:new $,fetcherError$:new $,severeStallOccured$:new $},this.experimental={element$:new py(void 0),enableDebugTelemetry$:new py(!1),dumpTelemetry:ni,getCurrentTime$:new py(null),skipVideoElVolumeSync$:new py(!1)},this.devNullLog=void 0,this.collectDecodingInfoDestroyCb=void 0,this.doInit=e=>{let{container:t}=e,n=ee(e,C);this.tracer.log(`initVideo`,Yv(n),!0),this.domContainer=Py(e),this.chromecastInitializer.contentId=e.meta?.videoId,this.providerContainer=new yv({sources:e.sources,meta:e.meta??{},failoverHosts:e.failoverHosts??[],container:this.domContainer,desiredState:this.desiredState,dependencies:{throughputEstimator:this.throughputEstimator,chromecastInitializer:this.chromecastInitializer,tracer:this.tracer,logger:this.logger,abrLogger:this.abrLogger},tuning:this.tuning,volumeMultiplier:e.volumeMultiplier,panelSize:e.panelSize,skipVideoElVolumeSync$:this.experimental.skipVideoElVolumeSync$,handleNetworkRecoverableErrorAsProviderError:e.handleNetworkRecoverableErrorAsProviderError}),this.initProviderContainerSubscription(this.providerContainer),this.initStartingVideoTrack(this.providerContainer),this.providerContainer.init(),this.setLiveLowLatency(this.tuning.dashCmafLive.lowLatency.isActiveOnDefault),this.initDebugTelemetry(),this.initWakeLock(),this.playerInited.next(!0),this.devNullLog&&this.tuning.devNullLogEnabled?(qv.subscribe(`core`,this.devNullLog),this.tuning.collectingDecodingInfoEnabled&&(this.collectDecodingInfoDestroyCb=Dy())):qv.destroy(`core`)},this.initLogs(),this.tuning=Wv(e),this.tracer=t,this.tuning.suppressExceptionsInObservables&&(ue(this.info).forEach(e=>e.setSuppressErrors(!0)),ue(this.events).forEach(e=>e.setSuppressErrors(!0)));let r={receiverApplicationId:this.tuning.chromecastReceiverId,isDisabled:this.tuning.disableChromecast,dependencies:{logger:this.logger}};if(this.chromecastInitializer=this.tuning.chromecastPresentationApi?new tn(r):new De(r),this.throughputEstimator=new Bv(this.tuning.throughputEstimator),e.exposeInternalsToGlobal&&(this.internalsExposure=new ey(`core`,Zv(n?.playerId)),this.internalsExposure.expose({player:this})),this.initChromecastSubscription(),this.initDesiredStateSubscriptions(),this.devNullLog=n?.onDevNullLog,qv.create(`core`),Proxy&&Reflect)return new Proxy(this,{get:(e,t,n)=>{let r=Reflect.get(e,t,n);return typeof r==`function`?(...n)=>{try{return r.apply(e,n)}catch(e){let r=n.map(e=>JSON.stringify(e,(e,t)=>{let n=typeof t;return de([`number`,`string`,`boolean`],n)?t:t===null?null:`<${n}>`})),i=`Player.${String(t)}`,a=`Exception calling ${i} (${r.join(`, `)})`;throw this.events.fatalError$.next({id:i,category:Jv.WTF,message:a,thrown:e}),e}}:r}})}resetDesiredState(){let e=(e,t)=>{e.setState(t)};Object.keys(this.desiredState).forEach(t=>{e(this.desiredState[t],My[t])})}reset(){this.subscription.unsubscribe(),this.providerContainer?.destroy(),this.providerContainer=void 0,$v().clearTimeout(this.hasLiveOffsetByPausedTimer),this.collectDecodingInfoDestroyCb?.call(this),this.playerInited.next(!1),this.resetDesiredState();let e=(e,t)=>{e.next(t)},t=[`muted$`,`volume$`];Object.keys(this.info).forEach(n=>{de(t,n)?e(this.info[n],this.info[n].getValue()):e(this.info[n],jy[n])})}initAudio(e){return this.initVideo(T(T({},e),{},{container:e.audioElement??document.createElement(`audio`)}))}initVideo(e){let t=$v();this.config=e,this.internalsExposure?.expose({config:e,logger:this.logger,tuning:this.tuning}),this.setMuted(this.tuning.isAudioDisabled);let n=()=>{this.tuning.autoplayOnlyIfVisible&&t.requestAnimationFrame?this.playerInitRequest=t.requestAnimationFrame(()=>this.doInit(e)):this.doInit(e)},r=()=>{this.tuning.asyncResolveClientChecker?j.isInited$.pipe(Y(e=>!!e),Q()).subscribe(()=>{console.log(`Core SDK async start`),n()}):n()};return this.isNotActiveTabCase()?(this.tracer.log(`request play from hidden tab`),Xv(t.document,`visibilitychange`).pipe(Q()).subscribe(r)):r(),this}destroy(e){let t=$v();this.tracer.log(`destroy`),t.clearTimeout(this.hasLiveOffsetByPausedTimer),this.playerInitRequest&&t.cancelAnimationFrame(this.playerInitRequest),this.events.willDestruct$.next(),this.suppressWillStop=e?.reportStop===!1,this.stop(),this.providerContainer?.destroy(),this.throughputEstimator.destroy(),this.chromecastInitializer.destroy(),this.subscription.unsubscribe(),this.persistentSubscription.unsubscribe(),this.tracer.end(),this.internalsExposure?.destroy(),qv.destroy(`core`),this.collectDecodingInfoDestroyCb?.call(this)}waitInit(e){this.playerInited.getValue()?e():this.subscription.add(this.playerInited.pipe(Y(e=>!!e),Q()).subscribe(e))}prepare(){return this.waitInit(()=>{let e=this.desiredState.playbackState;this.tracer.log(`prepare`,{currentPlayBackState:e.getState()}),e.getState()===`stopped`&&e.startTransitionTo(`ready`)}),this}play(){return this.waitInit(()=>{let e=this.desiredState.playbackState;this.tracer.log(`play`,{currentPlayBackState:e.getState()}),e.getState()!==`playing`&&e.startTransitionTo(`playing`)}),this}pause(){return this.waitInit(()=>{let e=this.desiredState.playbackState;this.tracer.log(`pause`,{currentPlayBackState:e.getState()}),e.getState()!==`paused`&&e.startTransitionTo(`paused`)}),this}stop(){return this.waitInit(()=>{let e=this.desiredState.playbackState;this.tracer.log(`stop`,{currentPlayBackState:e.getState()}),e.getState()!==`stopped`&&(e.startTransitionTo(`stopped`),this.tuning.allowPlayerReuse&&this.reset())}),this}seekTime(e,t=!0){return this.waitInit(()=>{let n=this.info.duration$.getValue(),r=this.info.isLive$.getValue(),i=e;e>=n&&!r&&(i=n-this.tuning.seekNearDurationBias),this.tracer.log(`seekTime`,{duration:n,isLive:r,time:e,calculatedTime:i,forcePrecise:t}),Number.isFinite(i)&&(this.events.willSeek$.next({from:this.getExactTime(),to:i}),this.desiredState.seekState.setState({state:`requested`,position:i*1e3,forcePrecise:t}))}),this}seekPercent(e){return this.waitInit(()=>{let t=this.info.duration$.getValue();this.tracer.log(`seekPercent`,{percent:e,duration:t}),isFinite(t)&&this.seekTime(Math.abs(t)*e,!1)}),this}setVolume(e,t,n=!1){return this.waitInit(()=>{this.experimental.skipVideoElVolumeSync$.next(n);let r=this.desiredState.volume,i=r.getTransition()?.to.muted??this.info.muted$.getValue(),a=t??(this.tuning.isAudioDisabled||i);this.tracer.log(`setVolume`,{volume:e,isAudioDisabled:this.tuning.isAudioDisabled,chromecastState:this.chromecastInitializer.castState$.getValue(),muted:a}),this.chromecastInitializer.castState$.getValue()===`CONNECTED`&&!(this.chromecastInitializer instanceof tn)?this.chromecastInitializer.setVolume(e):r.startTransitionTo({volume:e,muted:a})}),this}setMuted(e,t=!1,n=!1){return this.waitInit(()=>{this.experimental.skipVideoElVolumeSync$.next(n);let r=this.desiredState.volume,i=this.tuning.isAudioDisabled&&!t||e,a=r.getTransition()?.to.volume??this.info.volume$.getValue();this.tracer.log(`setMuted`,{isMuted:e,nextMuted:i,volume:a,isAudioDisabled:this.tuning.isAudioDisabled,chromecastState:this.chromecastInitializer.castState$.getValue()}),this.chromecastInitializer.castState$.getValue()===`CONNECTED`&&!(this.chromecastInitializer instanceof tn)?this.chromecastInitializer.setMuted(i):r.startTransitionTo({volume:a,muted:i})}),this}setVideoStream(e){return this.waitInit(()=>{this.desiredState.videoStream.startTransitionTo(e)}),this}setAudioStream(e){return this.waitInit(()=>{this.desiredState.audioStream.startTransitionTo(e)}),this}setQuality(e){return this.waitInit(()=>{Gv(this.providerContainer);let t=this.providerContainer.providerOutput.availableVideoTracks$.getValue();this.tracer.log(`setQuality`,{isDelayed:t.length===0,quality:e}),this.desiredState.videoTrack.getState()===void 0&&this.desiredState.videoTrack.getPrevState()===void 0&&t.length===0?this.wasSetStartedQuality?this.providerContainer.providerOutput.availableVideoTracks$.pipe(Y(e=>e.length>0),Q()).subscribe(t=>{this.setVideoTrackIdByQuality(t,e)}):this.explicitInitialQuality=e:t.length>0&&this.setVideoTrackIdByQuality(t,e)}),this}setAutoQuality(e){return this.waitInit(()=>{this.tracer.log(`setAutoQuality`,{enable:e}),this.desiredState.autoVideoTrackSwitching.startTransitionTo(e)}),this}setAutoQualityLimits(e){return this.waitInit(()=>{this.tracer.log(`setAutoQualityLimits`,Yv(e)),this.desiredState.autoVideoTrackLimits.startTransitionTo(e)}),this}setPredefinedQualityLimits(e){return this.waitInit(()=>{if(this.info.predefinedQualityLimitType$.getValue()===e)return this;let{highQualityLimit:t,trafficSavingLimit:n}=this.tuning.autoTrackSelection,r;switch(e){case`high_quality`:r={min:t,max:void 0};break;case`traffic_saving`:r={max:n,min:void 0};break;default:r={max:void 0,min:void 0}}this.setAutoQualityLimits(r)}),this}setPlaybackRate(e){return this.waitInit(()=>{this.tracer.log(`setPlaybackRate`,{playbackRate:e}),this.desiredState.playbackRate.startTransitionTo(e)}),this}setExternalTextTracks(e){return this.waitInit(()=>{e.length&&this.tracer.log(`setExternalTextTracks`,Yv(e)),this.desiredState.externalTextTracks.startTransitionTo(e.map(e=>T({type:`external`},e)))}),this}selectTextTrack(e){return this.waitInit(()=>{xy(e,this.desiredState.currentTextTrack,this.providerContainer?.providerOutput.availableTextTracks$,t=>t.id===e),this.tracer.log(`selectTextTrack`,{textTrackId:e})}),this}setTextTrackCueSettings(e){return this.waitInit(()=>{this.tracer.log(`setTextTrackCueSettings`,T({},e)),this.desiredState.textTrackCuesSettings.startTransitionTo(e)}),this}setLiveLowLatency(e){let t=this.info.isLive$.getValue(),n=this.desiredState.isLowLatency.getState();return!t||n===e?this:(this.tracer.log(`live switch to low latency `+e),this.desiredState.isLowLatency.setState(e),this.seekTime(0))}setLooped(e){return this.waitInit(()=>{this.tracer.log(`setLooped`,{isLooped:e}),this.desiredState.isLooped.startTransitionTo(e)}),this}toggleChromecast(){this.tracer.log(`toggleChromecast`),this.chromecastInitializer.toggleConnection()}startCameraManualRotation(e,t){return this.waitInit(()=>{let n=this.getScene3D();this.tracer.log(`startCameraManualRotation`,{isScene3DAvailable:!!n,mx:e,my:t}),n&&n.startCameraManualRotation(e,t)}),this}stopCameraManualRotation(e=!1){return this.waitInit(()=>{let t=this.getScene3D();this.tracer.log(`stopCameraManualRotation`,{isScene3DAvailable:!!t,immediate:e}),t&&t.stopCameraManualRotation(e)}),this}moveCameraFocusPX(e,t){return this.waitInit(()=>{let n=this.getScene3D();if(this.tracer.log(`moveCameraFocusPX`,{isScene3DAvailable:!!n,dxpx:e,dypx:t}),n){let r=n.getCameraRotation(),i=n.pixelToDegree({x:e,y:t});this.desiredState.cameraOrientation.setState({x:r.x+i.x,y:r.y+i.y})}}),this}holdCamera(){return this.waitInit(()=>{let e=this.getScene3D();e&&e.holdCamera()}),this}releaseCamera(){return this.waitInit(()=>{let e=this.getScene3D();e&&e.releaseCamera()}),this}getExactTime(){if(!this.providerContainer)return 0;let e=this.providerContainer.providerOutput.element$.getValue();if(iy(e))return this.info.position$.getValue();let t=this.desiredState.seekState.getState(),n=t.state===`none`?void 0:t.position;return ry(n)?n/1e3:e.currentTime}getExactLiveTime(){if(!this.providerContainer)return 0;let e=this.desiredState.seekState.getState(),t=e.state===`none`?void 0:e.position;return(ry(t)?t:this.info.liveTime$.getValue()??0)/1e3}getAllLogs(){return this.logger.getAllLogs()}getScene3D(){var e;let t=this.providerContainer?.current$.getValue();if(!(t==null||(e=t.provider)==null)&&e.scene3D)return t.provider.scene3D}setIntrinsicVideoSize(...e){let t={width:e.reduce((e,{width:t})=>e||t||0,0),height:e.reduce((e,{height:t})=>e||t||0,0)};t.width&&t.height&&this.info.intrinsicVideoSize$.next({width:t.width,height:t.height})}initDesiredStateSubscriptions(){this.persistentSubscription.add(sy(this.desiredState.playbackState.stateChangeStarted$,this.desiredState.playbackState.forceChanged$).pipe(Z(e=>e.to)).subscribe(this.info.playbackState$)).add(this.desiredState.isLooped.stateChangeEnded$.pipe(Z(e=>e.to)).subscribe(this.info.isLooped$)).add(this.desiredState.playbackRate.stateChangeEnded$.pipe(Z(e=>e.to)).subscribe(this.info.currentPlaybackRate$)).add(this.desiredState.autoVideoTrackSwitching.stateChangeEnded$.pipe(Z(e=>e.to)).subscribe(this.info.isAutoQualityEnabled$)).add(this.desiredState.autoVideoTrackLimits.stateChangeEnded$.pipe(Z(e=>e.to)).subscribe(e=>{this.info.autoQualityLimits$.next(e);let{highQualityLimit:t,trafficSavingLimit:n}=this.tuning.autoTrackSelection;this.info.predefinedQualityLimitType$.next(ui(e,t,n))})).add(sy(this.desiredState.playbackState.stateChangeStarted$,this.desiredState.playbackState.forceChanged$).pipe(Y(({from:e})=>e===`stopped`)).subscribe(()=>{this.initedAt=cy(),this.events.inited$.next()})).add(this.desiredState.playbackState.stateChangeEnded$.subscribe(e=>{switch(e.to){case`ready`:this.events.ready$.next();break;case`playing`:this.isPlaybackStarted||this.events.started$.next(),this.isPlaybackStarted=!0,this.events.playing$.next();break;case`paused`:this.events.paused$.next();break;case`stopped`:this.events.stopped$.next()}})).add(this.desiredState.playbackState.stateChangeStarted$.subscribe(e=>{switch(e.to){case`ready`:this.events.willReady$.next();break;case`paused`:this.events.willPause$.next();break;case`playing`:this.isPlaybackStarted?this.events.willResume$.next():this.events.willStart$.next();break;case`stopped`:this.suppressWillStop||this.events.willStop$.next();break;default:}}))}initProviderContainerSubscription(e){this.subscription.add(e.providerOutput.willSeekEvent$.subscribe(()=>{let e=this.desiredState.seekState.getState();this.tracer.log(`willSeekEvent`,Yv(e)),e.state===`requested`?this.desiredState.seekState.setState(T(T({},e),{},{state:`applying`})):this.events.managedError$.next({id:`WillSeekIn${e.state}`,category:Jv.WTF,message:`Received unexpeceted willSeek$`})})).add(e.providerOutput.soundProhibitedEvent$.pipe(Q()).subscribe(this.events.autoplaySoundProhibited$)).add(e.providerOutput.severeStallOccurred$.subscribe(this.events.severeStallOccured$)).add(e.providerOutput.seekedEvent$.subscribe(()=>{let e=this.desiredState.seekState.getState();this.tracer.log(`seekedEvent`,Yv(e)),e.state===`applying`&&(this.desiredState.seekState.setState({state:`none`}),this.events.seeked$.next())})).add(e.current$.pipe(Z(e=>e.type)).subscribe(this.info.currentFormat$)).add(e.current$.pipe(Z(e=>e.destination),X()).subscribe(()=>this.isPlaybackStarted=!1)).add(e.providerOutput.availableVideoStreams$.subscribe(this.info.availableVideoStreams$)).add(e.providerOutput.availableVideoTracks$.subscribe(this.info.availableVideoTracks$)).add(Kv({availableVideoTracks:e.providerOutput.availableVideoTracks$,currentVideoStream:e.providerOutput.currentVideoStream$}).pipe(Z(({availableVideoTracks:e,currentVideoStream:t})=>e.filter(e=>t?t.id===e.streamId:!0).map(({quality:e})=>e).sort((e,t)=>ny(e)?1:ny(t)?-1:ty(t,e)?1:-1))).subscribe(this.info.availableQualities$)).add(e.providerOutput.availableVideoTracks$.subscribe(e=>{let t={};for(let n of e)n.fps&&(t[n.quality]=n.fps);this.info.availableQualitiesFps$.next(t)})).add(e.providerOutput.availableAudioStreams$.subscribe(this.info.availableAudioStreams$)).add(e.providerOutput.currentVideoStream$.subscribe(this.info.currentVideoStream$)).add(e.providerOutput.currentAudioStream$.subscribe(this.info.currentAudioStream$)).add(e.providerOutput.availableAudioTracks$.subscribe(this.info.availableAudioTracks$)).add(e.providerOutput.isAudioAvailable$.pipe(X()).subscribe(this.info.isAudioAvailable$)).add(e.providerOutput.currentVideoTrack$.pipe(Y(e=>ry(e))).subscribe(e=>{this.info.currentQuality$.next(e?.quality),this.info.videoBitrate$.next(e?.bitrate)})).add(e.providerOutput.currentVideoSegmentLength$.pipe(X((e,t)=>Math.round(e)===Math.round(t))).subscribe(this.info.currentVideoSegmentLength$)).add(e.providerOutput.currentAudioSegmentLength$.pipe(X((e,t)=>Math.round(e)===Math.round(t))).subscribe(this.info.currentAudioSegmentLength$)).add(e.providerOutput.hostname$.pipe(X()).subscribe(this.info.hostname$)).add(e.providerOutput.httpConnectionType$.pipe(X()).subscribe(this.info.httpConnectionType$)).add(e.providerOutput.httpConnectionReused$.pipe(X()).subscribe(this.info.httpConnectionReused$)).add(e.providerOutput.httpConnectionMetrics$.pipe(X()).subscribe(this.info.httpConnectionMetrics$)).add(e.providerOutput.httpDownloadMetrics$.pipe(X()).subscribe(this.info.httpDownloadMetrics$)).add(e.providerOutput.currentTextTrack$.subscribe(this.info.currentTextTrack$)).add(e.providerOutput.availableTextTracks$.subscribe(this.info.availableTextTracks$)).add(e.providerOutput.autoVideoTrackLimitingAvailable$.subscribe(this.info.autoQualityLimitingAvailable$)).add(e.providerOutput.autoVideoTrackLimits$.subscribe(e=>{this.desiredState.autoVideoTrackLimits.setState(e??{})})).add(e.providerOutput.currentBuffer$.pipe(Z(e=>e?{start:e.from,end:e.to}:{start:0,end:0})).subscribe(this.info.currentBuffer$)).add(e.providerOutput.currentNativeBuffer$.pipe(Z(e=>e?{start:e.from,end:e.to}:{start:0,end:0})).subscribe(this.info.currentNativeBuffer$)).add(e.providerOutput.duration$.subscribe(this.info.duration$)).add(e.providerOutput.playedTime$.subscribe(this.info.playedTime$)).add(e.providerOutput.isBuffering$.subscribe(this.info.isBuffering$)).add(e.providerOutput.isLive$.subscribe(this.info.isLive$)).add(e.providerOutput.isLiveEnded$.pipe(uy(e=>e&&this.stop())).subscribe(this.info.isLiveEnded$)).add(e.providerOutput.canPlayLiveTailBuffer$.subscribe(this.info.canPlayLiveTailBuffer$)).add(e.providerOutput.canChangePlaybackSpeed$.subscribe(this.info.canChangePlaybackSpeed$)).add(e.providerOutput.liveTime$.pipe(X()).subscribe(this.info.liveTime$)).add(e.providerOutput.liveBufferTime$.subscribe(this.info.liveBufferTime$)).add(e.providerOutput.liveLatency$.subscribe(this.info.liveLatency$)).add(Kv({hasLiveOffsetByPaused:sy(this.desiredState.playbackState.stateChangeStarted$,this.desiredState.playbackState.forceChanged$).pipe(Z(e=>e.to),X(),Z(e=>e===`paused`)),isLowLatency:e.providerOutput.isLowLatency$}).subscribe(({hasLiveOffsetByPaused:e,isLowLatency:t})=>{let n=$v();if(n.clearTimeout(this.hasLiveOffsetByPausedTimer),e){this.hasLiveOffsetByPausedTimer=n.setTimeout(()=>{this.hasLiveOffsetByPaused.next(!0)},this.getActiveLiveDelay(t));return}this.hasLiveOffsetByPaused.next(!1)})).add(Kv({atLiveEdge:Kv({isLive:e.providerOutput.isLive$,isLowLatency:e.providerOutput.isLowLatency$,position:vy({seekState:this.desiredState.seekState,position$:e.providerOutput.position$})}).pipe(Z(({isLive:e,position:t,isLowLatency:n})=>{let r=this.getActiveLiveDelay(n);return e&&Math.abs(t)<r/1e3}),X(),uy(e=>e&&this.setPlaybackRate(1))),hasPausedTimeoutCase:this.hasLiveOffsetByPaused}).pipe(Z(({atLiveEdge:e,hasPausedTimeoutCase:t})=>e&&!t)).subscribe(this.info.atLiveEdge$)).add(Kv({isLive:e.providerOutput.isLive$,position:e.providerOutput.position$,duration:e.providerOutput.duration$}).pipe(Z(({isLive:e,position:t,duration:n})=>e&&(Math.abs(n)-Math.abs(t))*1e3<this.tuning.live.activeLiveDelay),X(),uy(e=>e&&this.setPlaybackRate(1))).subscribe(this.info.atLiveDurationEdge$)).add(e.providerOutput.volume$.pipe(Z(e=>e.muted),X()).subscribe(this.info.muted$)).add(e.providerOutput.volume$.pipe(Z(e=>e.volume),X()).subscribe(this.info.volume$)).add(vy({seekState:this.desiredState.seekState,position$:e.providerOutput.position$}).subscribe(this.info.position$)).add(e.providerOutput.seekedEvent$.subscribe(()=>{this.info.isEnded$.getValue()&&this.tuning.changePlaybackStateToPausedWhenEnded&&this.play()})).add(sy(e.providerOutput.endedEvent$.pipe(oy(!0)),e.providerOutput.seekedEvent$.pipe(oy(!1))).pipe(X()).subscribe(this.info.isEnded$)).add(e.providerOutput.endedEvent$.subscribe(this.events.ended$)).add(e.providerOutput.loopedEvent$.subscribe(this.events.looped$)).add(e.providerError$.subscribe(this.events.managedError$)).add(e.providerOutput.updateDurationError$.subscribe(this.events.managedError$)).add(e.providerOutput.fetcherRecoverableError$.subscribe(this.events.fetcherRecoverableError$)).add(e.providerOutput.fetcherError$.pipe(Y(e=>e.category===Jv.FATAL)).subscribe(this.events.fatalError$)).add(e.volumeMultiplierError$.subscribe(this.events.managedError$)).add(e.noAvailableProvidersError$.pipe(Z(({forced:e,input:t,supported:n})=>{let r,i;return e?(r=`NoForcedFormat`,i=`${e} was forced but failed or not available`):n.length?(r=`NoFormats`,i=`All formats failed`):t.length?(r=`NoSupportedFormats`,i=`No supported formats`):(r=`NoInputFormats`,i=`No formats supplied`),Gv(r),{id:r,category:Jv.VIDEO_PIPELINE,message:i}})).subscribe(this.events.fatalError$)).add(e.providerOutput.element$.subscribe(this.experimental.element$)).add(e.providerOutput.getCurrentTime$.subscribe(this.experimental.getCurrentTime$)).add(e.providerOutput.manifestRequested$.pipe(Q()).subscribe(this.events.manifestRequested$)).add(e.providerOutput.firstBytesManifest$.pipe(Q()).subscribe(this.events.firstBytesManifest$)).add(e.providerOutput.manifestReceived$.pipe(Q()).subscribe(this.events.manifestReceived$)).add(e.providerOutput.firstBytesRequested$.pipe(Q()).subscribe(this.events.firstBytesRequested$)).add(e.providerOutput.firstBytesReceived$.pipe(Q()).subscribe(this.events.firstBytesReceived$)).add(e.providerOutput.firstBytesEvent$.pipe(Q(),Z(e=>e??cy()-this.initedAt)).subscribe(this.events.firstBytes$)).add(e.providerOutput.loadedMetadataEvent$.subscribe(this.events.loadedMetadata$)).add(e.providerOutput.firstFrameEvent$.pipe(Q(),Z(()=>cy()-this.initedAt)).subscribe(this.events.firstFrame$)).add(e.providerOutput.canplay$.pipe(Q(),Z(()=>cy()-this.initedAt)).subscribe(this.events.canplay$)).add(this.throughputEstimator.throughput$.subscribe(this.info.throughputEstimation$)).add(this.throughputEstimator.rtt$.subscribe(this.info.rttEstimation$)).add(e.providerOutput.availableSources$.subscribe(this.info.availableSources$));let t=new py(!1);this.subscription.add(e.providerOutput.seekedEvent$.subscribe(()=>t.next(!1))).add(e.providerOutput.willSeekEvent$.subscribe(()=>t.next(!0)));let n=new py(!0);this.subscription.add(e.current$.subscribe(()=>n.next(!0))).add(this.desiredState.playbackState.stateChangeEnded$.pipe(Y(({to:e})=>e===`playing`),Q()).subscribe(()=>n.next(!1)));let r=0,i=0,a=sy(e.providerOutput.isBuffering$,t,n).pipe(Z(()=>{let r=e.providerOutput.isBuffering$.getValue(),i=t.getValue()||n.getValue();return r&&!i}),X());this.subscription.add(a.subscribe(e=>{let{stallIgnoreThreshold:t,stallHandlingStrategy:n}=this.tuning,a=$v();e?(i=cy(),n===`verbose`&&this.info.stallStartTime$.next(i),r=a.setTimeout(()=>{this.info.isStalled$.next(!0),i&&this.info.stallStartTime$.next(n===`exclude-threshold`?cy():i)},t)):(a.clearTimeout(r),this.info.isStalled$.next(!1),i=0,this.info.stallStartTime$.next(0))})),this.subscription.add(sy(e.providerOutput.canplay$,e.providerOutput.firstFrameEvent$,e.providerOutput.firstBytesEvent$).subscribe(()=>{let t=e.providerOutput.element$.getValue();this.setIntrinsicVideoSize({width:t?.videoWidth,height:t?.videoHeight})})).add(e.providerOutput.currentVideoTrack$.subscribe(t=>{var n,r;let i=e.providerOutput.element$.getValue();this.setIntrinsicVideoSize({width:t==null||(n=t.size)==null?void 0:n.width,height:t==null||(r=t.size)==null?void 0:r.height},{width:i?.videoWidth,height:i?.videoHeight})})).add(e.providerOutput.is3DVideo$.subscribe(this.info.is3DVideo$)),this.subscription.add(sy(e.providerOutput.inPiP$,e.providerOutput.inFullscreen$,e.providerOutput.element$,e.providerOutput.elementVisible$,this.chromecastInitializer.castState$).subscribe(()=>{let t=e.providerOutput.inPiP$.getValue(),n=e.providerOutput.inFullscreen$.getValue(),r=e.providerOutput.element$.getValue(),i=e.providerOutput.elementVisible$.getValue(),a=this.chromecastInitializer.castState$.getValue(),o;o=a===`CONNECTED`?`second_screen`:r?i?t?`pip`:n?`fullscreen`:`inline`:`invisible`:`none`,this.info.surface$.getValue()!==o&&this.info.surface$.next(o)}))}initChromecastSubscription(){this.subscription.add(this.chromecastInitializer.castState$.subscribe(this.info.chromecastState$)),this.subscription.add(this.chromecastInitializer.connection$.pipe(Z(e=>e?.castDevice.friendlyName)).subscribe(this.info.chromecastDeviceName$)),this.subscription.add(this.chromecastInitializer.errorEvent$.subscribe(this.events.managedError$))}initStartingVideoTrack(e){let t=new ly;this.subscription.add(t),this.subscription.add(e.current$.pipe(X((e,t)=>e.provider===t.provider)).subscribe(()=>{t.unsubscribe(),t.add(e.providerOutput.availableVideoTracks$.pipe(Y(e=>e.length>0),Q()).subscribe(e=>{this.setStartingVideoTrack(e)}))}))}setStartingVideoTrack(e){let t;this.wasSetStartedQuality=!0;let n=this.explicitInitialQuality??this.info.currentQuality$.getValue();n&&(t=e.find(({quality:e,tvDisabled:t})=>e===n&&!t),t||this.setAutoQuality(!0)),!t&&(t=Oi(e,{container:this.domContainer?.getBoundingClientRect(),panelSize:this.config.panelSize,estimatedThroughput:this.throughputEstimator.throughput$.getValue(),tuning:this.tuning.autoTrackSelection,limits:this.desiredState.autoVideoTrackLimits.getState(),playbackRate:this.info.currentPlaybackRate$.getValue(),forwardBufferHealth:0,abrLogger:this.abrLogger})),this.desiredState.videoTrack.startTransitionTo(t),this.info.currentQuality$.next(t.quality),this.info.videoBitrate$.next(t.bitrate)}initLogs(){this.persistentSubscription.add(sy(this.desiredState.videoTrack.stateChangeStarted$.pipe(Z(e=>({transition:e,entity:`quality`,type:`start`}))),this.desiredState.videoTrack.stateChangeEnded$.pipe(Z(e=>({transition:e,entity:`quality`,type:`end`}))),this.desiredState.autoVideoTrackSwitching.stateChangeStarted$.pipe(Z(e=>({transition:e,entity:`autoQualityEnabled`,type:`start`}))),this.desiredState.autoVideoTrackSwitching.stateChangeEnded$.pipe(Z(e=>({transition:e,entity:`autoQualityEnabled`,type:`end`}))),this.desiredState.seekState.stateChangeStarted$.pipe(Z(e=>({transition:e,entity:`seekState`,type:`start`}))),this.desiredState.seekState.stateChangeEnded$.pipe(Z(e=>({transition:e,entity:`seekState`,type:`end`}))),this.desiredState.playbackState.stateChangeStarted$.pipe(Z(e=>({transition:e,entity:`playbackState`,type:`start`}))),this.desiredState.playbackState.stateChangeEnded$.pipe(Z(e=>({transition:e,entity:`playbackState`,type:`end`})))).pipe(Z(e=>({component:`desiredState`,message:`[${e.entity} change] ${e.type}: ${JSON.stringify(e.transition)}`}))).subscribe(this.logger.log)),this.persistentSubscription.add(this.logger.log$.subscribe(this.events.log$))}initDebugTelemetry(){let e=this.providerContainer?.providerOutput;Gv(this.providerContainer),Gv(e),ti(),this.experimental.enableDebugTelemetry$.next(this.tuning.enableTelemetryAtStart),[this.experimental.enableDebugTelemetry$.subscribe(e=>ei(e)),this.providerContainer.current$.subscribe(({type:e})=>ri(`provider`,e)),e.duration$.subscribe(e=>ri(`duration`,e)),e.availableVideoTracks$.pipe(Y(e=>!!e.length),Q()).subscribe(e=>ri(`tracks`,e)),this.events.fatalError$.subscribe(new ii(`fatalError`)),this.events.managedError$.subscribe(new ii(`managedError`)),e.position$.subscribe(new ii(`position`)),e.currentVideoTrack$.pipe(Z(e=>e?.quality)).subscribe(new ii(`quality`)),this.info.currentBuffer$.subscribe(new ii(`buffer`)),e.isBuffering$.subscribe(new ii(`isBuffering`))].forEach(e=>this.subscription.add(e)),ri(`codecs`,j.video.supportedCodecs)}initTracerSubscription(){let e=Qv(this.tracer.log.bind(this.tracer)),t=Qv(this.tracer.error.bind(this.tracer));this.subscription.add(this.info.playbackState$.subscribe(e(`playbackState`))).add(this.info.isLooped$.subscribe(e(`isLooped`))).add(this.info.currentPlaybackRate$.pipe(X()).subscribe(e(`currentPlaybackRate`))).add(this.info.isAutoQualityEnabled$.subscribe(e(`isAutoQualityEnabled`))).add(this.info.autoQualityLimits$.subscribe(e(`autoQualityLimits`))).add(this.info.currentFormat$.subscribe(e(`currentFormat`))).add(this.info.availableQualities$.subscribe(e(`availableQualities`))).add(this.info.availableQualitiesFps$.subscribe(e(`availableQualitiesFps`))).add(this.info.availableAudioTracks$.subscribe(e(`availableAudioTracks`))).add(this.info.isAudioAvailable$.subscribe(e(`isAudioAvailable`))).add(Kv({currentQuality:this.info.currentQuality$,videoBitrate:this.info.videoBitrate$}).pipe(Y(({currentQuality:e,videoBitrate:t})=>!!e&&!!t),X((e,t)=>e.currentQuality===t.currentQuality)).subscribe(e(`currentVideoTrack`))).add(this.info.currentVideoSegmentLength$.pipe(Y(e=>e>0),X()).subscribe(e(`currentVideoSegmentLength`))).add(this.info.currentAudioSegmentLength$.pipe(Y(e=>e>0),X()).subscribe(e(`currentAudioSegmentLength`))).add(this.info.hostname$.subscribe(e(`hostname`))).add(this.info.currentTextTrack$.subscribe(e(`currentTextTrack`))).add(this.info.availableTextTracks$.subscribe(e(`availableTextTracks`))).add(this.info.autoQualityLimitingAvailable$.subscribe(e(`autoQualityLimitingAvailable`))).add(Kv({currentBuffer:this.info.currentBuffer$.pipe(Y(e=>e.end>0),X((e,t)=>e.end===t.end&&e.start===t.start)),position:this.info.position$.pipe(X())}).pipe(dy(1e3)).subscribe(e(`currentBufferAndPosition`))).add(this.info.duration$.pipe(X()).subscribe(e(`duration`))).add(this.info.isBuffering$.subscribe(e(`isBuffering`))).add(this.info.isLive$.pipe(X()).subscribe(e(`isLive`))).add(this.info.canChangePlaybackSpeed$.pipe(X()).subscribe(e(`canChangePlaybackSpeed`))).add(Kv({liveTime:this.info.liveTime$,liveBufferTime:this.info.liveBufferTime$,position:this.info.position$}).pipe(Y(({liveTime:e,liveBufferTime:t})=>!!e&&!!t),dy(1e3)).subscribe(e(`liveBufferAndPosition`))).add(this.info.atLiveEdge$.pipe(X(),Y(e=>e===!0)).subscribe(e(`atLiveEdge`))).add(this.info.atLiveDurationEdge$.pipe(X(),Y(e=>e===!0)).subscribe(e(`atLiveDurationEdge`))).add(this.info.muted$.pipe(X()).subscribe(e(`muted`))).add(this.info.volume$.pipe(X()).subscribe(e(`volume`))).add(this.info.isEnded$.pipe(X(),Y(e=>e===!0)).subscribe(e(`isEnded`))).add(this.info.availableSources$.subscribe(e(`availableSources`))).add(Kv({throughputEstimation:this.info.throughputEstimation$,rtt:this.info.rttEstimation$}).pipe(Y(({throughputEstimation:e,rtt:t})=>!!e&&!!t),dy(3e3)).subscribe(e(`throughputEstimation`))).add(this.info.isStalled$.subscribe(e(`isStalled`))).add(this.info.is3DVideo$.pipe(X(),Y(e=>e===!0)).subscribe(e(`is3DVideo`))).add(this.info.surface$.subscribe(e(`surface`))).add(this.events.ended$.subscribe(e(`ended`))).add(this.events.looped$.subscribe(e(`looped`))).add(this.events.managedError$.subscribe(t(`managedError`))).add(this.events.fatalError$.subscribe(t(`fatalError`))).add(this.events.firstBytes$.subscribe(e(`firstBytes`))).add(this.events.firstFrame$.subscribe(e(`firstFrame`))).add(this.events.canplay$.subscribe(e(`canplay`)))}initWakeLock(){var e=this;let t=$v();if(!t.navigator.wakeLock||!this.tuning.enableWakeLock)return;let n,r=()=>{n?.release(),n=void 0},i=function(){var t=w(function*(){r(),n=yield window.navigator.wakeLock.request(`screen`).catch(t=>{t instanceof DOMException&&t.name===`NotAllowedError`||e.events.managedError$.next({id:`WakeLock`,category:Jv.DOM,message:String(t)})})});return function(){return t.apply(this,arguments)}}();this.subscription.add(sy(Xv(t.document,`visibilitychange`),Xv(t.document,`fullscreenchange`),this.desiredState.playbackState.stateChangeEnded$).subscribe(()=>{let e=t.document.visibilityState===`visible`,a=this.desiredState.playbackState.getState()===`playing`,o=!!n&&!n?.released;e&&a?o||i():r()})).add(this.events.willDestruct$.subscribe(r))}setVideoTrackIdByQuality(e,t){let n=e.find(e=>e.quality===t);this.tracer.log(`setVideoTrackIdByQuality`,Yv({quality:t,availableTracks:Yv(e),track:Yv(n),isAutoQuality:!n})),n?n.tvDisabled?(this.setAutoQuality(!0),this.events.managedError$.next({id:`SetQualityTrackTvDisabled`,category:Jv.WTF,message:`Set quality was called on track with tvDisabled flag`})):this.desiredState.videoTrack.startTransitionTo(n):this.setAutoQuality(!0)}getActiveLiveDelay(e=!1){return e?this.tuning.live.lowLatencyActiveLiveDelay:this.tuning.live.activeLiveDelay}isNotActiveTabCase(){return $v().document.hidden&&this.tuning.autoplayOnlyInActiveTab&&!Wa()}}var Vy=`@vkontakte/videoplayer-core@${te}`;;return{st,j,Pt,Ya,By,re,ie,zy,te,se,Iy,Ry,Vy,ce,Fy,ne,Ly,oe,ae};}();var{st:_oxcModiyy8hh_st,j:_oxcModiyy8hh_j,Pt:_oxcModiyy8hh_Pt,Ya:_oxcModiyy8hh_Ya,By:_oxcModiyy8hh_By,re:_oxcModiyy8hh_re,ie:_oxcModiyy8hh_ie,zy:_oxcModiyy8hh_zy,te:_oxcModiyy8hh_te,se:_oxcModiyy8hh_se,Iy:_oxcModiyy8hh_Iy,Ry:_oxcModiyy8hh_Ry,Vy:_oxcModiyy8hh_Vy,ce:_oxcModiyy8hh_ce,Fy:_oxcModiyy8hh_Fy,ne:_oxcModiyy8hh_ne,Ly:_oxcModiyy8hh_Ly,oe:_oxcModiyy8hh_oe,ae:_oxcModiyy8hh_ae}=_oxcModiyy8hh;export{_oxcModiyy8hh_st as isMobile,_oxcModiyy8hh_j as clientChecker,_oxcModiyy8hh_Pt as areValidLiveRecordSources,_oxcModiyy8hh_Ya as WebmCodecStrategy,_oxcModiyy8hh_By as VideoQuality,_oxcModiyy8hh_re as VideoFormat,_oxcModiyy8hh_ie as VideoCodecName,_oxcModiyy8hh_zy as ValueSubject,_oxcModiyy8hh_te as VERSION,_oxcModiyy8hh_se as Surface,_oxcModiyy8hh_Iy as Subscription,_oxcModiyy8hh_Ry as Subject,_oxcModiyy8hh_Vy as SDK_VERSION,_oxcModiyy8hh_ce as PredefinedQualityLimits,_oxcModiyy8hh_Fy as Player,_oxcModiyy8hh_ne as PlaybackState,_oxcModiyy8hh_Ly as Observable,_oxcModiyy8hh_oe as HttpConnectionType,_oxcModiyy8hh_ae as ChromecastState};
|