@vkontakte/videoplayer-core 2.0.139 → 2.0.140-dev.26e4b860.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/es2015.cjs.js CHANGED
@@ -1,10 +1,10 @@
1
1
  /**
2
- * @vkontakte/videoplayer-core v2.0.139
3
- * Fri, 22 Aug 2025 14:38:31 GMT
4
- * https://st.mycdn.me/static/vkontakte-videoplayer/2-0-139/doc/
2
+ * @vkontakte/videoplayer-core v2.0.140-dev.26e4b860.0
3
+ * Mon, 25 Aug 2025 17:43:24 GMT
4
+ * https://st.mycdn.me/static/vkontakte-videoplayer/2-0-140/doc/
5
5
  */
6
- "use strict";var Yy=Object.create;var Wr=Object.defineProperty,Ky=Object.defineProperties,Xy=Object.getOwnPropertyDescriptor,Jy=Object.getOwnPropertyDescriptors,Zy=Object.getOwnPropertyNames,Ba=Object.getOwnPropertySymbols,eT=Object.getPrototypeOf,Lo=Object.prototype.hasOwnProperty,md=Object.prototype.propertyIsEnumerable;var tT=(s,e)=>(e=Symbol[s])?e:Symbol.for("Symbol."+s);var kt=Math.pow,fd=(s,e,t)=>e in s?Wr(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,C=(s,e)=>{for(var t in e||(e={}))Lo.call(e,t)&&fd(s,t,e[t]);if(Ba)for(var t of Ba(e))md.call(e,t)&&fd(s,t,e[t]);return s},j=(s,e)=>Ky(s,Jy(e));var bd=(s,e)=>{var t={};for(var i in s)Lo.call(s,i)&&e.indexOf(i)<0&&(t[i]=s[i]);if(s!=null&&Ba)for(var i of Ba(s))e.indexOf(i)<0&&md.call(s,i)&&(t[i]=s[i]);return t};var v=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports),iT=(s,e)=>{for(var t in e)Wr(s,t,{get:e[t],enumerable:!0})},gd=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Zy(e))!Lo.call(s,r)&&r!==t&&Wr(s,r,{get:()=>e[r],enumerable:!(i=Xy(e,r))||i.enumerable});return s};var Y=(s,e,t)=>(t=s!=null?Yy(eT(s)):{},gd(e||!s||!s.__esModule?Wr(t,"default",{value:s,enumerable:!0}):t,s)),rT=s=>gd(Wr({},"__esModule",{value:!0}),s);var R=(s,e,t)=>new Promise((i,r)=>{var a=u=>{try{o(t.next(u))}catch(l){r(l)}},n=u=>{try{o(t.throw(u))}catch(l){r(l)}},o=u=>u.done?i(u.value):Promise.resolve(u.value).then(a,n);o((t=t.apply(s,e)).next())}),Pi=function(s,e){this[0]=s,this[1]=e},oe=(s,e,t)=>{var i=(n,o,u,l)=>{try{var c=t[n](o),d=(o=c.value)instanceof Pi,f=c.done;Promise.resolve(d?o[0]:o).then(p=>d?i(n==="return"?n:"next",o[1]?{done:p.done,value:p.value}:p,u,l):u({value:p,done:f})).catch(p=>i("throw",p,u,l))}catch(p){l(p)}},r=n=>a[n]=o=>new Promise((u,l)=>i(n,o,u,l)),a={};return t=t.apply(s,e),a[tT("asyncIterator")]=()=>a,r("next"),r("throw"),r("return"),a};var Ae=v((Mo,vd)=>{"use strict";var Yr=function(s){return s&&s.Math===Math&&s};vd.exports=Yr(typeof globalThis=="object"&&globalThis)||Yr(typeof window=="object"&&window)||Yr(typeof self=="object"&&self)||Yr(typeof global=="object"&&global)||Yr(typeof Mo=="object"&&Mo)||function(){return this}()||Function("return this")()});var Me=v((z$,Sd)=>{"use strict";Sd.exports=function(s){try{return!!s()}catch(e){return!0}}});var Kr=v((Y$,yd)=>{"use strict";var sT=Me();yd.exports=!sT(function(){var s=function(){}.bind();return typeof s!="function"||s.hasOwnProperty("prototype")})});var Do=v((K$,xd)=>{"use strict";var aT=Kr(),Ed=Function.prototype,Td=Ed.apply,Id=Ed.call;xd.exports=typeof Reflect=="object"&&Reflect.apply||(aT?Id.bind(Td):function(){return Id.apply(Td,arguments)})});var De=v((X$,Pd)=>{"use strict";var wd=Kr(),Ad=Function.prototype,Co=Ad.call,nT=wd&&Ad.bind.bind(Co,Co);Pd.exports=wd?nT:function(s){return function(){return Co.apply(s,arguments)}}});var Ri=v((J$,kd)=>{"use strict";var Rd=De(),oT=Rd({}.toString),uT=Rd("".slice);kd.exports=function(s){return uT(oT(s),8,-1)}});var Bo=v((Z$,Ld)=>{"use strict";var lT=Ri(),cT=De();Ld.exports=function(s){if(lT(s)==="Function")return cT(s)}});var Pe=v((eM,$d)=>{"use strict";var Vo=typeof document=="object"&&document.all;$d.exports=typeof Vo=="undefined"&&Vo!==void 0?function(s){return typeof s=="function"||s===Vo}:function(s){return typeof s=="function"}});var rt=v((tM,Md)=>{"use strict";var dT=Me();Md.exports=!dT(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var st=v((iM,Dd)=>{"use strict";var pT=Kr(),Oa=Function.prototype.call;Dd.exports=pT?Oa.bind(Oa):function(){return Oa.apply(Oa,arguments)}});var _o=v(Vd=>{"use strict";var Cd={}.propertyIsEnumerable,Bd=Object.getOwnPropertyDescriptor,hT=Bd&&!Cd.call({1:2},1);Vd.f=hT?function(e){var t=Bd(this,e);return!!t&&t.enumerable}:Cd});var Xr=v((sM,_d)=>{"use strict";_d.exports=function(s,e){return{enumerable:!(s&1),configurable:!(s&2),writable:!(s&4),value:e}}});var Fd=v((aM,Od)=>{"use strict";var fT=De(),mT=Me(),bT=Ri(),Oo=Object,gT=fT("".split);Od.exports=mT(function(){return!Oo("z").propertyIsEnumerable(0)})?function(s){return bT(s)==="String"?gT(s,""):Oo(s)}:Oo});var Jr=v((nM,Nd)=>{"use strict";Nd.exports=function(s){return s==null}});var ui=v((oM,qd)=>{"use strict";var vT=Jr(),ST=TypeError;qd.exports=function(s){if(vT(s))throw new ST("Can't call method on "+s);return s}});var ki=v((uM,Ud)=>{"use strict";var yT=Fd(),TT=ui();Ud.exports=function(s){return yT(TT(s))}});var Ge=v((lM,Hd)=>{"use strict";var IT=Pe();Hd.exports=function(s){return typeof s=="object"?s!==null:IT(s)}});var Li=v((cM,jd)=>{"use strict";jd.exports={}});var Ht=v((dM,Wd)=>{"use strict";var Fo=Li(),No=Ae(),ET=Pe(),Qd=function(s){return ET(s)?s:void 0};Wd.exports=function(s,e){return arguments.length<2?Qd(Fo[s])||Qd(No[s]):Fo[s]&&Fo[s][e]||No[s]&&No[s][e]}});var Zr=v((pM,Gd)=>{"use strict";var xT=De();Gd.exports=xT({}.isPrototypeOf)});var $i=v((hM,Kd)=>{"use strict";var wT=Ae(),zd=wT.navigator,Yd=zd&&zd.userAgent;Kd.exports=Yd?String(Yd):""});var Uo=v((fM,ip)=>{"use strict";var tp=Ae(),qo=$i(),Xd=tp.process,Jd=tp.Deno,Zd=Xd&&Xd.versions||Jd&&Jd.version,ep=Zd&&Zd.v8,yt,Fa;ep&&(yt=ep.split("."),Fa=yt[0]>0&&yt[0]<4?1:+(yt[0]+yt[1]));!Fa&&qo&&(yt=qo.match(/Edge\/(\d+)/),(!yt||yt[1]>=74)&&(yt=qo.match(/Chrome\/(\d+)/),yt&&(Fa=+yt[1])));ip.exports=Fa});var Ho=v((mM,sp)=>{"use strict";var rp=Uo(),AT=Me(),PT=Ae(),RT=PT.String;sp.exports=!!Object.getOwnPropertySymbols&&!AT(function(){var s=Symbol("symbol detection");return!RT(s)||!(Object(s)instanceof Symbol)||!Symbol.sham&&rp&&rp<41})});var jo=v((bM,ap)=>{"use strict";var kT=Ho();ap.exports=kT&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var Qo=v((gM,np)=>{"use strict";var LT=Ht(),$T=Pe(),MT=Zr(),DT=jo(),CT=Object;np.exports=DT?function(s){return typeof s=="symbol"}:function(s){var e=LT("Symbol");return $T(e)&&MT(e.prototype,CT(s))}});var es=v((vM,op)=>{"use strict";var BT=String;op.exports=function(s){try{return BT(s)}catch(e){return"Object"}}});var $t=v((SM,up)=>{"use strict";var VT=Pe(),_T=es(),OT=TypeError;up.exports=function(s){if(VT(s))return s;throw new OT(_T(s)+" is not a function")}});var ts=v((yM,lp)=>{"use strict";var FT=$t(),NT=Jr();lp.exports=function(s,e){var t=s[e];return NT(t)?void 0:FT(t)}});var dp=v((TM,cp)=>{"use strict";var Wo=st(),Go=Pe(),zo=Ge(),qT=TypeError;cp.exports=function(s,e){var t,i;if(e==="string"&&Go(t=s.toString)&&!zo(i=Wo(t,s))||Go(t=s.valueOf)&&!zo(i=Wo(t,s))||e!=="string"&&Go(t=s.toString)&&!zo(i=Wo(t,s)))return i;throw new qT("Can't convert object to primitive value")}});var Tt=v((IM,pp)=>{"use strict";pp.exports=!0});var mp=v((EM,fp)=>{"use strict";var hp=Ae(),UT=Object.defineProperty;fp.exports=function(s,e){try{UT(hp,s,{value:e,configurable:!0,writable:!0})}catch(t){hp[s]=e}return e}});var is=v((xM,vp)=>{"use strict";var HT=Tt(),jT=Ae(),QT=mp(),bp="__core-js_shared__",gp=vp.exports=jT[bp]||QT(bp,{});(gp.versions||(gp.versions=[])).push({version:"3.43.0",mode:HT?"pure":"global",copyright:"\xA9 2014-2025 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.43.0/LICENSE",source:"https://github.com/zloirock/core-js"})});var Yo=v((wM,yp)=>{"use strict";var Sp=is();yp.exports=function(s,e){return Sp[s]||(Sp[s]=e||{})}});var rr=v((AM,Tp)=>{"use strict";var WT=ui(),GT=Object;Tp.exports=function(s){return GT(WT(s))}});var It=v((PM,Ip)=>{"use strict";var zT=De(),YT=rr(),KT=zT({}.hasOwnProperty);Ip.exports=Object.hasOwn||function(e,t){return KT(YT(e),t)}});var Ko=v((RM,Ep)=>{"use strict";var XT=De(),JT=0,ZT=Math.random(),eI=XT(1.1.toString);Ep.exports=function(s){return"Symbol("+(s===void 0?"":s)+")_"+eI(++JT+ZT,36)}});var Fe=v((kM,wp)=>{"use strict";var tI=Ae(),iI=Yo(),xp=It(),rI=Ko(),sI=Ho(),aI=jo(),sr=tI.Symbol,Xo=iI("wks"),nI=aI?sr.for||sr:sr&&sr.withoutSetter||rI;wp.exports=function(s){return xp(Xo,s)||(Xo[s]=sI&&xp(sr,s)?sr[s]:nI("Symbol."+s)),Xo[s]}});var kp=v((LM,Rp)=>{"use strict";var oI=st(),Ap=Ge(),Pp=Qo(),uI=ts(),lI=dp(),cI=Fe(),dI=TypeError,pI=cI("toPrimitive");Rp.exports=function(s,e){if(!Ap(s)||Pp(s))return s;var t=uI(s,pI),i;if(t){if(e===void 0&&(e="default"),i=oI(t,s,e),!Ap(i)||Pp(i))return i;throw new dI("Can't convert object to primitive value")}return e===void 0&&(e="number"),lI(s,e)}});var Jo=v(($M,Lp)=>{"use strict";var hI=kp(),fI=Qo();Lp.exports=function(s){var e=hI(s,"string");return fI(e)?e:e+""}});var Na=v((MM,Mp)=>{"use strict";var mI=Ae(),$p=Ge(),Zo=mI.document,bI=$p(Zo)&&$p(Zo.createElement);Mp.exports=function(s){return bI?Zo.createElement(s):{}}});var eu=v((DM,Dp)=>{"use strict";var gI=rt(),vI=Me(),SI=Na();Dp.exports=!gI&&!vI(function(){return Object.defineProperty(SI("div"),"a",{get:function(){return 7}}).a!==7})});var Vp=v(Bp=>{"use strict";var yI=rt(),TI=st(),II=_o(),EI=Xr(),xI=ki(),wI=Jo(),AI=It(),PI=eu(),Cp=Object.getOwnPropertyDescriptor;Bp.f=yI?Cp:function(e,t){if(e=xI(e),t=wI(t),PI)try{return Cp(e,t)}catch(i){}if(AI(e,t))return EI(!TI(II.f,e,t),e[t])}});var tu=v((BM,_p)=>{"use strict";var RI=Me(),kI=Pe(),LI=/#|\.prototype\./,rs=function(s,e){var t=MI[$I(s)];return t===CI?!0:t===DI?!1:kI(e)?RI(e):!!e},$I=rs.normalize=function(s){return String(s).replace(LI,".").toLowerCase()},MI=rs.data={},DI=rs.NATIVE="N",CI=rs.POLYFILL="P";_p.exports=rs});var ar=v((VM,Fp)=>{"use strict";var Op=Bo(),BI=$t(),VI=Kr(),_I=Op(Op.bind);Fp.exports=function(s,e){return BI(s),e===void 0?s:VI?_I(s,e):function(){return s.apply(e,arguments)}}});var iu=v((_M,Np)=>{"use strict";var OI=rt(),FI=Me();Np.exports=OI&&FI(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var Mt=v((OM,qp)=>{"use strict";var NI=Ge(),qI=String,UI=TypeError;qp.exports=function(s){if(NI(s))return s;throw new UI(qI(s)+" is not an object")}});var Mi=v(Hp=>{"use strict";var HI=rt(),jI=eu(),QI=iu(),qa=Mt(),Up=Jo(),WI=TypeError,ru=Object.defineProperty,GI=Object.getOwnPropertyDescriptor,su="enumerable",au="configurable",nu="writable";Hp.f=HI?QI?function(e,t,i){if(qa(e),t=Up(t),qa(i),typeof e=="function"&&t==="prototype"&&"value"in i&&nu in i&&!i[nu]){var r=GI(e,t);r&&r[nu]&&(e[t]=i.value,i={configurable:au in i?i[au]:r[au],enumerable:su in i?i[su]:r[su],writable:!1})}return ru(e,t,i)}:ru:function(e,t,i){if(qa(e),t=Up(t),qa(i),jI)try{return ru(e,t,i)}catch(r){}if("get"in i||"set"in i)throw new WI("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var nr=v((NM,jp)=>{"use strict";var zI=rt(),YI=Mi(),KI=Xr();jp.exports=zI?function(s,e,t){return YI.f(s,e,KI(1,t))}:function(s,e,t){return s[e]=t,s}});var Le=v((qM,Wp)=>{"use strict";var ss=Ae(),XI=Do(),JI=Bo(),ZI=Pe(),eE=Vp().f,tE=tu(),or=Li(),iE=ar(),ur=nr(),Qp=It();is();var rE=function(s){var e=function(t,i,r){if(this instanceof e){switch(arguments.length){case 0:return new s;case 1:return new s(t);case 2:return new s(t,i)}return new s(t,i,r)}return XI(s,this,arguments)};return e.prototype=s.prototype,e};Wp.exports=function(s,e){var t=s.target,i=s.global,r=s.stat,a=s.proto,n=i?ss:r?ss[t]:ss[t]&&ss[t].prototype,o=i?or:or[t]||ur(or,t,{})[t],u=o.prototype,l,c,d,f,p,h,b,S,g;for(f in e)l=tE(i?f:t+(r?".":"#")+f,s.forced),c=!l&&n&&Qp(n,f),h=o[f],c&&(s.dontCallGetSet?(g=eE(n,f),b=g&&g.value):b=n[f]),p=c&&b?b:e[f],!(!l&&!a&&typeof h==typeof p)&&(s.bind&&c?S=iE(p,ss):s.wrap&&c?S=rE(p):a&&ZI(p)?S=JI(p):S=p,(s.sham||p&&p.sham||h&&h.sham)&&ur(S,"sham",!0),ur(o,f,S),a&&(d=t+"Prototype",Qp(or,d)||ur(or,d,{}),ur(or[d],f,p),s.real&&u&&(l||!u[f])&&ur(u,f,p)))}});var Ua=v((UM,zp)=>{"use strict";var sE=Yo(),aE=Ko(),Gp=sE("keys");zp.exports=function(s){return Gp[s]||(Gp[s]=aE(s))}});var Kp=v((HM,Yp)=>{"use strict";var nE=Me();Yp.exports=!nE(function(){function s(){}return s.prototype.constructor=null,Object.getPrototypeOf(new s)!==s.prototype})});var Ha=v((jM,Jp)=>{"use strict";var oE=It(),uE=Pe(),lE=rr(),cE=Ua(),dE=Kp(),Xp=cE("IE_PROTO"),ou=Object,pE=ou.prototype;Jp.exports=dE?ou.getPrototypeOf:function(s){var e=lE(s);if(oE(e,Xp))return e[Xp];var t=e.constructor;return uE(t)&&e instanceof t?t.prototype:e instanceof ou?pE:null}});var eh=v((QM,Zp)=>{"use strict";var hE=Math.ceil,fE=Math.floor;Zp.exports=Math.trunc||function(e){var t=+e;return(t>0?fE:hE)(t)}});var as=v((WM,th)=>{"use strict";var mE=eh();th.exports=function(s){var e=+s;return e!==e||e===0?0:mE(e)}});var rh=v((GM,ih)=>{"use strict";var bE=as(),gE=Math.max,vE=Math.min;ih.exports=function(s,e){var t=bE(s);return t<0?gE(t+e,0):vE(t,e)}});var uu=v((zM,sh)=>{"use strict";var SE=as(),yE=Math.min;sh.exports=function(s){var e=SE(s);return e>0?yE(e,9007199254740991):0}});var lr=v((YM,ah)=>{"use strict";var TE=uu();ah.exports=function(s){return TE(s.length)}});var lu=v((KM,oh)=>{"use strict";var IE=ki(),EE=rh(),xE=lr(),nh=function(s){return function(e,t,i){var r=IE(e),a=xE(r);if(a===0)return!s&&-1;var n=EE(i,a),o;if(s&&t!==t){for(;a>n;)if(o=r[n++],o!==o)return!0}else for(;a>n;n++)if((s||n in r)&&r[n]===t)return s||n||0;return!s&&-1}};oh.exports={includes:nh(!0),indexOf:nh(!1)}});var ja=v((XM,uh)=>{"use strict";uh.exports={}});var dh=v((JM,ch)=>{"use strict";var wE=De(),cu=It(),AE=ki(),PE=lu().indexOf,RE=ja(),lh=wE([].push);ch.exports=function(s,e){var t=AE(s),i=0,r=[],a;for(a in t)!cu(RE,a)&&cu(t,a)&&lh(r,a);for(;e.length>i;)cu(t,a=e[i++])&&(~PE(r,a)||lh(r,a));return r}});var du=v((ZM,ph)=>{"use strict";ph.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var pu=v((eD,hh)=>{"use strict";var kE=dh(),LE=du();hh.exports=Object.keys||function(e){return kE(e,LE)}});var hu=v((tD,vh)=>{"use strict";var mh=rt(),$E=Me(),bh=De(),ME=Ha(),DE=pu(),CE=ki(),BE=_o().f,gh=bh(BE),VE=bh([].push),_E=mh&&$E(function(){var s=Object.create(null);return s[2]=2,!gh(s,2)}),fh=function(s){return function(e){for(var t=CE(e),i=DE(t),r=_E&&ME(t)===null,a=i.length,n=0,o=[],u;a>n;)u=i[n++],(!mh||(r?u in t:gh(t,u)))&&VE(o,s?[u,t[u]]:t[u]);return o}};vh.exports={entries:fh(!0),values:fh(!1)}});var Sh=v(()=>{"use strict";var OE=Le(),FE=hu().values;OE({target:"Object",stat:!0},{values:function(e){return FE(e)}})});var Th=v((sD,yh)=>{"use strict";Sh();var NE=Li();yh.exports=NE.Object.values});var Eh=v((aD,Ih)=>{"use strict";var qE=Th();Ih.exports=qE});var Di=v((nD,xh)=>{"use strict";var UE=Eh();xh.exports=UE});var ns=v((oD,wh)=>{"use strict";wh.exports=function(){}});var Ah=v(()=>{"use strict";var HE=Le(),jE=lu().includes,QE=Me(),WE=ns(),GE=QE(function(){return!Array(1).includes()});HE({target:"Array",proto:!0,forced:GE},{includes:function(e){return jE(this,e,arguments.length>1?arguments[1]:void 0)}});WE("includes")});var li=v((cD,Ph)=>{"use strict";var zE=Ht();Ph.exports=zE});var kh=v((dD,Rh)=>{"use strict";Ah();var YE=li();Rh.exports=YE("Array","includes")});var $h=v((pD,Lh)=>{"use strict";var KE=kh();Lh.exports=KE});var je=v((hD,Mh)=>{"use strict";var XE=$h();Mh.exports=XE});var Ch=v(()=>{"use strict";var ZE=Le(),ex=hu().entries;ZE({target:"Object",stat:!0},{entries:function(e){return ex(e)}})});var Vh=v((AD,Bh)=>{"use strict";Ch();var tx=Li();Bh.exports=tx.Object.entries});var Oh=v((PD,_h)=>{"use strict";var ix=Vh();_h.exports=ix});var cr=v((RD,Fh)=>{"use strict";var rx=Oh();Fh.exports=rx});var Ci=v((kD,Nh)=>{"use strict";Nh.exports={}});var Hh=v((LD,Uh)=>{"use strict";var sx=Ae(),ax=Pe(),qh=sx.WeakMap;Uh.exports=ax(qh)&&/native code/.test(String(qh))});var gu=v(($D,Wh)=>{"use strict";var nx=Hh(),Qh=Ae(),ox=Ge(),ux=nr(),fu=It(),mu=is(),lx=Ua(),cx=ja(),jh="Object already initialized",bu=Qh.TypeError,dx=Qh.WeakMap,Wa,os,Ga,px=function(s){return Ga(s)?os(s):Wa(s,{})},hx=function(s){return function(e){var t;if(!ox(e)||(t=os(e)).type!==s)throw new bu("Incompatible receiver, "+s+" required");return t}};nx||mu.state?(Et=mu.state||(mu.state=new dx),Et.get=Et.get,Et.has=Et.has,Et.set=Et.set,Wa=function(s,e){if(Et.has(s))throw new bu(jh);return e.facade=s,Et.set(s,e),e},os=function(s){return Et.get(s)||{}},Ga=function(s){return Et.has(s)}):(Bi=lx("state"),cx[Bi]=!0,Wa=function(s,e){if(fu(s,Bi))throw new bu(jh);return e.facade=s,ux(s,Bi,e),e},os=function(s){return fu(s,Bi)?s[Bi]:{}},Ga=function(s){return fu(s,Bi)});var Et,Bi;Wh.exports={set:Wa,get:os,has:Ga,enforce:px,getterFor:hx}});var yu=v((MD,zh)=>{"use strict";var vu=rt(),fx=It(),Gh=Function.prototype,mx=vu&&Object.getOwnPropertyDescriptor,Su=fx(Gh,"name"),bx=Su&&function(){}.name==="something",gx=Su&&(!vu||vu&&mx(Gh,"name").configurable);zh.exports={EXISTS:Su,PROPER:bx,CONFIGURABLE:gx}});var Kh=v(Yh=>{"use strict";var vx=rt(),Sx=iu(),yx=Mi(),Tx=Mt(),Ix=ki(),Ex=pu();Yh.f=vx&&!Sx?Object.defineProperties:function(e,t){Tx(e);for(var i=Ix(t),r=Ex(t),a=r.length,n=0,o;a>n;)yx.f(e,o=r[n++],i[o]);return e}});var Tu=v((CD,Xh)=>{"use strict";var xx=Ht();Xh.exports=xx("document","documentElement")});var wu=v((BD,af)=>{"use strict";var wx=Mt(),Ax=Kh(),Jh=du(),Px=ja(),Rx=Tu(),kx=Na(),Lx=Ua(),Zh=">",ef="<",Eu="prototype",xu="script",rf=Lx("IE_PROTO"),Iu=function(){},sf=function(s){return ef+xu+Zh+s+ef+"/"+xu+Zh},tf=function(s){s.write(sf("")),s.close();var e=s.parentWindow.Object;return s=null,e},$x=function(){var s=kx("iframe"),e="java"+xu+":",t;return s.style.display="none",Rx.appendChild(s),s.src=String(e),t=s.contentWindow.document,t.open(),t.write(sf("document.F=Object")),t.close(),t.F},za,Ya=function(){try{za=new ActiveXObject("htmlfile")}catch(e){}Ya=typeof document!="undefined"?document.domain&&za?tf(za):$x():tf(za);for(var s=Jh.length;s--;)delete Ya[Eu][Jh[s]];return Ya()};Px[rf]=!0;af.exports=Object.create||function(e,t){var i;return e!==null?(Iu[Eu]=wx(e),i=new Iu,Iu[Eu]=null,i[rf]=e):i=Ya(),t===void 0?i:Ax.f(i,t)}});var dr=v((VD,nf)=>{"use strict";var Mx=nr();nf.exports=function(s,e,t,i){return i&&i.enumerable?s[e]=t:Mx(s,e,t),s}});var ku=v((_D,lf)=>{"use strict";var Dx=Me(),Cx=Pe(),Bx=Ge(),Vx=wu(),of=Ha(),_x=dr(),Ox=Fe(),Fx=Tt(),Ru=Ox("iterator"),uf=!1,jt,Au,Pu;[].keys&&(Pu=[].keys(),"next"in Pu?(Au=of(of(Pu)),Au!==Object.prototype&&(jt=Au)):uf=!0);var Nx=!Bx(jt)||Dx(function(){var s={};return jt[Ru].call(s)!==s});Nx?jt={}:Fx&&(jt=Vx(jt));Cx(jt[Ru])||_x(jt,Ru,function(){return this});lf.exports={IteratorPrototype:jt,BUGGY_SAFARI_ITERATORS:uf}});var Ka=v((OD,df)=>{"use strict";var qx=Fe(),Ux=qx("toStringTag"),cf={};cf[Ux]="z";df.exports=String(cf)==="[object z]"});var us=v((FD,pf)=>{"use strict";var Hx=Ka(),jx=Pe(),Xa=Ri(),Qx=Fe(),Wx=Qx("toStringTag"),Gx=Object,zx=Xa(function(){return arguments}())==="Arguments",Yx=function(s,e){try{return s[e]}catch(t){}};pf.exports=Hx?Xa:function(s){var e,t,i;return s===void 0?"Undefined":s===null?"Null":typeof(t=Yx(e=Gx(s),Wx))=="string"?t:zx?Xa(e):(i=Xa(e))==="Object"&&jx(e.callee)?"Arguments":i}});var ff=v((ND,hf)=>{"use strict";var Kx=Ka(),Xx=us();hf.exports=Kx?{}.toString:function(){return"[object "+Xx(this)+"]"}});var ls=v((qD,bf)=>{"use strict";var Jx=Ka(),Zx=Mi().f,ew=nr(),tw=It(),iw=ff(),rw=Fe(),mf=rw("toStringTag");bf.exports=function(s,e,t,i){var r=t?s:s&&s.prototype;r&&(tw(r,mf)||Zx(r,mf,{configurable:!0,value:e}),i&&!Jx&&ew(r,"toString",iw))}});var vf=v((UD,gf)=>{"use strict";var sw=ku().IteratorPrototype,aw=wu(),nw=Xr(),ow=ls(),uw=Ci(),lw=function(){return this};gf.exports=function(s,e,t,i){var r=e+" Iterator";return s.prototype=aw(sw,{next:nw(+!i,t)}),ow(s,r,!1,!0),uw[r]=lw,s}});var yf=v((HD,Sf)=>{"use strict";var cw=De(),dw=$t();Sf.exports=function(s,e,t){try{return cw(dw(Object.getOwnPropertyDescriptor(s,e)[t]))}catch(i){}}});var If=v((jD,Tf)=>{"use strict";var pw=Ge();Tf.exports=function(s){return pw(s)||s===null}});var xf=v((QD,Ef)=>{"use strict";var hw=If(),fw=String,mw=TypeError;Ef.exports=function(s){if(hw(s))return s;throw new mw("Can't set "+fw(s)+" as a prototype")}});var Lu=v((WD,wf)=>{"use strict";var bw=yf(),gw=Ge(),vw=ui(),Sw=xf();wf.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var s=!1,e={},t;try{t=bw(Object.prototype,"__proto__","set"),t(e,[]),s=e instanceof Array}catch(i){}return function(r,a){return vw(r),Sw(a),gw(r)&&(s?t(r,a):r.__proto__=a),r}}():void 0)});var Vf=v((GD,Bf)=>{"use strict";var yw=Le(),Tw=st(),Ja=Tt(),Df=yu(),Iw=Pe(),Ew=vf(),Af=Ha(),Pf=Lu(),xw=ls(),ww=nr(),$u=dr(),Aw=Fe(),Rf=Ci(),Cf=ku(),Pw=Df.PROPER,Rw=Df.CONFIGURABLE,kf=Cf.IteratorPrototype,Za=Cf.BUGGY_SAFARI_ITERATORS,cs=Aw("iterator"),Lf="keys",ds="values",$f="entries",Mf=function(){return this};Bf.exports=function(s,e,t,i,r,a,n){Ew(t,e,i);var o=function(g){if(g===r&&f)return f;if(!Za&&g&&g in c)return c[g];switch(g){case Lf:return function(){return new t(this,g)};case ds:return function(){return new t(this,g)};case $f:return function(){return new t(this,g)}}return function(){return new t(this)}},u=e+" Iterator",l=!1,c=s.prototype,d=c[cs]||c["@@iterator"]||r&&c[r],f=!Za&&d||o(r),p=e==="Array"&&c.entries||d,h,b,S;if(p&&(h=Af(p.call(new s)),h!==Object.prototype&&h.next&&(!Ja&&Af(h)!==kf&&(Pf?Pf(h,kf):Iw(h[cs])||$u(h,cs,Mf)),xw(h,u,!0,!0),Ja&&(Rf[u]=Mf))),Pw&&r===ds&&d&&d.name!==ds&&(!Ja&&Rw?ww(c,"name",ds):(l=!0,f=function(){return Tw(d,this)})),r)if(b={values:o(ds),keys:a?f:o(Lf),entries:o($f)},n)for(S in b)(Za||l||!(S in c))&&$u(c,S,b[S]);else yw({target:e,proto:!0,forced:Za||l},b);return(!Ja||n)&&c[cs]!==f&&$u(c,cs,f,{name:r}),Rf[e]=f,b}});var Of=v((zD,_f)=>{"use strict";_f.exports=function(s,e){return{value:s,done:e}}});var Du=v((YD,Hf)=>{"use strict";var kw=ki(),Mu=ns(),Ff=Ci(),qf=gu(),Lw=Mi().f,$w=Vf(),en=Of(),Mw=Tt(),Dw=rt(),Uf="Array Iterator",Cw=qf.set,Bw=qf.getterFor(Uf);Hf.exports=$w(Array,"Array",function(s,e){Cw(this,{type:Uf,target:kw(s),index:0,kind:e})},function(){var s=Bw(this),e=s.target,t=s.index++;if(!e||t>=e.length)return s.target=null,en(void 0,!0);switch(s.kind){case"keys":return en(t,!1);case"values":return en(e[t],!1)}return en([t,e[t]],!1)},"values");var Nf=Ff.Arguments=Ff.Array;Mu("keys");Mu("values");Mu("entries");if(!Mw&&Dw&&Nf.name!=="values")try{Lw(Nf,"name",{value:"values"})}catch(s){}});var Qf=v((KD,jf)=>{"use strict";var Vw=Fe(),_w=Ci(),Ow=Vw("iterator"),Fw=Array.prototype;jf.exports=function(s){return s!==void 0&&(_w.Array===s||Fw[Ow]===s)}});var Cu=v((XD,Gf)=>{"use strict";var Nw=us(),Wf=ts(),qw=Jr(),Uw=Ci(),Hw=Fe(),jw=Hw("iterator");Gf.exports=function(s){if(!qw(s))return Wf(s,jw)||Wf(s,"@@iterator")||Uw[Nw(s)]}});var Yf=v((JD,zf)=>{"use strict";var Qw=st(),Ww=$t(),Gw=Mt(),zw=es(),Yw=Cu(),Kw=TypeError;zf.exports=function(s,e){var t=arguments.length<2?Yw(s):e;if(Ww(t))return Gw(Qw(t,s));throw new Kw(zw(s)+" is not iterable")}});var Jf=v((ZD,Xf)=>{"use strict";var Xw=st(),Kf=Mt(),Jw=ts();Xf.exports=function(s,e,t){var i,r;Kf(s);try{if(i=Jw(s,"return"),!i){if(e==="throw")throw t;return t}i=Xw(i,s)}catch(a){r=!0,i=a}if(e==="throw")throw t;if(r)throw i;return Kf(i),t}});var rn=v((eC,im)=>{"use strict";var Zw=ar(),eA=st(),tA=Mt(),iA=es(),rA=Qf(),sA=lr(),Zf=Zr(),aA=Yf(),nA=Cu(),em=Jf(),oA=TypeError,tn=function(s,e){this.stopped=s,this.result=e},tm=tn.prototype;im.exports=function(s,e,t){var i=t&&t.that,r=!!(t&&t.AS_ENTRIES),a=!!(t&&t.IS_RECORD),n=!!(t&&t.IS_ITERATOR),o=!!(t&&t.INTERRUPTED),u=Zw(e,i),l,c,d,f,p,h,b,S=function(y){return l&&em(l,"normal"),new tn(!0,y)},g=function(y){return r?(tA(y),o?u(y[0],y[1],S):u(y[0],y[1])):o?u(y,S):u(y)};if(a)l=s.iterator;else if(n)l=s;else{if(c=nA(s),!c)throw new oA(iA(s)+" is not iterable");if(rA(c)){for(d=0,f=sA(s);f>d;d++)if(p=g(s[d]),p&&Zf(tm,p))return p;return new tn(!1)}l=aA(s,c)}for(h=a?s.next:l.next;!(b=eA(h,l)).done;){try{p=g(b.value)}catch(y){em(l,"throw",y)}if(typeof p=="object"&&p&&Zf(tm,p))return p}return new tn(!1)}});var sm=v((tC,rm)=>{"use strict";var uA=rt(),lA=Mi(),cA=Xr();rm.exports=function(s,e,t){uA?lA.f(s,e,cA(0,t)):s[e]=t}});var am=v(()=>{"use strict";var dA=Le(),pA=rn(),hA=sm();dA({target:"Object",stat:!0},{fromEntries:function(e){var t={};return pA(e,function(i,r){hA(t,i,r)},{AS_ENTRIES:!0}),t}})});var om=v((sC,nm)=>{"use strict";Du();am();var fA=Li();nm.exports=fA.Object.fromEntries});var lm=v((aC,um)=>{"use strict";um.exports={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}});var dm=v(()=>{"use strict";Du();var mA=lm(),bA=Ae(),gA=ls(),cm=Ci();for(sn in mA)gA(bA[sn],sn),cm[sn]=cm.Array;var sn});var hm=v((uC,pm)=>{"use strict";var vA=om();dm();pm.exports=vA});var Bu=v((lC,fm)=>{"use strict";var SA=hm();fm.exports=SA});var mm=v(()=>{"use strict"});var Vu=v((pC,bm)=>{"use strict";var ps=Ae(),yA=$i(),TA=Ri(),an=function(s){return yA.slice(0,s.length)===s};bm.exports=function(){return an("Bun/")?"BUN":an("Cloudflare-Workers")?"CLOUDFLARE":an("Deno/")?"DENO":an("Node.js/")?"NODE":ps.Bun&&typeof Bun.version=="string"?"BUN":ps.Deno&&typeof Deno.version=="object"?"DENO":TA(ps.process)==="process"?"NODE":ps.window&&ps.document?"BROWSER":"REST"}()});var nn=v((hC,gm)=>{"use strict";var IA=Vu();gm.exports=IA==="NODE"});var Sm=v((fC,vm)=>{"use strict";var EA=Mi();vm.exports=function(s,e,t){return EA.f(s,e,t)}});var Im=v((mC,Tm)=>{"use strict";var xA=Ht(),wA=Sm(),AA=Fe(),PA=rt(),ym=AA("species");Tm.exports=function(s){var e=xA(s);PA&&e&&!e[ym]&&wA(e,ym,{configurable:!0,get:function(){return this}})}});var xm=v((bC,Em)=>{"use strict";var RA=Zr(),kA=TypeError;Em.exports=function(s,e){if(RA(e,s))return s;throw new kA("Incorrect invocation")}});var Ou=v((gC,wm)=>{"use strict";var LA=De(),$A=Pe(),_u=is(),MA=LA(Function.toString);$A(_u.inspectSource)||(_u.inspectSource=function(s){return MA(s)});wm.exports=_u.inspectSource});var Nu=v((vC,Lm)=>{"use strict";var DA=De(),CA=Me(),Am=Pe(),BA=us(),VA=Ht(),_A=Ou(),Pm=function(){},Rm=VA("Reflect","construct"),Fu=/^\s*(?:class|function)\b/,OA=DA(Fu.exec),FA=!Fu.test(Pm),hs=function(e){if(!Am(e))return!1;try{return Rm(Pm,[],e),!0}catch(t){return!1}},km=function(e){if(!Am(e))return!1;switch(BA(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return FA||!!OA(Fu,_A(e))}catch(t){return!0}};km.sham=!0;Lm.exports=!Rm||CA(function(){var s;return hs(hs.call)||!hs(Object)||!hs(function(){s=!0})||s})?km:hs});var Mm=v((SC,$m)=>{"use strict";var NA=Nu(),qA=es(),UA=TypeError;$m.exports=function(s){if(NA(s))return s;throw new UA(qA(s)+" is not a constructor")}});var qu=v((yC,Cm)=>{"use strict";var Dm=Mt(),HA=Mm(),jA=Jr(),QA=Fe(),WA=QA("species");Cm.exports=function(s,e){var t=Dm(s).constructor,i;return t===void 0||jA(i=Dm(t)[WA])?e:HA(i)}});var Vm=v((TC,Bm)=>{"use strict";var GA=De();Bm.exports=GA([].slice)});var Om=v((IC,_m)=>{"use strict";var zA=TypeError;_m.exports=function(s,e){if(s<e)throw new zA("Not enough arguments");return s}});var Uu=v((EC,Fm)=>{"use strict";var YA=$i();Fm.exports=/(?:ipad|iphone|ipod).*applewebkit/i.test(YA)});var Xu=v((xC,zm)=>{"use strict";var at=Ae(),KA=Do(),XA=ar(),Nm=Pe(),JA=It(),Gm=Me(),qm=Tu(),ZA=Vm(),Um=Na(),eP=Om(),tP=Uu(),iP=nn(),zu=at.setImmediate,Yu=at.clearImmediate,rP=at.process,Hu=at.Dispatch,sP=at.Function,Hm=at.MessageChannel,aP=at.String,ju=0,fs={},jm="onreadystatechange",ms,Vi,Qu,Wu;Gm(function(){ms=at.location});var Ku=function(s){if(JA(fs,s)){var e=fs[s];delete fs[s],e()}},Gu=function(s){return function(){Ku(s)}},Qm=function(s){Ku(s.data)},Wm=function(s){at.postMessage(aP(s),ms.protocol+"//"+ms.host)};(!zu||!Yu)&&(zu=function(e){eP(arguments.length,1);var t=Nm(e)?e:sP(e),i=ZA(arguments,1);return fs[++ju]=function(){KA(t,void 0,i)},Vi(ju),ju},Yu=function(e){delete fs[e]},iP?Vi=function(s){rP.nextTick(Gu(s))}:Hu&&Hu.now?Vi=function(s){Hu.now(Gu(s))}:Hm&&!tP?(Qu=new Hm,Wu=Qu.port2,Qu.port1.onmessage=Qm,Vi=XA(Wu.postMessage,Wu)):at.addEventListener&&Nm(at.postMessage)&&!at.importScripts&&ms&&ms.protocol!=="file:"&&!Gm(Wm)?(Vi=Wm,at.addEventListener("message",Qm,!1)):jm in Um("script")?Vi=function(s){qm.appendChild(Um("script"))[jm]=function(){qm.removeChild(this),Ku(s)}}:Vi=function(s){setTimeout(Gu(s),0)});zm.exports={set:zu,clear:Yu}});var Xm=v((wC,Km)=>{"use strict";var Ym=Ae(),nP=rt(),oP=Object.getOwnPropertyDescriptor;Km.exports=function(s){if(!nP)return Ym[s];var e=oP(Ym,s);return e&&e.value}});var Ju=v((AC,Zm)=>{"use strict";var Jm=function(){this.head=null,this.tail=null};Jm.prototype={add:function(s){var e={item:s,next:null},t=this.tail;t?t.next=e:this.head=e,this.tail=e},get:function(){var s=this.head;if(s){var e=this.head=s.next;return e===null&&(this.tail=null),s.item}}};Zm.exports=Jm});var tb=v((PC,eb)=>{"use strict";var uP=$i();eb.exports=/ipad|iphone|ipod/i.test(uP)&&typeof Pebble!="undefined"});var rb=v((RC,ib)=>{"use strict";var lP=$i();ib.exports=/web0s(?!.*chrome)/i.test(lP)});var cb=v((kC,lb)=>{"use strict";var hr=Ae(),cP=Xm(),sb=ar(),Zu=Xu().set,dP=Ju(),pP=Uu(),hP=tb(),fP=rb(),el=nn(),ab=hr.MutationObserver||hr.WebKitMutationObserver,nb=hr.document,ob=hr.process,on=hr.Promise,rl=cP("queueMicrotask"),pr,tl,il,un,ub;rl||(bs=new dP,gs=function(){var s,e;for(el&&(s=ob.domain)&&s.exit();e=bs.get();)try{e()}catch(t){throw bs.head&&pr(),t}s&&s.enter()},!pP&&!el&&!fP&&ab&&nb?(tl=!0,il=nb.createTextNode(""),new ab(gs).observe(il,{characterData:!0}),pr=function(){il.data=tl=!tl}):!hP&&on&&on.resolve?(un=on.resolve(void 0),un.constructor=on,ub=sb(un.then,un),pr=function(){ub(gs)}):el?pr=function(){ob.nextTick(gs)}:(Zu=sb(Zu,hr),pr=function(){Zu(gs)}),rl=function(s){bs.head||pr(),bs.add(s)});var bs,gs;lb.exports=rl});var pb=v((LC,db)=>{"use strict";db.exports=function(s,e){try{arguments.length===1?console.error(s):console.error(s,e)}catch(t){}}});var ln=v(($C,hb)=>{"use strict";hb.exports=function(s){try{return{error:!1,value:s()}}catch(e){return{error:!0,value:e}}}});var _i=v((MC,fb)=>{"use strict";var mP=Ae();fb.exports=mP.Promise});var fr=v((DC,vb)=>{"use strict";var bP=Ae(),vs=_i(),gP=Pe(),vP=tu(),SP=Ou(),yP=Fe(),mb=Vu(),TP=Tt(),sl=Uo(),bb=vs&&vs.prototype,IP=yP("species"),al=!1,gb=gP(bP.PromiseRejectionEvent),EP=vP("Promise",function(){var s=SP(vs),e=s!==String(vs);if(!e&&sl===66||TP&&!(bb.catch&&bb.finally))return!0;if(!sl||sl<51||!/native code/.test(s)){var t=new vs(function(a){a(1)}),i=function(a){a(function(){},function(){})},r=t.constructor={};if(r[IP]=i,al=t.then(function(){})instanceof i,!al)return!0}return!e&&(mb==="BROWSER"||mb==="DENO")&&!gb});vb.exports={CONSTRUCTOR:EP,REJECTION_EVENT:gb,SUBCLASSING:al}});var mr=v((CC,yb)=>{"use strict";var Sb=$t(),xP=TypeError,wP=function(s){var e,t;this.promise=new s(function(i,r){if(e!==void 0||t!==void 0)throw new xP("Bad Promise constructor");e=i,t=r}),this.resolve=Sb(e),this.reject=Sb(t)};yb.exports.f=function(s){return new wP(s)}});var Nb=v(()=>{"use strict";var AP=Le(),PP=Tt(),hn=nn(),ci=Ae(),RP=Li(),Sr=st(),Tb=dr(),Ib=Lu(),kP=ls(),LP=Im(),$P=$t(),pn=Pe(),MP=Ge(),DP=xm(),CP=qu(),Pb=Xu().set,cl=cb(),BP=pb(),VP=ln(),_P=Ju(),Rb=gu(),fn=_i(),dl=fr(),kb=mr(),mn="Promise",Lb=dl.CONSTRUCTOR,OP=dl.REJECTION_EVENT,FP=dl.SUBCLASSING,nl=Rb.getterFor(mn),NP=Rb.set,br=fn&&fn.prototype,Oi=fn,cn=br,$b=ci.TypeError,ol=ci.document,pl=ci.process,ul=kb.f,qP=ul,UP=!!(ol&&ol.createEvent&&ci.dispatchEvent),Mb="unhandledrejection",HP="rejectionhandled",Eb=0,Db=1,jP=2,hl=1,Cb=2,dn,xb,Bb,wb,Vb=function(s){var e;return MP(s)&&pn(e=s.then)?e:!1},_b=function(s,e){var t=e.value,i=e.state===Db,r=i?s.ok:s.fail,a=s.resolve,n=s.reject,o=s.domain,u,l,c;try{r?(i||(e.rejection===Cb&&WP(e),e.rejection=hl),r===!0?u=t:(o&&o.enter(),u=r(t),o&&(o.exit(),c=!0)),u===s.promise?n(new $b("Promise-chain cycle")):(l=Vb(u))?Sr(l,u,a,n):a(u)):n(t)}catch(d){o&&!c&&o.exit(),n(d)}},Ob=function(s,e){s.notified||(s.notified=!0,cl(function(){for(var t=s.reactions,i;i=t.get();)_b(i,s);s.notified=!1,e&&!s.rejection&&QP(s)}))},Fb=function(s,e,t){var i,r;UP?(i=ol.createEvent("Event"),i.promise=e,i.reason=t,i.initEvent(s,!1,!0),ci.dispatchEvent(i)):i={promise:e,reason:t},!OP&&(r=ci["on"+s])?r(i):s===Mb&&BP("Unhandled promise rejection",t)},QP=function(s){Sr(Pb,ci,function(){var e=s.facade,t=s.value,i=Ab(s),r;if(i&&(r=VP(function(){hn?pl.emit("unhandledRejection",t,e):Fb(Mb,e,t)}),s.rejection=hn||Ab(s)?Cb:hl,r.error))throw r.value})},Ab=function(s){return s.rejection!==hl&&!s.parent},WP=function(s){Sr(Pb,ci,function(){var e=s.facade;hn?pl.emit("rejectionHandled",e):Fb(HP,e,s.value)})},gr=function(s,e,t){return function(i){s(e,i,t)}},vr=function(s,e,t){s.done||(s.done=!0,t&&(s=t),s.value=e,s.state=jP,Ob(s,!0))},ll=function(s,e,t){if(!s.done){s.done=!0,t&&(s=t);try{if(s.facade===e)throw new $b("Promise can't be resolved itself");var i=Vb(e);i?cl(function(){var r={done:!1};try{Sr(i,e,gr(ll,r,s),gr(vr,r,s))}catch(a){vr(r,a,s)}}):(s.value=e,s.state=Db,Ob(s,!1))}catch(r){vr({done:!1},r,s)}}};if(Lb&&(Oi=function(e){DP(this,cn),$P(e),Sr(dn,this);var t=nl(this);try{e(gr(ll,t),gr(vr,t))}catch(i){vr(t,i)}},cn=Oi.prototype,dn=function(e){NP(this,{type:mn,done:!1,notified:!1,parent:!1,reactions:new _P,rejection:!1,state:Eb,value:null})},dn.prototype=Tb(cn,"then",function(e,t){var i=nl(this),r=ul(CP(this,Oi));return i.parent=!0,r.ok=pn(e)?e:!0,r.fail=pn(t)&&t,r.domain=hn?pl.domain:void 0,i.state===Eb?i.reactions.add(r):cl(function(){_b(r,i)}),r.promise}),xb=function(){var s=new dn,e=nl(s);this.promise=s,this.resolve=gr(ll,e),this.reject=gr(vr,e)},kb.f=ul=function(s){return s===Oi||s===Bb?new xb(s):qP(s)},!PP&&pn(fn)&&br!==Object.prototype)){wb=br.then,FP||Tb(br,"then",function(e,t){var i=this;return new Oi(function(r,a){Sr(wb,i,r,a)}).then(e,t)},{unsafe:!0});try{delete br.constructor}catch(s){}Ib&&Ib(br,cn)}AP({global:!0,constructor:!0,wrap:!0,forced:Lb},{Promise:Oi});Bb=RP.Promise;kP(Oi,mn,!1,!0);LP(mn)});var Qb=v((_C,jb)=>{"use strict";var GP=Fe(),Ub=GP("iterator"),Hb=!1;try{qb=0,fl={next:function(){return{done:!!qb++}},return:function(){Hb=!0}},fl[Ub]=function(){return this},Array.from(fl,function(){throw 2})}catch(s){}var qb,fl;jb.exports=function(s,e){try{if(!e&&!Hb)return!1}catch(r){return!1}var t=!1;try{var i={};i[Ub]=function(){return{next:function(){return{done:t=!0}}}},s(i)}catch(r){}return t}});var ml=v((OC,Wb)=>{"use strict";var zP=_i(),YP=Qb(),KP=fr().CONSTRUCTOR;Wb.exports=KP||!YP(function(s){zP.all(s).then(void 0,function(){})})});var Gb=v(()=>{"use strict";var XP=Le(),JP=st(),ZP=$t(),eR=mr(),tR=ln(),iR=rn(),rR=ml();XP({target:"Promise",stat:!0,forced:rR},{all:function(e){var t=this,i=eR.f(t),r=i.resolve,a=i.reject,n=tR(function(){var o=ZP(t.resolve),u=[],l=0,c=1;iR(e,function(d){var f=l++,p=!1;c++,JP(o,t,d).then(function(h){p||(p=!0,u[f]=h,--c||r(u))},a)}),--c||r(u)});return n.error&&a(n.value),i.promise}})});var Yb=v(()=>{"use strict";var sR=Le(),aR=Tt(),nR=fr().CONSTRUCTOR,gl=_i(),oR=Ht(),uR=Pe(),lR=dr(),zb=gl&&gl.prototype;sR({target:"Promise",proto:!0,forced:nR,real:!0},{catch:function(s){return this.then(void 0,s)}});!aR&&uR(gl)&&(bl=oR("Promise").prototype.catch,zb.catch!==bl&&lR(zb,"catch",bl,{unsafe:!0}));var bl});var Kb=v(()=>{"use strict";var cR=Le(),dR=st(),pR=$t(),hR=mr(),fR=ln(),mR=rn(),bR=ml();cR({target:"Promise",stat:!0,forced:bR},{race:function(e){var t=this,i=hR.f(t),r=i.reject,a=fR(function(){var n=pR(t.resolve);mR(e,function(o){dR(n,t,o).then(i.resolve,r)})});return a.error&&r(a.value),i.promise}})});var Xb=v(()=>{"use strict";var gR=Le(),vR=mr(),SR=fr().CONSTRUCTOR;gR({target:"Promise",stat:!0,forced:SR},{reject:function(e){var t=vR.f(this),i=t.reject;return i(e),t.promise}})});var vl=v((GC,Jb)=>{"use strict";var yR=Mt(),TR=Ge(),IR=mr();Jb.exports=function(s,e){if(yR(s),TR(e)&&e.constructor===s)return e;var t=IR.f(s),i=t.resolve;return i(e),t.promise}});var tg=v(()=>{"use strict";var ER=Le(),xR=Ht(),Zb=Tt(),wR=_i(),eg=fr().CONSTRUCTOR,AR=vl(),PR=xR("Promise"),RR=Zb&&!eg;ER({target:"Promise",stat:!0,forced:Zb||eg},{resolve:function(e){return AR(RR&&this===PR?wR:this,e)}})});var ig=v(()=>{"use strict";Nb();Gb();Yb();Kb();Xb();tg()});var ng=v(()=>{"use strict";var kR=Le(),LR=Tt(),bn=_i(),$R=Me(),sg=Ht(),ag=Pe(),MR=qu(),rg=vl(),DR=dr(),yl=bn&&bn.prototype,CR=!!bn&&$R(function(){yl.finally.call({then:function(){}},function(){})});kR({target:"Promise",proto:!0,real:!0,forced:CR},{finally:function(s){var e=MR(this,sg("Promise")),t=ag(s);return this.then(t?function(i){return rg(e,s()).then(function(){return i})}:s,t?function(i){return rg(e,s()).then(function(){throw i})}:s)}});!LR&&ag(bn)&&(Sl=sg("Promise").prototype.finally,yl.finally!==Sl&&DR(yl,"finally",Sl,{unsafe:!0}));var Sl});var ug=v((e0,og)=>{"use strict";mm();ig();ng();var BR=li();og.exports=BR("Promise","finally")});var cg=v((t0,lg)=>{"use strict";var VR=ug();lg.exports=VR});var gn=v((i0,dg)=>{"use strict";var _R=cg();dg.exports=_R});var Pg=v(()=>{"use strict";var XR=Le(),JR=rr(),ZR=lr(),ek=as(),tk=ns();XR({target:"Array",proto:!0},{at:function(e){var t=JR(this),i=ZR(t),r=ek(e),a=r>=0?r:i+r;return a<0||a>=i?void 0:t[a]}});tk("at")});var kg=v((OB,Rg)=>{"use strict";Pg();var ik=li();Rg.exports=ik("Array","at")});var $g=v((FB,Lg)=>{"use strict";var rk=kg();Lg.exports=rk});var xt=v((NB,Mg)=>{"use strict";var sk=$g();Mg.exports=sk});var Ul=v((E_,iv)=>{"use strict";var mk=Ri();iv.exports=Array.isArray||function(e){return mk(e)==="Array"}});var sv=v((x_,rv)=>{"use strict";var bk=TypeError,gk=9007199254740991;rv.exports=function(s){if(s>gk)throw bk("Maximum allowed index exceeded");return s}});var ov=v((w_,nv)=>{"use strict";var vk=Ul(),Sk=lr(),yk=sv(),Tk=ar(),av=function(s,e,t,i,r,a,n,o){for(var u=r,l=0,c=n?Tk(n,o):!1,d,f;l<i;)l in t&&(d=c?c(t[l],l,e):t[l],a>0&&vk(d)?(f=Sk(d),u=av(s,e,d,f,u,a-1)-1):(yk(u+1),s[u]=d),u++),l++;return u};nv.exports=av});var dv=v((A_,cv)=>{"use strict";var uv=Ul(),Ik=Nu(),Ek=Ge(),xk=Fe(),wk=xk("species"),lv=Array;cv.exports=function(s){var e;return uv(s)&&(e=s.constructor,Ik(e)&&(e===lv||uv(e.prototype))?e=void 0:Ek(e)&&(e=e[wk],e===null&&(e=void 0))),e===void 0?lv:e}});var hv=v((P_,pv)=>{"use strict";var Ak=dv();pv.exports=function(s,e){return new(Ak(s))(e===0?0:e)}});var fv=v(()=>{"use strict";var Pk=Le(),Rk=ov(),kk=$t(),Lk=rr(),$k=lr(),Mk=hv();Pk({target:"Array",proto:!0},{flatMap:function(e){var t=Lk(this),i=$k(t),r;return kk(e),r=Mk(t,0),r.length=Rk(r,t,t,i,0,1,e,arguments.length>1?arguments[1]:void 0),r}})});var mv=v(()=>{"use strict";var Dk=ns();Dk("flatMap")});var gv=v((M_,bv)=>{"use strict";fv();mv();var Ck=li();bv.exports=Ck("Array","flatMap")});var Sv=v((D_,vv)=>{"use strict";var Bk=gv();vv.exports=Bk});var Ls=v((C_,yv)=>{"use strict";var Vk=Sv();yv.exports=Vk});var $s=v((B_,Tv)=>{"use strict";var _k=us(),Ok=String;Tv.exports=function(s){if(_k(s)==="Symbol")throw new TypeError("Cannot convert a Symbol value to a string");return Ok(s)}});var Hl=v((V_,Iv)=>{"use strict";Iv.exports=`
7
- \v\f\r \xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF`});var wv=v((__,xv)=>{"use strict";var Fk=De(),Nk=ui(),qk=$s(),Ql=Hl(),Ev=Fk("".replace),Uk=RegExp("^["+Ql+"]+"),Hk=RegExp("(^|[^"+Ql+"])["+Ql+"]+$"),jl=function(s){return function(e){var t=qk(Nk(e));return s&1&&(t=Ev(t,Uk,"")),s&2&&(t=Ev(t,Hk,"$1")),t}};xv.exports={start:jl(1),end:jl(2),trim:jl(3)}});var kv=v((O_,Rv)=>{"use strict";var jk=yu().PROPER,Qk=Me(),Av=Hl(),Pv="\u200B\x85\u180E";Rv.exports=function(s){return Qk(function(){return!!Av[s]()||Pv[s]()!==Pv||jk&&Av[s].name!==s})}});var Wl=v((F_,Lv)=>{"use strict";var Wk=wv().start,Gk=kv();Lv.exports=Gk("trimStart")?function(){return Wk(this)}:"".trimStart});var Mv=v(()=>{"use strict";var zk=Le(),$v=Wl();zk({target:"String",proto:!0,name:"trimStart",forced:"".trimLeft!==$v},{trimLeft:$v})});var Cv=v(()=>{"use strict";Mv();var Yk=Le(),Dv=Wl();Yk({target:"String",proto:!0,name:"trimStart",forced:"".trimStart!==Dv},{trimStart:Dv})});var Vv=v((j_,Bv)=>{"use strict";Cv();var Kk=li();Bv.exports=Kk("String","trimLeft")});var Ov=v((Q_,_v)=>{"use strict";var Xk=Vv();_v.exports=Xk});var Nv=v((W_,Fv)=>{"use strict";var Jk=Ov();Fv.exports=Jk});var tS=v(()=>{"use strict"});var iS=v(()=>{"use strict"});var sS=v((LN,rS)=>{"use strict";var vL=Ge(),SL=Ri(),yL=Fe(),TL=yL("match");rS.exports=function(s){var e;return vL(s)&&((e=s[TL])!==void 0?!!e:SL(s)==="RegExp")}});var oS=v(($N,nS)=>{"use strict";var IL=Ae(),EL=Me(),aS=IL.RegExp,xL=!EL(function(){var s=!0;try{aS(".","d")}catch(u){s=!1}var e={},t="",i=s?"dgimsy":"gimsy",r=function(u,l){Object.defineProperty(e,u,{get:function(){return t+=l,!0}})},a={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};s&&(a.hasIndices="d");for(var n in a)r(n,a[n]);var o=Object.getOwnPropertyDescriptor(aS.prototype,"flags").get.call(e);return o!==i||t!==i});nS.exports={correct:xL}});var lS=v((MN,uS)=>{"use strict";var wL=Mt();uS.exports=function(){var s=wL(this),e="";return s.hasIndices&&(e+="d"),s.global&&(e+="g"),s.ignoreCase&&(e+="i"),s.multiline&&(e+="m"),s.dotAll&&(e+="s"),s.unicode&&(e+="u"),s.unicodeSets&&(e+="v"),s.sticky&&(e+="y"),e}});var pS=v((DN,dS)=>{"use strict";var AL=st(),PL=It(),RL=Zr(),cS=oS(),kL=lS(),LL=RegExp.prototype;dS.exports=cS.correct?function(s){return s.flags}:function(s){return!cS.correct&&RL(LL,s)&&!PL(s,"flags")?AL(kL,s):s.flags}});var fS=v((CN,hS)=>{"use strict";var Kl=De(),$L=rr(),ML=Math.floor,zl=Kl("".charAt),DL=Kl("".replace),Yl=Kl("".slice),CL=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,BL=/\$([$&'`]|\d{1,2})/g;hS.exports=function(s,e,t,i,r,a){var n=t+s.length,o=i.length,u=BL;return r!==void 0&&(r=$L(r),u=CL),DL(a,u,function(l,c){var d;switch(zl(c,0)){case"$":return"$";case"&":return s;case"`":return Yl(e,0,t);case"'":return Yl(e,n);case"<":d=r[Yl(c,1,-1)];break;default:var f=+c;if(f===0)return l;if(f>o){var p=ML(f/10);return p===0?l:p<=o?i[p-1]===void 0?zl(c,1):i[p-1]+zl(c,1):l}d=i[f-1]}return d===void 0?"":d})}});var gS=v(()=>{"use strict";var VL=Le(),_L=st(),Jl=De(),mS=ui(),OL=Pe(),FL=Ge(),NL=sS(),$r=$s(),qL=ts(),UL=pS(),HL=fS(),jL=Fe(),QL=Tt(),WL=jL("replace"),GL=TypeError,Xl=Jl("".indexOf),zL=Jl("".replace),bS=Jl("".slice),YL=Math.max;VL({target:"String",proto:!0},{replaceAll:function(e,t){var i=mS(this),r,a,n,o,u,l,c,d,f,p,h=0,b="";if(FL(e)){if(r=NL(e),r&&(a=$r(mS(UL(e))),!~Xl(a,"g")))throw new GL("`.replaceAll` does not allow non-global regexes");if(n=qL(e,WL),n)return _L(n,e,i,t);if(QL&&r)return zL($r(i),e,t)}for(o=$r(i),u=$r(e),l=OL(t),l||(t=$r(t)),c=u.length,d=YL(1,c),f=Xl(o,u);f!==-1;)p=l?$r(t(u,f,o)):HL(u,o,f,[],void 0,t),b+=bS(o,h,f)+p,h=f+c,f=f+d>o.length?-1:Xl(o,u,f+d);return h<o.length&&(b+=bS(o,h)),b}})});var SS=v((_N,vS)=>{"use strict";tS();iS();gS();var KL=li();vS.exports=KL("String","replaceAll")});var TS=v((ON,yS)=>{"use strict";var XL=SS();yS.exports=XL});var ES=v((FN,IS)=>{"use strict";var JL=TS();IS.exports=JL});var wS=v((NN,xS)=>{"use strict";var ZL=as(),e$=$s(),t$=ui(),i$=RangeError;xS.exports=function(e){var t=e$(t$(this)),i="",r=ZL(e);if(r<0||r===1/0)throw new i$("Wrong number of repetitions");for(;r>0;(r>>>=1)&&(t+=t))r&1&&(i+=t);return i}});var LS=v((qN,kS)=>{"use strict";var RS=De(),r$=uu(),AS=$s(),s$=wS(),a$=ui(),n$=RS(s$),o$=RS("".slice),u$=Math.ceil,PS=function(s){return function(e,t,i){var r=AS(a$(e)),a=r$(t),n=r.length,o=i===void 0?" ":AS(i),u,l;return a<=n||o===""?r:(u=a-n,l=n$(o,u$(u/o.length)),l.length>u&&(l=o$(l,0,u)),s?r+l:l+r)}};kS.exports={start:PS(!1),end:PS(!0)}});var MS=v((UN,$S)=>{"use strict";var l$=$i();$S.exports=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(l$)});var DS=v(()=>{"use strict";var c$=Le(),d$=LS().start,p$=MS();c$({target:"String",proto:!0,forced:p$},{padStart:function(e){return d$(this,e,arguments.length>1?arguments[1]:void 0)}})});var BS=v((QN,CS)=>{"use strict";DS();var h$=li();CS.exports=h$("String","padStart")});var _S=v((WN,VS)=>{"use strict";var f$=BS();VS.exports=f$});var FS=v((GN,OS)=>{"use strict";var m$=_S();OS.exports=m$});var j$={};iT(j$,{ChromecastState:()=>Gr,HttpConnectionType:()=>Va,Observable:()=>Nt.Observable,PlaybackState:()=>He,Player:()=>Ta,PredefinedQualityLimits:()=>zr,SDK_VERSION:()=>H$,Subject:()=>Nt.Subject,Subscription:()=>Nt.Subscription,Surface:()=>_a,VERSION:()=>$o,ValueSubject:()=>Nt.ValueSubject,VideoFormat:()=>Lt,VideoQuality:()=>Nt.VideoQuality,areValidLiveRecordSources:()=>Sg,clientChecker:()=>K,isMobile:()=>yr});module.exports=rT(j$);var $o="2.0.139";var He=(r=>(r.STOPPED="stopped",r.READY="ready",r.PLAYING="playing",r.PAUSED="paused",r))(He||{}),Lt=(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",E))(Lt||{});var Gr=(r=>(r.NOT_AVAILABLE="NOT_AVAILABLE",r.AVAILABLE="AVAILABLE",r.CONNECTING="CONNECTING",r.CONNECTED="CONNECTED",r))(Gr||{}),Va=(i=>(i.HTTP1="http1",i.HTTP2="http2",i.QUIC="quic",i))(Va||{});var _a=(n=>(n.NONE="none",n.INLINE="inline",n.FULLSCREEN="fullscreen",n.SECOND_SCREEN="second_screen",n.PIP="pip",n.INVISIBLE="invisible",n))(_a||{}),zr=(i=>(i.TRAFFIC_SAVING="traffic_saving",i.HIGH_QUALITY="high_quality",i.UNKNOWN="unknown",i))(zr||{});var kc=Y(Di(),1),qy=Y(je(),1);var ae=require("@vkontakte/videoplayer-shared/es2015");var Dh=s=>new Promise((e,t)=>{let i=document.createElement("script");i.setAttribute("src",s),i.onload=()=>e(),i.onerror=r=>t(r),document.body.appendChild(i)});var Qa=class{constructor(e){this.connection$=new ae.ValueSubject(void 0);this.castState$=new ae.ValueSubject("NOT_AVAILABLE");this.errorEvent$=new ae.Subject;this.realCastState$=new ae.ValueSubject("NOT_AVAILABLE");this.subscription=new ae.Subscription;this.isDestroyed=!1;var a;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 i=(0,ae.isNonNullable)((a=window.chrome)==null?void 0:a.cast),r=!!window.__onGCastApiAvailable;i?this.initializeCastApi():(window.__onGCastApiAvailable=n=>{delete window.__onGCastApiAvailable,n&&!this.isDestroyed&&this.initializeCastApi()},r||Dh("https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1").catch(()=>this.errorEvent$.next({id:"ChromecastLoading",category:ae.ErrorCategory.NETWORK,message:"Script loading failed!"})))}connect(){var e;(e=cast.framework.CastContext.getInstance())==null||e.requestSession()}disconnect(){var e,t;(t=(e=cast.framework.CastContext.getInstance())==null?void 0:e.getCurrentSession())==null||t.endSession(!0)}stopMedia(){return new Promise((e,t)=>{var i,r,a;(a=(r=(i=cast.framework.CastContext.getInstance())==null?void 0:i.getCurrentSession())==null?void 0:r.getMediaSession())==null||a.stop(new chrome.cast.media.StopRequest,e,t)})}toggleConnection(){(0,ae.isNonNullable)(this.connection$.getValue())?this.disconnect():this.connect()}setVolume(e){let t=this.connection$.getValue();(0,ae.isNullable)(t)||(t.remotePlayer.volumeLevel=e,t.remotePlayerController.setVolumeLevel())}setMuted(e){let t=this.connection$.getValue();(0,ae.isNullable)(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),i=cast.framework.CastContext.getInstance();this.subscription.add((0,ae.fromEvent)(i,cast.framework.CastContextEventType.SESSION_STATE_CHANGED).subscribe(r=>{var a,n,o;switch(r.sessionState){case cast.framework.SessionState.SESSION_STARTED:case cast.framework.SessionState.SESSION_STARTING:case cast.framework.SessionState.SESSION_RESUMED:this.contentId=(o=(n=(a=i.getCurrentSession())==null?void 0:a.getMediaSession())==null?void 0:n.media)==null?void 0:o.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(0,ae.assertNever)(r.sessionState)}})).add((0,ae.merge)((0,ae.fromEvent)(i,cast.framework.CastContextEventType.CAST_STATE_CHANGED).pipe((0,ae.tap)(r=>{this.log({message:`[cast.framework.RemotePlayerEventType.CAST_STATE_CHANGED]: ${JSON.stringify(r)}`})}),(0,ae.map)(r=>r.castState)),(0,ae.observableFrom)([i.getCastState()])).pipe((0,ae.filterChanged)(),(0,ae.map)(JE),(0,ae.tap)(r=>{this.log({message:`realCastState$: ${r}`})})).subscribe(this.realCastState$)).add(this.realCastState$.subscribe(r=>{var o,u;let a=r==="CONNECTED",n=(0,ae.isNonNullable)(this.connection$.getValue());if(a&&!n){let l=i.getCurrentSession();(0,ae.assertNonNullable)(l);let c=l.getCastDevice(),d=(u=(o=l.getMediaSession())==null?void 0:o.media)==null?void 0:u.contentId;((0,ae.isNullable)(d)||d===this.contentId)&&(this.log({message:"connection created"}),this.connection$.next({remotePlayer:e,remotePlayerController:t,session:l,castDevice:c}))}else!a&&n&&(this.log({message:"connection destroyed"}),this.connection$.next(void 0));this.castState$.next(r==="CONNECTED"?(0,ae.isNonNullable)(this.connection$.getValue())?"CONNECTED":"AVAILABLE":r)}))}initializeCastApi(){var r;let e,t,i;try{e=cast.framework.CastContext.getInstance(),t=chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,i=chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}catch(a){return}try{e.setOptions({receiverApplicationId:(r=this.params.receiverApplicationId)!=null?r:t,autoJoinPolicy:i}),this.initListeners()}catch(a){this.errorEvent$.next({id:"ChromecastInitializer",category:ae.ErrorCategory.EXTERNAL_API,message:"[initializeCastApi] failed",thrown:a})}}},JE=s=>{switch(s){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(0,ae.assertNever)(s)}};var Ac=Y(je(),1),Ry=Y(cr(),1),ky=Y(Bu(),1);var Tg=Y(gn(),1);var Tl=require("@vkontakte/videoplayer-shared/es2015");var Re=(s,e=0,t=0)=>{switch(t){case 0:return s.replace("_offset_p",e===0?"":"_"+e.toFixed(0));case 1:{if(e===0)return s;let i=new URL(s);return i.searchParams.append("playback_shift",e.toFixed(0)),i.toString()}case 2:{let i=new URL(s);return!i.searchParams.get("offset_p")&&e===0?s:(i.searchParams.set("offset_p",e.toFixed(0)),i.toString())}default:(0,Tl.assertNever)(t)}return s},di=(s,e)=>{var t;switch(e){case 0:return NaN;case 1:{let i=new URL(s);return Number(i.searchParams.get("playback_shift"))}case 2:{let i=new URL(s);return Number((t=i.searchParams.get("offset_p"))!=null?t:0)}default:(0,Tl.assertNever)(e)}};var N=(s,e,t=!1)=>{let i=s.getTransition();(t||!i||i.to===e)&&s.setState(e)};var Dt=require("@vkontakte/videoplayer-shared/es2015"),ne=class{constructor(e){this.transitionStarted$=new Dt.Subject;this.transitionEnded$=new Dt.Subject;this.transitionUpdated$=new Dt.Subject;this.forceChanged$=new Dt.Subject;this.stateChangeStarted$=(0,Dt.merge)(this.transitionStarted$,this.transitionUpdated$);this.stateChangeEnded$=(0,Dt.merge)(this.transitionEnded$,this.forceChanged$);this.state=e,this.prevState=void 0}setState(e){let t=this.transition,i=this.state;this.transition=void 0,this.prevState=i,this.state=e,t?t.to===e?this.transitionEnded$.next(t):this.forceChanged$.next({from:t.from,to:e,canceledTransition:t}):this.forceChanged$.next({from:i,to:e,canceledTransition:t})}startTransitionTo(e){let t=this.transition,i=this.state;i===e||(0,Dt.isNonNullable)(t)&&t.to===e||(this.prevState=i,this.state=e,t?(this.transition={from:t.from,to:e,canceledTransition:t},this.transitionUpdated$.next(this.transition)):(this.transition={from:i,to:e},this.transitionStarted$.next(this.transition)))}getTransition(){return this.transition}getState(){return this.state}getPrevState(){return this.prevState}};var El=require("@vkontakte/videoplayer-shared/es2015");var vn=class{constructor(){this._isMiuiBrowser=!1}get current(){return this._current}get isChrome(){return this.current==="Chrome"}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,i=/samsungbrowser/i.test(e)?"SamsungBrowser":void 0,r=/chrome|crios/i.test(e)?"Chrome":void 0,a=/chromium/i.test(e)?"Chromium":void 0,n=/firefox|fxios/i.test(e)?"Firefox":void 0,o=/webkit|safari|khtml/i.test(e)?"Safari":void 0,u=/opr\//i.test(e)?"Opera":void 0,l=/edg/i.test(e)?"Edge":void 0;this._isMiuiBrowser=/(XiaoMi)|(MiuiBrowser)/i.test(e),this._current=t||i||n||u||l||r||a||o||"Rest"}catch(t){console.error(t)}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}=window.navigator,i=t.match(e);if(!i)return;let r=i[1],a=parseInt(r,10);if(!isNaN(a))return this._current_version=a,a}catch(t){console.error(t)}}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 pg=Y(je(),1);var yr=()=>{var s,e;return/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test((s=navigator.appVersion)!=null?s:navigator.userAgent)||((e=navigator==null?void 0:navigator.userAgentData)==null?void 0:e.mobile)};var Sn=class{constructor(e){this._highEntropyValues={};this._displayChecker=e}get current(){return this._current}get isIOS(){let e=["iPhone","iPad","iPod"];return this._highEntropyValues.platform==="iOS"||(0,pg.default)(e,this.current)}get isMac(){return this._highEntropyValues.platform==="macOS"||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"||this.current==="Android"}get isMobile(){return this._highEntropyValues.mobile||this._isMobile}get iOSVersion(){return this._iosVersion}detect(){let{userAgent:e}=navigator;try{this._isMobile=yr()}catch(t){console.error(t)}this.detectDevice(e),this.detectHighEntropyValues(),this.isIOS&&this.detectIOSVersion()}detectHighEntropyValues(){return R(this,null,function*(){let{userAgentData:e}=navigator;if(e!=null&&e.getHighEntropyValues){let t=yield e.getHighEntropyValues(["architecture","bitness","brands","mobile","platform","formFactor","model","platformVersion","wow64"]);this._highEntropyValues=t}})}detectDevice(e){try{let t=/android/i.test(e)?"Android":void 0,i=/iphone/i.test(e)?"iPhone":void 0,r=/ipad/i.test(e)?"iPad":void 0,a=/ipod/i.test(e)?"iPod":void 0,n=/mac/i.test(e)?"Mac":void 0,o=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(e)?"RestMobile":void 0;this._current=t||i||r||a||o||n||"Desktop"}catch(t){console.error(t)}}detectIOSVersion(){try{if(this._highEntropyValues.platformVersion){let a=this._highEntropyValues.platformVersion.split(".").slice(0,2).join("."),n=parseFloat(a);this._iosVersion=n;return}let{userAgent:e}=window.navigator,t=e.match(/OS (\d+(_\d+)?)/i);if(!t)return;let i=t[1].replace(/_/g,".");if(!i)return;let r=parseFloat(i);if(isNaN(r))return;this._iosVersion=r}catch(e){console.error(e)}}};var yn=class{get isTouch(){return typeof this._maxTouchPoints=="number"?this._maxTouchPoints>1:"ontouchstart"in window}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(){var t;let{maxTouchPoints:e}=navigator;try{this._maxTouchPoints=e!=null?e:0,this._isHdr=!!((t=matchMedia("(dynamic-range: high)"))!=null&&t.matches),this._colorDepth=screen.colorDepth}catch(i){console.error(i)}try{this._pixelRatio=window.devicePixelRatio||1,this._height=screen.height,this._width=screen.width,this._height=screen.height,this._screenHeight=this._height*this._pixelRatio,this._screenWidth=this._width*this._pixelRatio}catch(i){console.error(i)}}};var nt=()=>window.ManagedMediaSource||window.MediaSource,Tr=()=>{var s,e;return!!(window.ManagedMediaSource&&((e=(s=window.ManagedSourceBuffer)==null?void 0:s.prototype)!=null&&e.appendBuffer))},hg=()=>{var s,e;return!!(window.MediaSource&&((e=(s=window.SourceBuffer)==null?void 0:s.prototype)!=null&&e.appendBuffer))},Tn=()=>window.ManagedMediaSource?new ManagedMediaSource:new MediaSource;var OR=document.createElement("video"),FR='video/mp4; codecs="avc1.42000a,mp4a.40.2"',NR='video/mp4; codecs="hev1.1.6.L93.B0"',fg='video/webm; codecs="vp09.00.10.08"',mg='video/webm; codecs="av01.0.00M.08"',qR='audio/mp4; codecs="mp4a.40.2"',UR='audio/webm; codecs="opus"',bg,HR=()=>R(null,null,function*(){if(!window.navigator.mediaCapabilities)return;let s={type:"media-source",video:{contentType:"video/webm",width:1280,height:720,bitrate:1e6,framerate:30}},[e,t]=yield Promise.all([window.navigator.mediaCapabilities.decodingInfo(j(C({},s),{video:j(C({},s.video),{contentType:mg})})),window.navigator.mediaCapabilities.decodingInfo(j(C({},s),{video:j(C({},s.video),{contentType:fg})}))]);bg={DASH_WEBM_AV1:e,DASH_WEBM:t}});HR().catch(s=>{console.log(OR),console.error(s)});var In=class{constructor(e,t){this._deviceChecker=e,this._browserChecker=t}get protocols(){return this._protocols}get containers(){return this._containers}get codecs(){return this._codecs}get webmDecodingInfo(){return bg}get supportedCodecs(){return Object.keys(this._codecs).filter(e=>this._codecs[e])}get nativeHlsSupported(){return this._nativeHlsSupported}detect(){var e,t,i,r,a,n,o,u,l,c,d,f,p,h,b,S,g,y,A,E;this._video=document.createElement("video");try{this._protocols={mms:Tr(),mse:hg(),hls:!!((t=(e=this._video).canPlayType)!=null&&t.call(e,"application/x-mpegurl")||(r=(i=this._video).canPlayType)!=null&&r.call(i,"vnd.apple.mpegURL")),webrtc:!!window.RTCPeerConnection,ws:!!window.WebSocket},this._containers={mp4:!!((n=(a=this._video).canPlayType)!=null&&n.call(a,"video/mp4")),webm:!!((u=(o=this._video).canPlayType)!=null&&u.call(o,"video/webm")),cmaf:!0};let w=!!((c=(l=nt())==null?void 0:l.isTypeSupported)!=null&&c.call(l,FR)),_=!!((f=(d=nt())==null?void 0:d.isTypeSupported)!=null&&f.call(d,NR)),W=!!((h=(p=nt())==null?void 0:p.isTypeSupported)!=null&&h.call(p,qR));this._codecs={h264:w,h265:_,vp9:!!((S=(b=nt())==null?void 0:b.isTypeSupported)!=null&&S.call(b,fg)),av1:!!((y=(g=nt())==null?void 0:g.isTypeSupported)!=null&&y.call(g,mg)),aac:W,opus:!!((E=(A=nt())==null?void 0:A.isTypeSupported)!=null&&E.call(A,UR)),mpeg:(w||_)&&W},this._nativeHlsSupported=this._protocols.hls&&this._containers.mp4}catch(w){console.error(w)}try{this.destroyVideoElement()}catch(w){console.error("Error destroying video element:",w)}}destroyVideoElement(){var t;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);(t=this._video.parentNode)==null||t.replaceChild(e,this._video),this._video=null}};var gg="audio/mpeg",En=class{supportMp3(){return this._codecs.mp3&&this._containers.mpeg}detect(){var e,t,i,r;this._audio=document.createElement("audio");try{this._containers={mpeg:!!((t=(e=this._audio).canPlayType)!=null&&t.call(e,gg))},this._codecs={mp3:!!((r=(i=nt())==null?void 0:i.isTypeSupported)!=null&&r.call(i,gg))}}catch(a){console.error(a)}try{this.destroyAudioElement()}catch(a){console.error("Error destroying audio element:",a)}}destroyAudioElement(){var t;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);(t=this._audio.parentNode)==null||t.replaceChild(e,this._audio),this._audio=null}};var vg=require("@vkontakte/videoplayer-shared/es2015");var Il=class{constructor(){this.isInited$=new vg.ValueSubject(!1);this._displayChecker=new yn,this._deviceChecker=new Sn(this._displayChecker),this._browserChecker=new vn,this._videoChecker=new In(this._deviceChecker,this._browserChecker),this._audioChecker=new En,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(){return R(this,null,function*(){this._displayChecker.detect(),this._deviceChecker.detect(),this._browserChecker.detect(),this._videoChecker.detect(),this._audioChecker.detect(),this.isInited$.next(!0)})}},K=new Il;var xl=s=>{let{containers:e,protocols:t,codecs:i,nativeHlsSupported:r}=K.video,a=(i.h264||i.h265)&&i.aac,n=t.mse||t.mms;return s.filter(o=>{switch(o){case"DASH_SEP":return n&&e.mp4&&a;case"DASH_WEBM":return n&&e.webm&&i.vp9&&i.opus;case"DASH_WEBM_AV1":return n&&e.webm&&i.av1&&i.opus;case"DASH_STREAMS":return n&&(e.mp4&&a||e.webm&&(i.vp9||i.av1)&&(i.opus||i.aac));case"DASH_LIVE":return n&&e.mp4&&a;case"DASH_LIVE_CMAF":return n&&e.mp4&&a&&e.cmaf;case"DASH_ONDEMAND":return n&&e.mp4&&a;case"HLS":case"HLS_ONDEMAND":case"HLS_FMP4":case"HLS_LIVE":case"HLS_LIVE_CMAF":return r;case"MPEG":return e.mp4;case"DASH":case"DASH_LIVE_WEBM":return!1;case"WEB_RTC_LIVE":return t.webrtc&&t.ws&&i.h264&&(e.mp4||e.webm);default:return(0,El.assertNever)(o)}})},wl=s=>{switch(s){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(0,El.assertNever)(s)}},Sg=s=>{let t=Object.keys(s).filter(i=>!wl(i));return xl(t).length>0};var G=require("@vkontakte/videoplayer-shared/es2015");var jR=5,QR=5,WR=500,yg=7e3,Ss=class{constructor(e){this.subscription=new G.Subscription;this.loadMediaTimeoutSubscription=new G.Subscription;this.videoState=new ne("stopped");this.syncPlayback=()=>{let e=this.videoState.getState(),t=this.videoState.getTransition(),i=this.params.desiredState.playbackState.getState(),r=this.params.desiredState.playbackState.getTransition(),a=this.params.desiredState.seekState.getState();if(this.log({message:`[syncPlayback] videoState: ${e}; videoTransition: ${JSON.stringify(t)}; desiredPlaybackState: ${i}; desiredPlaybackStateTransition: ${this.params.desiredState.playbackState.getTransition()}; seekState: ${JSON.stringify(a)};`}),i==="stopped"){e!=="stopped"&&(this.videoState.startTransitionTo("stopped"),this.stop());return}if(!t){if((r==null?void 0:r.to)!=="paused"&&a.state==="requested"&&e!=="stopped"){this.seek(a.position/1e3);return}switch(i){case"ready":{switch(e){case"playing":case"paused":case"ready":break;case"stopped":this.videoState.startTransitionTo("ready"),this.prepare();break;default:(0,G.assertNever)(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:(0,G.assertNever)(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:(0,G.assertNever)(e)}break}default:(0,G.assertNever)(i)}}};this.params=e,this.log=this.params.dependencies.logger.createComponentLog("ChromecastProvider"),this.log({message:`constructor, format: ${e.format}`}),this.params.output.isLive$.next(wl(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 G.Subscription;this.subscription.add(e),this.subscription.add((0,G.merge)(this.videoState.stateChangeStarted$.pipe((0,G.map)(r=>`stateChangeStarted$ ${JSON.stringify(r)}`)),this.videoState.stateChangeEnded$.pipe((0,G.map)(r=>`stateChangeEnded$ ${JSON.stringify(r)}`))).subscribe(r=>this.log({message:`[videoState] ${r}`})));let t=(r,a)=>this.subscription.add(r.subscribe(a));if(this.params.output.isLive$.getValue())this.params.output.position$.next(0),this.params.output.duration$.next(0);else{let r=new G.Subject;e.add(r.pipe((0,G.debounce)(WR)).subscribe(()=>{this.params.output.seekedEvent$.next()}));let a=NaN;e.add((0,G.fromEvent)(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED).subscribe(n=>{this.logRemoteEvent(n);let o=n.value;this.params.output.position$.next(o),(this.params.desiredState.seekState.getState().state==="applying"||Math.abs(o-a)>jR)&&r.next(o),a=o})),e.add((0,G.fromEvent)(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.DURATION_CHANGED).subscribe(n=>{this.logRemoteEvent(n),this.params.output.duration$.next(n.value)}))}t((0,G.fromEvent)(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED),r=>{this.logRemoteEvent(r),r.value?this.handleRemoteReady():(this.handleRemoteStop(),e.unsubscribe())}),t((0,G.fromEvent)(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED),r=>{this.logRemoteEvent(r),r.value?this.handleRemotePause():this.handleRemotePlay()}),t((0,G.fromEvent)(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED),r=>{this.logRemoteEvent(r);let{remotePlayer:a}=this.params.connection,n=r.value,o=this.params.output.isBuffering$.getValue(),u=n===chrome.cast.media.PlayerState.BUFFERING;switch(o!==u&&this.params.output.isBuffering$.next(u),n){case chrome.cast.media.PlayerState.IDLE:!this.params.output.isLive$.getValue()&&a.duration-a.currentTime<QR&&this.params.output.endedEvent$.next(),this.handleRemoteStop(),N(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:(0,G.assertNever)(n)}}),t((0,G.fromEvent)(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED),r=>{this.logRemoteEvent(r),this.handleRemoteVolumeChange({volume:r.value})}),t((0,G.fromEvent)(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED),r=>{this.logRemoteEvent(r),this.handleRemoteVolumeChange({muted:r.value})});let i=(0,G.merge)(this.params.desiredState.playbackState.stateChangeStarted$,this.params.desiredState.seekState.stateChangeEnded$,this.videoState.stateChangeEnded$,(0,G.observableFrom)(["init"])).pipe((0,G.debounce)(0));t(i,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"),N(this.params.desiredState.playbackState,"paused")):(this.videoState.setState("playing"),N(this.params.desiredState.playbackState,"playing"));let i=this.params.output.isLive$.getValue();this.params.output.duration$.next(i?0:t.duration),this.params.output.position$.next(i?0:t.currentTime),this.params.desiredState.seekState.setState({state:"none"})}}prepare(){let e=this.params.format;this.log({message:`[prepare] format: ${e}`});let t=this.createMediaInfo(e),i=this.createLoadRequest(t);this.loadMedia(i)}handleRemotePause(){let e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)==="paused"||e==="playing")&&(this.videoState.setState("paused"),N(this.params.desiredState.playbackState,"paused"))}handleRemotePlay(){let e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)==="playing"||e==="paused")&&(this.videoState.setState("playing"),N(this.params.desiredState.playbackState,"playing"))}handleRemoteReady(){var t;let e=this.videoState.getTransition();(e==null?void 0:e.to)==="ready"&&this.videoState.setState("ready"),((t=this.params.desiredState.playbackState.getTransition())==null?void 0:t.to)==="ready"&&N(this.params.desiredState.playbackState,"ready")}handleRemoteStop(){this.videoState.getState()!=="stopped"&&this.videoState.setState("stopped")}handleRemoteVolumeChange(e){var r,a;let t=this.params.output.volume$.getValue(),i={volume:(r=e.volume)!=null?r:t.volume,muted:(a=e.muted)!=null?a:t.muted};(i.volume!==t.volume||i.muted!==i.muted)&&this.params.output.volume$.next(i)}seek(e){this.params.output.willSeekEvent$.next();let{remotePlayer:t,remotePlayerController:i}=this.params.connection;t.currentTime=e,i.seek()}stop(){let{remotePlayerController:e}=this.params.connection;e.stop()}createMediaInfo(e){var l;let t=this.params.source,i,r,a;switch(e){case"MPEG":{let c=t[e];(0,G.assertNonNullable)(c);let d=(0,G.getHighestQuality)(Object.keys(c));(0,G.assertNonNullable)(d);let f=c[d];(0,G.assertNonNullable)(f),i=f,r="video/mp4",a=chrome.cast.media.StreamType.BUFFERED;break}case"HLS":case"HLS_FMP4":case"HLS_ONDEMAND":{let c=t[e];(0,G.assertNonNullable)(c),i=c.url,r="application/x-mpegurl",a=chrome.cast.media.StreamType.BUFFERED;break}case"DASH_SEP":case"DASH_ONDEMAND":case"DASH_WEBM":case"DASH_WEBM_AV1":case"DASH_STREAMS":{let c=t[e];(0,G.assertNonNullable)(c),i=c.url,r="application/dash+xml",a=chrome.cast.media.StreamType.BUFFERED;break}case"DASH_LIVE_CMAF":{let c=t[e];(0,G.assertNonNullable)(c),i=c.url,r="application/dash+xml",a=chrome.cast.media.StreamType.LIVE;break}case"HLS_LIVE":case"HLS_LIVE_CMAF":{let c=t[e];(0,G.assertNonNullable)(c),i=Re(c.url),r="application/x-mpegurl",a=chrome.cast.media.StreamType.LIVE;break}case"DASH_LIVE":case"WEB_RTC_LIVE":{let c="Unsupported format for Chromecast",d=new Error(c);throw this.params.output.error$.next({id:"ChromecastProvider.createMediaInfo()",category:G.ErrorCategory.VIDEO_PIPELINE,message:c,thrown:d}),d}case"DASH":case"DASH_LIVE_WEBM":throw new Error(`${e} is no longer supported`);default:return(0,G.assertNever)(e)}let n=new chrome.cast.media.MediaInfo((l=this.params.meta.videoId)!=null?l:i,r);n.contentUrl=i,n.streamType=a,n.metadata=new chrome.cast.media.GenericMediaMetadata;let{title:o,subtitle:u}=this.params.meta;return(0,G.isNonNullable)(o)&&(n.metadata.title=o),(0,G.isNonNullable)(u)&&(n.metadata.subtitle=u),n}createLoadRequest(e){let t=new chrome.cast.media.LoadRequest(e);t.autoplay=!1;let i=this.params.desiredState.seekState.getState();return i.state==="applying"||i.state==="requested"?t.currentTime=this.params.output.isLive$.getValue()?0:i.position/1e3:t.currentTime=0,t}loadMedia(e){let t=this.params.connection.session.loadMedia(e),i=new Promise((r,a)=>{this.loadMediaTimeoutSubscription.add((0,G.timeout)(yg).subscribe(()=>a(`timeout(${yg})`)))});(0,Tg.default)(Promise.race([t,i]).then(()=>{this.log({message:`[loadMedia] completed, format: ${this.params.format}`}),this.params.desiredState.seekState.getState().state==="applying"&&this.params.output.seekedEvent$.next(),this.handleRemoteReady()},r=>{let a=`[prepare] loadMedia failed, format: ${this.params.format}, reason: ${r}`;this.log({message:a}),this.params.output.error$.next({id:"ChromecastProvider.loadMedia",category:G.ErrorCategory.VIDEO_PIPELINE,message:a,thrown:r})}),()=>{this.loadMediaTimeoutSubscription.unsubscribe()})}logRemoteEvent(e){this.log({message:`[remoteEvent] ${JSON.stringify(e)}`})}};var Nl=Y(je(),1);var kl=require("@vkontakte/videoplayer-shared/es2015");var Ig=require("@vkontakte/videoplayer-shared/es2015"),Eg=s=>{try{s.pause(),s.playbackRate=0,(0,Ig.clearVideoElement)(s),s.remove()}catch(e){console.error(e)}};var xn=require("@vkontakte/videoplayer-shared/es2015"),Al=class{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)}},Pl=window.WeakMap?new WeakMap:new Al,Rl=window.WeakMap?new WeakMap:new Map,GR=(s,e=20)=>{let t=0;return(0,xn.fromEvent)(s,"ratechange").subscribe(i=>{t++,t>=e&&(s.currentTime=s.currentTime,t=0)})},ze=(s,{audioVideoSyncRate:e,disableYandexPiP:t})=>{let i=s.querySelector("video"),r=!!i;i?(0,kl.clearVideoElement)(i):(i=document.createElement("video"),s.appendChild(i)),Pl.set(i,r);let a=new xn.Subscription;return a.add(GR(i,e)),Rl.set(i,a),i.setAttribute("crossorigin","anonymous"),i.setAttribute("playsinline","playsinline"),t&&i.setAttribute("x-yandex-pip","false"),i.controls=!1,i.setAttribute("poster","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),i},Ye=s=>{let e=Rl.get(s);e==null||e.unsubscribe(),Rl.delete(s);let t=Pl.get(s);Pl.delete(s),t?(0,kl.clearVideoElement)(s):Eg(s)};var Ll=Y(Di(),1),z=require("@vkontakte/videoplayer-shared/es2015");var pi=require("@vkontakte/videoplayer-shared/es2015"),wn=(s,e,t,{equal:i=(n,o)=>n===o,changed$:r,onError:a}={})=>{let n=s.getState(),o=e(),u=(0,pi.isNullable)(r),l=new pi.Subscription;return r&&l.add(r.subscribe(c=>{let d=s.getState();i(c,d)&&s.setState(c)},a)),i(o,n)||(t(n),u&&s.setState(n)),l.add(s.stateChangeStarted$.subscribe(c=>{t(c.to),u&&s.setState(c.to)},a)),l},Ct=(s,e,t)=>wn(e,()=>s.loop,i=>{(0,pi.isNonNullable)(i)&&(s.loop=i)},{onError:t}),Ke=(s,e,t,i)=>wn(e,()=>({muted:s.muted,volume:s.volume}),r=>{(0,pi.isNonNullable)(r)&&(s.muted=r.muted,s.volume=r.volume)},{equal:(r,a)=>r===a||(r==null?void 0:r.muted)===(a==null?void 0:a.muted)&&(r==null?void 0:r.volume)===(a==null?void 0:a.volume),changed$:t,onError:i}),pt=(s,e,t,i)=>wn(e,()=>s.playbackRate,r=>{(0,pi.isNonNullable)(r)&&(s.playbackRate=r)},{changed$:t,onError:i}),ys=wn;var zR=s=>["__",s.language,s.label].join("|"),YR=(s,e)=>{if(s.id===e)return!0;let[t,i,r]=e.split("|");return s.language===i&&s.label===r},$l=class s{constructor(e){this.available$=new z.Subject;this.current$=new z.ValueSubject(void 0);this.error$=new z.Subject;this.subscription=new z.Subscription;this.externalTracks=new Map;this.internalTracks=new Map;this.baseURL=e}connect(e,t,i){this.video=e,this.cueSettings=t.textTrackCuesSettings,this.subscribe();let r=a=>{this.error$.next({id:"TextTracksManager",category:z.ErrorCategory.WTF,message:"Generic HtmlVideoTextTrackManager error",thrown:a})};this.subscription.add(this.available$.subscribe(i.availableTextTracks$)),this.subscription.add(this.current$.subscribe(i.currentTextTrack$)),this.subscription.add(this.error$.subscribe(i.error$)),this.subscription.add(ys(t.internalTextTracks,()=>(0,Ll.default)(this.internalTracks),a=>{(0,z.isNonNullable)(a)&&this.setInternal(a)},{equal:(a,n)=>(0,z.isNonNullable)(a)&&(0,z.isNonNullable)(n)&&a.length===n.length&&a.every(({id:o},u)=>o===n[u].id),changed$:this.available$.pipe((0,z.map)(a=>a.filter(({type:n})=>n==="internal"))),onError:r})),this.subscription.add(ys(t.externalTextTracks,()=>(0,Ll.default)(this.externalTracks),a=>{(0,z.isNonNullable)(a)&&this.setExternal(a)},{equal:(a,n)=>(0,z.isNonNullable)(a)&&(0,z.isNonNullable)(n)&&a.length===n.length&&a.every(({id:o},u)=>o===n[u].id),changed$:this.available$.pipe((0,z.map)(a=>a.filter(({type:n})=>n==="external"))),onError:r})),this.subscription.add(ys(t.currentTextTrack,()=>{if(this.video)return;let a=this.htmlTextTracksAsArray().find(({mode:n})=>n==="showing");return a&&this.htmlTextTrackToITextTrack(a).id},a=>this.select(a),{changed$:this.current$,onError:r})),this.subscription.add(ys(t.textTrackCuesSettings,()=>({}),()=>{if(this.video)for(let a of this.htmlTextTracksAsArray())this.applyCueSettings(a.cues),this.applyCueSettings(a.activeCues)}))}subscribe(){(0,z.assertNonNullable)(this.video);let{textTracks:e}=this.video;this.subscription.add((0,z.fromEvent)(e,"addtrack").subscribe(()=>{let i=this.current$.getValue();i&&this.select(i)})),this.subscription.add((0,z.merge)((0,z.fromEvent)(e,"addtrack"),(0,z.fromEvent)(e,"removetrack"),(0,z.observableFrom)(["init"])).pipe((0,z.map)(()=>this.htmlTextTracksAsArray().map(i=>this.htmlTextTrackToITextTrack(i))),(0,z.filterChanged)((i,r)=>i.length===r.length&&i.every(({id:a},n)=>a===r[n].id))).subscribe(this.available$)),this.subscription.add((0,z.merge)((0,z.fromEvent)(e,"change"),(0,z.observableFrom)(["init"])).pipe((0,z.map)(()=>this.htmlTextTracksAsArray().find(({mode:i})=>i==="showing")),(0,z.map)(i=>i&&this.htmlTextTrackToITextTrack(i).id),(0,z.filterChanged)()).subscribe(this.current$));let t=i=>{var r,a;return this.applyCueSettings((a=(r=i.target)==null?void 0:r.activeCues)!=null?a:null)};this.subscription.add((0,z.fromEvent)(e,"addtrack").subscribe(i=>{var a,n;(a=i.track)==null||a.addEventListener("cuechange",t);let r=o=>{var l,c,d,f,p;let u=(c=(l=o.target)==null?void 0:l.cues)!=null?c:null;u&&u.length&&(this.applyCueSettings((f=(d=o.target)==null?void 0:d.cues)!=null?f:null),(p=o.target)==null||p.removeEventListener("cuechange",r))};(n=i.track)==null||n.addEventListener("cuechange",r)})),this.subscription.add((0,z.fromEvent)(e,"removetrack").subscribe(i=>{var r;(r=i.track)==null||r.removeEventListener("cuechange",t)}))}applyCueSettings(e){if(!e||!e.length)return;let t=this.cueSettings.getState();for(let i of Array.from(e)){let r=i;(0,z.isNonNullable)(t.align)&&(r.align=t.align),(0,z.isNonNullable)(t.position)&&(r.position=t.position),(0,z.isNonNullable)(t.size)&&(r.size=t.size),(0,z.isNonNullable)(t.line)&&(r.line=t.line)}}htmlTextTracksAsArray(e=!1){(0,z.assertNonNullable)(this.video);let t=[...this.video.textTracks];return e?t:t.filter(s.isHealthyTrack)}htmlTextTrackToITextTrack(e){var o,u,l,c,d;let{language:t,label:i}=e,r=e.id?e.id:zR(e),a=this.externalTracks.has(r),n=(l=a?(o=this.externalTracks.get(r))==null?void 0:o.isAuto:(u=this.internalTracks.get(r))==null?void 0:u.isAuto)!=null?l:r.includes("auto");return a?{id:r,type:"external",isAuto:n,language:t,label:i,url:(c=this.externalTracks.get(r))==null?void 0:c.url}:{id:r,type:"internal",isAuto:n,language:t,label:i,url:(d=this.internalTracks.get(r))==null?void 0:d.url}}static isHealthyTrack(e){return!(e.kind==="metadata"||e.groupId||e.id===""&&e.label===""&&e.language==="")}setExternal(e){this.internalTracks.size>0&&Array.from(this.internalTracks).forEach(([,t])=>this.detach(t)),e.filter(({id:t})=>!this.externalTracks.has(t)).forEach(t=>this.attach(t)),Array.from(this.externalTracks).filter(([t])=>!e.find(i=>i.id===t)).forEach(([,t])=>this.detach(t))}setInternal(e){let t=[...this.externalTracks];e.filter(({id:i,language:r,isAuto:a})=>!this.internalTracks.has(i)&&!t.some(([,n])=>n.language===r&&n.isAuto===a)).forEach(i=>this.attach(i)),Array.from(this.internalTracks).filter(([i])=>!e.find(r=>r.id===i)).forEach(([,i])=>this.detach(i))}select(e){(0,z.assertNonNullable)(this.video);for(let t of this.htmlTextTracksAsArray(!0))t.mode="showing";for(let t of this.htmlTextTracksAsArray(!0))((0,z.isNullable)(e)||!YR(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){(0,z.assertNonNullable)(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){(0,z.assertNonNullable)(this.video);let t=Array.prototype.find.call(this.video.getElementsByTagName("track"),i=>i.getAttribute("id")===e.id);t&&this.video.removeChild(t),e.type==="external"?this.externalTracks.delete(e.id):e.type==="internal"&&this.internalTracks.delete(e.id)}},ht=$l;var Fi=class{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 xg=s=>{let e=s;for(;!(e instanceof Document)&&!(e instanceof ShadowRoot)&&e!==null;)e=e==null?void 0:e.parentNode;return e!=null?e:void 0},Ml=s=>{let e=xg(s);return!!(e&&e.fullscreenElement&&e.fullscreenElement===s)},wg=s=>{let e=xg(s);return!!(e&&e.pictureInPictureElement&&e.pictureInPictureElement===s)};var D=require("@vkontakte/videoplayer-shared/es2015");var KR=3,Ag=(s,e,t=KR)=>{let i=0,r=0;for(let a=0;a<s.length;a++){let n=s.start(a),o=s.end(a);if(n<=e&&e<=o){if(i=n,r=o,!t)return{from:i,to:r};for(let u=a-1;u>=0;u--)s.end(u)+t>=i&&(i=s.start(u));for(let u=a+1;u<s.length;u++)s.start(u)-t<=r&&(r=s.end(u))}}return{from:i,to:r}};var Xe=s=>{let e=M=>(0,D.fromEvent)(s,M).pipe((0,D.mapTo)(void 0),(0,D.shareReplay)(1)),t=new D.Subscription,i=()=>t.unsubscribe(),r=(0,D.merge)((0,D.fromEvent)(s,"progress"),(0,D.fromEvent)(s,"timeupdate")).pipe((0,D.map)(()=>Ag(s.buffered,s.currentTime)),(0,D.shareReplay)(1)),a=K.browser.isSafari?(0,D.combine)({play:e("play").pipe((0,D.once)()),playing:e("playing")}).pipe((0,D.mapTo)(void 0),(0,D.shareReplay)(1)):e("playing"),n=(0,D.fromEvent)(s,"volumechange").pipe((0,D.map)(()=>({muted:s.muted,volume:s.volume})),(0,D.shareReplay)(1)),o=(0,D.fromEvent)(s,"ratechange").pipe((0,D.map)(()=>s.playbackRate),(0,D.shareReplay)(1)),u=(0,D.fromEvent)(s,"error").pipe((0,D.filter)(()=>!!(s.error||s.played.length)),(0,D.map)(()=>{var Q;let M=s.error;return{id:M?`MediaError#${M.code}`:"HtmlVideoError",category:D.ErrorCategory.VIDEO_PIPELINE,message:M?M.message:"Error event from HTML video element",thrown:(Q=s.error)!=null?Q:void 0}}),(0,D.shareReplay)(1)),l=(0,D.fromEvent)(s,"timeupdate").pipe((0,D.map)(()=>s.currentTime),(0,D.shareReplay)(1)),c=["waiting","seeking","seeked","timeupdate"],d=new D.Subject,f=.3,p;t.add((0,D.merge)(...c.map(M=>(0,D.fromEvent)(s,M))).subscribe(M=>{let Q=s.currentTime;s.loop&&(0,D.isNonNullable)(p)&&(0,D.isNonNullable)(Q)&&p>=s.duration-f&&Q<=f&&d.next(p),p=Q}));let h=e("pause").pipe((0,D.filter)(()=>!s.error&&p!==s.duration),(0,D.shareReplay)(1)),b=(0,D.fromEvent)(s,"enterpictureinpicture").pipe((0,D.shareReplay)(1)),S=(0,D.fromEvent)(s,"leavepictureinpicture").pipe((0,D.shareReplay)(1)),g=new D.ValueSubject(wg(s));t.add(b.subscribe(()=>g.next(!0))),t.add(S.subscribe(()=>g.next(!1)));let y=new D.ValueSubject(Ml(s)),A=(0,D.fromEvent)(s,"fullscreenchange").pipe((0,D.shareReplay)(1));t.add(A.pipe((0,D.map)(()=>Ml(s))).subscribe(y));let E=.1,w=1e3,_=(0,D.fromEvent)(s,"timeupdate").pipe((0,D.map)(M=>s.duration-s.currentTime<E),(0,D.filterChanged)(),(0,D.shareReplay)(1)),W=(0,D.merge)(_.pipe((0,D.filter)(M=>!s.loop&&M)),(0,D.fromEvent)(s,"ended")).pipe((0,D.throttle)(w),(0,D.mapTo)(void 0),(0,D.shareReplay)(1)),U=(0,D.merge)(...["waiting","pause","canplay","play","canplaythrough","playing","seeking","seeked","ended"].map(M=>(0,D.fromEvent)(s,M)),_.pipe((0,D.map)(M=>({type:M?"ended":"unknown"})))).pipe((0,D.map)(M=>K.browser.isFirefox&&M.type==="ended"?s.readyState<2:s.readyState<3),(0,D.filterChanged)(),(0,D.shareReplay)(1));return{playing$:a,pause$:h,canplay$:e("canplay"),ended$:W,looped$:d,error$:u,seeked$:e("seeked"),seeking$:e("seeking"),progress$:e("progress"),loadStart$:e("loadstart"),loadedMetadata$:e("loadedmetadata"),loadedData$:e("loadeddata"),timeUpdate$:l,durationChange$:(0,D.fromEvent)(s,"durationchange").pipe((0,D.map)(()=>s.duration),(0,D.shareReplay)(1)),isBuffering$:U,currentBuffer$:r,volumeState$:n,playbackRateState$:o,inPiP$:g,inFullscreen$:y,enterPip$:b,leavePip$:S,destroy:i}};var Wt=require("@vkontakte/videoplayer-shared/es2015"),hi=s=>{switch(s){case"mobile":return Wt.VideoQuality.Q_144P;case"lowest":return Wt.VideoQuality.Q_240P;case"low":return Wt.VideoQuality.Q_360P;case"sd":case"medium":return Wt.VideoQuality.Q_480P;case"hd":case"high":return Wt.VideoQuality.Q_720P;case"fullhd":case"full":return Wt.VideoQuality.Q_1080P;case"quadhd":case"quad":return Wt.VideoQuality.Q_1440P;case"ultrahd":case"ultra":return Wt.VideoQuality.Q_2160P}};var We=Y(xt(),1),Bl=Y(je(),1),Ni=Y(cr(),1),V=require("@vkontakte/videoplayer-shared/es2015");var Dl=!1,Gt={},Dg=s=>{Dl=s},Cg=()=>{Gt={}},Bg=s=>{s(Gt)},Ts=(s,e)=>{var t;Dl&&(Gt.meta=(t=Gt.meta)!=null?t:{},Gt.meta[s]=e)},Qe=class{constructor(e){this.name=e}next(e){var i,r;if(!Dl)return;Gt.series=(i=Gt.series)!=null?i:{};let t=(r=Gt.series[this.name])!=null?r:[];t.push([Date.now(),e]),Gt.series[this.name]=t}};var $e=require("@vkontakte/videoplayer-shared/es2015");function Cl(s,e,t){return!s.max&&s.min===e?"high_quality":!s.min&&s.max===t?"traffic_saving":"unknown"}function An(s,e,t){return!!s&&Cl(s,e,t)==="high_quality"}function Ir(s,e,t){return(0,$e.isNullable)(s)||(0,$e.isNonNullable)(s.min)&&(0,$e.isNonNullable)(s.max)&&(0,$e.isLower)(s.max,s.min)||(0,$e.isNonNullable)(s.min)&&e&&(0,$e.isHigher)(s.min,e)||(0,$e.isNonNullable)(s.max)&&t&&(0,$e.isLower)(s.max,t)}function Vg({limits:s,highestAvailableHeight:e,lowestAvailableHeight:t}){return Ir({max:s!=null&&s.max?(0,$e.videoHeightToQuality)(s.max):void 0,min:s!=null&&s.min?(0,$e.videoHeightToQuality)(s.min):void 0},e?(0,$e.videoHeightToQuality)(e):void 0,t?(0,$e.videoHeightToQuality)(t):void 0)}var qg=new Qe("best_bitrate"),Rn=(s,e,t)=>(e-t)*Math.pow(2,-10*s)+t;var Er=s=>(e,t)=>s*(Number(e.bitrate)-Number(t.bitrate)),fi=class{constructor(){this.history={}}recordSelection(e){this.history[e.id]=(0,V.now)()}recordSwitch(e){this.last=e}clear(){this.last=void 0,this.history={}}},kn='Assertion "ABR Tracks is empty array" failed',Pn=new WeakMap,_g=new WeakMap,Og=new WeakMap,Is=(s,e,t,i)=>{var u;let r=[...e].sort(Er(1)),a=[...t].sort(Er(1)),n=a.filter(l=>(0,V.isNonNullable)(l.bitrate)&&(0,V.isNonNullable)(s.bitrate)?s.bitrate/l.bitrate>i:!0),o=(u=(0,We.default)(a,Math.round(a.length*r.indexOf(s)/(r.length+1))))!=null?u:(0,We.default)(a,-1);return o&&(0,Bl.default)(n,o)?o:n.length?(0,We.default)(n,-1):(0,We.default)(a,0)},Es=(s,e,t,i)=>{var u;let r=Pn.get(e);r||(r=[...e].sort(Er(1)),Pn.set(e,r));let a=Pn.get(t);a||(a=[...t].sort(Er(1)),Pn.set(t,a));let n=Og.get(s);n||(n=a.filter(l=>(0,V.isNonNullable)(l.bitrate)&&(0,V.isNonNullable)(s.bitrate)?s.bitrate/l.bitrate>i:!0),Og.set(s,n));let o=(u=(0,We.default)(a,Math.round(a.length*r.indexOf(s)/(r.length+1))))!=null?u:(0,We.default)(a,-1);return o&&(0,Bl.default)(n,o)?o:n.length?(0,We.default)(n,-1):(0,We.default)(a,0)},Fg=s=>"quality"in s,Ln=(s,e,t,i)=>{var n;let r=(0,V.isNonNullable)((n=i==null?void 0:i.last)==null?void 0:n.bitrate)&&(0,V.isNonNullable)(t==null?void 0:t.bitrate)&&i.last.bitrate<t.bitrate?s.trackCooldownIncreaseQuality:s.trackCooldownDecreaseQuality,a=t&&i&&i.history[t.id]&&(0,V.now)()-i.history[t.id]<=r&&(!i.last||t.id!==i.last.id);if(t!=null&&t.id&&i&&!a&&i.recordSelection(t),a&&(i!=null&&i.last)){let o=i.last;i==null||i.recordSwitch(o);let u=Fg(o)?"video":"audio",l=Fg(o)?o.quality:o.bitrate;return e({message:`
6
+ "use strict";var Yy=Object.create;var Wr=Object.defineProperty,Ky=Object.defineProperties,Xy=Object.getOwnPropertyDescriptor,Jy=Object.getOwnPropertyDescriptors,Zy=Object.getOwnPropertyNames,Ba=Object.getOwnPropertySymbols,eT=Object.getPrototypeOf,Lo=Object.prototype.hasOwnProperty,md=Object.prototype.propertyIsEnumerable;var tT=(s,e)=>(e=Symbol[s])?e:Symbol.for("Symbol."+s);var kt=Math.pow,fd=(s,e,t)=>e in s?Wr(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,C=(s,e)=>{for(var t in e||(e={}))Lo.call(e,t)&&fd(s,t,e[t]);if(Ba)for(var t of Ba(e))md.call(e,t)&&fd(s,t,e[t]);return s},j=(s,e)=>Ky(s,Jy(e));var bd=(s,e)=>{var t={};for(var i in s)Lo.call(s,i)&&e.indexOf(i)<0&&(t[i]=s[i]);if(s!=null&&Ba)for(var i of Ba(s))e.indexOf(i)<0&&md.call(s,i)&&(t[i]=s[i]);return t};var v=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports),iT=(s,e)=>{for(var t in e)Wr(s,t,{get:e[t],enumerable:!0})},gd=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Zy(e))!Lo.call(s,r)&&r!==t&&Wr(s,r,{get:()=>e[r],enumerable:!(i=Xy(e,r))||i.enumerable});return s};var Y=(s,e,t)=>(t=s!=null?Yy(eT(s)):{},gd(e||!s||!s.__esModule?Wr(t,"default",{value:s,enumerable:!0}):t,s)),rT=s=>gd(Wr({},"__esModule",{value:!0}),s);var R=(s,e,t)=>new Promise((i,r)=>{var a=u=>{try{o(t.next(u))}catch(l){r(l)}},n=u=>{try{o(t.throw(u))}catch(l){r(l)}},o=u=>u.done?i(u.value):Promise.resolve(u.value).then(a,n);o((t=t.apply(s,e)).next())}),Pi=function(s,e){this[0]=s,this[1]=e},oe=(s,e,t)=>{var i=(n,o,u,l)=>{try{var c=t[n](o),d=(o=c.value)instanceof Pi,f=c.done;Promise.resolve(d?o[0]:o).then(p=>d?i(n==="return"?n:"next",o[1]?{done:p.done,value:p.value}:p,u,l):u({value:p,done:f})).catch(p=>i("throw",p,u,l))}catch(p){l(p)}},r=n=>a[n]=o=>new Promise((u,l)=>i(n,o,u,l)),a={};return t=t.apply(s,e),a[tT("asyncIterator")]=()=>a,r("next"),r("throw"),r("return"),a};var Ae=v((Mo,vd)=>{"use strict";var Yr=function(s){return s&&s.Math===Math&&s};vd.exports=Yr(typeof globalThis=="object"&&globalThis)||Yr(typeof window=="object"&&window)||Yr(typeof self=="object"&&self)||Yr(typeof global=="object"&&global)||Yr(typeof Mo=="object"&&Mo)||function(){return this}()||Function("return this")()});var Me=v((z$,Sd)=>{"use strict";Sd.exports=function(s){try{return!!s()}catch(e){return!0}}});var Kr=v((Y$,yd)=>{"use strict";var sT=Me();yd.exports=!sT(function(){var s=function(){}.bind();return typeof s!="function"||s.hasOwnProperty("prototype")})});var Do=v((K$,xd)=>{"use strict";var aT=Kr(),Ed=Function.prototype,Td=Ed.apply,Id=Ed.call;xd.exports=typeof Reflect=="object"&&Reflect.apply||(aT?Id.bind(Td):function(){return Id.apply(Td,arguments)})});var De=v((X$,Pd)=>{"use strict";var wd=Kr(),Ad=Function.prototype,Co=Ad.call,nT=wd&&Ad.bind.bind(Co,Co);Pd.exports=wd?nT:function(s){return function(){return Co.apply(s,arguments)}}});var Ri=v((J$,kd)=>{"use strict";var Rd=De(),oT=Rd({}.toString),uT=Rd("".slice);kd.exports=function(s){return uT(oT(s),8,-1)}});var Bo=v((Z$,Ld)=>{"use strict";var lT=Ri(),cT=De();Ld.exports=function(s){if(lT(s)==="Function")return cT(s)}});var Pe=v((eM,$d)=>{"use strict";var Vo=typeof document=="object"&&document.all;$d.exports=typeof Vo=="undefined"&&Vo!==void 0?function(s){return typeof s=="function"||s===Vo}:function(s){return typeof s=="function"}});var rt=v((tM,Md)=>{"use strict";var dT=Me();Md.exports=!dT(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var st=v((iM,Dd)=>{"use strict";var pT=Kr(),Oa=Function.prototype.call;Dd.exports=pT?Oa.bind(Oa):function(){return Oa.apply(Oa,arguments)}});var _o=v(Vd=>{"use strict";var Cd={}.propertyIsEnumerable,Bd=Object.getOwnPropertyDescriptor,hT=Bd&&!Cd.call({1:2},1);Vd.f=hT?function(e){var t=Bd(this,e);return!!t&&t.enumerable}:Cd});var Xr=v((sM,_d)=>{"use strict";_d.exports=function(s,e){return{enumerable:!(s&1),configurable:!(s&2),writable:!(s&4),value:e}}});var Fd=v((aM,Od)=>{"use strict";var fT=De(),mT=Me(),bT=Ri(),Oo=Object,gT=fT("".split);Od.exports=mT(function(){return!Oo("z").propertyIsEnumerable(0)})?function(s){return bT(s)==="String"?gT(s,""):Oo(s)}:Oo});var Jr=v((nM,Nd)=>{"use strict";Nd.exports=function(s){return s==null}});var ui=v((oM,qd)=>{"use strict";var vT=Jr(),ST=TypeError;qd.exports=function(s){if(vT(s))throw new ST("Can't call method on "+s);return s}});var ki=v((uM,Ud)=>{"use strict";var yT=Fd(),TT=ui();Ud.exports=function(s){return yT(TT(s))}});var Ge=v((lM,Hd)=>{"use strict";var IT=Pe();Hd.exports=function(s){return typeof s=="object"?s!==null:IT(s)}});var Li=v((cM,jd)=>{"use strict";jd.exports={}});var Ht=v((dM,Wd)=>{"use strict";var Fo=Li(),No=Ae(),ET=Pe(),Qd=function(s){return ET(s)?s:void 0};Wd.exports=function(s,e){return arguments.length<2?Qd(Fo[s])||Qd(No[s]):Fo[s]&&Fo[s][e]||No[s]&&No[s][e]}});var Zr=v((pM,Gd)=>{"use strict";var xT=De();Gd.exports=xT({}.isPrototypeOf)});var $i=v((hM,Kd)=>{"use strict";var wT=Ae(),zd=wT.navigator,Yd=zd&&zd.userAgent;Kd.exports=Yd?String(Yd):""});var Uo=v((fM,ip)=>{"use strict";var tp=Ae(),qo=$i(),Xd=tp.process,Jd=tp.Deno,Zd=Xd&&Xd.versions||Jd&&Jd.version,ep=Zd&&Zd.v8,yt,Fa;ep&&(yt=ep.split("."),Fa=yt[0]>0&&yt[0]<4?1:+(yt[0]+yt[1]));!Fa&&qo&&(yt=qo.match(/Edge\/(\d+)/),(!yt||yt[1]>=74)&&(yt=qo.match(/Chrome\/(\d+)/),yt&&(Fa=+yt[1])));ip.exports=Fa});var Ho=v((mM,sp)=>{"use strict";var rp=Uo(),AT=Me(),PT=Ae(),RT=PT.String;sp.exports=!!Object.getOwnPropertySymbols&&!AT(function(){var s=Symbol("symbol detection");return!RT(s)||!(Object(s)instanceof Symbol)||!Symbol.sham&&rp&&rp<41})});var jo=v((bM,ap)=>{"use strict";var kT=Ho();ap.exports=kT&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var Qo=v((gM,np)=>{"use strict";var LT=Ht(),$T=Pe(),MT=Zr(),DT=jo(),CT=Object;np.exports=DT?function(s){return typeof s=="symbol"}:function(s){var e=LT("Symbol");return $T(e)&&MT(e.prototype,CT(s))}});var es=v((vM,op)=>{"use strict";var BT=String;op.exports=function(s){try{return BT(s)}catch(e){return"Object"}}});var $t=v((SM,up)=>{"use strict";var VT=Pe(),_T=es(),OT=TypeError;up.exports=function(s){if(VT(s))return s;throw new OT(_T(s)+" is not a function")}});var ts=v((yM,lp)=>{"use strict";var FT=$t(),NT=Jr();lp.exports=function(s,e){var t=s[e];return NT(t)?void 0:FT(t)}});var dp=v((TM,cp)=>{"use strict";var Wo=st(),Go=Pe(),zo=Ge(),qT=TypeError;cp.exports=function(s,e){var t,i;if(e==="string"&&Go(t=s.toString)&&!zo(i=Wo(t,s))||Go(t=s.valueOf)&&!zo(i=Wo(t,s))||e!=="string"&&Go(t=s.toString)&&!zo(i=Wo(t,s)))return i;throw new qT("Can't convert object to primitive value")}});var Tt=v((IM,pp)=>{"use strict";pp.exports=!0});var mp=v((EM,fp)=>{"use strict";var hp=Ae(),UT=Object.defineProperty;fp.exports=function(s,e){try{UT(hp,s,{value:e,configurable:!0,writable:!0})}catch(t){hp[s]=e}return e}});var is=v((xM,vp)=>{"use strict";var HT=Tt(),jT=Ae(),QT=mp(),bp="__core-js_shared__",gp=vp.exports=jT[bp]||QT(bp,{});(gp.versions||(gp.versions=[])).push({version:"3.43.0",mode:HT?"pure":"global",copyright:"\xA9 2014-2025 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.43.0/LICENSE",source:"https://github.com/zloirock/core-js"})});var Yo=v((wM,yp)=>{"use strict";var Sp=is();yp.exports=function(s,e){return Sp[s]||(Sp[s]=e||{})}});var rr=v((AM,Tp)=>{"use strict";var WT=ui(),GT=Object;Tp.exports=function(s){return GT(WT(s))}});var It=v((PM,Ip)=>{"use strict";var zT=De(),YT=rr(),KT=zT({}.hasOwnProperty);Ip.exports=Object.hasOwn||function(e,t){return KT(YT(e),t)}});var Ko=v((RM,Ep)=>{"use strict";var XT=De(),JT=0,ZT=Math.random(),eI=XT(1.1.toString);Ep.exports=function(s){return"Symbol("+(s===void 0?"":s)+")_"+eI(++JT+ZT,36)}});var Fe=v((kM,wp)=>{"use strict";var tI=Ae(),iI=Yo(),xp=It(),rI=Ko(),sI=Ho(),aI=jo(),sr=tI.Symbol,Xo=iI("wks"),nI=aI?sr.for||sr:sr&&sr.withoutSetter||rI;wp.exports=function(s){return xp(Xo,s)||(Xo[s]=sI&&xp(sr,s)?sr[s]:nI("Symbol."+s)),Xo[s]}});var kp=v((LM,Rp)=>{"use strict";var oI=st(),Ap=Ge(),Pp=Qo(),uI=ts(),lI=dp(),cI=Fe(),dI=TypeError,pI=cI("toPrimitive");Rp.exports=function(s,e){if(!Ap(s)||Pp(s))return s;var t=uI(s,pI),i;if(t){if(e===void 0&&(e="default"),i=oI(t,s,e),!Ap(i)||Pp(i))return i;throw new dI("Can't convert object to primitive value")}return e===void 0&&(e="number"),lI(s,e)}});var Jo=v(($M,Lp)=>{"use strict";var hI=kp(),fI=Qo();Lp.exports=function(s){var e=hI(s,"string");return fI(e)?e:e+""}});var Na=v((MM,Mp)=>{"use strict";var mI=Ae(),$p=Ge(),Zo=mI.document,bI=$p(Zo)&&$p(Zo.createElement);Mp.exports=function(s){return bI?Zo.createElement(s):{}}});var eu=v((DM,Dp)=>{"use strict";var gI=rt(),vI=Me(),SI=Na();Dp.exports=!gI&&!vI(function(){return Object.defineProperty(SI("div"),"a",{get:function(){return 7}}).a!==7})});var Vp=v(Bp=>{"use strict";var yI=rt(),TI=st(),II=_o(),EI=Xr(),xI=ki(),wI=Jo(),AI=It(),PI=eu(),Cp=Object.getOwnPropertyDescriptor;Bp.f=yI?Cp:function(e,t){if(e=xI(e),t=wI(t),PI)try{return Cp(e,t)}catch(i){}if(AI(e,t))return EI(!TI(II.f,e,t),e[t])}});var tu=v((BM,_p)=>{"use strict";var RI=Me(),kI=Pe(),LI=/#|\.prototype\./,rs=function(s,e){var t=MI[$I(s)];return t===CI?!0:t===DI?!1:kI(e)?RI(e):!!e},$I=rs.normalize=function(s){return String(s).replace(LI,".").toLowerCase()},MI=rs.data={},DI=rs.NATIVE="N",CI=rs.POLYFILL="P";_p.exports=rs});var ar=v((VM,Fp)=>{"use strict";var Op=Bo(),BI=$t(),VI=Kr(),_I=Op(Op.bind);Fp.exports=function(s,e){return BI(s),e===void 0?s:VI?_I(s,e):function(){return s.apply(e,arguments)}}});var iu=v((_M,Np)=>{"use strict";var OI=rt(),FI=Me();Np.exports=OI&&FI(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var Mt=v((OM,qp)=>{"use strict";var NI=Ge(),qI=String,UI=TypeError;qp.exports=function(s){if(NI(s))return s;throw new UI(qI(s)+" is not an object")}});var Mi=v(Hp=>{"use strict";var HI=rt(),jI=eu(),QI=iu(),qa=Mt(),Up=Jo(),WI=TypeError,ru=Object.defineProperty,GI=Object.getOwnPropertyDescriptor,su="enumerable",au="configurable",nu="writable";Hp.f=HI?QI?function(e,t,i){if(qa(e),t=Up(t),qa(i),typeof e=="function"&&t==="prototype"&&"value"in i&&nu in i&&!i[nu]){var r=GI(e,t);r&&r[nu]&&(e[t]=i.value,i={configurable:au in i?i[au]:r[au],enumerable:su in i?i[su]:r[su],writable:!1})}return ru(e,t,i)}:ru:function(e,t,i){if(qa(e),t=Up(t),qa(i),jI)try{return ru(e,t,i)}catch(r){}if("get"in i||"set"in i)throw new WI("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var nr=v((NM,jp)=>{"use strict";var zI=rt(),YI=Mi(),KI=Xr();jp.exports=zI?function(s,e,t){return YI.f(s,e,KI(1,t))}:function(s,e,t){return s[e]=t,s}});var Le=v((qM,Wp)=>{"use strict";var ss=Ae(),XI=Do(),JI=Bo(),ZI=Pe(),eE=Vp().f,tE=tu(),or=Li(),iE=ar(),ur=nr(),Qp=It();is();var rE=function(s){var e=function(t,i,r){if(this instanceof e){switch(arguments.length){case 0:return new s;case 1:return new s(t);case 2:return new s(t,i)}return new s(t,i,r)}return XI(s,this,arguments)};return e.prototype=s.prototype,e};Wp.exports=function(s,e){var t=s.target,i=s.global,r=s.stat,a=s.proto,n=i?ss:r?ss[t]:ss[t]&&ss[t].prototype,o=i?or:or[t]||ur(or,t,{})[t],u=o.prototype,l,c,d,f,p,h,b,S,g;for(f in e)l=tE(i?f:t+(r?".":"#")+f,s.forced),c=!l&&n&&Qp(n,f),h=o[f],c&&(s.dontCallGetSet?(g=eE(n,f),b=g&&g.value):b=n[f]),p=c&&b?b:e[f],!(!l&&!a&&typeof h==typeof p)&&(s.bind&&c?S=iE(p,ss):s.wrap&&c?S=rE(p):a&&ZI(p)?S=JI(p):S=p,(s.sham||p&&p.sham||h&&h.sham)&&ur(S,"sham",!0),ur(o,f,S),a&&(d=t+"Prototype",Qp(or,d)||ur(or,d,{}),ur(or[d],f,p),s.real&&u&&(l||!u[f])&&ur(u,f,p)))}});var Ua=v((UM,zp)=>{"use strict";var sE=Yo(),aE=Ko(),Gp=sE("keys");zp.exports=function(s){return Gp[s]||(Gp[s]=aE(s))}});var Kp=v((HM,Yp)=>{"use strict";var nE=Me();Yp.exports=!nE(function(){function s(){}return s.prototype.constructor=null,Object.getPrototypeOf(new s)!==s.prototype})});var Ha=v((jM,Jp)=>{"use strict";var oE=It(),uE=Pe(),lE=rr(),cE=Ua(),dE=Kp(),Xp=cE("IE_PROTO"),ou=Object,pE=ou.prototype;Jp.exports=dE?ou.getPrototypeOf:function(s){var e=lE(s);if(oE(e,Xp))return e[Xp];var t=e.constructor;return uE(t)&&e instanceof t?t.prototype:e instanceof ou?pE:null}});var eh=v((QM,Zp)=>{"use strict";var hE=Math.ceil,fE=Math.floor;Zp.exports=Math.trunc||function(e){var t=+e;return(t>0?fE:hE)(t)}});var as=v((WM,th)=>{"use strict";var mE=eh();th.exports=function(s){var e=+s;return e!==e||e===0?0:mE(e)}});var rh=v((GM,ih)=>{"use strict";var bE=as(),gE=Math.max,vE=Math.min;ih.exports=function(s,e){var t=bE(s);return t<0?gE(t+e,0):vE(t,e)}});var uu=v((zM,sh)=>{"use strict";var SE=as(),yE=Math.min;sh.exports=function(s){var e=SE(s);return e>0?yE(e,9007199254740991):0}});var lr=v((YM,ah)=>{"use strict";var TE=uu();ah.exports=function(s){return TE(s.length)}});var lu=v((KM,oh)=>{"use strict";var IE=ki(),EE=rh(),xE=lr(),nh=function(s){return function(e,t,i){var r=IE(e),a=xE(r);if(a===0)return!s&&-1;var n=EE(i,a),o;if(s&&t!==t){for(;a>n;)if(o=r[n++],o!==o)return!0}else for(;a>n;n++)if((s||n in r)&&r[n]===t)return s||n||0;return!s&&-1}};oh.exports={includes:nh(!0),indexOf:nh(!1)}});var ja=v((XM,uh)=>{"use strict";uh.exports={}});var dh=v((JM,ch)=>{"use strict";var wE=De(),cu=It(),AE=ki(),PE=lu().indexOf,RE=ja(),lh=wE([].push);ch.exports=function(s,e){var t=AE(s),i=0,r=[],a;for(a in t)!cu(RE,a)&&cu(t,a)&&lh(r,a);for(;e.length>i;)cu(t,a=e[i++])&&(~PE(r,a)||lh(r,a));return r}});var du=v((ZM,ph)=>{"use strict";ph.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var pu=v((eD,hh)=>{"use strict";var kE=dh(),LE=du();hh.exports=Object.keys||function(e){return kE(e,LE)}});var hu=v((tD,vh)=>{"use strict";var mh=rt(),$E=Me(),bh=De(),ME=Ha(),DE=pu(),CE=ki(),BE=_o().f,gh=bh(BE),VE=bh([].push),_E=mh&&$E(function(){var s=Object.create(null);return s[2]=2,!gh(s,2)}),fh=function(s){return function(e){for(var t=CE(e),i=DE(t),r=_E&&ME(t)===null,a=i.length,n=0,o=[],u;a>n;)u=i[n++],(!mh||(r?u in t:gh(t,u)))&&VE(o,s?[u,t[u]]:t[u]);return o}};vh.exports={entries:fh(!0),values:fh(!1)}});var Sh=v(()=>{"use strict";var OE=Le(),FE=hu().values;OE({target:"Object",stat:!0},{values:function(e){return FE(e)}})});var Th=v((sD,yh)=>{"use strict";Sh();var NE=Li();yh.exports=NE.Object.values});var Eh=v((aD,Ih)=>{"use strict";var qE=Th();Ih.exports=qE});var Di=v((nD,xh)=>{"use strict";var UE=Eh();xh.exports=UE});var ns=v((oD,wh)=>{"use strict";wh.exports=function(){}});var Ah=v(()=>{"use strict";var HE=Le(),jE=lu().includes,QE=Me(),WE=ns(),GE=QE(function(){return!Array(1).includes()});HE({target:"Array",proto:!0,forced:GE},{includes:function(e){return jE(this,e,arguments.length>1?arguments[1]:void 0)}});WE("includes")});var li=v((cD,Ph)=>{"use strict";var zE=Ht();Ph.exports=zE});var kh=v((dD,Rh)=>{"use strict";Ah();var YE=li();Rh.exports=YE("Array","includes")});var $h=v((pD,Lh)=>{"use strict";var KE=kh();Lh.exports=KE});var je=v((hD,Mh)=>{"use strict";var XE=$h();Mh.exports=XE});var Ch=v(()=>{"use strict";var ZE=Le(),ex=hu().entries;ZE({target:"Object",stat:!0},{entries:function(e){return ex(e)}})});var Vh=v((AD,Bh)=>{"use strict";Ch();var tx=Li();Bh.exports=tx.Object.entries});var Oh=v((PD,_h)=>{"use strict";var ix=Vh();_h.exports=ix});var cr=v((RD,Fh)=>{"use strict";var rx=Oh();Fh.exports=rx});var Ci=v((kD,Nh)=>{"use strict";Nh.exports={}});var Hh=v((LD,Uh)=>{"use strict";var sx=Ae(),ax=Pe(),qh=sx.WeakMap;Uh.exports=ax(qh)&&/native code/.test(String(qh))});var gu=v(($D,Wh)=>{"use strict";var nx=Hh(),Qh=Ae(),ox=Ge(),ux=nr(),fu=It(),mu=is(),lx=Ua(),cx=ja(),jh="Object already initialized",bu=Qh.TypeError,dx=Qh.WeakMap,Wa,os,Ga,px=function(s){return Ga(s)?os(s):Wa(s,{})},hx=function(s){return function(e){var t;if(!ox(e)||(t=os(e)).type!==s)throw new bu("Incompatible receiver, "+s+" required");return t}};nx||mu.state?(Et=mu.state||(mu.state=new dx),Et.get=Et.get,Et.has=Et.has,Et.set=Et.set,Wa=function(s,e){if(Et.has(s))throw new bu(jh);return e.facade=s,Et.set(s,e),e},os=function(s){return Et.get(s)||{}},Ga=function(s){return Et.has(s)}):(Bi=lx("state"),cx[Bi]=!0,Wa=function(s,e){if(fu(s,Bi))throw new bu(jh);return e.facade=s,ux(s,Bi,e),e},os=function(s){return fu(s,Bi)?s[Bi]:{}},Ga=function(s){return fu(s,Bi)});var Et,Bi;Wh.exports={set:Wa,get:os,has:Ga,enforce:px,getterFor:hx}});var yu=v((MD,zh)=>{"use strict";var vu=rt(),fx=It(),Gh=Function.prototype,mx=vu&&Object.getOwnPropertyDescriptor,Su=fx(Gh,"name"),bx=Su&&function(){}.name==="something",gx=Su&&(!vu||vu&&mx(Gh,"name").configurable);zh.exports={EXISTS:Su,PROPER:bx,CONFIGURABLE:gx}});var Kh=v(Yh=>{"use strict";var vx=rt(),Sx=iu(),yx=Mi(),Tx=Mt(),Ix=ki(),Ex=pu();Yh.f=vx&&!Sx?Object.defineProperties:function(e,t){Tx(e);for(var i=Ix(t),r=Ex(t),a=r.length,n=0,o;a>n;)yx.f(e,o=r[n++],i[o]);return e}});var Tu=v((CD,Xh)=>{"use strict";var xx=Ht();Xh.exports=xx("document","documentElement")});var wu=v((BD,af)=>{"use strict";var wx=Mt(),Ax=Kh(),Jh=du(),Px=ja(),Rx=Tu(),kx=Na(),Lx=Ua(),Zh=">",ef="<",Eu="prototype",xu="script",rf=Lx("IE_PROTO"),Iu=function(){},sf=function(s){return ef+xu+Zh+s+ef+"/"+xu+Zh},tf=function(s){s.write(sf("")),s.close();var e=s.parentWindow.Object;return s=null,e},$x=function(){var s=kx("iframe"),e="java"+xu+":",t;return s.style.display="none",Rx.appendChild(s),s.src=String(e),t=s.contentWindow.document,t.open(),t.write(sf("document.F=Object")),t.close(),t.F},za,Ya=function(){try{za=new ActiveXObject("htmlfile")}catch(e){}Ya=typeof document!="undefined"?document.domain&&za?tf(za):$x():tf(za);for(var s=Jh.length;s--;)delete Ya[Eu][Jh[s]];return Ya()};Px[rf]=!0;af.exports=Object.create||function(e,t){var i;return e!==null?(Iu[Eu]=wx(e),i=new Iu,Iu[Eu]=null,i[rf]=e):i=Ya(),t===void 0?i:Ax.f(i,t)}});var dr=v((VD,nf)=>{"use strict";var Mx=nr();nf.exports=function(s,e,t,i){return i&&i.enumerable?s[e]=t:Mx(s,e,t),s}});var ku=v((_D,lf)=>{"use strict";var Dx=Me(),Cx=Pe(),Bx=Ge(),Vx=wu(),of=Ha(),_x=dr(),Ox=Fe(),Fx=Tt(),Ru=Ox("iterator"),uf=!1,jt,Au,Pu;[].keys&&(Pu=[].keys(),"next"in Pu?(Au=of(of(Pu)),Au!==Object.prototype&&(jt=Au)):uf=!0);var Nx=!Bx(jt)||Dx(function(){var s={};return jt[Ru].call(s)!==s});Nx?jt={}:Fx&&(jt=Vx(jt));Cx(jt[Ru])||_x(jt,Ru,function(){return this});lf.exports={IteratorPrototype:jt,BUGGY_SAFARI_ITERATORS:uf}});var Ka=v((OD,df)=>{"use strict";var qx=Fe(),Ux=qx("toStringTag"),cf={};cf[Ux]="z";df.exports=String(cf)==="[object z]"});var us=v((FD,pf)=>{"use strict";var Hx=Ka(),jx=Pe(),Xa=Ri(),Qx=Fe(),Wx=Qx("toStringTag"),Gx=Object,zx=Xa(function(){return arguments}())==="Arguments",Yx=function(s,e){try{return s[e]}catch(t){}};pf.exports=Hx?Xa:function(s){var e,t,i;return s===void 0?"Undefined":s===null?"Null":typeof(t=Yx(e=Gx(s),Wx))=="string"?t:zx?Xa(e):(i=Xa(e))==="Object"&&jx(e.callee)?"Arguments":i}});var ff=v((ND,hf)=>{"use strict";var Kx=Ka(),Xx=us();hf.exports=Kx?{}.toString:function(){return"[object "+Xx(this)+"]"}});var ls=v((qD,bf)=>{"use strict";var Jx=Ka(),Zx=Mi().f,ew=nr(),tw=It(),iw=ff(),rw=Fe(),mf=rw("toStringTag");bf.exports=function(s,e,t,i){var r=t?s:s&&s.prototype;r&&(tw(r,mf)||Zx(r,mf,{configurable:!0,value:e}),i&&!Jx&&ew(r,"toString",iw))}});var vf=v((UD,gf)=>{"use strict";var sw=ku().IteratorPrototype,aw=wu(),nw=Xr(),ow=ls(),uw=Ci(),lw=function(){return this};gf.exports=function(s,e,t,i){var r=e+" Iterator";return s.prototype=aw(sw,{next:nw(+!i,t)}),ow(s,r,!1,!0),uw[r]=lw,s}});var yf=v((HD,Sf)=>{"use strict";var cw=De(),dw=$t();Sf.exports=function(s,e,t){try{return cw(dw(Object.getOwnPropertyDescriptor(s,e)[t]))}catch(i){}}});var If=v((jD,Tf)=>{"use strict";var pw=Ge();Tf.exports=function(s){return pw(s)||s===null}});var xf=v((QD,Ef)=>{"use strict";var hw=If(),fw=String,mw=TypeError;Ef.exports=function(s){if(hw(s))return s;throw new mw("Can't set "+fw(s)+" as a prototype")}});var Lu=v((WD,wf)=>{"use strict";var bw=yf(),gw=Ge(),vw=ui(),Sw=xf();wf.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var s=!1,e={},t;try{t=bw(Object.prototype,"__proto__","set"),t(e,[]),s=e instanceof Array}catch(i){}return function(r,a){return vw(r),Sw(a),gw(r)&&(s?t(r,a):r.__proto__=a),r}}():void 0)});var Vf=v((GD,Bf)=>{"use strict";var yw=Le(),Tw=st(),Ja=Tt(),Df=yu(),Iw=Pe(),Ew=vf(),Af=Ha(),Pf=Lu(),xw=ls(),ww=nr(),$u=dr(),Aw=Fe(),Rf=Ci(),Cf=ku(),Pw=Df.PROPER,Rw=Df.CONFIGURABLE,kf=Cf.IteratorPrototype,Za=Cf.BUGGY_SAFARI_ITERATORS,cs=Aw("iterator"),Lf="keys",ds="values",$f="entries",Mf=function(){return this};Bf.exports=function(s,e,t,i,r,a,n){Ew(t,e,i);var o=function(g){if(g===r&&f)return f;if(!Za&&g&&g in c)return c[g];switch(g){case Lf:return function(){return new t(this,g)};case ds:return function(){return new t(this,g)};case $f:return function(){return new t(this,g)}}return function(){return new t(this)}},u=e+" Iterator",l=!1,c=s.prototype,d=c[cs]||c["@@iterator"]||r&&c[r],f=!Za&&d||o(r),p=e==="Array"&&c.entries||d,h,b,S;if(p&&(h=Af(p.call(new s)),h!==Object.prototype&&h.next&&(!Ja&&Af(h)!==kf&&(Pf?Pf(h,kf):Iw(h[cs])||$u(h,cs,Mf)),xw(h,u,!0,!0),Ja&&(Rf[u]=Mf))),Pw&&r===ds&&d&&d.name!==ds&&(!Ja&&Rw?ww(c,"name",ds):(l=!0,f=function(){return Tw(d,this)})),r)if(b={values:o(ds),keys:a?f:o(Lf),entries:o($f)},n)for(S in b)(Za||l||!(S in c))&&$u(c,S,b[S]);else yw({target:e,proto:!0,forced:Za||l},b);return(!Ja||n)&&c[cs]!==f&&$u(c,cs,f,{name:r}),Rf[e]=f,b}});var Of=v((zD,_f)=>{"use strict";_f.exports=function(s,e){return{value:s,done:e}}});var Du=v((YD,Hf)=>{"use strict";var kw=ki(),Mu=ns(),Ff=Ci(),qf=gu(),Lw=Mi().f,$w=Vf(),en=Of(),Mw=Tt(),Dw=rt(),Uf="Array Iterator",Cw=qf.set,Bw=qf.getterFor(Uf);Hf.exports=$w(Array,"Array",function(s,e){Cw(this,{type:Uf,target:kw(s),index:0,kind:e})},function(){var s=Bw(this),e=s.target,t=s.index++;if(!e||t>=e.length)return s.target=null,en(void 0,!0);switch(s.kind){case"keys":return en(t,!1);case"values":return en(e[t],!1)}return en([t,e[t]],!1)},"values");var Nf=Ff.Arguments=Ff.Array;Mu("keys");Mu("values");Mu("entries");if(!Mw&&Dw&&Nf.name!=="values")try{Lw(Nf,"name",{value:"values"})}catch(s){}});var Qf=v((KD,jf)=>{"use strict";var Vw=Fe(),_w=Ci(),Ow=Vw("iterator"),Fw=Array.prototype;jf.exports=function(s){return s!==void 0&&(_w.Array===s||Fw[Ow]===s)}});var Cu=v((XD,Gf)=>{"use strict";var Nw=us(),Wf=ts(),qw=Jr(),Uw=Ci(),Hw=Fe(),jw=Hw("iterator");Gf.exports=function(s){if(!qw(s))return Wf(s,jw)||Wf(s,"@@iterator")||Uw[Nw(s)]}});var Yf=v((JD,zf)=>{"use strict";var Qw=st(),Ww=$t(),Gw=Mt(),zw=es(),Yw=Cu(),Kw=TypeError;zf.exports=function(s,e){var t=arguments.length<2?Yw(s):e;if(Ww(t))return Gw(Qw(t,s));throw new Kw(zw(s)+" is not iterable")}});var Jf=v((ZD,Xf)=>{"use strict";var Xw=st(),Kf=Mt(),Jw=ts();Xf.exports=function(s,e,t){var i,r;Kf(s);try{if(i=Jw(s,"return"),!i){if(e==="throw")throw t;return t}i=Xw(i,s)}catch(a){r=!0,i=a}if(e==="throw")throw t;if(r)throw i;return Kf(i),t}});var rn=v((eC,im)=>{"use strict";var Zw=ar(),eA=st(),tA=Mt(),iA=es(),rA=Qf(),sA=lr(),Zf=Zr(),aA=Yf(),nA=Cu(),em=Jf(),oA=TypeError,tn=function(s,e){this.stopped=s,this.result=e},tm=tn.prototype;im.exports=function(s,e,t){var i=t&&t.that,r=!!(t&&t.AS_ENTRIES),a=!!(t&&t.IS_RECORD),n=!!(t&&t.IS_ITERATOR),o=!!(t&&t.INTERRUPTED),u=Zw(e,i),l,c,d,f,p,h,b,S=function(y){return l&&em(l,"normal"),new tn(!0,y)},g=function(y){return r?(tA(y),o?u(y[0],y[1],S):u(y[0],y[1])):o?u(y,S):u(y)};if(a)l=s.iterator;else if(n)l=s;else{if(c=nA(s),!c)throw new oA(iA(s)+" is not iterable");if(rA(c)){for(d=0,f=sA(s);f>d;d++)if(p=g(s[d]),p&&Zf(tm,p))return p;return new tn(!1)}l=aA(s,c)}for(h=a?s.next:l.next;!(b=eA(h,l)).done;){try{p=g(b.value)}catch(y){em(l,"throw",y)}if(typeof p=="object"&&p&&Zf(tm,p))return p}return new tn(!1)}});var sm=v((tC,rm)=>{"use strict";var uA=rt(),lA=Mi(),cA=Xr();rm.exports=function(s,e,t){uA?lA.f(s,e,cA(0,t)):s[e]=t}});var am=v(()=>{"use strict";var dA=Le(),pA=rn(),hA=sm();dA({target:"Object",stat:!0},{fromEntries:function(e){var t={};return pA(e,function(i,r){hA(t,i,r)},{AS_ENTRIES:!0}),t}})});var om=v((sC,nm)=>{"use strict";Du();am();var fA=Li();nm.exports=fA.Object.fromEntries});var lm=v((aC,um)=>{"use strict";um.exports={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}});var dm=v(()=>{"use strict";Du();var mA=lm(),bA=Ae(),gA=ls(),cm=Ci();for(sn in mA)gA(bA[sn],sn),cm[sn]=cm.Array;var sn});var hm=v((uC,pm)=>{"use strict";var vA=om();dm();pm.exports=vA});var Bu=v((lC,fm)=>{"use strict";var SA=hm();fm.exports=SA});var mm=v(()=>{"use strict"});var Vu=v((pC,bm)=>{"use strict";var ps=Ae(),yA=$i(),TA=Ri(),an=function(s){return yA.slice(0,s.length)===s};bm.exports=function(){return an("Bun/")?"BUN":an("Cloudflare-Workers")?"CLOUDFLARE":an("Deno/")?"DENO":an("Node.js/")?"NODE":ps.Bun&&typeof Bun.version=="string"?"BUN":ps.Deno&&typeof Deno.version=="object"?"DENO":TA(ps.process)==="process"?"NODE":ps.window&&ps.document?"BROWSER":"REST"}()});var nn=v((hC,gm)=>{"use strict";var IA=Vu();gm.exports=IA==="NODE"});var Sm=v((fC,vm)=>{"use strict";var EA=Mi();vm.exports=function(s,e,t){return EA.f(s,e,t)}});var Im=v((mC,Tm)=>{"use strict";var xA=Ht(),wA=Sm(),AA=Fe(),PA=rt(),ym=AA("species");Tm.exports=function(s){var e=xA(s);PA&&e&&!e[ym]&&wA(e,ym,{configurable:!0,get:function(){return this}})}});var xm=v((bC,Em)=>{"use strict";var RA=Zr(),kA=TypeError;Em.exports=function(s,e){if(RA(e,s))return s;throw new kA("Incorrect invocation")}});var Ou=v((gC,wm)=>{"use strict";var LA=De(),$A=Pe(),_u=is(),MA=LA(Function.toString);$A(_u.inspectSource)||(_u.inspectSource=function(s){return MA(s)});wm.exports=_u.inspectSource});var Nu=v((vC,Lm)=>{"use strict";var DA=De(),CA=Me(),Am=Pe(),BA=us(),VA=Ht(),_A=Ou(),Pm=function(){},Rm=VA("Reflect","construct"),Fu=/^\s*(?:class|function)\b/,OA=DA(Fu.exec),FA=!Fu.test(Pm),hs=function(e){if(!Am(e))return!1;try{return Rm(Pm,[],e),!0}catch(t){return!1}},km=function(e){if(!Am(e))return!1;switch(BA(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return FA||!!OA(Fu,_A(e))}catch(t){return!0}};km.sham=!0;Lm.exports=!Rm||CA(function(){var s;return hs(hs.call)||!hs(Object)||!hs(function(){s=!0})||s})?km:hs});var Mm=v((SC,$m)=>{"use strict";var NA=Nu(),qA=es(),UA=TypeError;$m.exports=function(s){if(NA(s))return s;throw new UA(qA(s)+" is not a constructor")}});var qu=v((yC,Cm)=>{"use strict";var Dm=Mt(),HA=Mm(),jA=Jr(),QA=Fe(),WA=QA("species");Cm.exports=function(s,e){var t=Dm(s).constructor,i;return t===void 0||jA(i=Dm(t)[WA])?e:HA(i)}});var Vm=v((TC,Bm)=>{"use strict";var GA=De();Bm.exports=GA([].slice)});var Om=v((IC,_m)=>{"use strict";var zA=TypeError;_m.exports=function(s,e){if(s<e)throw new zA("Not enough arguments");return s}});var Uu=v((EC,Fm)=>{"use strict";var YA=$i();Fm.exports=/(?:ipad|iphone|ipod).*applewebkit/i.test(YA)});var Xu=v((xC,zm)=>{"use strict";var at=Ae(),KA=Do(),XA=ar(),Nm=Pe(),JA=It(),Gm=Me(),qm=Tu(),ZA=Vm(),Um=Na(),eP=Om(),tP=Uu(),iP=nn(),zu=at.setImmediate,Yu=at.clearImmediate,rP=at.process,Hu=at.Dispatch,sP=at.Function,Hm=at.MessageChannel,aP=at.String,ju=0,fs={},jm="onreadystatechange",ms,Vi,Qu,Wu;Gm(function(){ms=at.location});var Ku=function(s){if(JA(fs,s)){var e=fs[s];delete fs[s],e()}},Gu=function(s){return function(){Ku(s)}},Qm=function(s){Ku(s.data)},Wm=function(s){at.postMessage(aP(s),ms.protocol+"//"+ms.host)};(!zu||!Yu)&&(zu=function(e){eP(arguments.length,1);var t=Nm(e)?e:sP(e),i=ZA(arguments,1);return fs[++ju]=function(){KA(t,void 0,i)},Vi(ju),ju},Yu=function(e){delete fs[e]},iP?Vi=function(s){rP.nextTick(Gu(s))}:Hu&&Hu.now?Vi=function(s){Hu.now(Gu(s))}:Hm&&!tP?(Qu=new Hm,Wu=Qu.port2,Qu.port1.onmessage=Qm,Vi=XA(Wu.postMessage,Wu)):at.addEventListener&&Nm(at.postMessage)&&!at.importScripts&&ms&&ms.protocol!=="file:"&&!Gm(Wm)?(Vi=Wm,at.addEventListener("message",Qm,!1)):jm in Um("script")?Vi=function(s){qm.appendChild(Um("script"))[jm]=function(){qm.removeChild(this),Ku(s)}}:Vi=function(s){setTimeout(Gu(s),0)});zm.exports={set:zu,clear:Yu}});var Xm=v((wC,Km)=>{"use strict";var Ym=Ae(),nP=rt(),oP=Object.getOwnPropertyDescriptor;Km.exports=function(s){if(!nP)return Ym[s];var e=oP(Ym,s);return e&&e.value}});var Ju=v((AC,Zm)=>{"use strict";var Jm=function(){this.head=null,this.tail=null};Jm.prototype={add:function(s){var e={item:s,next:null},t=this.tail;t?t.next=e:this.head=e,this.tail=e},get:function(){var s=this.head;if(s){var e=this.head=s.next;return e===null&&(this.tail=null),s.item}}};Zm.exports=Jm});var tb=v((PC,eb)=>{"use strict";var uP=$i();eb.exports=/ipad|iphone|ipod/i.test(uP)&&typeof Pebble!="undefined"});var rb=v((RC,ib)=>{"use strict";var lP=$i();ib.exports=/web0s(?!.*chrome)/i.test(lP)});var cb=v((kC,lb)=>{"use strict";var hr=Ae(),cP=Xm(),sb=ar(),Zu=Xu().set,dP=Ju(),pP=Uu(),hP=tb(),fP=rb(),el=nn(),ab=hr.MutationObserver||hr.WebKitMutationObserver,nb=hr.document,ob=hr.process,on=hr.Promise,rl=cP("queueMicrotask"),pr,tl,il,un,ub;rl||(bs=new dP,gs=function(){var s,e;for(el&&(s=ob.domain)&&s.exit();e=bs.get();)try{e()}catch(t){throw bs.head&&pr(),t}s&&s.enter()},!pP&&!el&&!fP&&ab&&nb?(tl=!0,il=nb.createTextNode(""),new ab(gs).observe(il,{characterData:!0}),pr=function(){il.data=tl=!tl}):!hP&&on&&on.resolve?(un=on.resolve(void 0),un.constructor=on,ub=sb(un.then,un),pr=function(){ub(gs)}):el?pr=function(){ob.nextTick(gs)}:(Zu=sb(Zu,hr),pr=function(){Zu(gs)}),rl=function(s){bs.head||pr(),bs.add(s)});var bs,gs;lb.exports=rl});var pb=v((LC,db)=>{"use strict";db.exports=function(s,e){try{arguments.length===1?console.error(s):console.error(s,e)}catch(t){}}});var ln=v(($C,hb)=>{"use strict";hb.exports=function(s){try{return{error:!1,value:s()}}catch(e){return{error:!0,value:e}}}});var _i=v((MC,fb)=>{"use strict";var mP=Ae();fb.exports=mP.Promise});var fr=v((DC,vb)=>{"use strict";var bP=Ae(),vs=_i(),gP=Pe(),vP=tu(),SP=Ou(),yP=Fe(),mb=Vu(),TP=Tt(),sl=Uo(),bb=vs&&vs.prototype,IP=yP("species"),al=!1,gb=gP(bP.PromiseRejectionEvent),EP=vP("Promise",function(){var s=SP(vs),e=s!==String(vs);if(!e&&sl===66||TP&&!(bb.catch&&bb.finally))return!0;if(!sl||sl<51||!/native code/.test(s)){var t=new vs(function(a){a(1)}),i=function(a){a(function(){},function(){})},r=t.constructor={};if(r[IP]=i,al=t.then(function(){})instanceof i,!al)return!0}return!e&&(mb==="BROWSER"||mb==="DENO")&&!gb});vb.exports={CONSTRUCTOR:EP,REJECTION_EVENT:gb,SUBCLASSING:al}});var mr=v((CC,yb)=>{"use strict";var Sb=$t(),xP=TypeError,wP=function(s){var e,t;this.promise=new s(function(i,r){if(e!==void 0||t!==void 0)throw new xP("Bad Promise constructor");e=i,t=r}),this.resolve=Sb(e),this.reject=Sb(t)};yb.exports.f=function(s){return new wP(s)}});var Nb=v(()=>{"use strict";var AP=Le(),PP=Tt(),hn=nn(),ci=Ae(),RP=Li(),Sr=st(),Tb=dr(),Ib=Lu(),kP=ls(),LP=Im(),$P=$t(),pn=Pe(),MP=Ge(),DP=xm(),CP=qu(),Pb=Xu().set,cl=cb(),BP=pb(),VP=ln(),_P=Ju(),Rb=gu(),fn=_i(),dl=fr(),kb=mr(),mn="Promise",Lb=dl.CONSTRUCTOR,OP=dl.REJECTION_EVENT,FP=dl.SUBCLASSING,nl=Rb.getterFor(mn),NP=Rb.set,br=fn&&fn.prototype,Oi=fn,cn=br,$b=ci.TypeError,ol=ci.document,pl=ci.process,ul=kb.f,qP=ul,UP=!!(ol&&ol.createEvent&&ci.dispatchEvent),Mb="unhandledrejection",HP="rejectionhandled",Eb=0,Db=1,jP=2,hl=1,Cb=2,dn,xb,Bb,wb,Vb=function(s){var e;return MP(s)&&pn(e=s.then)?e:!1},_b=function(s,e){var t=e.value,i=e.state===Db,r=i?s.ok:s.fail,a=s.resolve,n=s.reject,o=s.domain,u,l,c;try{r?(i||(e.rejection===Cb&&WP(e),e.rejection=hl),r===!0?u=t:(o&&o.enter(),u=r(t),o&&(o.exit(),c=!0)),u===s.promise?n(new $b("Promise-chain cycle")):(l=Vb(u))?Sr(l,u,a,n):a(u)):n(t)}catch(d){o&&!c&&o.exit(),n(d)}},Ob=function(s,e){s.notified||(s.notified=!0,cl(function(){for(var t=s.reactions,i;i=t.get();)_b(i,s);s.notified=!1,e&&!s.rejection&&QP(s)}))},Fb=function(s,e,t){var i,r;UP?(i=ol.createEvent("Event"),i.promise=e,i.reason=t,i.initEvent(s,!1,!0),ci.dispatchEvent(i)):i={promise:e,reason:t},!OP&&(r=ci["on"+s])?r(i):s===Mb&&BP("Unhandled promise rejection",t)},QP=function(s){Sr(Pb,ci,function(){var e=s.facade,t=s.value,i=Ab(s),r;if(i&&(r=VP(function(){hn?pl.emit("unhandledRejection",t,e):Fb(Mb,e,t)}),s.rejection=hn||Ab(s)?Cb:hl,r.error))throw r.value})},Ab=function(s){return s.rejection!==hl&&!s.parent},WP=function(s){Sr(Pb,ci,function(){var e=s.facade;hn?pl.emit("rejectionHandled",e):Fb(HP,e,s.value)})},gr=function(s,e,t){return function(i){s(e,i,t)}},vr=function(s,e,t){s.done||(s.done=!0,t&&(s=t),s.value=e,s.state=jP,Ob(s,!0))},ll=function(s,e,t){if(!s.done){s.done=!0,t&&(s=t);try{if(s.facade===e)throw new $b("Promise can't be resolved itself");var i=Vb(e);i?cl(function(){var r={done:!1};try{Sr(i,e,gr(ll,r,s),gr(vr,r,s))}catch(a){vr(r,a,s)}}):(s.value=e,s.state=Db,Ob(s,!1))}catch(r){vr({done:!1},r,s)}}};if(Lb&&(Oi=function(e){DP(this,cn),$P(e),Sr(dn,this);var t=nl(this);try{e(gr(ll,t),gr(vr,t))}catch(i){vr(t,i)}},cn=Oi.prototype,dn=function(e){NP(this,{type:mn,done:!1,notified:!1,parent:!1,reactions:new _P,rejection:!1,state:Eb,value:null})},dn.prototype=Tb(cn,"then",function(e,t){var i=nl(this),r=ul(CP(this,Oi));return i.parent=!0,r.ok=pn(e)?e:!0,r.fail=pn(t)&&t,r.domain=hn?pl.domain:void 0,i.state===Eb?i.reactions.add(r):cl(function(){_b(r,i)}),r.promise}),xb=function(){var s=new dn,e=nl(s);this.promise=s,this.resolve=gr(ll,e),this.reject=gr(vr,e)},kb.f=ul=function(s){return s===Oi||s===Bb?new xb(s):qP(s)},!PP&&pn(fn)&&br!==Object.prototype)){wb=br.then,FP||Tb(br,"then",function(e,t){var i=this;return new Oi(function(r,a){Sr(wb,i,r,a)}).then(e,t)},{unsafe:!0});try{delete br.constructor}catch(s){}Ib&&Ib(br,cn)}AP({global:!0,constructor:!0,wrap:!0,forced:Lb},{Promise:Oi});Bb=RP.Promise;kP(Oi,mn,!1,!0);LP(mn)});var Qb=v((_C,jb)=>{"use strict";var GP=Fe(),Ub=GP("iterator"),Hb=!1;try{qb=0,fl={next:function(){return{done:!!qb++}},return:function(){Hb=!0}},fl[Ub]=function(){return this},Array.from(fl,function(){throw 2})}catch(s){}var qb,fl;jb.exports=function(s,e){try{if(!e&&!Hb)return!1}catch(r){return!1}var t=!1;try{var i={};i[Ub]=function(){return{next:function(){return{done:t=!0}}}},s(i)}catch(r){}return t}});var ml=v((OC,Wb)=>{"use strict";var zP=_i(),YP=Qb(),KP=fr().CONSTRUCTOR;Wb.exports=KP||!YP(function(s){zP.all(s).then(void 0,function(){})})});var Gb=v(()=>{"use strict";var XP=Le(),JP=st(),ZP=$t(),eR=mr(),tR=ln(),iR=rn(),rR=ml();XP({target:"Promise",stat:!0,forced:rR},{all:function(e){var t=this,i=eR.f(t),r=i.resolve,a=i.reject,n=tR(function(){var o=ZP(t.resolve),u=[],l=0,c=1;iR(e,function(d){var f=l++,p=!1;c++,JP(o,t,d).then(function(h){p||(p=!0,u[f]=h,--c||r(u))},a)}),--c||r(u)});return n.error&&a(n.value),i.promise}})});var Yb=v(()=>{"use strict";var sR=Le(),aR=Tt(),nR=fr().CONSTRUCTOR,gl=_i(),oR=Ht(),uR=Pe(),lR=dr(),zb=gl&&gl.prototype;sR({target:"Promise",proto:!0,forced:nR,real:!0},{catch:function(s){return this.then(void 0,s)}});!aR&&uR(gl)&&(bl=oR("Promise").prototype.catch,zb.catch!==bl&&lR(zb,"catch",bl,{unsafe:!0}));var bl});var Kb=v(()=>{"use strict";var cR=Le(),dR=st(),pR=$t(),hR=mr(),fR=ln(),mR=rn(),bR=ml();cR({target:"Promise",stat:!0,forced:bR},{race:function(e){var t=this,i=hR.f(t),r=i.reject,a=fR(function(){var n=pR(t.resolve);mR(e,function(o){dR(n,t,o).then(i.resolve,r)})});return a.error&&r(a.value),i.promise}})});var Xb=v(()=>{"use strict";var gR=Le(),vR=mr(),SR=fr().CONSTRUCTOR;gR({target:"Promise",stat:!0,forced:SR},{reject:function(e){var t=vR.f(this),i=t.reject;return i(e),t.promise}})});var vl=v((GC,Jb)=>{"use strict";var yR=Mt(),TR=Ge(),IR=mr();Jb.exports=function(s,e){if(yR(s),TR(e)&&e.constructor===s)return e;var t=IR.f(s),i=t.resolve;return i(e),t.promise}});var tg=v(()=>{"use strict";var ER=Le(),xR=Ht(),Zb=Tt(),wR=_i(),eg=fr().CONSTRUCTOR,AR=vl(),PR=xR("Promise"),RR=Zb&&!eg;ER({target:"Promise",stat:!0,forced:Zb||eg},{resolve:function(e){return AR(RR&&this===PR?wR:this,e)}})});var ig=v(()=>{"use strict";Nb();Gb();Yb();Kb();Xb();tg()});var ng=v(()=>{"use strict";var kR=Le(),LR=Tt(),bn=_i(),$R=Me(),sg=Ht(),ag=Pe(),MR=qu(),rg=vl(),DR=dr(),yl=bn&&bn.prototype,CR=!!bn&&$R(function(){yl.finally.call({then:function(){}},function(){})});kR({target:"Promise",proto:!0,real:!0,forced:CR},{finally:function(s){var e=MR(this,sg("Promise")),t=ag(s);return this.then(t?function(i){return rg(e,s()).then(function(){return i})}:s,t?function(i){return rg(e,s()).then(function(){throw i})}:s)}});!LR&&ag(bn)&&(Sl=sg("Promise").prototype.finally,yl.finally!==Sl&&DR(yl,"finally",Sl,{unsafe:!0}));var Sl});var ug=v((eB,og)=>{"use strict";mm();ig();ng();var BR=li();og.exports=BR("Promise","finally")});var cg=v((tB,lg)=>{"use strict";var VR=ug();lg.exports=VR});var gn=v((iB,dg)=>{"use strict";var _R=cg();dg.exports=_R});var Pg=v(()=>{"use strict";var XR=Le(),JR=rr(),ZR=lr(),ek=as(),tk=ns();XR({target:"Array",proto:!0},{at:function(e){var t=JR(this),i=ZR(t),r=ek(e),a=r>=0?r:i+r;return a<0||a>=i?void 0:t[a]}});tk("at")});var kg=v((O0,Rg)=>{"use strict";Pg();var ik=li();Rg.exports=ik("Array","at")});var $g=v((F0,Lg)=>{"use strict";var rk=kg();Lg.exports=rk});var xt=v((N0,Mg)=>{"use strict";var sk=$g();Mg.exports=sk});var Ul=v((E_,iv)=>{"use strict";var mk=Ri();iv.exports=Array.isArray||function(e){return mk(e)==="Array"}});var sv=v((x_,rv)=>{"use strict";var bk=TypeError,gk=9007199254740991;rv.exports=function(s){if(s>gk)throw bk("Maximum allowed index exceeded");return s}});var ov=v((w_,nv)=>{"use strict";var vk=Ul(),Sk=lr(),yk=sv(),Tk=ar(),av=function(s,e,t,i,r,a,n,o){for(var u=r,l=0,c=n?Tk(n,o):!1,d,f;l<i;)l in t&&(d=c?c(t[l],l,e):t[l],a>0&&vk(d)?(f=Sk(d),u=av(s,e,d,f,u,a-1)-1):(yk(u+1),s[u]=d),u++),l++;return u};nv.exports=av});var dv=v((A_,cv)=>{"use strict";var uv=Ul(),Ik=Nu(),Ek=Ge(),xk=Fe(),wk=xk("species"),lv=Array;cv.exports=function(s){var e;return uv(s)&&(e=s.constructor,Ik(e)&&(e===lv||uv(e.prototype))?e=void 0:Ek(e)&&(e=e[wk],e===null&&(e=void 0))),e===void 0?lv:e}});var hv=v((P_,pv)=>{"use strict";var Ak=dv();pv.exports=function(s,e){return new(Ak(s))(e===0?0:e)}});var fv=v(()=>{"use strict";var Pk=Le(),Rk=ov(),kk=$t(),Lk=rr(),$k=lr(),Mk=hv();Pk({target:"Array",proto:!0},{flatMap:function(e){var t=Lk(this),i=$k(t),r;return kk(e),r=Mk(t,0),r.length=Rk(r,t,t,i,0,1,e,arguments.length>1?arguments[1]:void 0),r}})});var mv=v(()=>{"use strict";var Dk=ns();Dk("flatMap")});var gv=v((M_,bv)=>{"use strict";fv();mv();var Ck=li();bv.exports=Ck("Array","flatMap")});var Sv=v((D_,vv)=>{"use strict";var Bk=gv();vv.exports=Bk});var Ls=v((C_,yv)=>{"use strict";var Vk=Sv();yv.exports=Vk});var $s=v((B_,Tv)=>{"use strict";var _k=us(),Ok=String;Tv.exports=function(s){if(_k(s)==="Symbol")throw new TypeError("Cannot convert a Symbol value to a string");return Ok(s)}});var Hl=v((V_,Iv)=>{"use strict";Iv.exports=`
7
+ \v\f\r \xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF`});var wv=v((__,xv)=>{"use strict";var Fk=De(),Nk=ui(),qk=$s(),Ql=Hl(),Ev=Fk("".replace),Uk=RegExp("^["+Ql+"]+"),Hk=RegExp("(^|[^"+Ql+"])["+Ql+"]+$"),jl=function(s){return function(e){var t=qk(Nk(e));return s&1&&(t=Ev(t,Uk,"")),s&2&&(t=Ev(t,Hk,"$1")),t}};xv.exports={start:jl(1),end:jl(2),trim:jl(3)}});var kv=v((O_,Rv)=>{"use strict";var jk=yu().PROPER,Qk=Me(),Av=Hl(),Pv="\u200B\x85\u180E";Rv.exports=function(s){return Qk(function(){return!!Av[s]()||Pv[s]()!==Pv||jk&&Av[s].name!==s})}});var Wl=v((F_,Lv)=>{"use strict";var Wk=wv().start,Gk=kv();Lv.exports=Gk("trimStart")?function(){return Wk(this)}:"".trimStart});var Mv=v(()=>{"use strict";var zk=Le(),$v=Wl();zk({target:"String",proto:!0,name:"trimStart",forced:"".trimLeft!==$v},{trimLeft:$v})});var Cv=v(()=>{"use strict";Mv();var Yk=Le(),Dv=Wl();Yk({target:"String",proto:!0,name:"trimStart",forced:"".trimStart!==Dv},{trimStart:Dv})});var Vv=v((j_,Bv)=>{"use strict";Cv();var Kk=li();Bv.exports=Kk("String","trimLeft")});var Ov=v((Q_,_v)=>{"use strict";var Xk=Vv();_v.exports=Xk});var Nv=v((W_,Fv)=>{"use strict";var Jk=Ov();Fv.exports=Jk});var tS=v(()=>{"use strict"});var iS=v(()=>{"use strict"});var sS=v((LN,rS)=>{"use strict";var vL=Ge(),SL=Ri(),yL=Fe(),TL=yL("match");rS.exports=function(s){var e;return vL(s)&&((e=s[TL])!==void 0?!!e:SL(s)==="RegExp")}});var oS=v(($N,nS)=>{"use strict";var IL=Ae(),EL=Me(),aS=IL.RegExp,xL=!EL(function(){var s=!0;try{aS(".","d")}catch(u){s=!1}var e={},t="",i=s?"dgimsy":"gimsy",r=function(u,l){Object.defineProperty(e,u,{get:function(){return t+=l,!0}})},a={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};s&&(a.hasIndices="d");for(var n in a)r(n,a[n]);var o=Object.getOwnPropertyDescriptor(aS.prototype,"flags").get.call(e);return o!==i||t!==i});nS.exports={correct:xL}});var lS=v((MN,uS)=>{"use strict";var wL=Mt();uS.exports=function(){var s=wL(this),e="";return s.hasIndices&&(e+="d"),s.global&&(e+="g"),s.ignoreCase&&(e+="i"),s.multiline&&(e+="m"),s.dotAll&&(e+="s"),s.unicode&&(e+="u"),s.unicodeSets&&(e+="v"),s.sticky&&(e+="y"),e}});var pS=v((DN,dS)=>{"use strict";var AL=st(),PL=It(),RL=Zr(),cS=oS(),kL=lS(),LL=RegExp.prototype;dS.exports=cS.correct?function(s){return s.flags}:function(s){return!cS.correct&&RL(LL,s)&&!PL(s,"flags")?AL(kL,s):s.flags}});var fS=v((CN,hS)=>{"use strict";var Kl=De(),$L=rr(),ML=Math.floor,zl=Kl("".charAt),DL=Kl("".replace),Yl=Kl("".slice),CL=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,BL=/\$([$&'`]|\d{1,2})/g;hS.exports=function(s,e,t,i,r,a){var n=t+s.length,o=i.length,u=BL;return r!==void 0&&(r=$L(r),u=CL),DL(a,u,function(l,c){var d;switch(zl(c,0)){case"$":return"$";case"&":return s;case"`":return Yl(e,0,t);case"'":return Yl(e,n);case"<":d=r[Yl(c,1,-1)];break;default:var f=+c;if(f===0)return l;if(f>o){var p=ML(f/10);return p===0?l:p<=o?i[p-1]===void 0?zl(c,1):i[p-1]+zl(c,1):l}d=i[f-1]}return d===void 0?"":d})}});var gS=v(()=>{"use strict";var VL=Le(),_L=st(),Jl=De(),mS=ui(),OL=Pe(),FL=Ge(),NL=sS(),$r=$s(),qL=ts(),UL=pS(),HL=fS(),jL=Fe(),QL=Tt(),WL=jL("replace"),GL=TypeError,Xl=Jl("".indexOf),zL=Jl("".replace),bS=Jl("".slice),YL=Math.max;VL({target:"String",proto:!0},{replaceAll:function(e,t){var i=mS(this),r,a,n,o,u,l,c,d,f,p,h=0,b="";if(FL(e)){if(r=NL(e),r&&(a=$r(mS(UL(e))),!~Xl(a,"g")))throw new GL("`.replaceAll` does not allow non-global regexes");if(n=qL(e,WL),n)return _L(n,e,i,t);if(QL&&r)return zL($r(i),e,t)}for(o=$r(i),u=$r(e),l=OL(t),l||(t=$r(t)),c=u.length,d=YL(1,c),f=Xl(o,u);f!==-1;)p=l?$r(t(u,f,o)):HL(u,o,f,[],void 0,t),b+=bS(o,h,f)+p,h=f+c,f=f+d>o.length?-1:Xl(o,u,f+d);return h<o.length&&(b+=bS(o,h)),b}})});var SS=v((_N,vS)=>{"use strict";tS();iS();gS();var KL=li();vS.exports=KL("String","replaceAll")});var TS=v((ON,yS)=>{"use strict";var XL=SS();yS.exports=XL});var ES=v((FN,IS)=>{"use strict";var JL=TS();IS.exports=JL});var wS=v((NN,xS)=>{"use strict";var ZL=as(),e$=$s(),t$=ui(),i$=RangeError;xS.exports=function(e){var t=e$(t$(this)),i="",r=ZL(e);if(r<0||r===1/0)throw new i$("Wrong number of repetitions");for(;r>0;(r>>>=1)&&(t+=t))r&1&&(i+=t);return i}});var LS=v((qN,kS)=>{"use strict";var RS=De(),r$=uu(),AS=$s(),s$=wS(),a$=ui(),n$=RS(s$),o$=RS("".slice),u$=Math.ceil,PS=function(s){return function(e,t,i){var r=AS(a$(e)),a=r$(t),n=r.length,o=i===void 0?" ":AS(i),u,l;return a<=n||o===""?r:(u=a-n,l=n$(o,u$(u/o.length)),l.length>u&&(l=o$(l,0,u)),s?r+l:l+r)}};kS.exports={start:PS(!1),end:PS(!0)}});var MS=v((UN,$S)=>{"use strict";var l$=$i();$S.exports=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(l$)});var DS=v(()=>{"use strict";var c$=Le(),d$=LS().start,p$=MS();c$({target:"String",proto:!0,forced:p$},{padStart:function(e){return d$(this,e,arguments.length>1?arguments[1]:void 0)}})});var BS=v((QN,CS)=>{"use strict";DS();var h$=li();CS.exports=h$("String","padStart")});var _S=v((WN,VS)=>{"use strict";var f$=BS();VS.exports=f$});var FS=v((GN,OS)=>{"use strict";var m$=_S();OS.exports=m$});var j$={};iT(j$,{ChromecastState:()=>Gr,HttpConnectionType:()=>Va,Observable:()=>Nt.Observable,PlaybackState:()=>He,Player:()=>Ta,PredefinedQualityLimits:()=>zr,SDK_VERSION:()=>H$,Subject:()=>Nt.Subject,Subscription:()=>Nt.Subscription,Surface:()=>_a,VERSION:()=>$o,ValueSubject:()=>Nt.ValueSubject,VideoFormat:()=>Lt,VideoQuality:()=>Nt.VideoQuality,areValidLiveRecordSources:()=>Sg,clientChecker:()=>K,isMobile:()=>yr});module.exports=rT(j$);var $o="2.0.140-dev.26e4b860.0";var He=(r=>(r.STOPPED="stopped",r.READY="ready",r.PLAYING="playing",r.PAUSED="paused",r))(He||{}),Lt=(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",E))(Lt||{});var Gr=(r=>(r.NOT_AVAILABLE="NOT_AVAILABLE",r.AVAILABLE="AVAILABLE",r.CONNECTING="CONNECTING",r.CONNECTED="CONNECTED",r))(Gr||{}),Va=(i=>(i.HTTP1="http1",i.HTTP2="http2",i.QUIC="quic",i))(Va||{});var _a=(n=>(n.NONE="none",n.INLINE="inline",n.FULLSCREEN="fullscreen",n.SECOND_SCREEN="second_screen",n.PIP="pip",n.INVISIBLE="invisible",n))(_a||{}),zr=(i=>(i.TRAFFIC_SAVING="traffic_saving",i.HIGH_QUALITY="high_quality",i.UNKNOWN="unknown",i))(zr||{});var kc=Y(Di(),1),qy=Y(je(),1);var ae=require("@vkontakte/videoplayer-shared/es2015");var Dh=s=>new Promise((e,t)=>{let i=document.createElement("script");i.setAttribute("src",s),i.onload=()=>e(),i.onerror=r=>t(r),document.body.appendChild(i)});var Qa=class{constructor(e){this.connection$=new ae.ValueSubject(void 0);this.castState$=new ae.ValueSubject("NOT_AVAILABLE");this.errorEvent$=new ae.Subject;this.realCastState$=new ae.ValueSubject("NOT_AVAILABLE");this.subscription=new ae.Subscription;this.isDestroyed=!1;var a;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 i=(0,ae.isNonNullable)((a=window.chrome)==null?void 0:a.cast),r=!!window.__onGCastApiAvailable;i?this.initializeCastApi():(window.__onGCastApiAvailable=n=>{delete window.__onGCastApiAvailable,n&&!this.isDestroyed&&this.initializeCastApi()},r||Dh("https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1").catch(()=>this.errorEvent$.next({id:"ChromecastLoading",category:ae.ErrorCategory.NETWORK,message:"Script loading failed!"})))}connect(){var e;(e=cast.framework.CastContext.getInstance())==null||e.requestSession()}disconnect(){var e,t;(t=(e=cast.framework.CastContext.getInstance())==null?void 0:e.getCurrentSession())==null||t.endSession(!0)}stopMedia(){return new Promise((e,t)=>{var i,r,a;(a=(r=(i=cast.framework.CastContext.getInstance())==null?void 0:i.getCurrentSession())==null?void 0:r.getMediaSession())==null||a.stop(new chrome.cast.media.StopRequest,e,t)})}toggleConnection(){(0,ae.isNonNullable)(this.connection$.getValue())?this.disconnect():this.connect()}setVolume(e){let t=this.connection$.getValue();(0,ae.isNullable)(t)||(t.remotePlayer.volumeLevel=e,t.remotePlayerController.setVolumeLevel())}setMuted(e){let t=this.connection$.getValue();(0,ae.isNullable)(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),i=cast.framework.CastContext.getInstance();this.subscription.add((0,ae.fromEvent)(i,cast.framework.CastContextEventType.SESSION_STATE_CHANGED).subscribe(r=>{var a,n,o;switch(r.sessionState){case cast.framework.SessionState.SESSION_STARTED:case cast.framework.SessionState.SESSION_STARTING:case cast.framework.SessionState.SESSION_RESUMED:this.contentId=(o=(n=(a=i.getCurrentSession())==null?void 0:a.getMediaSession())==null?void 0:n.media)==null?void 0:o.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(0,ae.assertNever)(r.sessionState)}})).add((0,ae.merge)((0,ae.fromEvent)(i,cast.framework.CastContextEventType.CAST_STATE_CHANGED).pipe((0,ae.tap)(r=>{this.log({message:`[cast.framework.RemotePlayerEventType.CAST_STATE_CHANGED]: ${JSON.stringify(r)}`})}),(0,ae.map)(r=>r.castState)),(0,ae.observableFrom)([i.getCastState()])).pipe((0,ae.filterChanged)(),(0,ae.map)(JE),(0,ae.tap)(r=>{this.log({message:`realCastState$: ${r}`})})).subscribe(this.realCastState$)).add(this.realCastState$.subscribe(r=>{var o,u;let a=r==="CONNECTED",n=(0,ae.isNonNullable)(this.connection$.getValue());if(a&&!n){let l=i.getCurrentSession();(0,ae.assertNonNullable)(l);let c=l.getCastDevice(),d=(u=(o=l.getMediaSession())==null?void 0:o.media)==null?void 0:u.contentId;((0,ae.isNullable)(d)||d===this.contentId)&&(this.log({message:"connection created"}),this.connection$.next({remotePlayer:e,remotePlayerController:t,session:l,castDevice:c}))}else!a&&n&&(this.log({message:"connection destroyed"}),this.connection$.next(void 0));this.castState$.next(r==="CONNECTED"?(0,ae.isNonNullable)(this.connection$.getValue())?"CONNECTED":"AVAILABLE":r)}))}initializeCastApi(){var r;let e,t,i;try{e=cast.framework.CastContext.getInstance(),t=chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,i=chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}catch(a){return}try{e.setOptions({receiverApplicationId:(r=this.params.receiverApplicationId)!=null?r:t,autoJoinPolicy:i}),this.initListeners()}catch(a){this.errorEvent$.next({id:"ChromecastInitializer",category:ae.ErrorCategory.EXTERNAL_API,message:"[initializeCastApi] failed",thrown:a})}}},JE=s=>{switch(s){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(0,ae.assertNever)(s)}};var Ac=Y(je(),1),Ry=Y(cr(),1),ky=Y(Bu(),1);var Tg=Y(gn(),1);var Tl=require("@vkontakte/videoplayer-shared/es2015");var Re=(s,e=0,t=0)=>{switch(t){case 0:return s.replace("_offset_p",e===0?"":"_"+e.toFixed(0));case 1:{if(e===0)return s;let i=new URL(s);return i.searchParams.append("playback_shift",e.toFixed(0)),i.toString()}case 2:{let i=new URL(s);return!i.searchParams.get("offset_p")&&e===0?s:(i.searchParams.set("offset_p",e.toFixed(0)),i.toString())}default:(0,Tl.assertNever)(t)}return s},di=(s,e)=>{var t;switch(e){case 0:return NaN;case 1:{let i=new URL(s);return Number(i.searchParams.get("playback_shift"))}case 2:{let i=new URL(s);return Number((t=i.searchParams.get("offset_p"))!=null?t:0)}default:(0,Tl.assertNever)(e)}};var N=(s,e,t=!1)=>{let i=s.getTransition();(t||!i||i.to===e)&&s.setState(e)};var Dt=require("@vkontakte/videoplayer-shared/es2015"),ne=class{constructor(e){this.transitionStarted$=new Dt.Subject;this.transitionEnded$=new Dt.Subject;this.transitionUpdated$=new Dt.Subject;this.forceChanged$=new Dt.Subject;this.stateChangeStarted$=(0,Dt.merge)(this.transitionStarted$,this.transitionUpdated$);this.stateChangeEnded$=(0,Dt.merge)(this.transitionEnded$,this.forceChanged$);this.state=e,this.prevState=void 0}setState(e){let t=this.transition,i=this.state;this.transition=void 0,this.prevState=i,this.state=e,t?t.to===e?this.transitionEnded$.next(t):this.forceChanged$.next({from:t.from,to:e,canceledTransition:t}):this.forceChanged$.next({from:i,to:e,canceledTransition:t})}startTransitionTo(e){let t=this.transition,i=this.state;i===e||(0,Dt.isNonNullable)(t)&&t.to===e||(this.prevState=i,this.state=e,t?(this.transition={from:t.from,to:e,canceledTransition:t},this.transitionUpdated$.next(this.transition)):(this.transition={from:i,to:e},this.transitionStarted$.next(this.transition)))}getTransition(){return this.transition}getState(){return this.state}getPrevState(){return this.prevState}};var El=require("@vkontakte/videoplayer-shared/es2015");var vn=class{constructor(){this._isMiuiBrowser=!1}get current(){return this._current}get isChrome(){return this.current==="Chrome"}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,i=/samsungbrowser/i.test(e)?"SamsungBrowser":void 0,r=/chrome|crios/i.test(e)?"Chrome":void 0,a=/chromium/i.test(e)?"Chromium":void 0,n=/firefox|fxios/i.test(e)?"Firefox":void 0,o=/webkit|safari|khtml/i.test(e)?"Safari":void 0,u=/opr\//i.test(e)?"Opera":void 0,l=/edg/i.test(e)?"Edge":void 0;this._isMiuiBrowser=/(XiaoMi)|(MiuiBrowser)/i.test(e),this._current=t||i||n||u||l||r||a||o||"Rest"}catch(t){console.error(t)}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}=window.navigator,i=t.match(e);if(!i)return;let r=i[1],a=parseInt(r,10);if(!isNaN(a))return this._current_version=a,a}catch(t){console.error(t)}}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 pg=Y(je(),1);var yr=()=>{var s,e;return/Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test((s=navigator.appVersion)!=null?s:navigator.userAgent)||((e=navigator==null?void 0:navigator.userAgentData)==null?void 0:e.mobile)};var Sn=class{constructor(e){this._highEntropyValues={};this._displayChecker=e}get current(){return this._current}get isIOS(){let e=["iPhone","iPad","iPod"];return this._highEntropyValues.platform==="iOS"||(0,pg.default)(e,this.current)}get isMac(){return this._highEntropyValues.platform==="macOS"||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"||this.current==="Android"}get isMobile(){return this._highEntropyValues.mobile||this._isMobile}get iOSVersion(){return this._iosVersion}detect(){let{userAgent:e}=navigator;try{this._isMobile=yr()}catch(t){console.error(t)}this.detectDevice(e),this.detectHighEntropyValues(),this.isIOS&&this.detectIOSVersion()}detectHighEntropyValues(){return R(this,null,function*(){let{userAgentData:e}=navigator;if(e!=null&&e.getHighEntropyValues){let t=yield e.getHighEntropyValues(["architecture","bitness","brands","mobile","platform","formFactor","model","platformVersion","wow64"]);this._highEntropyValues=t}})}detectDevice(e){try{let t=/android/i.test(e)?"Android":void 0,i=/iphone/i.test(e)?"iPhone":void 0,r=/ipad/i.test(e)?"iPad":void 0,a=/ipod/i.test(e)?"iPod":void 0,n=/mac/i.test(e)?"Mac":void 0,o=/webOS|BlackBerry|IEMobile|Opera Mini/i.test(e)?"RestMobile":void 0;this._current=t||i||r||a||o||n||"Desktop"}catch(t){console.error(t)}}detectIOSVersion(){try{if(this._highEntropyValues.platformVersion){let a=this._highEntropyValues.platformVersion.split(".").slice(0,2).join("."),n=parseFloat(a);this._iosVersion=n;return}let{userAgent:e}=window.navigator,t=e.match(/OS (\d+(_\d+)?)/i);if(!t)return;let i=t[1].replace(/_/g,".");if(!i)return;let r=parseFloat(i);if(isNaN(r))return;this._iosVersion=r}catch(e){console.error(e)}}};var yn=class{get isTouch(){return typeof this._maxTouchPoints=="number"?this._maxTouchPoints>1:"ontouchstart"in window}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(){var t;let{maxTouchPoints:e}=navigator;try{this._maxTouchPoints=e!=null?e:0,this._isHdr=!!((t=matchMedia("(dynamic-range: high)"))!=null&&t.matches),this._colorDepth=screen.colorDepth}catch(i){console.error(i)}try{this._pixelRatio=window.devicePixelRatio||1,this._height=screen.height,this._width=screen.width,this._height=screen.height,this._screenHeight=this._height*this._pixelRatio,this._screenWidth=this._width*this._pixelRatio}catch(i){console.error(i)}}};var nt=()=>window.ManagedMediaSource||window.MediaSource,Tr=()=>{var s,e;return!!(window.ManagedMediaSource&&((e=(s=window.ManagedSourceBuffer)==null?void 0:s.prototype)!=null&&e.appendBuffer))},hg=()=>{var s,e;return!!(window.MediaSource&&((e=(s=window.SourceBuffer)==null?void 0:s.prototype)!=null&&e.appendBuffer))},Tn=()=>window.ManagedMediaSource?new ManagedMediaSource:new MediaSource;var OR=document.createElement("video"),FR='video/mp4; codecs="avc1.42000a,mp4a.40.2"',NR='video/mp4; codecs="hev1.1.6.L93.B0"',fg='video/webm; codecs="vp09.00.10.08"',mg='video/webm; codecs="av01.0.00M.08"',qR='audio/mp4; codecs="mp4a.40.2"',UR='audio/webm; codecs="opus"',bg,HR=()=>R(null,null,function*(){if(!window.navigator.mediaCapabilities)return;let s={type:"media-source",video:{contentType:"video/webm",width:1280,height:720,bitrate:1e6,framerate:30}},[e,t]=yield Promise.all([window.navigator.mediaCapabilities.decodingInfo(j(C({},s),{video:j(C({},s.video),{contentType:mg})})),window.navigator.mediaCapabilities.decodingInfo(j(C({},s),{video:j(C({},s.video),{contentType:fg})}))]);bg={DASH_WEBM_AV1:e,DASH_WEBM:t}});HR().catch(s=>{console.log(OR),console.error(s)});var In=class{constructor(e,t){this._deviceChecker=e,this._browserChecker=t}get protocols(){return this._protocols}get containers(){return this._containers}get codecs(){return this._codecs}get webmDecodingInfo(){return bg}get supportedCodecs(){return Object.keys(this._codecs).filter(e=>this._codecs[e])}get nativeHlsSupported(){return this._nativeHlsSupported}detect(){var e,t,i,r,a,n,o,u,l,c,d,f,p,h,b,S,g,y,A,E;this._video=document.createElement("video");try{this._protocols={mms:Tr(),mse:hg(),hls:!!((t=(e=this._video).canPlayType)!=null&&t.call(e,"application/x-mpegurl")||(r=(i=this._video).canPlayType)!=null&&r.call(i,"vnd.apple.mpegURL")),webrtc:!!window.RTCPeerConnection,ws:!!window.WebSocket},this._containers={mp4:!!((n=(a=this._video).canPlayType)!=null&&n.call(a,"video/mp4")),webm:!!((u=(o=this._video).canPlayType)!=null&&u.call(o,"video/webm")),cmaf:!0};let w=!!((c=(l=nt())==null?void 0:l.isTypeSupported)!=null&&c.call(l,FR)),_=!!((f=(d=nt())==null?void 0:d.isTypeSupported)!=null&&f.call(d,NR)),W=!!((h=(p=nt())==null?void 0:p.isTypeSupported)!=null&&h.call(p,qR));this._codecs={h264:w,h265:_,vp9:!!((S=(b=nt())==null?void 0:b.isTypeSupported)!=null&&S.call(b,fg)),av1:!!((y=(g=nt())==null?void 0:g.isTypeSupported)!=null&&y.call(g,mg)),aac:W,opus:!!((E=(A=nt())==null?void 0:A.isTypeSupported)!=null&&E.call(A,UR)),mpeg:(w||_)&&W},this._nativeHlsSupported=this._protocols.hls&&this._containers.mp4}catch(w){console.error(w)}try{this.destroyVideoElement()}catch(w){console.error("Error destroying video element:",w)}}destroyVideoElement(){var t;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);(t=this._video.parentNode)==null||t.replaceChild(e,this._video),this._video=null}};var gg="audio/mpeg",En=class{supportMp3(){return this._codecs.mp3&&this._containers.mpeg}detect(){var e,t,i,r;this._audio=document.createElement("audio");try{this._containers={mpeg:!!((t=(e=this._audio).canPlayType)!=null&&t.call(e,gg))},this._codecs={mp3:!!((r=(i=nt())==null?void 0:i.isTypeSupported)!=null&&r.call(i,gg))}}catch(a){console.error(a)}try{this.destroyAudioElement()}catch(a){console.error("Error destroying audio element:",a)}}destroyAudioElement(){var t;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);(t=this._audio.parentNode)==null||t.replaceChild(e,this._audio),this._audio=null}};var vg=require("@vkontakte/videoplayer-shared/es2015");var Il=class{constructor(){this.isInited$=new vg.ValueSubject(!1);this._displayChecker=new yn,this._deviceChecker=new Sn(this._displayChecker),this._browserChecker=new vn,this._videoChecker=new In(this._deviceChecker,this._browserChecker),this._audioChecker=new En,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(){return R(this,null,function*(){this._displayChecker.detect(),this._deviceChecker.detect(),this._browserChecker.detect(),this._videoChecker.detect(),this._audioChecker.detect(),this.isInited$.next(!0)})}},K=new Il;var xl=s=>{let{containers:e,protocols:t,codecs:i,nativeHlsSupported:r}=K.video,a=(i.h264||i.h265)&&i.aac,n=t.mse||t.mms;return s.filter(o=>{switch(o){case"DASH_SEP":return n&&e.mp4&&a;case"DASH_WEBM":return n&&e.webm&&i.vp9&&i.opus;case"DASH_WEBM_AV1":return n&&e.webm&&i.av1&&i.opus;case"DASH_STREAMS":return n&&(e.mp4&&a||e.webm&&(i.vp9||i.av1)&&(i.opus||i.aac));case"DASH_LIVE":return n&&e.mp4&&a;case"DASH_LIVE_CMAF":return n&&e.mp4&&a&&e.cmaf;case"DASH_ONDEMAND":return n&&e.mp4&&a;case"HLS":case"HLS_ONDEMAND":case"HLS_FMP4":case"HLS_LIVE":case"HLS_LIVE_CMAF":return r;case"MPEG":return e.mp4;case"DASH":case"DASH_LIVE_WEBM":return!1;case"WEB_RTC_LIVE":return t.webrtc&&t.ws&&i.h264&&(e.mp4||e.webm);default:return(0,El.assertNever)(o)}})},wl=s=>{switch(s){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(0,El.assertNever)(s)}},Sg=s=>{let t=Object.keys(s).filter(i=>!wl(i));return xl(t).length>0};var G=require("@vkontakte/videoplayer-shared/es2015");var jR=5,QR=5,WR=500,yg=7e3,Ss=class{constructor(e){this.subscription=new G.Subscription;this.loadMediaTimeoutSubscription=new G.Subscription;this.videoState=new ne("stopped");this.syncPlayback=()=>{let e=this.videoState.getState(),t=this.videoState.getTransition(),i=this.params.desiredState.playbackState.getState(),r=this.params.desiredState.playbackState.getTransition(),a=this.params.desiredState.seekState.getState();if(this.log({message:`[syncPlayback] videoState: ${e}; videoTransition: ${JSON.stringify(t)}; desiredPlaybackState: ${i}; desiredPlaybackStateTransition: ${this.params.desiredState.playbackState.getTransition()}; seekState: ${JSON.stringify(a)};`}),i==="stopped"){e!=="stopped"&&(this.videoState.startTransitionTo("stopped"),this.stop());return}if(!t){if((r==null?void 0:r.to)!=="paused"&&a.state==="requested"&&e!=="stopped"){this.seek(a.position/1e3);return}switch(i){case"ready":{switch(e){case"playing":case"paused":case"ready":break;case"stopped":this.videoState.startTransitionTo("ready"),this.prepare();break;default:(0,G.assertNever)(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:(0,G.assertNever)(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:(0,G.assertNever)(e)}break}default:(0,G.assertNever)(i)}}};this.params=e,this.log=this.params.dependencies.logger.createComponentLog("ChromecastProvider"),this.log({message:`constructor, format: ${e.format}`}),this.params.output.isLive$.next(wl(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 G.Subscription;this.subscription.add(e),this.subscription.add((0,G.merge)(this.videoState.stateChangeStarted$.pipe((0,G.map)(r=>`stateChangeStarted$ ${JSON.stringify(r)}`)),this.videoState.stateChangeEnded$.pipe((0,G.map)(r=>`stateChangeEnded$ ${JSON.stringify(r)}`))).subscribe(r=>this.log({message:`[videoState] ${r}`})));let t=(r,a)=>this.subscription.add(r.subscribe(a));if(this.params.output.isLive$.getValue())this.params.output.position$.next(0),this.params.output.duration$.next(0);else{let r=new G.Subject;e.add(r.pipe((0,G.debounce)(WR)).subscribe(()=>{this.params.output.seekedEvent$.next()}));let a=NaN;e.add((0,G.fromEvent)(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED).subscribe(n=>{this.logRemoteEvent(n);let o=n.value;this.params.output.position$.next(o),(this.params.desiredState.seekState.getState().state==="applying"||Math.abs(o-a)>jR)&&r.next(o),a=o})),e.add((0,G.fromEvent)(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.DURATION_CHANGED).subscribe(n=>{this.logRemoteEvent(n),this.params.output.duration$.next(n.value)}))}t((0,G.fromEvent)(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED),r=>{this.logRemoteEvent(r),r.value?this.handleRemoteReady():(this.handleRemoteStop(),e.unsubscribe())}),t((0,G.fromEvent)(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED),r=>{this.logRemoteEvent(r),r.value?this.handleRemotePause():this.handleRemotePlay()}),t((0,G.fromEvent)(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED),r=>{this.logRemoteEvent(r);let{remotePlayer:a}=this.params.connection,n=r.value,o=this.params.output.isBuffering$.getValue(),u=n===chrome.cast.media.PlayerState.BUFFERING;switch(o!==u&&this.params.output.isBuffering$.next(u),n){case chrome.cast.media.PlayerState.IDLE:!this.params.output.isLive$.getValue()&&a.duration-a.currentTime<QR&&this.params.output.endedEvent$.next(),this.handleRemoteStop(),N(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:(0,G.assertNever)(n)}}),t((0,G.fromEvent)(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED),r=>{this.logRemoteEvent(r),this.handleRemoteVolumeChange({volume:r.value})}),t((0,G.fromEvent)(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED),r=>{this.logRemoteEvent(r),this.handleRemoteVolumeChange({muted:r.value})});let i=(0,G.merge)(this.params.desiredState.playbackState.stateChangeStarted$,this.params.desiredState.seekState.stateChangeEnded$,this.videoState.stateChangeEnded$,(0,G.observableFrom)(["init"])).pipe((0,G.debounce)(0));t(i,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"),N(this.params.desiredState.playbackState,"paused")):(this.videoState.setState("playing"),N(this.params.desiredState.playbackState,"playing"));let i=this.params.output.isLive$.getValue();this.params.output.duration$.next(i?0:t.duration),this.params.output.position$.next(i?0:t.currentTime),this.params.desiredState.seekState.setState({state:"none"})}}prepare(){let e=this.params.format;this.log({message:`[prepare] format: ${e}`});let t=this.createMediaInfo(e),i=this.createLoadRequest(t);this.loadMedia(i)}handleRemotePause(){let e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)==="paused"||e==="playing")&&(this.videoState.setState("paused"),N(this.params.desiredState.playbackState,"paused"))}handleRemotePlay(){let e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)==="playing"||e==="paused")&&(this.videoState.setState("playing"),N(this.params.desiredState.playbackState,"playing"))}handleRemoteReady(){var t;let e=this.videoState.getTransition();(e==null?void 0:e.to)==="ready"&&this.videoState.setState("ready"),((t=this.params.desiredState.playbackState.getTransition())==null?void 0:t.to)==="ready"&&N(this.params.desiredState.playbackState,"ready")}handleRemoteStop(){this.videoState.getState()!=="stopped"&&this.videoState.setState("stopped")}handleRemoteVolumeChange(e){var r,a;let t=this.params.output.volume$.getValue(),i={volume:(r=e.volume)!=null?r:t.volume,muted:(a=e.muted)!=null?a:t.muted};(i.volume!==t.volume||i.muted!==i.muted)&&this.params.output.volume$.next(i)}seek(e){this.params.output.willSeekEvent$.next();let{remotePlayer:t,remotePlayerController:i}=this.params.connection;t.currentTime=e,i.seek()}stop(){let{remotePlayerController:e}=this.params.connection;e.stop()}createMediaInfo(e){var l;let t=this.params.source,i,r,a;switch(e){case"MPEG":{let c=t[e];(0,G.assertNonNullable)(c);let d=(0,G.getHighestQuality)(Object.keys(c));(0,G.assertNonNullable)(d);let f=c[d];(0,G.assertNonNullable)(f),i=f,r="video/mp4",a=chrome.cast.media.StreamType.BUFFERED;break}case"HLS":case"HLS_FMP4":case"HLS_ONDEMAND":{let c=t[e];(0,G.assertNonNullable)(c),i=c.url,r="application/x-mpegurl",a=chrome.cast.media.StreamType.BUFFERED;break}case"DASH_SEP":case"DASH_ONDEMAND":case"DASH_WEBM":case"DASH_WEBM_AV1":case"DASH_STREAMS":{let c=t[e];(0,G.assertNonNullable)(c),i=c.url,r="application/dash+xml",a=chrome.cast.media.StreamType.BUFFERED;break}case"DASH_LIVE_CMAF":{let c=t[e];(0,G.assertNonNullable)(c),i=c.url,r="application/dash+xml",a=chrome.cast.media.StreamType.LIVE;break}case"HLS_LIVE":case"HLS_LIVE_CMAF":{let c=t[e];(0,G.assertNonNullable)(c),i=Re(c.url),r="application/x-mpegurl",a=chrome.cast.media.StreamType.LIVE;break}case"DASH_LIVE":case"WEB_RTC_LIVE":{let c="Unsupported format for Chromecast",d=new Error(c);throw this.params.output.error$.next({id:"ChromecastProvider.createMediaInfo()",category:G.ErrorCategory.VIDEO_PIPELINE,message:c,thrown:d}),d}case"DASH":case"DASH_LIVE_WEBM":throw new Error(`${e} is no longer supported`);default:return(0,G.assertNever)(e)}let n=new chrome.cast.media.MediaInfo((l=this.params.meta.videoId)!=null?l:i,r);n.contentUrl=i,n.streamType=a,n.metadata=new chrome.cast.media.GenericMediaMetadata;let{title:o,subtitle:u}=this.params.meta;return(0,G.isNonNullable)(o)&&(n.metadata.title=o),(0,G.isNonNullable)(u)&&(n.metadata.subtitle=u),n}createLoadRequest(e){let t=new chrome.cast.media.LoadRequest(e);t.autoplay=!1;let i=this.params.desiredState.seekState.getState();return i.state==="applying"||i.state==="requested"?t.currentTime=this.params.output.isLive$.getValue()?0:i.position/1e3:t.currentTime=0,t}loadMedia(e){let t=this.params.connection.session.loadMedia(e),i=new Promise((r,a)=>{this.loadMediaTimeoutSubscription.add((0,G.timeout)(yg).subscribe(()=>a(`timeout(${yg})`)))});(0,Tg.default)(Promise.race([t,i]).then(()=>{this.log({message:`[loadMedia] completed, format: ${this.params.format}`}),this.params.desiredState.seekState.getState().state==="applying"&&this.params.output.seekedEvent$.next(),this.handleRemoteReady()},r=>{let a=`[prepare] loadMedia failed, format: ${this.params.format}, reason: ${r}`;this.log({message:a}),this.params.output.error$.next({id:"ChromecastProvider.loadMedia",category:G.ErrorCategory.VIDEO_PIPELINE,message:a,thrown:r})}),()=>{this.loadMediaTimeoutSubscription.unsubscribe()})}logRemoteEvent(e){this.log({message:`[remoteEvent] ${JSON.stringify(e)}`})}};var Nl=Y(je(),1);var kl=require("@vkontakte/videoplayer-shared/es2015");var Ig=require("@vkontakte/videoplayer-shared/es2015"),Eg=s=>{try{s.pause(),s.playbackRate=0,(0,Ig.clearVideoElement)(s),s.remove()}catch(e){console.error(e)}};var xn=require("@vkontakte/videoplayer-shared/es2015"),Al=class{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)}},Pl=window.WeakMap?new WeakMap:new Al,Rl=window.WeakMap?new WeakMap:new Map,GR=(s,e=20)=>{let t=0;return(0,xn.fromEvent)(s,"ratechange").subscribe(i=>{t++,t>=e&&(s.currentTime=s.currentTime,t=0)})},ze=(s,{audioVideoSyncRate:e,disableYandexPiP:t})=>{let i=s.querySelector("video"),r=!!i;i?(0,kl.clearVideoElement)(i):(i=document.createElement("video"),s.appendChild(i)),Pl.set(i,r);let a=new xn.Subscription;return a.add(GR(i,e)),Rl.set(i,a),i.setAttribute("crossorigin","anonymous"),i.setAttribute("playsinline","playsinline"),t&&i.setAttribute("x-yandex-pip","false"),i.controls=!1,i.setAttribute("poster","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),i},Ye=s=>{let e=Rl.get(s);e==null||e.unsubscribe(),Rl.delete(s);let t=Pl.get(s);Pl.delete(s),t?(0,kl.clearVideoElement)(s):Eg(s)};var Ll=Y(Di(),1),z=require("@vkontakte/videoplayer-shared/es2015");var pi=require("@vkontakte/videoplayer-shared/es2015"),wn=(s,e,t,{equal:i=(n,o)=>n===o,changed$:r,onError:a}={})=>{let n=s.getState(),o=e(),u=(0,pi.isNullable)(r),l=new pi.Subscription;return r&&l.add(r.subscribe(c=>{let d=s.getState();i(c,d)&&s.setState(c)},a)),i(o,n)||(t(n),u&&s.setState(n)),l.add(s.stateChangeStarted$.subscribe(c=>{t(c.to),u&&s.setState(c.to)},a)),l},Ct=(s,e,t)=>wn(e,()=>s.loop,i=>{(0,pi.isNonNullable)(i)&&(s.loop=i)},{onError:t}),Ke=(s,e,t,i)=>wn(e,()=>({muted:s.muted,volume:s.volume}),r=>{(0,pi.isNonNullable)(r)&&(s.muted=r.muted,s.volume=r.volume)},{equal:(r,a)=>r===a||(r==null?void 0:r.muted)===(a==null?void 0:a.muted)&&(r==null?void 0:r.volume)===(a==null?void 0:a.volume),changed$:t,onError:i}),pt=(s,e,t,i)=>wn(e,()=>s.playbackRate,r=>{(0,pi.isNonNullable)(r)&&(s.playbackRate=r)},{changed$:t,onError:i}),ys=wn;var zR=s=>["__",s.language,s.label].join("|"),YR=(s,e)=>{if(s.id===e)return!0;let[t,i,r]=e.split("|");return s.language===i&&s.label===r},$l=class s{constructor(e){this.available$=new z.Subject;this.current$=new z.ValueSubject(void 0);this.error$=new z.Subject;this.subscription=new z.Subscription;this.externalTracks=new Map;this.internalTracks=new Map;this.baseURL=e}connect(e,t,i){this.video=e,this.cueSettings=t.textTrackCuesSettings,this.subscribe();let r=a=>{this.error$.next({id:"TextTracksManager",category:z.ErrorCategory.WTF,message:"Generic HtmlVideoTextTrackManager error",thrown:a})};this.subscription.add(this.available$.subscribe(i.availableTextTracks$)),this.subscription.add(this.current$.subscribe(i.currentTextTrack$)),this.subscription.add(this.error$.subscribe(i.error$)),this.subscription.add(ys(t.internalTextTracks,()=>(0,Ll.default)(this.internalTracks),a=>{(0,z.isNonNullable)(a)&&this.setInternal(a)},{equal:(a,n)=>(0,z.isNonNullable)(a)&&(0,z.isNonNullable)(n)&&a.length===n.length&&a.every(({id:o},u)=>o===n[u].id),changed$:this.available$.pipe((0,z.map)(a=>a.filter(({type:n})=>n==="internal"))),onError:r})),this.subscription.add(ys(t.externalTextTracks,()=>(0,Ll.default)(this.externalTracks),a=>{(0,z.isNonNullable)(a)&&this.setExternal(a)},{equal:(a,n)=>(0,z.isNonNullable)(a)&&(0,z.isNonNullable)(n)&&a.length===n.length&&a.every(({id:o},u)=>o===n[u].id),changed$:this.available$.pipe((0,z.map)(a=>a.filter(({type:n})=>n==="external"))),onError:r})),this.subscription.add(ys(t.currentTextTrack,()=>{if(this.video)return;let a=this.htmlTextTracksAsArray().find(({mode:n})=>n==="showing");return a&&this.htmlTextTrackToITextTrack(a).id},a=>this.select(a),{changed$:this.current$,onError:r})),this.subscription.add(ys(t.textTrackCuesSettings,()=>({}),()=>{if(this.video)for(let a of this.htmlTextTracksAsArray())this.applyCueSettings(a.cues),this.applyCueSettings(a.activeCues)}))}subscribe(){(0,z.assertNonNullable)(this.video);let{textTracks:e}=this.video;this.subscription.add((0,z.fromEvent)(e,"addtrack").subscribe(()=>{let i=this.current$.getValue();i&&this.select(i)})),this.subscription.add((0,z.merge)((0,z.fromEvent)(e,"addtrack"),(0,z.fromEvent)(e,"removetrack"),(0,z.observableFrom)(["init"])).pipe((0,z.map)(()=>this.htmlTextTracksAsArray().map(i=>this.htmlTextTrackToITextTrack(i))),(0,z.filterChanged)((i,r)=>i.length===r.length&&i.every(({id:a},n)=>a===r[n].id))).subscribe(this.available$)),this.subscription.add((0,z.merge)((0,z.fromEvent)(e,"change"),(0,z.observableFrom)(["init"])).pipe((0,z.map)(()=>this.htmlTextTracksAsArray().find(({mode:i})=>i==="showing")),(0,z.map)(i=>i&&this.htmlTextTrackToITextTrack(i).id),(0,z.filterChanged)()).subscribe(this.current$));let t=i=>{var r,a;return this.applyCueSettings((a=(r=i.target)==null?void 0:r.activeCues)!=null?a:null)};this.subscription.add((0,z.fromEvent)(e,"addtrack").subscribe(i=>{var a,n;(a=i.track)==null||a.addEventListener("cuechange",t);let r=o=>{var l,c,d,f,p;let u=(c=(l=o.target)==null?void 0:l.cues)!=null?c:null;u&&u.length&&(this.applyCueSettings((f=(d=o.target)==null?void 0:d.cues)!=null?f:null),(p=o.target)==null||p.removeEventListener("cuechange",r))};(n=i.track)==null||n.addEventListener("cuechange",r)})),this.subscription.add((0,z.fromEvent)(e,"removetrack").subscribe(i=>{var r;(r=i.track)==null||r.removeEventListener("cuechange",t)}))}applyCueSettings(e){if(!e||!e.length)return;let t=this.cueSettings.getState();for(let i of Array.from(e)){let r=i;(0,z.isNonNullable)(t.align)&&(r.align=t.align),(0,z.isNonNullable)(t.position)&&(r.position=t.position),(0,z.isNonNullable)(t.size)&&(r.size=t.size),(0,z.isNonNullable)(t.line)&&(r.line=t.line)}}htmlTextTracksAsArray(e=!1){(0,z.assertNonNullable)(this.video);let t=[...this.video.textTracks];return e?t:t.filter(s.isHealthyTrack)}htmlTextTrackToITextTrack(e){var o,u,l,c,d;let{language:t,label:i}=e,r=e.id?e.id:zR(e),a=this.externalTracks.has(r),n=(l=a?(o=this.externalTracks.get(r))==null?void 0:o.isAuto:(u=this.internalTracks.get(r))==null?void 0:u.isAuto)!=null?l:r.includes("auto");return a?{id:r,type:"external",isAuto:n,language:t,label:i,url:(c=this.externalTracks.get(r))==null?void 0:c.url}:{id:r,type:"internal",isAuto:n,language:t,label:i,url:(d=this.internalTracks.get(r))==null?void 0:d.url}}static isHealthyTrack(e){return!(e.kind==="metadata"||e.groupId||e.id===""&&e.label===""&&e.language==="")}setExternal(e){this.internalTracks.size>0&&Array.from(this.internalTracks).forEach(([,t])=>this.detach(t)),e.filter(({id:t})=>!this.externalTracks.has(t)).forEach(t=>this.attach(t)),Array.from(this.externalTracks).filter(([t])=>!e.find(i=>i.id===t)).forEach(([,t])=>this.detach(t))}setInternal(e){let t=[...this.externalTracks];e.filter(({id:i,language:r,isAuto:a})=>!this.internalTracks.has(i)&&!t.some(([,n])=>n.language===r&&n.isAuto===a)).forEach(i=>this.attach(i)),Array.from(this.internalTracks).filter(([i])=>!e.find(r=>r.id===i)).forEach(([,i])=>this.detach(i))}select(e){(0,z.assertNonNullable)(this.video);for(let t of this.htmlTextTracksAsArray(!0))t.mode="showing";for(let t of this.htmlTextTracksAsArray(!0))((0,z.isNullable)(e)||!YR(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){(0,z.assertNonNullable)(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){(0,z.assertNonNullable)(this.video);let t=Array.prototype.find.call(this.video.getElementsByTagName("track"),i=>i.getAttribute("id")===e.id);t&&this.video.removeChild(t),e.type==="external"?this.externalTracks.delete(e.id):e.type==="internal"&&this.internalTracks.delete(e.id)}},ht=$l;var Fi=class{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 xg=s=>{let e=s;for(;!(e instanceof Document)&&!(e instanceof ShadowRoot)&&e!==null;)e=e==null?void 0:e.parentNode;return e!=null?e:void 0},Ml=s=>{let e=xg(s);return!!(e&&e.fullscreenElement&&e.fullscreenElement===s)},wg=s=>{let e=xg(s);return!!(e&&e.pictureInPictureElement&&e.pictureInPictureElement===s)};var D=require("@vkontakte/videoplayer-shared/es2015");var KR=3,Ag=(s,e,t=KR)=>{let i=0,r=0;for(let a=0;a<s.length;a++){let n=s.start(a),o=s.end(a);if(n<=e&&e<=o){if(i=n,r=o,!t)return{from:i,to:r};for(let u=a-1;u>=0;u--)s.end(u)+t>=i&&(i=s.start(u));for(let u=a+1;u<s.length;u++)s.start(u)-t<=r&&(r=s.end(u))}}return{from:i,to:r}};var Xe=s=>{let e=M=>(0,D.fromEvent)(s,M).pipe((0,D.mapTo)(void 0),(0,D.shareReplay)(1)),t=new D.Subscription,i=()=>t.unsubscribe(),r=(0,D.merge)((0,D.fromEvent)(s,"progress"),(0,D.fromEvent)(s,"timeupdate")).pipe((0,D.map)(()=>Ag(s.buffered,s.currentTime)),(0,D.shareReplay)(1)),a=K.browser.isSafari?(0,D.combine)({play:e("play").pipe((0,D.once)()),playing:e("playing")}).pipe((0,D.mapTo)(void 0),(0,D.shareReplay)(1)):e("playing"),n=(0,D.fromEvent)(s,"volumechange").pipe((0,D.map)(()=>({muted:s.muted,volume:s.volume})),(0,D.shareReplay)(1)),o=(0,D.fromEvent)(s,"ratechange").pipe((0,D.map)(()=>s.playbackRate),(0,D.shareReplay)(1)),u=(0,D.fromEvent)(s,"error").pipe((0,D.filter)(()=>!!(s.error||s.played.length)),(0,D.map)(()=>{var Q;let M=s.error;return{id:M?`MediaError#${M.code}`:"HtmlVideoError",category:D.ErrorCategory.VIDEO_PIPELINE,message:M?M.message:"Error event from HTML video element",thrown:(Q=s.error)!=null?Q:void 0}}),(0,D.shareReplay)(1)),l=(0,D.fromEvent)(s,"timeupdate").pipe((0,D.map)(()=>s.currentTime),(0,D.shareReplay)(1)),c=["waiting","seeking","seeked","timeupdate"],d=new D.Subject,f=.3,p;t.add((0,D.merge)(...c.map(M=>(0,D.fromEvent)(s,M))).subscribe(M=>{let Q=s.currentTime;s.loop&&(0,D.isNonNullable)(p)&&(0,D.isNonNullable)(Q)&&p>=s.duration-f&&Q<=f&&d.next(p),p=Q}));let h=e("pause").pipe((0,D.filter)(()=>!s.error&&p!==s.duration),(0,D.shareReplay)(1)),b=(0,D.fromEvent)(s,"enterpictureinpicture").pipe((0,D.shareReplay)(1)),S=(0,D.fromEvent)(s,"leavepictureinpicture").pipe((0,D.shareReplay)(1)),g=new D.ValueSubject(wg(s));t.add(b.subscribe(()=>g.next(!0))),t.add(S.subscribe(()=>g.next(!1)));let y=new D.ValueSubject(Ml(s)),A=(0,D.fromEvent)(s,"fullscreenchange").pipe((0,D.shareReplay)(1));t.add(A.pipe((0,D.map)(()=>Ml(s))).subscribe(y));let E=.1,w=1e3,_=(0,D.fromEvent)(s,"timeupdate").pipe((0,D.map)(M=>s.duration-s.currentTime<E),(0,D.filterChanged)(),(0,D.shareReplay)(1)),W=(0,D.merge)(_.pipe((0,D.filter)(M=>!s.loop&&M)),(0,D.fromEvent)(s,"ended")).pipe((0,D.throttle)(w),(0,D.mapTo)(void 0),(0,D.shareReplay)(1)),U=(0,D.merge)(...["waiting","pause","canplay","play","canplaythrough","playing","seeking","seeked","ended"].map(M=>(0,D.fromEvent)(s,M)),_.pipe((0,D.map)(M=>({type:M?"ended":"unknown"})))).pipe((0,D.map)(M=>K.browser.isFirefox&&M.type==="ended"?s.readyState<2:s.readyState<3),(0,D.filterChanged)(),(0,D.shareReplay)(1));return{playing$:a,pause$:h,canplay$:e("canplay"),ended$:W,looped$:d,error$:u,seeked$:e("seeked"),seeking$:e("seeking"),progress$:e("progress"),loadStart$:e("loadstart"),loadedMetadata$:e("loadedmetadata"),loadedData$:e("loadeddata"),timeUpdate$:l,durationChange$:(0,D.fromEvent)(s,"durationchange").pipe((0,D.map)(()=>s.duration),(0,D.shareReplay)(1)),isBuffering$:U,currentBuffer$:r,volumeState$:n,playbackRateState$:o,inPiP$:g,inFullscreen$:y,enterPip$:b,leavePip$:S,destroy:i}};var Wt=require("@vkontakte/videoplayer-shared/es2015"),hi=s=>{switch(s){case"mobile":return Wt.VideoQuality.Q_144P;case"lowest":return Wt.VideoQuality.Q_240P;case"low":return Wt.VideoQuality.Q_360P;case"sd":case"medium":return Wt.VideoQuality.Q_480P;case"hd":case"high":return Wt.VideoQuality.Q_720P;case"fullhd":case"full":return Wt.VideoQuality.Q_1080P;case"quadhd":case"quad":return Wt.VideoQuality.Q_1440P;case"ultrahd":case"ultra":return Wt.VideoQuality.Q_2160P}};var We=Y(xt(),1),Bl=Y(je(),1),Ni=Y(cr(),1),V=require("@vkontakte/videoplayer-shared/es2015");var Dl=!1,Gt={},Dg=s=>{Dl=s},Cg=()=>{Gt={}},Bg=s=>{s(Gt)},Ts=(s,e)=>{var t;Dl&&(Gt.meta=(t=Gt.meta)!=null?t:{},Gt.meta[s]=e)},Qe=class{constructor(e){this.name=e}next(e){var i,r;if(!Dl)return;Gt.series=(i=Gt.series)!=null?i:{};let t=(r=Gt.series[this.name])!=null?r:[];t.push([Date.now(),e]),Gt.series[this.name]=t}};var $e=require("@vkontakte/videoplayer-shared/es2015");function Cl(s,e,t){return!s.max&&s.min===e?"high_quality":!s.min&&s.max===t?"traffic_saving":"unknown"}function An(s,e,t){return!!s&&Cl(s,e,t)==="high_quality"}function Ir(s,e,t){return(0,$e.isNullable)(s)||(0,$e.isNonNullable)(s.min)&&(0,$e.isNonNullable)(s.max)&&(0,$e.isLower)(s.max,s.min)||(0,$e.isNonNullable)(s.min)&&e&&(0,$e.isHigher)(s.min,e)||(0,$e.isNonNullable)(s.max)&&t&&(0,$e.isLower)(s.max,t)}function Vg({limits:s,highestAvailableHeight:e,lowestAvailableHeight:t}){return Ir({max:s!=null&&s.max?(0,$e.videoHeightToQuality)(s.max):void 0,min:s!=null&&s.min?(0,$e.videoHeightToQuality)(s.min):void 0},e?(0,$e.videoHeightToQuality)(e):void 0,t?(0,$e.videoHeightToQuality)(t):void 0)}var qg=new Qe("best_bitrate"),Rn=(s,e,t)=>(e-t)*Math.pow(2,-10*s)+t;var Er=s=>(e,t)=>s*(Number(e.bitrate)-Number(t.bitrate)),fi=class{constructor(){this.history={}}recordSelection(e){this.history[e.id]=(0,V.now)()}recordSwitch(e){this.last=e}clear(){this.last=void 0,this.history={}}},kn='Assertion "ABR Tracks is empty array" failed',Pn=new WeakMap,_g=new WeakMap,Og=new WeakMap,Is=(s,e,t,i)=>{var u;let r=[...e].sort(Er(1)),a=[...t].sort(Er(1)),n=a.filter(l=>(0,V.isNonNullable)(l.bitrate)&&(0,V.isNonNullable)(s.bitrate)?s.bitrate/l.bitrate>i:!0),o=(u=(0,We.default)(a,Math.round(a.length*r.indexOf(s)/(r.length+1))))!=null?u:(0,We.default)(a,-1);return o&&(0,Bl.default)(n,o)?o:n.length?(0,We.default)(n,-1):(0,We.default)(a,0)},Es=(s,e,t,i)=>{var u;let r=Pn.get(e);r||(r=[...e].sort(Er(1)),Pn.set(e,r));let a=Pn.get(t);a||(a=[...t].sort(Er(1)),Pn.set(t,a));let n=Og.get(s);n||(n=a.filter(l=>(0,V.isNonNullable)(l.bitrate)&&(0,V.isNonNullable)(s.bitrate)?s.bitrate/l.bitrate>i:!0),Og.set(s,n));let o=(u=(0,We.default)(a,Math.round(a.length*r.indexOf(s)/(r.length+1))))!=null?u:(0,We.default)(a,-1);return o&&(0,Bl.default)(n,o)?o:n.length?(0,We.default)(n,-1):(0,We.default)(a,0)},Fg=s=>"quality"in s,Ln=(s,e,t,i)=>{var n;let r=(0,V.isNonNullable)((n=i==null?void 0:i.last)==null?void 0:n.bitrate)&&(0,V.isNonNullable)(t==null?void 0:t.bitrate)&&i.last.bitrate<t.bitrate?s.trackCooldownIncreaseQuality:s.trackCooldownDecreaseQuality,a=t&&i&&i.history[t.id]&&(0,V.now)()-i.history[t.id]<=r&&(!i.last||t.id!==i.last.id);if(t!=null&&t.id&&i&&!a&&i.recordSelection(t),a&&(i!=null&&i.last)){let o=i.last;i==null||i.recordSwitch(o);let u=Fg(o)?"video":"audio",l=Fg(o)?o.quality:o.bitrate;return e({message:`
8
8
  [last ${u} selected] ${l}
9
9
  `}),o}return i==null||i.recordSwitch(t),t},ak=(s,e)=>Math.log(e)/Math.log(s),Ug=({tuning:s,container:e,limits:t,panelSize:i})=>{let r=s.containerSizeFactor;if(i)return{containerSizeLimit:i,containerSizeFactor:r};if(s.usePixelRatio&&K.display.pixelRatio){let a=K.display.pixelRatio;if(s.pixelRatioMultiplier)r*=s.pixelRatioMultiplier*(a-1)+1;else{let n=s.pixelRatioLogBase,[o=0,u=0,l=0]=s.pixelRatioLogCoefficients,c=ak(n,o*a+u)+l;Number.isFinite(c)&&(r*=c)}}return An(t,s.highQualityLimit,s.trafficSavingLimit)&&(r*=2),{containerSizeLimit:s.limitByContainer&&e&&e.width>0&&e.height>0?{width:e.width*r,height:e.height*r}:void 0,containerSizeFactor:r}},Ng=new WeakMap,Bt=(s,{container:e,estimatedThroughput:t,tuning:i,limits:r,reserve:a=0,forwardBufferHealth:n,playbackRate:o,current:u,history:l,visible:c,droppedVideoMaxQualityLimit:d,stallsVideoMaxQualityLimit:f,stallsPredictedThroughput:p,abrLogger:h,panelSize:b})=>{var Z,le,he,F,$;(0,V.assertNotEmptyArray)(s,kn);let{containerSizeFactor:S,containerSizeLimit:g}=Ug({container:e,tuning:i,limits:r,panelSize:b}),y=i.considerPlaybackRate&&(0,V.isNonNullable)(o)?o:1,A=Ng.get(s);A||(A=s.filter(P=>!(0,V.isInvariantQuality)(P.quality)).sort((P,B)=>(0,V.isHigher)(P.quality,B.quality)?-1:1),Ng.set(s,A));let E=(Z=(0,We.default)(A,-1))==null?void 0:Z.quality,w=(le=(0,We.default)(A,0))==null?void 0:le.quality,_=Ir(r,w,E),W=y*Rn(n!=null?n:.5,i.bitrateFactorAtEmptyBuffer,i.bitrateFactorAtFullBuffer),O={},U=null;for(let P of A){let B=!0;if(g)if(P.size)B=P.size.width<=g.width&&P.size.height<=g.height;else{let it=g&&(0,V.videoSizeToQuality)(g);B=it?(0,V.isLowerOrEqual)(P.quality,it):!0}if(!B){O[P.quality]="FitsContainer";continue}let q=p||t,we=(0,V.isNonNullable)(q)&&isFinite(q)&&(0,V.isNonNullable)(P.bitrate)?q-a>=P.bitrate*W:!0,tt=An(r,i.highQualityLimit,i.trafficSavingLimit)&&(r==null?void 0:r.min)===P.quality;if(!we&&!tt){O[P.quality]="FitsThroughput";continue}if(i.lazyQualitySwitch&&(0,V.isNonNullable)(i.minBufferToSwitchUp)&&u&&!(0,V.isInvariantQuality)(u.quality)&&(n!=null?n:0)<i.minBufferToSwitchUp&&(0,V.isHigher)(P.quality,u.quality)){O[P.quality]="Buffer";continue}if(!!d&&(0,V.isHigherOrEqual)(P.quality,d)&&!tt){O[P.quality]="DroppedFramesLimit";continue}if(!!f&&(0,V.isHigherOrEqual)(P.quality,f)&&!tt){O[P.quality]="StallsLimit";continue}let _e=_||((0,V.isNullable)(r==null?void 0:r.max)||(0,V.isLowerOrEqual)(P.quality,r.max))&&((0,V.isNullable)(r==null?void 0:r.min)||(0,V.isHigherOrEqual)(P.quality,r.min)),Oe=(0,V.isNonNullable)(c)&&!c?(0,V.isLowerOrEqual)(P.quality,i.backgroundVideoQualityLimit):!0;if(!_e||!Oe){O[P.quality]="FitsQualityLimits";continue}U||(U=P)}U&&U.bitrate&&qg.next(U.bitrate);let M=(he=U!=null?U:(0,We.default)(A,-1))!=null?he:s[0],Q=l==null?void 0:l.last,H=Ln(i,h,M,l);return(0,V.isNonNullable)(l)&&H.quality!==(Q==null?void 0:Q.quality)&&h({message:`
10
10
  [VIDEO TRACKS ABR]
@@ -121,7 +121,7 @@
121
121
  (?<variants>(?:-(?:[a-z0-9]{5,8}|[0-9][a-z0-9]{3}))*)
122
122
  (?<extensions>(?:-[0-9a-wy-z](?:-[a-z0-9]{2,8})+)*)
123
123
  (?:-(?<privateuse>(?:${e})))?
124
- `})|(?<privateuse2>${e}))$`.replace(/[\s\t\n]/g,"");return new RegExp(c,"i")}var HS=s=>{if(!(s!=null&&s.startsWith("P")))return;let e=(n,o)=>{let u=n?parseFloat(n.replace(",",".")):NaN;return(isNaN(u)?0:u)*o},i=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/.exec(s),r=(i==null?void 0:i[1])==="-"?-1:1,a={days:e(i==null?void 0:i[5],r),hours:e(i==null?void 0:i[6],r),minutes:e(i==null?void 0:i[7],r),seconds:e(i==null?void 0:i[8],r)};return a.days*24*60*60*1e3+a.hours*60*60*1e3+a.minutes*60*1e3+a.seconds*1e3},At=(s,e)=>{let t=s;t=(0,ec.default)(t,"$$","$");let i={RepresentationID:e.representationId,Number:e.segmentNumber,Bandwidth:e.bandwidth,Time:e.segmentTime};for(let[r,a]of(0,jS.default)(i)){let n=new RegExp(`\\$${r}(?:%0(\\d+)d)?\\$`,"g");t=(0,ec.default)(t,n,(o,u)=>(0,sa.isNullable)(a)?o:(0,sa.isNullable)(u)?a:(0,QS.default)(a,parseInt(u,10),"0"))}return t},Nn=(s,e)=>{var U,M,Q,H,Z,le,he,F,$,P,B,q,we,tt,Se,de,Ve,_e,Oe,it,qt,ti,yi,Ki,Fr,Lc,$c,Mc,Dc,Cc,Bc,Vc,_c,Oc,Fc,Nc,qc,Uc,Hc,jc,Qc,Wc,Gc,zc,Yc,Kc,Xc,Jc,Zc,ed,td,id,rd,sd,ad,nd,od,ud,ld,cd,dd;let i=new DOMParser().parseFromString(s,"application/xml"),r={video:[],audio:[],text:[]},a=i.children[0],n=Array.from(a.querySelectorAll("MPD > BaseURL").values()).map(gt=>{var ve,Ti;return(Ti=(ve=gt.textContent)==null?void 0:ve.trim())!=null?Ti:""}),o=(U=(0,WS.default)(n,0))!=null?U:"",u=a.getAttribute("type")==="dynamic",l=a.getAttribute("availabilityStartTime"),c=a.getAttribute("publishTime"),d=a.getElementsByTagName("vk:Attrs")[0],f=d==null?void 0:d.getElementsByTagName("vk:XLatestSegmentPublishTime")[0].textContent,p=d==null?void 0:d.getElementsByTagName("vk:XStreamIsLive")[0].textContent,h=d==null?void 0:d.getElementsByTagName("vk:XStreamIsUnpublished")[0].textContent,b=d==null?void 0:d.getElementsByTagName("vk:XPlaybackDuration")[0].textContent,S;u&&(S={availabilityStartTime:l?new Date(l).getTime():0,publishTime:c?new Date(c).getTime():0,latestSegmentPublishTime:f?new Date(f).getTime():0,streamIsAlive:p==="yes",streamIsUnpublished:h==="yes"});let g,y=a.getAttribute("mediaPresentationDuration"),A=[...a.getElementsByTagName("Period")],E=A.reduce((gt,ve)=>j(C({},gt),{[ve.id]:ve.children}),{}),w=A.reduce((gt,ve)=>j(C({},gt),{[ve.id]:ve.getAttribute("duration")}),{});y?g=HS(y):(0,tc.default)(w).filter(gt=>gt).length&&!u?g=(0,tc.default)(w).reduce((gt,ve)=>{var Ti;return gt+((Ti=HS(ve))!=null?Ti:0)},0):b&&(g=parseInt(b,10));let _=0,W=(Q=(M=a.getAttribute("profiles"))==null?void 0:M.split(","))!=null?Q:[];for(let gt of A.map(ve=>ve.id))for(let ve of E[gt]){let Ti=(H=ve.getAttribute("id"))!=null?H:"id"+(_++).toString(10),Nr=(Z=ve.getAttribute("mimeType"))!=null?Z:"",wo=(le=ve.getAttribute("codecs"))!=null?le:"",Ao=(he=ve.getAttribute("contentType"))!=null?he:Nr==null?void 0:Nr.split("/")[0],Uy=($=(F=ve.getAttribute("profiles"))==null?void 0:F.split(","))!=null?$:[],pd=(B=US((P=ve.getAttribute("lang"))!=null?P:""))!=null?B:{},Ia=(tt=(we=(q=ve.querySelector("Label"))==null?void 0:q.textContent)==null?void 0:we.trim())!=null?tt:void 0,Hy=ve.querySelectorAll("Representation"),jy=ve.querySelector("SegmentTemplate"),Qy=(de=(Se=ve.querySelector("Role"))==null?void 0:Se.getAttribute("value"))!=null?de:void 0,Xi=Ao,ke={id:Ti,language:pd.language,isDefault:Qy==="main",label:Ia,codecs:wo,hdr:Xi==="video"&&Zl(wo),mime:Nr,representations:[]};for(let me of Hy){let ii=(Ve=me.getAttribute("lang"))!=null?Ve:void 0,qr=(Oe=(_e=Ia!=null?Ia:ve.getAttribute("label"))!=null?_e:me.getAttribute("label"))!=null?Oe:void 0,Ea=(ti=(qt=(it=me.querySelector("BaseURL"))==null?void 0:it.textContent)==null?void 0:qt.trim())!=null?ti:"",Ii=new URL(Ea||o,e).toString(),ri=(yi=me.getAttribute("mimeType"))!=null?yi:Nr,xa=(Fr=(Ki=me.getAttribute("codecs"))!=null?Ki:wo)!=null?Fr:"",wa;if(Ao==="text"){let si=me.getAttribute("id")||"",Aa=((Lc=pd.privateuse)==null?void 0:Lc.includes("x-auto"))||si.includes("_auto"),Ei=me.querySelector("SegmentTemplate");if(Ei){let Ur={representationId:($c=me.getAttribute("id"))!=null?$c:void 0,bandwidth:(Mc=me.getAttribute("bandwidth"))!=null?Mc:void 0},Pa=parseInt((Dc=me.getAttribute("bandwidth"))!=null?Dc:"",10)/1e3,Ra=(Bc=parseInt((Cc=Ei.getAttribute("startNumber"))!=null?Cc:"",10))!=null?Bc:1,Ji=parseInt((Vc=Ei.getAttribute("timescale"))!=null?Vc:"",10),Po=(_c=Ei.querySelectorAll("SegmentTimeline S"))!=null?_c:[],Zi=Ei.getAttribute("media");if(!Zi)continue;let ka=[],La=0,$a="",er=0,Hr=Ra,Ue=0;for(let vt of Po){let xi=parseInt((Oc=vt.getAttribute("d"))!=null?Oc:"",10),dt=parseInt((Fc=vt.getAttribute("r"))!=null?Fc:"",10)||0,ai=parseInt((Nc=vt.getAttribute("t"))!=null?Nc:"",10);Ue=Number.isFinite(ai)?ai:Ue;let wi=xi/Ji*1e3,ni=Ue/Ji*1e3;for(let Pt=0;Pt<dt+1;Pt++){let oi=At(Zi,j(C({},Ur),{segmentNumber:Hr.toString(10),segmentTime:(Ue+Pt*xi).toString(10)})),tr=(ni!=null?ni:0)+Pt*wi,Qr=tr+wi;Hr++,ka.push({time:{from:tr,to:Qr},url:oi})}Ue+=(dt+1)*xi,La+=(dt+1)*wi}er=Ue/Ji*1e3,$a=At(Zi,j(C({},Ur),{segmentNumber:Hr.toString(10),segmentTime:Ue.toString(10)}));let jr={time:{from:er,to:1/0},url:$a},Ut={type:"template",baseUrl:Ii,segmentTemplateUrl:Zi,initUrl:"",totalSegmentsDurationMs:La,segments:ka,nextSegmentBeyondManifest:jr,timescale:Ji};wa={id:si,kind:"text",segmentReference:Ut,profiles:[],duration:g,bitrate:Pa,mime:"",codecs:"",width:0,height:0,isAuto:Aa}}else wa={id:si,isAuto:Aa,kind:"text",url:Ii}}else{let si=(Uc=(qc=me.getAttribute("contentType"))!=null?qc:ri==null?void 0:ri.split("/")[0])!=null?Uc:Ao,Aa=(jc=(Hc=ve.getAttribute("profiles"))==null?void 0:Hc.split(","))!=null?jc:[],Ei=parseInt((Qc=me.getAttribute("width"))!=null?Qc:"",10),Ur=parseInt((Wc=me.getAttribute("height"))!=null?Wc:"",10),Pa=parseInt((Gc=me.getAttribute("bandwidth"))!=null?Gc:"",10)/1e3,Ra=(zc=me.getAttribute("frameRate"))!=null?zc:"",Ji=(Yc=me.getAttribute("quality"))!=null?Yc:void 0,Po=Ra?qS(Ra):void 0,Zi=(Kc=me.getAttribute("id"))!=null?Kc:"id"+(_++).toString(10),ka=si==="video"?`${Ur}p`:si==="audio"?`${Pa}Kbps`:xa,La=`${Zi}@${ka}`,$a=[...W,...Uy,...Aa],er,Hr=me.querySelector("SegmentBase"),Ue=(Xc=me.querySelector("SegmentTemplate"))!=null?Xc:jy;if(Hr){let Ut=(Zc=(Jc=me.querySelector("SegmentBase Initialization"))==null?void 0:Jc.getAttribute("range"))!=null?Zc:"",[vt,xi]=Ut.split("-").map(oi=>parseInt(oi,10)),dt={from:vt,to:xi},ai=(ed=me.querySelector("SegmentBase"))==null?void 0:ed.getAttribute("indexRange"),[wi,ni]=ai?ai.split("-").map(oi=>parseInt(oi,10)):[],Pt=ai?{from:wi,to:ni}:void 0;er={type:"byteRange",url:Ii,initRange:dt,indexRange:Pt}}else if(Ue){let Ut={representationId:(td=me.getAttribute("id"))!=null?td:void 0,bandwidth:(id=me.getAttribute("bandwidth"))!=null?id:void 0},vt=parseInt((rd=Ue.getAttribute("timescale"))!=null?rd:"",10),xi=(sd=Ue.getAttribute("initialization"))!=null?sd:"",dt=Ue.getAttribute("media"),ai=(nd=parseInt((ad=Ue.getAttribute("startNumber"))!=null?ad:"",10))!=null?nd:1,wi=At(xi,Ut);if(!dt)throw new ReferenceError("No media attribute in SegmentTemplate");let ni=(od=Ue.querySelectorAll("SegmentTimeline S"))!=null?od:[],Pt=[],oi=0,tr="",Qr=0;if(ni.length){let Ma=ai,St=0;for(let ir of ni){let Rt=parseInt((ud=ir.getAttribute("d"))!=null?ud:"",10),Ai=parseInt((ld=ir.getAttribute("r"))!=null?ld:"",10)||0,Da=parseInt((cd=ir.getAttribute("t"))!=null?cd:"",10);St=Number.isFinite(Da)?Da:St;let Ro=Rt/vt*1e3,ko=St/vt*1e3;for(let Ca=0;Ca<Ai+1;Ca++){let Gy=At(dt,j(C({},Ut),{segmentNumber:Ma.toString(10),segmentTime:(St+Ca*Rt).toString(10)})),hd=(ko!=null?ko:0)+Ca*Ro,zy=hd+Ro;Ma++,Pt.push({time:{from:hd,to:zy},url:Gy})}St+=(Ai+1)*Rt,oi+=(Ai+1)*Ro}Qr=St/vt*1e3,tr=At(dt,j(C({},Ut),{segmentNumber:Ma.toString(10),segmentTime:St.toString(10)}))}else if((0,sa.isNonNullable)(g)){let St=parseInt((dd=Ue.getAttribute("duration"))!=null?dd:"",10)/vt*1e3,ir=Math.ceil(g/St),Rt=0;for(let Ai=1;Ai<ir;Ai++){let Da=At(dt,j(C({},Ut),{segmentNumber:Ai.toString(10),segmentTime:Rt.toString(10)}));Pt.push({time:{from:Rt,to:Rt+St},url:Da}),Rt+=St}Qr=Rt,tr=At(dt,j(C({},Ut),{segmentNumber:ir.toString(10),segmentTime:Rt.toString(10)}))}let Wy={time:{from:Qr,to:1/0},url:tr};er={type:"template",baseUrl:Ii,segmentTemplateUrl:dt,initUrl:wi,totalSegmentsDurationMs:oi,segments:Pt,nextSegmentBeyondManifest:Wy,timescale:vt}}else throw new ReferenceError("Unknown MPD segment referencing type");if(!si||!ri)continue;let jr={video:"video",audio:"audio",text:"text"}[si];if(!jr)continue;Xi||(Xi=jr),wa={id:La,kind:jr,segmentReference:er,profiles:$a,duration:g,bitrate:Pa,mime:ri,codecs:xa,width:Ei,height:Ur,fps:Po,quality:Ji}}ke.language||(ke.language=ii),ke.label||(ke.label=qr),ke.mime||(ke.mime=ri),ke.codecs||(ke.codecs=xa),ke.hdr||(ke.hdr=Xi==="video"&&Zl(xa)),ke.representations.push(wa)}if(Xi){let me=r[Xi].find(ii=>ii.id===ke.id);if(me&&ke.representations.every(ii=>ii.segmentReference.type==="template"))for(let ii of me.representations){let qr=ke.representations.find(ri=>ri.id===ii.id),Ea=qr==null?void 0:qr.segmentReference,Ii=ii.segmentReference;Ii.segments.push(...Ea.segments),Ii.nextSegmentBeyondManifest=Ea.nextSegmentBeyondManifest}else r[Xi].push(ke)}}return{duration:g,streams:r,baseUrls:n,live:S}};var ic=Y(xt(),1);var GS=require("@vkontakte/videoplayer-shared/es2015"),zS=({id:s,width:e,height:t,bitrate:i,fps:r,quality:a,streamId:n})=>{var u;let o=(u=a?hi(a):void 0)!=null?u:(0,GS.videoSizeToQuality)({width:e,height:t});return o&&{id:s,quality:o,bitrate:i,size:{width:e,height:t},fps:r,streamId:n}},YS=({id:s,bitrate:e})=>({id:s,bitrate:e}),KS=({language:s,label:e},{id:t,url:i,isAuto:r})=>({id:t,url:i,isAuto:r,type:"internal",language:s,label:e}),XS=({language:s,label:e,id:t,url:i,isAuto:r})=>({id:t,url:i,isAuto:r,type:"internal",language:s,label:e}),rc=({id:s,language:e,label:t,codecs:i,isDefault:r})=>({id:s,language:e,label:t,codec:(0,ic.default)(i.split("."),0),isDefault:r}),sc=({id:s,language:e,label:t,hdr:i,codecs:r})=>({id:s,language:e,hdr:i,label:t,codec:(0,ic.default)(r.split("."),0)}),ac=s=>"url"in s,ut=s=>s.type==="template";var nc=require("@vkontakte/videoplayer-shared/es2015"),te=(s,e)=>(0,nc.isNonNullable)(s)&&(0,nc.isNonNullable)(e)&&s.readyState==="open"&&g$(s,e);function g$(s,e){for(let t=0;t<s.activeSourceBuffers.length;++t)if(s.activeSourceBuffers[t]===e)return!0;return!1}var aa=class{constructor(e,t,i,{fetcher:r,tuning:a,getCurrentPosition:n,isActiveLowLatency:o,compatibilityMode:u=!1,manifest:l}){this.currentLiveSegmentServerLatency$=new k.ValueSubject(0);this.currentLowLatencySegmentLength$=new k.ValueSubject(0);this.currentSegmentLength$=new k.ValueSubject(0);this.onLastSegment$=new k.ValueSubject(!1);this.fullyBuffered$=new k.ValueSubject(!1);this.playingRepresentation$=new k.ValueSubject(void 0);this.playingRepresentationInit$=new k.ValueSubject(void 0);this.error$=new k.Subject;this.gaps=[];this.subscription=new k.Subscription;this.allInitsLoaded=!1;this.activeSegments=new Set;this.downloadAbortController=new fe;this.switchAbortController=new fe;this.destroyAbortController=new fe;this.bufferLimit=1/0;this.failedDownloads=0;this.baseUrls=[];this.baseUrlsIndex=0;this.isLive=!1;this.liveUpdateSegmentIndex=0;this.liveInitialAdditionalOffset=0;this.isSeekingLive=!1;this.index=0;this.lastDataObtainedTimestampMs=0;this.loadByteRangeSegmentsTimeoutId=0;this.startWith=(0,k.abortable)(this.destroyAbortController.signal,function(e){return oe(this,null,function*(){let t=this.representations.get(e);(0,k.assertNonNullable)(t,`Cannot find representation ${e}`),this.playingRepresentationId=e,this.downloadingRepresentationId=e,this.sourceBuffer=this.mediaSource.addSourceBuffer(`${t.mime}; codecs="${t.codecs}"`),this.sourceBufferTaskQueue=new Qv(this.sourceBuffer),this.subscription.add((0,k.fromEvent)(this.sourceBuffer,"updateend").subscribe(()=>{this.checkEjectedSegments(),this.maintain()},n=>{let o,u=this.mediaSource.readyState;u!=="open"&&(o={id:`SegmentEjection_source_${u}`,category:k.ErrorCategory.VIDEO_PIPELINE,message:"Error when trying to clear segments ejected by browser",thrown:n}),o!=null||(o={id:"SegmentEjection",category:k.ErrorCategory.VIDEO_PIPELINE,message:"Error when trying to clear segments ejected by browser",thrown:n}),this.error$.next(o)})),this.subscription.add((0,k.fromEvent)(this.sourceBuffer,"error").subscribe(()=>this.error$.next({id:"SourceBuffer",category:k.ErrorCategory.VIDEO_PIPELINE,message:"SourceBuffer Error event fired"}))),this.subscription.add(this.sourceBufferTaskQueue.bufferFull$.subscribe(n=>{let o=this.getCurrentPosition();if(!this.sourceBuffer||!o||!te(this.mediaSource,this.sourceBuffer))return;let u=Math.min(this.bufferLimit,kr(this.sourceBuffer.buffered)*.8);this.bufferLimit=u;let l=this.getForwardBufferDuration(o),c=Math.min(this.forwardBufferTarget,this.bufferLimit)*this.tuning.dash.minSafeBufferThreshold;this.pruneBuffer(o,n*2,l<c).catch(d=>{this.handleAsyncError(d,"pruneBuffer")})})),this.subscription.add(this.sourceBufferTaskQueue.error$.subscribe(n=>this.error$.next(n))),yield this.loadInit(t,"high",!0);let i=this.initData.get(t.id),r=this.segments.get(t.id),a=this.parsedInitData.get(t.id);(0,k.assertNonNullable)(i,"No init buffer for starting representation"),(0,k.assertNonNullable)(r,"No segments for starting representation"),i instanceof ArrayBuffer&&(this.searchGaps(r,t),yield this.sourceBufferTaskQueue.append(i,this.destroyAbortController.signal),this.playingRepresentation$.next(this.playingRepresentationId),this.playingRepresentationInit$.next(a))})}.bind(this));this.switchTo=(0,k.abortable)(this.destroyAbortController.signal,function(e,t=!1){return oe(this,null,function*(){if(!te(this.mediaSource,this.sourceBuffer)||e===this.downloadingRepresentationId||e===this.switchingToRepresentationId)return;this.switchingToRepresentationId=e;let i=this.representations.get(e);(0,k.assertNonNullable)(i,`No such representation ${e}`);let r=this.segments.get(e),a=this.initData.get(e);if((0,k.isNullable)(a)||(0,k.isNullable)(r)?yield this.loadInit(i,"high",!1):a instanceof Promise&&(yield a),r=this.segments.get(e),(0,k.assertNonNullable)(r,"No segments for starting representation"),a=this.initData.get(e),!(!a||!(a instanceof ArrayBuffer)||!this.sourceBuffer||!te(this.mediaSource,this.sourceBuffer))){if(yield this.abort(),yield this.sourceBufferTaskQueue.append(a,this.downloadAbortController.signal),t)this.switchingToRepresentationId=void 0,this.downloadingRepresentationId=e,yield this.dropBuffer();else{let n=this.getCurrentPosition();(0,k.isNonNullable)(n)&&!this.isLive&&(this.bufferLimit=1/0,yield new Pi(this.pruneBuffer(n,1/0,!0))),this.switchingToRepresentationId=void 0,this.downloadingRepresentationId=e}this.maintain()}})}.bind(this));this.switchToOld=(0,k.abortable)(this.destroyAbortController.signal,function(e,t=!1){return oe(this,null,function*(){if(!te(this.mediaSource,this.sourceBuffer)||e===this.downloadingRepresentationId||e===this.switchingToRepresentationId)return;this.switchingToRepresentationId=e;let i=this.representations.get(e);(0,k.assertNonNullable)(i,`No such representation ${e}`);let r=this.segments.get(e),a=this.initData.get(e);if((0,k.isNullable)(a)||(0,k.isNullable)(r)?yield this.loadInit(i,"high",!1):a instanceof Promise&&(yield a),r=this.segments.get(e),(0,k.assertNonNullable)(r,"No segments for starting representation"),a=this.initData.get(e),!(!a||!(a instanceof ArrayBuffer)||!this.sourceBuffer||!te(this.mediaSource,this.sourceBuffer)))if(yield this.abort(),yield this.sourceBufferTaskQueue.append(a,this.downloadAbortController.signal),t)this.switchingToRepresentationId=void 0,this.downloadingRepresentationId=e,yield this.dropBuffer(),this.maintain();else{let n=this.getCurrentPosition();(0,k.isNonNullable)(n)&&(this.isLive||(this.bufferLimit=1/0,yield new Pi(this.pruneBuffer(n,1/0,!0))),this.maintain(n)),this.switchingToRepresentationId=void 0,this.downloadingRepresentationId=e}})}.bind(this));this.seekLive=(0,k.abortable)(this.destroyAbortController.signal,function(e){return oe(this,null,function*(){var u,l;let t=(u=(0,Un.default)(e,c=>c.representations))!=null?u:[];if(this.isSeekingLive=!0,!this.downloadingRepresentationId||!t)return;for(let c of this.representations.keys()){let d=t.find(h=>h.id===c);d&&this.representations.set(c,d);let f=this.representations.get(c);if(!f||!ut(f.segmentReference))return;let p=this.getActualLiveStartingSegments(f.segmentReference);this.segments.set(f.id,p)}let i=(l=this.switchingToRepresentationId)!=null?l:this.downloadingRepresentationId,r=this.representations.get(i);(0,k.assertNonNullable)(r);let a=this.segments.get(i);(0,k.assertNonNullable)(a,"No segments for starting representation");let n=this.initData.get(i);if((0,k.assertNonNullable)(n,"No init buffer for starting representation"),!(n instanceof ArrayBuffer))return;let o=this.getDebugBufferState();this.liveUpdateSegmentIndex=0,yield this.abort(),o&&(yield this.sourceBufferTaskQueue.remove(o.from*1e3,o.to*1e3,this.destroyAbortController.signal)),this.searchGaps(a,r),yield this.sourceBufferTaskQueue.append(n,this.destroyAbortController.signal),this.isSeekingLive=!1})}.bind(this));var c;this.fetcher=r,this.tuning=a,this.compatibilityMode=u,this.forwardBufferTarget=a.dash.forwardBufferTargetAuto,this.getCurrentPosition=n,this.isActiveLowLatency=o,this.isLive=!!(l!=null&&l.live),this.baseUrls=(c=l==null?void 0:l.baseUrls)!=null?c:[],this.initData=new Map(i.map(d=>[d.id,null])),this.segments=new Map,this.parsedInitData=new Map,this.representations=new Map(i.map(d=>[d.id,d])),this.kind=e,this.mediaSource=t,this.sourceBuffer=null}switchToWithPreviousAbort(e,t=!1){!te(this.mediaSource,this.sourceBuffer)||e===this.downloadingRepresentationId||e===this.switchingToRepresentationId||(this.switchAbortController.abort(),this.switchAbortController=new fe,(0,k.abortable)(this.switchAbortController.signal,function(i,r=!1){return oe(this,null,function*(){this.switchingToRepresentationId=i;let a=this.representations.get(i);(0,k.assertNonNullable)(a,`No such representation ${i}`);let n=this.segments.get(i),o=this.initData.get(i);if((0,k.isNullable)(o)||(0,k.isNullable)(n)?yield this.loadInit(a,"high",!1):o instanceof Promise&&(yield o),n=this.segments.get(i),(0,k.assertNonNullable)(n,"No segments for starting representation"),o=this.initData.get(i),!(!(o instanceof ArrayBuffer)||!this.sourceBuffer||!te(this.mediaSource,this.sourceBuffer))){if(yield this.abort(),yield this.sourceBufferTaskQueue.append(o,this.downloadAbortController.signal),r)this.switchingToRepresentationId=void 0,this.downloadingRepresentationId=i,yield this.dropBuffer();else{let u=this.getCurrentPosition();(0,k.isNonNullable)(u)&&!this.isLive&&(this.bufferLimit=this.forwardBufferTarget,yield this.pruneBuffer(u,1/0,!0)),this.downloadingRepresentationId=i,this.switchingToRepresentationId=void 0}this.maintain()}})}.bind(this))(e,t))}warmUpMediaSource(){!(0,k.isNullable)(this.sourceBuffer)&&!this.sourceBuffer.updating&&(this.sourceBuffer.mode="segments")}abort(){return R(this,null,function*(){for(let e of this.activeSegments)this.abortSegment(e.segment);return this.activeSegments.clear(),this.downloadAbortController.abort(),this.downloadAbortController=new fe,this.abortBuffer()})}maintain(e=this.getCurrentPosition()){if((0,k.isNullable)(e)||(0,k.isNullable)(this.downloadingRepresentationId)||(0,k.isNullable)(this.playingRepresentationId)||(0,k.isNullable)(this.sourceBuffer)||!te(this.mediaSource,this.sourceBuffer)||(0,k.isNonNullable)(this.switchingToRepresentationId)||this.isSeekingLive)return;let t=this.representations.get(this.downloadingRepresentationId),i=this.segments.get(this.downloadingRepresentationId);if((0,k.assertNonNullable)(t,`No such representation ${this.downloadingRepresentationId}`),!i)return;let r=i.find(c=>e>=c.time.from&&e<c.time.to);(0,k.isNonNullable)(r)&&isFinite(r.time.from)&&isFinite(r.time.to)&&this.currentSegmentLength$.next((r==null?void 0:r.time.to)-r.time.from);let a=e,n=100;if(this.playingRepresentationId!==this.downloadingRepresentationId){let c=this.getForwardBufferDuration(e),d=r?r.time.to+n:-1/0;r&&r.time.to-e<this.tuning.dash.maxSegmentDurationLeftToSelectNextSegment&&c>=r.time.to-e+n&&(a=d)}if(isFinite(this.bufferLimit)&&kr(this.sourceBuffer.buffered)>=this.bufferLimit){let c=this.getForwardBufferDuration(e),d=Math.min(this.forwardBufferTarget,this.bufferLimit)*this.tuning.dash.minSafeBufferThreshold;this.pruneBuffer(e,1/0,c<d).catch(f=>{this.handleAsyncError(f,"pruneBuffer")});return}let u=[];if(!this.activeSegments.size&&(u=this.selectForwardBufferSegments(i,t.segmentReference.type,a),u.length)){let c="auto";if(this.tuning.dash.useFetchPriorityHints&&r)if((0,qn.default)(u,r))c="high";else{let d=(0,ji.default)(u,0);d&&d.time.from-r.time.to>=this.forwardBufferTarget/2&&(c="low")}this.loadSegments(u,t,c).catch(d=>{this.handleAsyncError(d,"loadSegments")})}(!this.preloadOnly&&!this.allInitsLoaded&&r&&r.status==="fed"&&!u.length&&this.getForwardBufferDuration(e)>3e3||this.isActiveLowLatency())&&this.loadNextInit();let l=(0,ji.default)(i,-1);!this.isLive&&l&&(this.fullyBuffered$.next(l.time.to-e-this.getForwardBufferDuration(e)<n),this.onLastSegment$.next(e-l.time.from>0))}get lastDataObtainedTimestamp(){return this.lastDataObtainedTimestampMs}searchGaps(e,t){this.gaps=[];let i=0,r=this.isLive?this.liveInitialAdditionalOffset:0;for(let a of e)Math.trunc(a.time.from-i)>0&&this.gaps.push({representation:t.id,from:i,to:a.time.from+r}),i=a.time.to;(0,k.isNonNullable)(t.duration)&&t.duration-i>0&&!this.isLive&&this.gaps.push({representation:t.id,from:i,to:t.duration})}getActualLiveStartingSegments(e){let t=e.segments,i=this.isActiveLowLatency()?this.tuning.dashCmafLive.lowLatency.maxTargetOffset:this.tuning.dashCmafLive.maxActiveLiveOffset,r=[],a=0,n=t.length-1;do r.unshift(t[n]),a+=t[n].time.to-t[n].time.from,n--;while(a<i&&n>=0);return this.liveInitialAdditionalOffset=a-i,this.isActiveLowLatency()?[r[0]]:r}getLiveSegmentsToLoadState(e){let t=(0,Un.default)(e==null?void 0:e.streams[this.kind],r=>r.representations).find(r=>r.id===this.downloadingRepresentationId);if(!t)return;let i=this.segments.get(t.id);if(i!=null&&i.length)return{from:i[0].time.from,to:i[i.length-1].time.to}}updateLive(e){var i,r,a,n;let t=(i=(0,Un.default)(e==null?void 0:e.streams[this.kind],o=>o.representations))!=null?i:[];if(![...this.segments.values()].every(o=>!o.length))for(let o of t){if(!o||!ut(o.segmentReference))return;let u=o.segmentReference.segments.map(p=>j(C({},p),{status:"none",size:void 0})),l=100,c=(r=this.segments.get(o.id))!=null?r:[],d=(n=(a=(0,ji.default)(c,-1))==null?void 0:a.time.to)!=null?n:0,f=u==null?void 0:u.findIndex(p=>d>=p.time.from+l&&d<=p.time.to+l);if(f===-1){this.liveUpdateSegmentIndex=0;let p=this.getActualLiveStartingSegments(o.segmentReference);this.segments.set(o.id,p)}else{let p=u.slice(f+1);this.segments.set(o.id,[...c,...p])}}}proceedLowLatencyLive(){let e=this.downloadingRepresentationId;(0,k.assertNonNullable)(e);let t=this.segments.get(e);if(t!=null&&t.length){let i=t[t.length-1];this.updateLowLatencyLiveIfNeeded(i)}}calculateDurationFromSegments(){var t;if(!this.playingRepresentationId)return 0;let e=this.segments.get(this.playingRepresentationId);return(e?(t=(0,ji.default)(e,-1))==null?void 0:t.time.to:0)||0}updateLowLatencyLiveIfNeeded(e){var i;let t=0;for(let r of this.representations.values()){let a=r.segmentReference;if(!ut(a))return;let n=(i=this.segments.get(r.id))!=null?i:[],o=n.find(l=>Math.floor(l.time.from)===Math.floor(e.time.from));if(o&&!isFinite(o.time.to)&&(o.time.to=e.time.to,t=o.time.to-o.time.from),!!!n.find(l=>Math.floor(l.time.from)===Math.floor(e.time.to))&&this.isActiveLowLatency()){let l=Math.round(e.time.to*a.timescale/1e3).toString(10),c=At(a.segmentTemplateUrl,{segmentTime:l});n.push({status:"none",time:{from:e.time.to,to:1/0},url:c})}}this.currentLowLatencySegmentLength$.next(t)}findSegmentStartTime(e){var a,n,o;let t=(n=(a=this.switchingToRepresentationId)!=null?a:this.downloadingRepresentationId)!=null?n:this.playingRepresentationId;if(!t)return;let i=this.segments.get(t);if(!i)return;let r=i.find(u=>u.time.from<=e&&u.time.to>=e);return(o=r==null?void 0:r.time.from)!=null?o:void 0}setTarget(e){this.forwardBufferTarget=e}setPreloadOnly(e){this.preloadOnly=e}destroy(){var e;if(this.initData.clear(),this.segments.clear(),this.parsedInitData.clear(),this.representations.clear(),(e=this.sourceBufferTaskQueue)==null||e.destroy(),this.gapDetectionIdleCallback&&_t&&_t(this.gapDetectionIdleCallback),this.initLoadIdleCallback&&_t&&_t(this.initLoadIdleCallback),this.subscription.unsubscribe(),this.sourceBuffer)try{this.mediaSource.removeSourceBuffer(this.sourceBuffer)}catch(t){if(!(t instanceof DOMException&&t.name==="NotFoundError"))throw t}this.sourceBuffer=null,this.downloadAbortController.abort(),this.switchAbortController.abort(),this.destroyAbortController.abort(),window.clearTimeout(this.loadByteRangeSegmentsTimeoutId)}selectForwardBufferSegments(e,t,i){return this.isLive?this.selectForwardBufferSegmentsLive(e,i):this.selectForwardBufferSegmentsRecord(e,t,i)}selectForwardBufferSegmentsLive(e,t){let i=e.findIndex(r=>t>=r.time.from&&t<r.time.to);return this.playingRepresentationId!==this.downloadingRepresentationId&&(this.liveUpdateSegmentIndex=i),this.liveUpdateSegmentIndex<e.length?e.slice(this.liveUpdateSegmentIndex++):[]}selectForwardBufferSegmentsRecord(e,t,i){let r=this.getForwardBufferDuration(i),a=e.findIndex(({status:f,time:{from:p,to:h}},b)=>{let S=p<=i&&h>=i,g=p>i||S||b===0&&i===0,y=Math.min(this.forwardBufferTarget,this.bufferLimit),A=this.preloadOnly&&p<=i+y||r<y&&h-p>=y||h<=i+y;return(f==="none"||f==="partially_ejected"&&g&&A&&this.sourceBuffer&&te(this.mediaSource,this.sourceBuffer)&&!(qe(this.sourceBuffer.buffered,p)&&qe(this.sourceBuffer.buffered,h)))&&g&&A});if(a===-1)return[];if(t!=="byteRange")return e.slice(a,a+1);let n=e,o=0,u=0,l=[],c=this.preloadOnly?0:this.tuning.dash.segmentRequestSize,d=this.preloadOnly?this.forwardBufferTarget:0;for(let f=a;f<n.length&&(o<=c||u<=d);f++){let p=n[f];if(o+=p.byte.to+1-p.byte.from,u+=p.time.to+1-p.time.from,p.status==="none"||p.status==="partially_ejected")l.push(p);else break}return l}loadSegments(e,t,i="auto"){return R(this,null,function*(){ut(t.segmentReference)?yield this.loadTemplateSegment(e[0],t,i):yield this.loadByteRangeSegments(e,t,i)})}loadTemplateSegment(e,t,i="auto"){return R(this,null,function*(){e.status="downloading";let r={segment:e,loadedBytes:0,feedingBytes:0,fedBytes:0,representationId:t.id};this.activeSegments.add(r);let{range:a,url:n,signal:o,onProgress:u,onProgressTasks:l}=this.prepareTemplateFetchSegmentParams(e,t);this.failedDownloads&&o&&(yield(0,k.abortable)(o,function(){return oe(this,null,function*(){let c=(0,k.getExponentialDelay)(this.failedDownloads,this.tuning.downloadBackoff);yield new Promise(d=>setTimeout(d,c))})}.bind(this))(),o.aborted&&this.abortActiveSegments([e]));try{let c=yield this.fetcher.fetch(n,{range:a,signal:o,onProgress:u,priority:i,isLowLatency:this.isActiveLowLatency(),bufferOptimisation:this.tuning.dash.fetcherBufferOptimisation});if(this.lastDataObtainedTimestampMs=(0,k.now)(),!c)return;let d=new DataView(c),f=Ot(t.mime);if(!isFinite(r.segment.time.to)){let b=t.segmentReference.timescale;r.segment.time.to=f.getChunkEndTime(d,b)}u&&r.feedingBytes&&l?yield Promise.all(l):yield this.sourceBufferTaskQueue.append(d,o);let{serverDataReceivedTimestamp:p,serverDataPreparedTime:h}=f.getServerLatencyTimestamps(d);p&&h&&this.currentLiveSegmentServerLatency$.next(h-p),r.segment.status="downloaded",this.onSegmentFullyAppended(r,t.id),this.failedDownloads=0}catch(c){this.abortActiveSegments([e]),Ft(c)||(this.failedDownloads++,this.updateRepresentationsBaseUrlIfNeeded())}})}updateRepresentationsBaseUrlIfNeeded(){if(!this.tuning.dash.enableBaseUrlSupport||!this.baseUrls.length||this.failedDownloads<=this.tuning.dash.maxSegmentRetryCount)return;this.baseUrlsIndex=(this.baseUrlsIndex+1)%this.baseUrls.length;let e=this.baseUrls[this.baseUrlsIndex];for(let t of this.representations.values())ut(t.segmentReference)?t.segmentReference.baseUrl=e:t.segmentReference.url=e}loadByteRangeSegments(e,t,i="auto"){return R(this,null,function*(){if(!e.length)return;for(let u of e)u.status="downloading",this.activeSegments.add({segment:u,loadedBytes:0,feedingBytes:0,fedBytes:0,representationId:t.id});let{range:r,url:a,signal:n,onProgress:o}=this.prepareByteRangeFetchSegmentParams(e,t);this.failedDownloads&&n&&(yield(0,k.abortable)(n,function(){return oe(this,null,function*(){let u=(0,k.getExponentialDelay)(this.failedDownloads,this.tuning.downloadBackoff);yield new Promise(l=>{this.loadByteRangeSegmentsTimeoutId=window.setTimeout(l,u),(0,k.fromEvent)(window,"online").pipe((0,k.once)()).subscribe(()=>{l(),window.clearTimeout(this.loadByteRangeSegmentsTimeoutId)})})})}.bind(this))(),n.aborted&&this.abortActiveSegments(e));try{yield this.fetcher.fetch(a,{range:r,onProgress:o,signal:n,priority:i,bufferOptimisation:this.tuning.dash.fetcherBufferOptimisation}),this.lastDataObtainedTimestampMs=(0,k.now)(),this.failedDownloads=0}catch(u){this.abortActiveSegments(e),Ft(u)||(this.failedDownloads++,this.updateRepresentationsBaseUrlIfNeeded())}})}prepareByteRangeFetchSegmentParams(e,t){if(ut(t.segmentReference))throw new Error("Representation is not byte range type");let i=t.segmentReference.url,r={from:(0,ji.default)(e,0).byte.from,to:(0,ji.default)(e,-1).byte.to},{signal:a}=this.downloadAbortController;return{url:i,range:r,signal:a,onProgress:(o,u)=>R(this,null,function*(){if(!a.aborted)try{this.lastDataObtainedTimestampMs=(0,k.now)(),yield this.onSomeByteRangesDataLoaded({dataView:o,loaded:u,signal:a,onSegmentAppendFailed:()=>this.abort(),globalFrom:r?r.from:0,representationId:t.id})}catch(l){this.error$.next({id:"SegmentFeeding",category:k.ErrorCategory.VIDEO_PIPELINE,message:"Error when feeding segments",thrown:l})}})}}prepareTemplateFetchSegmentParams(e,t){if(!ut(t.segmentReference))throw new Error("Representation is not template type");let i=new URL(e.url,t.segmentReference.baseUrl);this.isActiveLowLatency()&&i.searchParams.set("low-latency","yes");let r=i.toString(),{signal:a}=this.downloadAbortController,n=[],u=this.isActiveLowLatency()||this.tuning.dash.enableSubSegmentBufferFeeding&&this.liveUpdateSegmentIndex<3?(l,c)=>{if(!a.aborted)try{this.lastDataObtainedTimestampMs=(0,k.now)();let d=this.onSomeTemplateDataLoaded({dataView:l,loaded:c,signal:a,onSegmentAppendFailed:()=>this.abort(),representationId:t.id});n.push(d)}catch(d){this.error$.next({id:"SegmentFeeding",category:k.ErrorCategory.VIDEO_PIPELINE,message:"Error when feeding segments",thrown:d})}}:void 0;return{url:r,signal:a,onProgress:u,onProgressTasks:n}}abortActiveSegments(e){for(let t of this.activeSegments)(0,qn.default)(e,t.segment)&&this.abortSegment(t.segment)}onSomeTemplateDataLoaded(n){return R(this,arguments,function*({dataView:e,representationId:t,loaded:i,onSegmentAppendFailed:r,signal:a}){if(!this.activeSegments.size||!te(this.mediaSource,this.sourceBuffer))return;let o=this.representations.get(t);if(o)for(let u of this.activeSegments){let{segment:l}=u;if(u.representationId===t){if(a.aborted){r();continue}if(u.loadedBytes=i,u.loadedBytes>u.feedingBytes){let c=new DataView(e.buffer,e.byteOffset+u.feedingBytes,u.loadedBytes-u.feedingBytes),d=Ot(o.mime).parseFeedableSegmentChunk(c,this.isLive);d!=null&&d.byteLength&&(l.status="partially_fed",u.feedingBytes+=d.byteLength,yield this.sourceBufferTaskQueue.append(d),u.fedBytes+=d.byteLength)}}}})}onSomeByteRangesDataLoaded(o){return R(this,arguments,function*({dataView:e,representationId:t,globalFrom:i,loaded:r,signal:a,onSegmentAppendFailed:n}){if(!this.activeSegments.size||!te(this.mediaSource,this.sourceBuffer))return;let u=this.representations.get(t);if(u)for(let l of this.activeSegments){let{segment:c}=l;if(l.representationId!==t)continue;if(a.aborted){yield n();continue}let d=c.byte.from-i,f=c.byte.to-i,p=f-d+1,h=d<r,b=f<=r;if(!h)continue;let S=Ot(u.mime);if(c.status==="downloading"&&b){c.status="downloaded";let g=new DataView(e.buffer,e.byteOffset+d,p);(yield this.sourceBufferTaskQueue.append(g,a))&&!a.aborted?this.onSegmentFullyAppended(l,t):yield n()}else if(this.tuning.dash.enableSubSegmentBufferFeeding&&(c.status==="downloading"||c.status==="partially_fed")&&(l.loadedBytes=Math.min(p,r-d),l.loadedBytes>l.feedingBytes)){let g=new DataView(e.buffer,e.byteOffset+d+l.feedingBytes,l.loadedBytes-l.feedingBytes),y=l.loadedBytes===p?g:S.parseFeedableSegmentChunk(g);y!=null&&y.byteLength&&(c.status="partially_fed",l.feedingBytes+=y.byteLength,(yield this.sourceBufferTaskQueue.append(y,a))&&!a.aborted?(l.fedBytes+=y.byteLength,l.fedBytes===p&&this.onSegmentFullyAppended(l,t)):yield n())}}})}onSegmentFullyAppended(e,t){var i;if(!((0,k.isNullable)(this.sourceBuffer)||!te(this.mediaSource,this.sourceBuffer))){!this.isLive&&K.browser.isSafari&&this.tuning.useSafariEndlessRequestBugfix&&(qe(this.sourceBuffer.buffered,e.segment.time.from,100)&&qe(this.sourceBuffer.buffered,e.segment.time.to,100)||this.error$.next({id:"EmptyAppendBuffer",category:k.ErrorCategory.VIDEO_PIPELINE,message:"Browser stuck on empty result of adding segment to source buffer"})),this.playingRepresentationId=t,this.playingRepresentation$.next(this.playingRepresentationId),this.playingRepresentationInit$.next(this.parsedInitData.get(this.playingRepresentationId)),e.segment.status="fed",ac(e.segment)&&(e.segment.size=e.fedBytes);for(let r of this.representations.values())if(r.id!==t)for(let a of(i=this.segments.get(r.id))!=null?i:[])a.status==="fed"&&Math.round(a.time.from)===Math.round(e.segment.time.from)&&Math.round(a.time.to)===Math.round(e.segment.time.to)&&(a.status="none");this.updateLowLatencyLiveIfNeeded(e.segment),this.activeSegments.delete(e),this.detectGapsWhenIdle(t,[e.segment])}}abortSegment(e){e.status==="partially_fed"?e.status="partially_ejected":e.status!=="partially_ejected"&&(e.status="none");for(let t of this.activeSegments.values())if(t.segment===e){this.activeSegments.delete(t);break}}loadNextInit(){if(this.allInitsLoaded||this.initLoadIdleCallback)return;let e=null,t=!1;for(let[r,a]of this.initData.entries()){let n=a instanceof Promise;t||(t=n),a===null&&(e=r)}if(!e){this.allInitsLoaded=!0;return}if(t)return;let i=this.representations.get(e);i&&(this.initLoadIdleCallback=Rr(()=>(0,JS.default)(this.loadInit(i,"low",!1),()=>this.initLoadIdleCallback=null)))}loadInit(e,t="auto",i=!1){return R(this,null,function*(){let r=this.tuning.dash.useFetchPriorityHints?t:"auto",n=(!i&&this.failedDownloads>0?(0,k.abortable)(this.destroyAbortController.signal,function(){return oe(this,null,function*(){let o=(0,k.getExponentialDelay)(this.failedDownloads,this.tuning.downloadBackoff);yield new Promise(u=>setTimeout(u,o))})}.bind(this))():Promise.resolve()).then(()=>this.fetcher.fetchRepresentation(e.segmentReference,Ot(e.mime),r)).then(o=>R(this,null,function*(){if(!o)return;let{init:u,dataView:l,segments:c}=o,d=l.buffer.slice(l.byteOffset,l.byteOffset+l.byteLength);this.initData.set(e.id,d);let f=c;this.isLive&&ut(e.segmentReference)&&(f=this.getActualLiveStartingSegments(e.segmentReference)),(!this.isLive||!this.segments.has(e.id))&&this.segments.set(e.id,f),u&&this.parsedInitData.set(e.id,u)})).then(()=>this.failedDownloads=0,o=>{this.initData.set(e.id,null),i&&this.error$.next({id:"LoadInits",category:k.ErrorCategory.WTF,message:"loadInit threw",thrown:o})});return this.initData.set(e.id,n),n})}dropBuffer(){return R(this,null,function*(){for(let e of this.segments.values())for(let t of e)t.status="none";yield this.pruneBuffer(0,1/0,!0)})}pruneBuffer(e,t,i=!1){return R(this,null,function*(){if(!this.sourceBuffer||!te(this.mediaSource,this.sourceBuffer)||!this.playingRepresentationId||(0,k.isNullable)(e))return!1;let r=[],a=0,n=u=>{u.sort((c,d)=>c.from-d.from);let l=[u[0]];for(let c=1;c<u.length;c++){let{from:d,to:f}=u[c],p=l[l.length-1];p.to>=d?p.to=Math.max(p.to,f):l.push(u[c])}return l},o=u=>{var c;if(a>=t)return r;r.push(C({},u.time)),r=n(r);let l=ac(u)?(c=u.size)!=null?c:0:u.byte.to-u.byte.from;a+=l};for(let u of this.segments.values())for(let l of u){let c=l.time.to<=e-this.tuning.dash.bufferPruningSafeZone,d=l.time.from>=e+Math.min(this.forwardBufferTarget,this.bufferLimit);(c||d)&&l.status==="fed"&&o(l)}for(let u=0;u<this.sourceBuffer.buffered.length;u++){let l=this.sourceBuffer.buffered.start(u)*1e3,c=this.sourceBuffer.buffered.end(u)*1e3,d=0;for(let f of this.segments.values())for(let p of f)(0,qn.default)(["none","partially_ejected"],p.status)&&Math.round(p.time.from)<=Math.round(l)&&Math.round(p.time.to)>=Math.round(c)&&d++;if(d===this.segments.size){let f={time:{from:l,to:c},url:"",status:"none"};o(f)}}if(r.length&&i){let u=Math.min(this.forwardBufferTarget,this.bufferLimit)*this.tuning.dash.minSafeBufferThreshold;for(let l of this.segments.values())for(let c of l)c.time.from>=e+u&&c.status==="fed"&&o(c)}return r.length?(yield Promise.all(r.map(l=>this.sourceBufferTaskQueue.remove(l.from,l.to)))).reduce((l,c)=>l||c,!1):!1})}abortBuffer(){return R(this,null,function*(){if(!this.sourceBuffer||!te(this.mediaSource,this.sourceBuffer))return!1;let e=this.playingRepresentationId&&this.initData.get(this.playingRepresentationId),t=e instanceof ArrayBuffer?e:void 0;return this.sourceBufferTaskQueue.abort(t)})}getDebugBufferState(){if(!(!this.sourceBuffer||!te(this.mediaSource,this.sourceBuffer)||!this.sourceBuffer.buffered.length))return{from:this.sourceBuffer.buffered.start(0),to:this.sourceBuffer.buffered.end(this.sourceBuffer.buffered.length-1)}}getForwardBufferDuration(e=this.getCurrentPosition()){return!this.sourceBuffer||!te(this.mediaSource,this.sourceBuffer)||!this.sourceBuffer.buffered.length||(0,k.isNullable)(e)?0:Be(this.sourceBuffer.buffered,e)}detectGaps(e,t){if(!(!this.sourceBuffer||!te(this.mediaSource,this.sourceBuffer))){if(this.tuning.useRefactoredSearchGap)for(let i=0;i<this.sourceBuffer.buffered.length;i++)this.gaps=this.gaps.filter(r=>this.sourceBuffer&&(Math.round(r.from)<Math.round(this.sourceBuffer.buffered.start(i)*1e3)||Math.round(r.to)>Math.round(this.sourceBuffer.buffered.end(i)*1e3)));for(let i of t){let r={representation:e,from:i.time.from,to:i.time.to};for(let a=0;a<this.sourceBuffer.buffered.length;a++){let n=this.sourceBuffer.buffered.start(a)*1e3,o=this.sourceBuffer.buffered.end(a)*1e3;if(!(o<=i.time.from||n>=i.time.to)){if(n<=i.time.from&&o>=i.time.to){r=void 0;break}o>i.time.from&&o<i.time.to&&(r.from=o),n<i.time.to&&n>i.time.from&&(r.to=n)}}r&&r.to-r.from>1&&!this.gaps.some(a=>r&&a.from===r.from&&a.to===r.to)&&this.gaps.push(r)}}}detectGapsWhenIdle(e,t){if(!(this.gapDetectionIdleCallback||!this.sourceBuffer||!te(this.mediaSource,this.sourceBuffer))){if(!this.tuning.useRefactoredSearchGap)for(let i=0;i<this.sourceBuffer.buffered.length;i++)this.gaps=this.gaps.filter(r=>this.sourceBuffer&&(Math.round(r.from)<Math.round(this.sourceBuffer.buffered.start(i)*1e3)||Math.round(r.to)>Math.round(this.sourceBuffer.buffered.end(i)*1e3)));this.gapDetectionIdleCallback=Rr(()=>{try{this.detectGaps(e,t)}catch(i){this.error$.next({id:"GapDetection",category:k.ErrorCategory.WTF,message:"detectGaps threw",thrown:i})}finally{this.gapDetectionIdleCallback=null}})}}checkEjectedSegments(){if((0,k.isNullable)(this.sourceBuffer)||!te(this.mediaSource,this.sourceBuffer)||(0,k.isNullable)(this.playingRepresentationId))return;let e=[];for(let i=0;i<this.sourceBuffer.buffered.length;i++){let r=Math.floor(this.sourceBuffer.buffered.start(i)*1e3),a=Math.ceil(this.sourceBuffer.buffered.end(i)*1e3);e.push({from:r,to:a})}let t=100;for(let i of this.segments.values())for(let r of i){let{status:a}=r;if(a!=="fed"&&a!=="partially_ejected")continue;let n=Math.floor(r.time.from),o=Math.ceil(r.time.to),u=e.some(c=>c.from-t<=n&&c.to+t>=o),l=e.filter(c=>n>=c.from&&n<c.to-t||o>c.from+t&&o<=c.to);u||(l.length===1?r.status="partially_ejected":this.gaps.some(c=>c.from===r.time.from||c.to===r.time.to)?r.status="partially_ejected":r.status="none")}}handleAsyncError(e,t){this.error$.next({id:t,category:k.ErrorCategory.VIDEO_PIPELINE,thrown:e,message:"Something went wrong"})}};var gi=s=>{let e=new URL(s);return e.searchParams.set("quic","1"),e.toString()};var Hn=s=>{var a;let e=s.get("X-Delivery-Type"),t=s.get("X-Reused"),i=e===null?"http1":e!=null?e:void 0,r=t===null?void 0:(a={1:!0,0:!1}[t])!=null?a:void 0;return{type:i,reused:r}};var X=require("@vkontakte/videoplayer-shared/es2015");var jn=s=>{let e=new URL(s);return e.searchParams.set("enable-subtitles","yes"),e.toString()};var Wn=class{constructor({throughputEstimator:e,requestQuic:t,tracer:i,compatibilityMode:r=!1,useEnableSubtitlesParam:a=!1}){this.manifestRequested=new X.Subject;this.manifestReceived=new X.Subject;this.firstBytesRequested=new X.Subject;this.firstBytesReceived=new X.Subject;this.lastConnectionType$=new X.ValueSubject(void 0);this.lastConnectionReused$=new X.ValueSubject(void 0);this.lastRequestFirstBytes$=new X.ValueSubject(void 0);this.recoverableError$=new X.Subject;this.error$=new X.Subject;this.abortAllController=new fe;this.subscription=new X.Subscription;this.fetchManifest=(0,X.abortable)(this.abortAllController.signal,function(e){return oe(this,null,function*(){let t=this.tracer.createComponentTracer("FetchManifest"),i=e;this.requestQuic&&(i=gi(i)),!this.compatibilityMode&&this.useEnableSubtitlesParam&&(i=jn(i)),this.manifestRequested.next();let r=yield this.doFetch(i,{signal:this.abortAllController.signal}).catch(Qn);return r?(t.log("success",(0,X.flattenObject)({url:i,message:"Request successfully executed"})),t.end(),this.manifestReceived.next(),this.onHeadersReceived(r.headers),r.text()):(t.error("error",(0,X.flattenObject)({url:i,message:"No data in request manifest"})),t.end(),null)})}.bind(this));this.fetch=(0,X.abortable)(this.abortAllController.signal,function(c){return oe(this,arguments,function*(e,{rangeMethod:t=this.compatibilityMode?0:1,range:i,onProgress:r,priority:a="auto",signal:n,measureThroughput:o=!0,isLowLatency:u=!1,bufferOptimisation:l=!1}={}){var le,he,F;let d=e,f=new Headers,p=this.tracer.createComponentTracer("Fetch");if(i)switch(t){case 0:{f.append("Range",`bytes=${i.from}-${i.to}`);break}case 1:{let $=new URL(d,location.href);$.searchParams.append("bytes",`${i.from}-${i.to}`),d=$.toString();break}default:(0,X.assertNever)(t)}this.requestQuic&&(d=gi(d));let h=this.abortAllController.signal,b;if(n){let $=new fe;if(b=(0,X.merge)((0,X.fromEvent)(this.abortAllController.signal,"abort"),(0,X.fromEvent)(n,"abort")).subscribe(()=>{try{$.abort()}catch(P){Qn(P)}}),this.subscription.add(b),this.abortAllController.signal.aborted||n.aborted)try{$.abort()}catch(P){Qn(P)}h=$.signal}let S=0,g=(0,X.now)();p.log("startRequest",(0,X.flattenObject)({url:d,priority:a,rangeMethod:t,range:i,isLowLatency:u,requestStartedAt:g})),this.firstBytesRequested.next();let y=yield this.doFetch(d,{priority:a,headers:f,signal:h}),A=(0,X.now)();if(!y)return p.error("error",{message:"No response in request"}),p.end(),b==null||b.unsubscribe(),null;if((le=this.throughputEstimator)==null||le.addRawRtt(A-g),!y.ok||!y.body){b==null||b.unsubscribe();let $=`Fetch error ${y.status}: ${y.statusText}`;return p.error("error",{message:$}),p.end(),Promise.reject(new Error(`Fetch error ${y.status}: ${y.statusText}`))}if(this.onHeadersReceived(y.headers),!r&&!o){b==null||b.unsubscribe();let $=(0,X.now)(),P={requestStartedAt:g,requestEndedAt:$,duration:$-g};return p.log("endRequest",(0,X.flattenObject)(P)),p.end(),y.arrayBuffer()}let E=y.body;if(o){let $;[E,$]=y.body.tee(),(he=this.throughputEstimator)==null||he.trackStream($,u)}let w=E.getReader(),_,W=parseInt((F=y.headers.get("content-length"))!=null?F:"",10);Number.isFinite(W)&&(_=W),!_&&i&&(_=i.to-i.from+1);let O=_?new Uint8Array(_):new Uint8Array(0),U=!1,M=$=>{b==null||b.unsubscribe(),U=!0,Qn($)},Q=(0,X.abortable)(h,function(B){return oe(this,arguments,function*({done:$,value:P}){if(S===0&&(this.lastRequestFirstBytes$.next((0,X.now)()-g),this.firstBytesReceived.next()),h.aborted){b==null||b.unsubscribe();return}if(!$&&P){if(l&&_)O.set(P,S),S+=P.byteLength;else{let q=new Uint8Array(O.length+P.length);q.set(O),q.set(P,O.length),O=q,S+=P.byteLength}r==null||r(new DataView(O.buffer),S),yield w==null?void 0:w.read().then(Q,M)}})}.bind(this));yield w==null?void 0:w.read().then(Q,M),b==null||b.unsubscribe();let H=(0,X.now)(),Z={failed:U,requestStartedAt:g,requestEndedAt:H,duration:H-g};return U?(p.error("endRequest",(0,X.flattenObject)(Z)),p.end(),null):(p.log("endRequest",(0,X.flattenObject)(Z)),p.end(),O.buffer)})}.bind(this));this.fetchByteRangeRepresentation=(0,X.abortable)(this.abortAllController.signal,function(e,t,i){return oe(this,null,function*(){var g;if(e.type!=="byteRange")return null;let{from:r,to:a}=e.initRange,n=r,o=a,u=!1,l,c;e.indexRange&&(l=e.indexRange.from,c=e.indexRange.to,u=a+1===l,u&&(n=Math.min(l,r),o=Math.max(c,a))),n=Math.min(n,0);let d=yield this.fetch(e.url,{range:{from:n,to:o},priority:i,measureThroughput:!1});if(!d)return null;let f=new DataView(d,r-n,a-n+1);if(!t.validateData(f))throw new Error("Invalid media file");let p=t.parseInit(f),h=(g=e.indexRange)!=null?g:t.getIndexRange(p);if(!h)throw new ReferenceError("No way to load representation index");let b;if(u)b=new DataView(d,h.from-n,h.to-h.from+1);else{let y=yield this.fetch(e.url,{range:h,priority:i,measureThroughput:!1});if(!y)return null;b=new DataView(y)}let S=t.parseSegments(b,p,h);return{init:p,dataView:new DataView(d),segments:S}})}.bind(this));this.fetchTemplateRepresentation=(0,X.abortable)(this.abortAllController.signal,function(e,t){return oe(this,null,function*(){if(e.type!=="template")return null;let i=new URL(e.initUrl,e.baseUrl).toString(),r=yield this.fetch(i,{priority:t,measureThroughput:!1});return r?{init:null,segments:e.segments.map(n=>j(C({},n),{status:"none",size:void 0})),dataView:new DataView(r)}:null})}.bind(this));this.throughputEstimator=e,this.requestQuic=t,this.compatibilityMode=r,this.tracer=i.createComponentTracer("Fetcher"),this.useEnableSubtitlesParam=a}onHeadersReceived(e){let{type:t,reused:i}=Hn(e);this.lastConnectionType$.next(t),this.lastConnectionReused$.next(i)}fetchRepresentation(e,t,i="auto"){return R(this,null,function*(){var a,n;let{type:r}=e;switch(r){case"byteRange":return(a=yield this.fetchByteRangeRepresentation(e,t,i))!=null?a:null;case"template":return(n=yield this.fetchTemplateRepresentation(e,i))!=null?n:null;default:(0,X.assertNever)(r)}})}destroy(){this.abortAllController.abort(),this.subscription.unsubscribe(),this.tracer.end()}doFetch(e,t){return R(this,null,function*(){let i=yield mt(e,t);if(i.ok)return i;let r=yield i.text(),a=parseInt(r);if(!isNaN(a))switch(a){case 1:this.recoverableError$.next({id:"VideoDataLinkExpiredError",message:"Video data links have expired",category:X.ErrorCategory.FATAL});break;case 8:this.recoverableError$.next({id:"VideoDataLinkBlockedForFloodError",message:"Url blocked for flood",category:X.ErrorCategory.FATAL});break;case 18:this.recoverableError$.next({id:"VideoDataLinkIllegalIpChangeError",message:"Client IP has changed",category:X.ErrorCategory.FATAL});break;case 21:this.recoverableError$.next({id:"VideoDataLinkIllegalHostChangeError",message:"Request HOST has changed",category:X.ErrorCategory.FATAL});break;default:this.error$.next({id:"GeneralVideoDataFetchError",message:`Generic video data fetch error (${a})`,category:X.ErrorCategory.FATAL})}})}},Qn=s=>{if(!Ft(s))throw s};var Kt=(s,e,t)=>t*e+(1-t)*s,oc=(s,e)=>s.reduce((t,i)=>t+i,0)/e,ZS=(s,e,t,i)=>{let r=0,a=t,n=oc(s,e),o=e<i?e:i;for(let u=0;u<o;u++)s[a]>n?r++:r--,a=(s.length+a-1)%s.length;return Math.abs(r)===o};var na=require("@vkontakte/videoplayer-shared/es2015");var vi=class{constructor(e){this.prevReported=void 0;this.pastMeasures=[];this.takenMeasures=0;this.measuresCursor=0;var i;this.params=e,this.pastMeasures=Array(e.deviationDepth),this.smoothed=this.prevReported=e.initial,this.smoothed$=new na.ValueSubject(e.initial),this.debounced$=new na.ValueSubject(e.initial);let t=(i=e.label)!=null?i:"value"+Math.random().toString(16).substring(2,6);this.rawSeries$=new Qe(`raw_${t}`),this.smoothedSeries$=new Qe(`smoothed_${t}`),this.reportedSeries$=new Qe(`reported_${t}`),this.rawSeries$.next(e.initial),this.smoothedSeries$.next(e.initial),this.reportedSeries$.next(e.initial)}next(e){let t=0,i=0;for(let o=0;o<this.pastMeasures.length;o++)this.pastMeasures[o]!==void 0&&(t+=kt(this.pastMeasures[o]-this.smoothed,2),i++);this.takenMeasures=i,t/=i;let r=Math.sqrt(t),a=this.smoothed+this.params.deviationFactor*r,n=this.smoothed-this.params.deviationFactor*r;this.pastMeasures[this.measuresCursor]=e,this.measuresCursor=(this.measuresCursor+1)%this.pastMeasures.length,this.rawSeries$.next(e),this.updateSmoothedValue(e),this.smoothed$.next(this.smoothed),this.smoothedSeries$.next(this.smoothed),!(this.smoothed>a||this.smoothed<n)&&((0,na.isNullable)(this.prevReported)||Math.abs(this.smoothed-this.prevReported)/this.prevReported>=this.params.changeThreshold)&&(this.prevReported=this.smoothed,this.debounced$.next(this.smoothed),this.reportedSeries$.next(this.smoothed))}};var Gn=class extends vi{constructor(e){super(e),this.slow=this.fast=e.initial}updateSmoothedValue(e){this.slow=Kt(this.slow,e,this.params.emaAlphaSlow),this.fast=Kt(this.fast,e,this.params.emaAlphaFast);let t=this.params.fastDirection>0?Math.max:Math.min;this.smoothed=t(this.slow,this.fast)}};var zn=class extends vi{constructor(e){super(e),this.emaSmoothed=e.initial}updateSmoothedValue(e){let t=oc(this.pastMeasures,this.takenMeasures);this.emaSmoothed=Kt(this.emaSmoothed,e,this.params.emaAlpha);let i=ZS(this.pastMeasures,this.takenMeasures,this.measuresCursor-1,this.params.basisTrendChangeCount);this.smoothed=i?this.emaSmoothed:t}};var Yn=class extends vi{constructor(t){super(t);this.furtherValues=[];this.currentTopExtremumValue=0;this.extremumInterval=t.extremumInterval}next(t){this.currentTopExtremumValue<=t?(this.currentTopExtremumValue=t,this.furtherValues=[]):this.furtherValues.length===this.extremumInterval?(super.next(this.currentTopExtremumValue),this.currentTopExtremumValue=t,this.furtherValues=[]):this.furtherValues.push(t)}updateSmoothedValue(t){this.smoothed=this.smoothed?Kt(this.smoothed,t,this.params.emaAlpha):t}};var Xt=class{static getSmoothedValue(e,t,i){return i.type==="TwoEma"?new Gn({initial:e,emaAlphaSlow:i.emaAlphaSlow,emaAlphaFast:i.emaAlphaFast,changeThreshold:i.changeThreshold,fastDirection:t,deviationDepth:i.deviationDepth,deviationFactor:i.deviationFactor,label:"throughput"}):new zn({initial:e,emaAlpha:i.emaAlpha,basisTrendChangeCount:i.basisTrendChangeCount,changeThreshold:i.changeThreshold,deviationDepth:i.deviationDepth,deviationFactor:i.deviationFactor,label:"throughput"})}static getLiveBufferSmoothedValue(e,t){return new Yn(C({initial:e,label:"liveEdgeDelay"},t))}};var Cr=(s,e)=>{s&&s.playbackRate!==e&&(s.playbackRate=e)};var Kn=require("@vkontakte/videoplayer-shared/es2015");var oa=class s{constructor(e,t){this.currentRepresentation$=new Kn.ValueSubject(null);this.maxRepresentations=4;this.representationsCursor=0;this.representations=[];this.currentSegment=null;this.getCurrentPosition=t.getCurrentPosition,this.processStreams(e)}updateLive(e){this.processStreams(e==null?void 0:e.streams.text)}seekLive(e){this.processStreams(e)}maintain(e=this.getCurrentPosition()){var t;if(!(0,Kn.isNullable)(e))for(let i of this.representations)for(let r of i){let a=r.segmentReference,n=a.segments.length,o=a.segments[0].time.from,u=a.segments[n-1].time.to;if(e<o||e>u)continue;let l=a.segments.find(c=>c.time.from<=e&&c.time.to>=e);!l||((t=this.currentSegment)==null?void 0:t.time.from)===l.time.from&&this.currentSegment.time.to===l.time.to||(this.currentSegment=l,this.currentRepresentation$.next(j(C({},r),{label:"Live Text",language:"ru",isAuto:!0,url:new URL(l.url,a.baseUrl).toString()})))}}destroy(){this.currentRepresentation$.next(null),this.currentSegment=null,this.representations=[]}processStreams(e){for(let t of e!=null?e:[]){let i=s.filterRepresentations(t.representations);if(i){this.representations[this.representationsCursor]=i,this.representationsCursor=(this.representationsCursor+1)%this.maxRepresentations;break}}}static isSupported(e){return!!(e!=null&&e.some(t=>s.filterRepresentations(t.representations)))}static filterRepresentations(e){return e==null?void 0:e.filter(t=>t.kind==="text"&&"segmentReference"in t&&ut(t.segmentReference))}};var Jn=Y(xt(),1),uc=Y(je(),1),ua=require("@vkontakte/videoplayer-shared/es2015");var Xn=s=>{let{webmDecodingInfo:e}=K.video,t="DASH_WEBM",i="DASH_WEBM_AV1";switch(s){case"vp9":return[t,i];case"av1":return[i,t];case"none":return[];case"smooth":return e?e[i].smooth?[i,t]:e[t].smooth?[t,i]:[i,t]:[t,i];case"power_efficient":return e?e[i].powerEfficient?[i,t]:e[t].powerEfficient?[t,i]:[i,t]:[t,i];default:(0,ua.assertNever)(s)}return[t,i]},ey=({webmCodec:s,androidPreferredFormat:e,iosPreferredFormat:t,preferMultiStream:i})=>{let r=[...i?["DASH_STREAMS"]:[],...Xn(s),"DASH_SEP","DASH_ONDEMAND",...i?[]:["DASH_STREAMS"]],a=[...i?["DASH_STREAMS"]:[],"DASH_SEP","DASH_ONDEMAND",...i?[]:["DASH_STREAMS"]];if(K.device.isAndroid)switch(e){case"mpeg":return["MPEG",...r,"HLS","HLS_ONDEMAND"];case"hls":return["HLS","HLS_ONDEMAND",...r,"MPEG"];case"dash":return[...r,"HLS","HLS_ONDEMAND","MPEG"];case"dash_any_mpeg":return[...a,"MPEG",...Xn(s),"HLS","HLS_ONDEMAND"];case"dash_any_webm":return[...Xn(s),"MPEG",...a,"HLS","HLS_ONDEMAND"];case"dash_sep":return["DASH_SEP","MPEG",...Xn(s),...a,"HLS","HLS_ONDEMAND"];default:(0,ua.assertNever)(e)}if(K.video.nativeHlsSupported)switch(t){case"hls":return[...r,"HLS","HLS_FMP4","HLS_ONDEMAND","MPEG"];case"hls_fmp4":return[...r,"HLS_FMP4","HLS","HLS_ONDEMAND","MPEG"];default:(0,ua.assertNever)(t)}return[...r,"HLS","HLS_ONDEMAND","MPEG"]},ty=({androidPreferredFormat:s,preferCMAF:e,preferWebRTC:t})=>{let i=e?["DASH_LIVE_CMAF","DASH_LIVE"]:["DASH_LIVE","DASH_LIVE_CMAF"],r=e?["HLS_LIVE_CMAF","HLS_LIVE"]:["HLS_LIVE","HLS_LIVE_CMAF"],a=[...i,...r],n=[...r,...i],o,u=K.device.isMac&&K.browser.isSafari;if(K.device.isAndroid)switch(s){case"dash":case"dash_any_mpeg":case"dash_any_webm":case"dash_sep":{o=a;break}case"hls":case"mpeg":{o=n;break}default:(0,ua.assertNever)(s)}else K.video.nativeHlsSupported&&!u?o=n:u?o=e?["DASH_LIVE_CMAF","HLS_LIVE_CMAF","HLS_LIVE","DASH_LIVE"]:["HLS_LIVE","DASH_LIVE","DASH_LIVE_CMAF","HLS_LIVE_CMAF"]:o=a;return t?["WEB_RTC_LIVE",...o]:[...o,"WEB_RTC_LIVE"]},lc=s=>s?["HLS_LIVE","HLS_LIVE_CMAF","DASH_LIVE_CMAF"]:["DASH_WEBM","DASH_WEBM_AV1","DASH_SEP","DASH_ONDEMAND","HLS","HLS_ONDEMAND","MPEG"],Zn=s=>{if(s.size===0)return;if(s.size===1){let t=s.values().next();return(0,Jn.default)(t.value.split("."),0)}for(let t of s){let i=(0,Jn.default)(t.split("."),0);if(i==="opus"||i==="vp09"||i==="av01")return i}let e=s.values().next();return(0,Jn.default)(e.value.split("."),0)},eo=s=>{let e=s.map(i=>Br(i)),{codecs:t}=K.video;return T$().filter(i=>{if((0,uc.default)(e,i))switch(i){case"av1":return t.av1;case"vp9":return t.vp9;case"avc1":return t.h264;case"hev1":return t.h265;default:return!1}else return!1})},to=s=>{let e=s.map(i=>Br(i)),{codecs:t}=K.video;return I$().filter(i=>{if((0,uc.default)(e,i))switch(i){case"opus":return t.opus;case"mp4a":return t.aac;default:return!1}else return!1})},Br=s=>s.split(".")[0].replace("0",""),T$=()=>["av1","vp9","hev1","avc1"],I$=()=>["opus","mp4a"];var w$=["timeupdate","progress","play","seeked","stalled","waiting"],A$=["timeupdate","progress","loadeddata","playing","seeked"];var io=class{constructor(e){this.element=null;this.manifestUrlString="";this.source=null;this.manifest=null;this.bufferManagers=[];this.subscription=new I.Subscription;this.representationSubscription=new I.Subscription;this.state$=new ne("none");this.currentVideoRepresentation$=new I.ValueSubject(void 0);this.currentVideoRepresentationInit$=new I.ValueSubject(void 0);this.currentAudioRepresentation$=new I.ValueSubject(void 0);this.currentVideoSegmentLength$=new I.ValueSubject(0);this.currentAudioSegmentLength$=new I.ValueSubject(0);this.error$=new I.Subject;this.manifestRequested=new I.Subject;this.manifestReceived=new I.Subject;this.firstBytesRequested=new I.Subject;this.firstBytesReceived=new I.Subject;this.lastConnectionType$=new I.ValueSubject(void 0);this.lastConnectionReused$=new I.ValueSubject(void 0);this.lastRequestFirstBytes$=new I.ValueSubject(void 0);this.currentLiveTextRepresentation$=new I.ValueSubject(null);this.isLive$=new I.ValueSubject(!1);this.isActiveLive$=new I.ValueSubject(!1);this.isLowLatency$=new I.ValueSubject(!1);this.liveDuration$=new I.ValueSubject(0);this.liveSeekableDuration$=new I.ValueSubject(0);this.liveAvailabilityStartTime$=new I.ValueSubject(0);this.liveStreamStatus$=new I.ValueSubject(void 0);this.bufferLength$=new I.ValueSubject(0);this.liveLatency$=new I.ValueSubject(void 0);this.liveLoadBufferLength$=new I.ValueSubject(0);this.livePositionFromPlayer$=new I.ValueSubject(0);this.currentStallDuration$=new I.ValueSubject(0);this.videoLastDataObtainedTimestamp$=new I.ValueSubject(0);this.fetcherRecoverableError$=new I.Subject;this.fetcherError$=new I.Subject;this.liveStreamEndTimestamp=0;this.isUpdatingLive=!1;this.isJumpGapAfterSeekLive=!1;this.forceEnded$=new I.Subject;this.gapWatchdogActive=!1;this.destroyController=new fe;this.initManifest=(0,I.abortable)(this.destroyController.signal,function(e,t,i){return oe(this,null,function*(){var r;this.tracer.log("initManifest"),this.element=e,this.manifestUrlString=Re(t,i,2),this.state$.startTransitionTo("manifest_ready"),this.manifest=yield this.updateManifest(),(r=this.manifest)!=null&&r.streams.video.length?this.state$.setState("manifest_ready"):this.error$.next({id:"NoRepresentations",category:I.ErrorCategory.PARSER,message:"No playable video representations"})})}.bind(this));this.updateManifest=(0,I.abortable)(this.destroyController.signal,function(){return oe(this,null,function*(){var u,l;this.tracer.log("updateManifestStart",{manifestUrl:this.manifestUrlString});let e=yield this.fetcher.fetchManifest(this.manifestUrlString).catch(c=>{!this.manifest&&!this.bufferLength$.getValue()&&this.error$.next({id:"LoadManifest",category:I.ErrorCategory.NETWORK,message:"Failed to load manifest",thrown:c})});if(!e)return null;let t=null;try{t=Nn(e!=null?e:"",this.manifestUrlString)}catch(c){let d=(u=On(e))!=null?u:{id:"ManifestParsing",category:I.ErrorCategory.PARSER,message:"Failed to parse MPD manifest",thrown:c};this.error$.next(d)}if(!t)return null;let i=(c,d,f)=>{var p,h,b,S;return!!((h=(p=this.element)==null?void 0:p.canPlayType)!=null&&h.call(p,d)&&((S=(b=nt())==null?void 0:b.isTypeSupported)!=null&&S.call(b,`${d}; codecs="${f}"`))||c==="text")};if(t.live){this.isLive$.next(!!t.live);let{availabilityStartTime:c,latestSegmentPublishTime:d,streamIsUnpublished:f,streamIsAlive:p}=t.live,h=((l=t.duration)!=null?l:0)/1e3;this.liveSeekableDuration$.next(-1*h),this.liveDuration$.next((d-c)/1e3),this.liveAvailabilityStartTime$.next(t.live.availabilityStartTime);let b="active";p||(b=f?"unpublished":"unexpectedly_down"),this.liveStreamStatus$.next(b)}let r={text:t.streams.text,video:[],audio:[]},a,n;for(let c of["video","audio"]){let f=t.streams[c].filter(({mime:h,codecs:b})=>i(c,h,b));r[c]=f;let p;if(this.tuning.dash.codecsPrioritizeEnabled){let h=f.map(({codecs:b})=>b);c==="audio"&&(n=to(h),p=n[0]),c==="video"&&(a=eo(h),this.forceVideoCodec&&(0,sy.default)(a,this.forceVideoCodec)?p=this.forceVideoCodec:p=a[0]),p&&(r[c]=f.filter(({codecs:b})=>Br(b)===p))}else{let h=new Set(f.map(({codecs:b})=>b));p=Zn(h),p&&(r[c]=f.filter(({codecs:b})=>b.startsWith(p)))}if(c==="video"){let h=this.tuning.preferHDR,b=r.video.some(g=>g.hdr),S=r.video.some(g=>!g.hdr);K.display.isHDR&&h&&b?r.video=r.video.filter(g=>g.hdr):S&&(r.video=r.video.filter(g=>!g.hdr))}}let o=j(C({},t),{streams:r});return this.tuning.dash.codecsPrioritizeEnabled&&(o.codecs={video:a,audio:n}),this.tracer.log("updateManifestEnd",(0,I.flattenObject)(o)),o})}.bind(this));this.initRepresentations=(0,I.abortable)(this.destroyController.signal,function(e,t,i){return oe(this,null,function*(){var f;this.tracer.log("initRepresentationsStart",(0,I.flattenObject)({initialVideo:e,initialAudio:t,sourceHls:i})),(0,I.assertNonNullable)(this.manifest),(0,I.assertNonNullable)(this.element),this.representationSubscription.unsubscribe(),this.state$.startTransitionTo("representations_ready");let r=p=>{this.representationSubscription.add((0,I.fromEvent)(p,"error").pipe((0,I.filter)(h=>{var b;return!!((b=this.element)!=null&&b.played.length)})).subscribe(h=>{this.error$.next({id:"VideoSource",category:I.ErrorCategory.VIDEO_PIPELINE,message:"Unexpected video source error",thrown:h})}))};this.source=Tn();let a=document.createElement("source");if(r(a),a.src=URL.createObjectURL(this.source),this.element.appendChild(a),Tr())if(i){let p=document.createElement("source");r(p),p.type="application/x-mpegurl",p.src=i.url,this.element.appendChild(p)}else this.element.disableRemotePlayback=!0;this.isActiveLive$.next(this.isLive$.getValue());let n={fetcher:this.fetcher,tuning:this.tuning,getCurrentPosition:()=>this.element?this.element.currentTime*1e3:void 0,isActiveLowLatency:()=>this.isActiveLive$.getValue()&&this.isLowLatency$.getValue(),manifest:this.manifest},o=this.manifest.streams.video.reduce((p,h)=>[...p,...h.representations],[]);if(this.videoBufferManager=new aa("video",this.source,o,n),this.bufferManagers=[this.videoBufferManager],(0,I.isNonNullable)(t)){let p=this.manifest.streams.audio.reduce((h,b)=>[...h,...b.representations],[]);this.audioBufferManager=new aa("audio",this.source,p,n),this.bufferManagers.push(this.audioBufferManager)}oa.isSupported(this.manifest.streams.text)&&!this.isLowLatency$.getValue()&&(this.liveTextManager=new oa(this.manifest.streams.text,n)),this.representationSubscription.add(this.fetcher.manifestRequested.subscribe(this.manifestRequested)),this.representationSubscription.add(this.fetcher.manifestReceived.subscribe(this.manifestReceived)),this.representationSubscription.add(this.fetcher.firstBytesRequested.subscribe(this.firstBytesRequested)),this.representationSubscription.add(this.fetcher.firstBytesReceived.subscribe(this.firstBytesReceived)),this.representationSubscription.add(this.fetcher.lastConnectionType$.subscribe(this.lastConnectionType$)),this.representationSubscription.add(this.fetcher.lastConnectionReused$.subscribe(this.lastConnectionReused$)),this.representationSubscription.add(this.fetcher.lastRequestFirstBytes$.subscribe(this.lastRequestFirstBytes$));let u=()=>{var p;(p=this.stallWatchdogSubscription)==null||p.unsubscribe(),this.currentStallDuration$.next(0)};if(this.representationSubscription.add((0,I.merge)(...A$.map(p=>(0,I.fromEvent)(this.element,p))).pipe((0,I.map)(p=>this.element?Be(this.element.buffered,this.element.currentTime*1e3):0),(0,I.filterChanged)(),(0,I.tap)(p=>{p>this.tuning.dash.bufferEmptinessTolerance&&u()})).subscribe(this.bufferLength$)),this.representationSubscription.add((0,I.merge)((0,I.fromEvent)(this.element,"ended"),this.forceEnded$).subscribe(()=>{u()})),this.isLive$.getValue()){this.subscription.add(this.liveDuration$.pipe((0,I.filterChanged)()).subscribe(h=>this.liveStreamEndTimestamp=(0,I.now)())),this.subscription.add((0,I.fromEvent)(this.element,"pause").subscribe(()=>{this.livePauseWatchdogSubscription=(0,I.interval)(1e3).subscribe(h=>{let b=di(this.manifestUrlString,2);this.manifestUrlString=Re(this.manifestUrlString,b+1e3,2),this.liveStreamStatus$.getValue()==="active"&&this.updateManifest()}),this.subscription.add(this.livePauseWatchdogSubscription)})).add((0,I.fromEvent)(this.element,"play").subscribe(h=>{var b;return(b=this.livePauseWatchdogSubscription)==null?void 0:b.unsubscribe()})),this.representationSubscription.add((0,I.combine)({isActiveLive:this.isActiveLive$,isLowLatency:this.isLowLatency$}).pipe((0,I.map)(({isActiveLive:h,isLowLatency:b})=>h&&b),(0,I.filterChanged)()).subscribe(h=>{this.isManualDecreasePlaybackInLive()||Cr(this.element,1)})),this.representationSubscription.add((0,I.combine)({bufferLength:this.bufferLength$,isActiveLive:this.isActiveLive$,isLowLatency:this.isLowLatency$}).pipe((0,I.filter)(({bufferLength:h,isActiveLive:b,isLowLatency:S})=>b&&S&&!!h)).subscribe(({bufferLength:h})=>this.liveBuffer.next(h))),this.representationSubscription.add(this.videoBufferManager.currentLowLatencySegmentLength$.subscribe(h=>{if(!this.isActiveLive$.getValue()&&!this.isLowLatency$.getValue()&&!h)return;let b=this.liveSeekableDuration$.getValue()-h/1e3;this.liveSeekableDuration$.next(Math.max(b,-1*this.tuning.dashCmafLive.maxLiveDuration)),this.liveDuration$.next(this.liveDuration$.getValue()+h/1e3)})),this.representationSubscription.add((0,I.combine)({isLive:this.isLive$,rtt:this.throughputEstimator.rtt$,bufferLength:this.bufferLength$,segmentServerLatency:this.videoBufferManager.currentLiveSegmentServerLatency$}).pipe((0,I.filter)(({isLive:h})=>h),(0,I.filterChanged)((h,b)=>b.bufferLength<h.bufferLength),(0,I.map)(({rtt:h,bufferLength:b,segmentServerLatency:S})=>{let g=di(this.manifestUrlString,2);return(h/2+b+S+g)/1e3})).subscribe(this.liveLatency$)),this.representationSubscription.add((0,I.combine)({liveBuffer:this.liveBuffer.smoothed$,isActiveLive:this.isActiveLive$,isLowLatency:this.isLowLatency$}).subscribe(({liveBuffer:h,isActiveLive:b,isLowLatency:S})=>{if(!S||!b)return;let g=this.tuning.dashCmafLive.lowLatency.maxTargetOffset,y=this.tuning.dashCmafLive.lowLatency.maxTargetOffsetDeviation,A=this.tuning.dashCmafLive.lowLatency.playbackCatchupSpeedup,E=h-g;if(this.isManualDecreasePlaybackInLive())return;let w=1;Math.abs(E)>y&&(w=1+Math.sign(E)*A),Cr(this.element,w)})),this.representationSubscription.add(this.bufferLength$.subscribe(h=>{var S,g;let b=0;if(h){let y=((g=(S=this.element)==null?void 0:S.currentTime)!=null?g:0)*1e3;b=Math.min(...this.bufferManagers.map(E=>{var w,_;return(_=(w=E.getLiveSegmentsToLoadState(this.manifest))==null?void 0:w.to)!=null?_:y}))-y}this.liveLoadBufferLength$.getValue()!==b&&this.liveLoadBufferLength$.next(b)}));let p=0;this.representationSubscription.add((0,I.combine)({liveLoadBufferLength:this.liveLoadBufferLength$,bufferLength:this.bufferLength$}).pipe((0,I.throttle)(1e3)).subscribe(S=>R(this,[S],function*({liveLoadBufferLength:h,bufferLength:b}){if(!this.element||this.isUpdatingLive)return;let g=this.element.playbackRate,y=di(this.manifestUrlString,2),A=Math.abs(this.livePositionFromPlayer$.getValue())*1e3,E=Math.min(A,this.tuning.dashCmafLive.normalizedTargetMinBufferSize*g),w=this.tuning.dashCmafLive.normalizedActualBufferOffset*g,_=this.tuning.dashCmafLive.normalizedLiveMinBufferSize*g,W=isFinite(h)?h:b,O=this.isActiveLive$.getValue()&&this.isLowLatency$.getValue(),U=A<=this.tuning.live.activeLiveDelay;this.isActiveLive$.next(U);let M="none";if(O?M="active_low_latency":this.isLowLatency$.getValue()&&U?(this.bufferManagers.forEach(Q=>Q.proceedLowLatencyLive()),M="active_low_latency"):y!==0&&W<E?M="live_forward_buffering":W<E+_&&(M="live_with_target_offset"),isFinite(h)&&(p=h>p?h:p),M==="live_forward_buffering"||M==="live_with_target_offset"){let Q=p-(E+w),H=this.normolizeLiveOffset(Math.trunc(y+Q/g)),Z=Math.abs(H-y),le=0;!h||Z<=this.tuning.dashCmafLive.offsetCalculationError?le=y:H>0&&Z>this.tuning.dashCmafLive.offsetCalculationError&&(le=H),this.manifestUrlString=Re(this.manifestUrlString,le,2)}(M==="live_with_target_offset"||M==="live_forward_buffering")&&(p=0,yield this.updateLive())}),h=>{this.error$.next({id:"updateLive",category:I.ErrorCategory.VIDEO_PIPELINE,thrown:h,message:"Failed to update live with subscription"})}))}let l=(0,I.merge)(...this.bufferManagers.map(p=>p.fullyBuffered$)).pipe((0,I.map)(()=>this.bufferManagers.every(p=>p.fullyBuffered$.getValue()))),c=(0,I.merge)(...this.bufferManagers.map(p=>p.onLastSegment$)).pipe((0,I.map)(()=>this.bufferManagers.some(p=>p.onLastSegment$.getValue()))),d=(0,I.combine)({allBuffersFull:l,someBufferEnded:c}).pipe((0,I.filterChanged)(),(0,I.map)(({allBuffersFull:p,someBufferEnded:h})=>p&&h),(0,I.filter)(p=>p));if(this.representationSubscription.add((0,I.merge)(this.forceEnded$,d).subscribe(()=>{var p;if(this.source&&this.source.readyState==="open"&&Array.from(this.source.sourceBuffers).every(h=>!h.updating))try{(p=this.source)==null||p.endOfStream()}catch(h){this.error$.next({id:"EndOfStream",category:I.ErrorCategory.VIDEO_PIPELINE,message:"Failed to end MediaSource stream",thrown:h})}})),this.representationSubscription.add((0,I.merge)(...this.bufferManagers.map(p=>p.error$)).subscribe(this.error$)),this.representationSubscription.add(this.videoBufferManager.playingRepresentation$.subscribe(this.currentVideoRepresentation$)),this.representationSubscription.add(this.videoBufferManager.playingRepresentationInit$.subscribe(this.currentVideoRepresentationInit$)),this.representationSubscription.add(this.videoBufferManager.currentSegmentLength$.subscribe(this.currentVideoSegmentLength$)),this.audioBufferManager&&(this.representationSubscription.add(this.audioBufferManager.playingRepresentation$.subscribe(this.currentAudioRepresentation$)),this.representationSubscription.add(this.audioBufferManager.currentSegmentLength$.subscribe(this.currentAudioSegmentLength$))),this.liveTextManager&&this.representationSubscription.add(this.liveTextManager.currentRepresentation$.subscribe(this.currentLiveTextRepresentation$)),this.source.readyState!=="open"){let p=this.tuning.dash.sourceOpenTimeout>=0;yield new Promise(h=>{var b;p&&(this.timeoutSourceOpenId=setTimeout(()=>{var S;if(((S=this.source)==null?void 0:S.readyState)==="open"){h();return}this.error$.next({id:"OpenOfStream",category:I.ErrorCategory.VIDEO_PIPELINE,message:"Failed to open MediaSource",thrown:new Error("Timeout reject when wait sourceopen event"),traceAsLog:!0})},this.tuning.dash.sourceOpenTimeout)),(b=this.source)==null||b.addEventListener("sourceopen",()=>{this.timeoutSourceOpenId&&clearTimeout(this.timeoutSourceOpenId),h()},{once:!0})})}if(!this.isLive$.getValue()){let p=[(f=this.manifest.duration)!=null?f:0,...(0,dc.default)((0,dc.default)([...this.manifest.streams.audio,...this.manifest.streams.video],h=>h.representations),h=>{let b=[];return h.duration&&b.push(h.duration),ut(h.segmentReference)&&h.segmentReference.totalSegmentsDurationMs&&b.push(h.segmentReference.totalSegmentsDurationMs),b})];this.source.duration=Math.max(...p)/1e3}this.audioBufferManager&&(0,I.isNonNullable)(t)?yield Promise.all([this.videoBufferManager.startWith(e),this.audioBufferManager.startWith(t)]):yield this.videoBufferManager.startWith(e),this.state$.setState("representations_ready"),this.tracer.log("initRepresentationsEnd")})}.bind(this));this.tick=()=>{var t,i,r,a;if(!this.element||!this.videoBufferManager||((t=this.source)==null?void 0:t.readyState)!=="open")return;let e=this.element.currentTime*1e3;this.videoBufferManager.maintain(e),(i=this.audioBufferManager)==null||i.maintain(e),(r=this.liveTextManager)==null||r.maintain(e),(this.videoBufferManager.gaps.length||(a=this.audioBufferManager)!=null&&a.gaps.length)&&!this.gapWatchdogActive&&(this.gapWatchdogActive=!0,this.gapWatchdogSubscription=(0,I.interval)(this.tuning.gapWatchdogInterval).subscribe(()=>this.jumpGap(),n=>{this.error$.next({id:"GapWatchdog",category:I.ErrorCategory.WTF,message:"Error handling gaps",thrown:n})}),this.subscription.add(this.gapWatchdogSubscription))};this.throughputEstimator=e.throughputEstimator,this.tuning=e.tuning,this.tracer=e.tracer.createComponentTracer(this.constructor.name),this.forceVideoCodec=e.forceVideoCodec,this.fetcher=new Wn({throughputEstimator:this.throughputEstimator,requestQuic:this.tuning.requestQuick,compatibilityMode:e.compatibilityMode,tracer:this.tracer,useEnableSubtitlesParam:e.tuning.useEnableSubtitlesParam}),this.subscription.add(this.fetcher.recoverableError$.subscribe(this.fetcherRecoverableError$)),this.subscription.add(this.fetcher.error$.subscribe(this.fetcherError$)),this.liveBuffer=Xt.getLiveBufferSmoothedValue(this.tuning.dashCmafLive.lowLatency.maxTargetOffset,C({},e.tuning.dashCmafLive.lowLatency.bufferEstimator)),this.initTracerSubscription()}seekLive(e){return R(this,null,function*(){var r,a,n;(0,I.assertNonNullable)(this.element);let t=this.liveStreamStatus$.getValue()!=="active"?(0,I.now)()-this.liveStreamEndTimestamp:0,i=this.normolizeLiveOffset(e+t);this.isActiveLive$.next(i===0),this.manifestUrlString=Re(this.manifestUrlString,i,2),this.manifest=yield this.updateManifest(),this.manifest&&(this.isJumpGapAfterSeekLive=!0,yield(r=this.videoBufferManager)==null?void 0:r.seekLive(this.manifest.streams.video),yield(a=this.audioBufferManager)==null?void 0:a.seekLive(this.manifest.streams.audio),(n=this.liveTextManager)==null||n.seekLive(this.manifest.streams.text))})}initBuffer(){(0,I.assertNonNullable)(this.element),this.state$.setState("running"),this.subscription.add((0,I.merge)(...w$.map(e=>(0,I.fromEvent)(this.element,e)),(0,I.fromEvent)(window,"online")).subscribe(()=>this.tick(),e=>{this.error$.next({id:"DashVKPlayer",category:I.ErrorCategory.WTF,message:"Internal logic error",thrown:e})})),this.subscription.add((0,I.fromEvent)(this.element,"progress").subscribe(()=>{this.element&&this.element.readyState===2&&!this.element.seeking&&(this.element.currentTime=this.element.currentTime)})),this.subscription.add((0,I.fromEvent)(this.element,"waiting").subscribe(()=>{var t;this.element&&this.element.readyState===2&&!this.element.seeking&&qe(this.element.buffered,this.element.currentTime*1e3)&&(this.element.currentTime=this.element.currentTime);let e=()=>{var p,h,b,S,g,y,A,E,w,_,W;if(!this.element||((p=this.source)==null?void 0:p.readyState)!=="open")return;let i=this.currentStallDuration$.getValue();i+=50,this.currentStallDuration$.next(i);let r={timeInWaiting:i},a=(0,I.now)(),n=100,o=(b=(h=this.videoBufferManager)==null?void 0:h.lastDataObtainedTimestamp)!=null?b:0;this.videoLastDataObtainedTimestamp$.next(o);let u=(g=(S=this.audioBufferManager)==null?void 0:S.lastDataObtainedTimestamp)!=null?g:0,l=(A=(y=this.videoBufferManager)==null?void 0:y.getForwardBufferDuration())!=null?A:0,c=(w=(E=this.audioBufferManager)==null?void 0:E.getForwardBufferDuration())!=null?w:0,d=l<n&&a-o>this.tuning.dash.crashOnStallTWithoutDataTimeout,f=this.audioBufferManager&&c<n&&a-u>this.tuning.dash.crashOnStallTWithoutDataTimeout;if((d||f)&&i>this.tuning.dash.crashOnStallTWithoutDataTimeout||i>=this.tuning.dash.crashOnStallTimeout)throw new Error(`Stall timeout exceeded: ${i} ms`);if(this.isLive$.getValue()&&i%2e3===0){let O=this.normolizeLiveOffset(-1*this.livePositionFromPlayer$.getValue()*1e3);this.seekLive(O).catch(U=>{this.error$.next({id:"stallIntervalCallback",category:I.ErrorCategory.VIDEO_PIPELINE,message:"stallIntervalCallback failed",thrown:U})}),r.liveLastOffset=O}else{let O=this.element.currentTime*1e3;(_=this.videoBufferManager)==null||_.maintain(O),(W=this.audioBufferManager)==null||W.maintain(O),r.position=O}this.tracer.log("stallIntervalCallback",(0,I.flattenObject)(r))};(t=this.stallWatchdogSubscription)==null||t.unsubscribe(),this.stallWatchdogSubscription=(0,I.interval)(50).subscribe(e,i=>{this.error$.next({id:"StallWatchdogCallback",category:I.ErrorCategory.NETWORK,message:"Can't restore DASH after stall.",thrown:i})}),this.subscription.add(this.stallWatchdogSubscription)})),this.tick()}switchRepresentation(e,t,i=!1){return R(this,null,function*(){let r={video:this.videoBufferManager,audio:this.audioBufferManager,text:null}[e];return this.tuning.useNewSwitchTo?this.currentStallDuration$.getValue()>0?r==null?void 0:r.switchToWithPreviousAbort(t,i):r==null?void 0:r.switchTo(t,i):r==null?void 0:r.switchToOld(t,i)})}seek(e,t){return R(this,null,function*(){var r,a,n,o,u;(0,I.assertNonNullable)(this.element),(0,I.assertNonNullable)(this.videoBufferManager);let i;t||this.element.duration*1e3<=this.tuning.dashSeekInSegmentDurationThreshold||Math.abs(this.element.currentTime*1e3-e)<=this.tuning.dashSeekInSegmentAlwaysSeekDelta?i=e:i=Math.max((r=this.videoBufferManager.findSegmentStartTime(e))!=null?r:e,(n=(a=this.audioBufferManager)==null?void 0:a.findSegmentStartTime(e))!=null?n:e),this.warmUpMediaSourceIfNeeded(i),qe(this.element.buffered,i)||(yield Promise.all([this.videoBufferManager.abort(),(o=this.audioBufferManager)==null?void 0:o.abort()])),!((0,I.isNullable)(this.element)||(0,I.isNullable)(this.videoBufferManager))&&(this.videoBufferManager.maintain(i),(u=this.audioBufferManager)==null||u.maintain(i),this.element.currentTime=i/1e3,this.tracer.log("seek",(0,I.flattenObject)({requestedPosition:e,forcePrecise:t,position:i})))})}warmUpMediaSourceIfNeeded(e=(t=>(t=this.element)==null?void 0:t.currentTime)()){var i;(0,I.isNonNullable)(this.element)&&(0,I.isNonNullable)(this.source)&&(0,I.isNonNullable)(e)&&((i=this.source)==null?void 0:i.readyState)==="ended"&&this.element.duration*1e3-e>this.tuning.dash.seekBiasInTheEnd&&this.bufferManagers.forEach(r=>r.warmUpMediaSource())}get isStreamEnded(){var e;return((e=this.source)==null?void 0:e.readyState)==="ended"}stop(){var e,t,i;this.tracer.log("stop"),(e=this.element)==null||e.querySelectorAll("source").forEach(r=>{URL.revokeObjectURL(r.src),r.remove()}),this.element=null,this.source=null,this.manifest=null,this.currentVideoRepresentation$.next(void 0),(t=this.videoBufferManager)==null||t.destroy(),this.videoBufferManager=null,(i=this.audioBufferManager)==null||i.destroy(),this.audioBufferManager=null,this.bufferManagers=[],this.state$.setState("none")}setBufferTarget(e){for(let t of this.bufferManagers)t.setTarget(e)}getStreams(){var e;return(e=this.manifest)==null?void 0:e.streams}getCodecs(){var e;return(e=this.manifest)==null?void 0:e.codecs}setPreloadOnly(e){for(let t of this.bufferManagers)t.setPreloadOnly(e)}destroy(){var e;this.subscription.unsubscribe(),this.representationSubscription.unsubscribe(),this.timeoutSourceOpenId&&clearTimeout(this.timeoutSourceOpenId),this.destroyController.abort(),this.fetcher.destroy(),this.stop(),((e=this.source)==null?void 0:e.readyState)==="open"&&Array.from(this.source.sourceBuffers).every(t=>!t.updating)&&this.source.endOfStream(),this.source=null,this.tracer.end()}initTracerSubscription(){let e=(0,I.getTraceSubscriptionMethod)(this.tracer.error.bind(this.tracer));this.subscription.add(this.error$.subscribe(e("error")))}isManualDecreasePlaybackInLive(){if(!this.element||!this.isLive$.getValue())return!1;let e=1-this.element.playbackRate;return Number(e.toFixed(2))>Number(this.tuning.dashCmafLive.lowLatency.playbackCatchupSpeedup.toFixed(2))}normolizeLiveOffset(e){return Math.trunc(e/1e3)*1e3}updateLive(){return R(this,null,function*(){var e;this.isUpdatingLive=!0,this.manifest=yield this.updateManifest(),this.manifest&&(this.bufferManagers.forEach(t=>t.updateLive(this.manifest)),(e=this.liveTextManager)==null||e.updateLive(this.manifest)),this.isUpdatingLive=!1})}jumpGap(){if(!this.element||!this.videoBufferManager)return;let e=this.videoBufferManager.getDebugBufferState();if(!e)return;let t=this.isActiveLive$.getValue()&&this.isLowLatency$.getValue(),i={isJumpGapAfterSeekLive:this.isJumpGapAfterSeekLive,isActiveLowLatency:t,initialCurrentTime:this.element.currentTime};this.isJumpGapAfterSeekLive&&!t&&this.element.currentTime>e.to&&(this.isJumpGapAfterSeekLive=!1,this.element.currentTime=0);let r=this.element.currentTime*1e3,a=[],n=this.element.readyState===1?this.tuning.endGapTolerance:0;for(let o of this.bufferManagers)for(let u of o.gaps)o.playingRepresentation$.getValue()===u.representation&&u.from-n<=r&&u.to+n>r&&(this.element.duration*1e3-u.to<this.tuning.endGapTolerance?a.push(1/0):a.push(u.to));if(a.length){let o=Math.max(...a)+10;this.gapWatchdogSubscription.unsubscribe(),this.gapWatchdogActive=!1,o===1/0?this.forceEnded$.next():(this.element.currentTime=o/1e3,i=j(C({},i),{gapEnds:a,jumpTo:o,resultCurrentTime:this.element.currentTime}),this.tracer.log("jumpGap",(0,I.flattenObject)(i)))}}calculateDurationFromSegments(){var e,t;return Math.max(((e=this.videoBufferManager)==null?void 0:e.calculateDurationFromSegments())||0,((t=this.audioBufferManager)==null?void 0:t.calculateDurationFromSegments())||0)}};var ro=class{constructor(e,t){this.fov=e,this.orientation=t}};var so=class{constructor(e,t){this.rotating=!1;this.fading=!1;this.lastTickTS=0;this.lastCameraTurnTS=0;this.fadeStartSpeed=null;this.fadeTime=0;this.camera=e,this.options=t,this.rotationSpeed={x:0,y:0,z:0},this.fadeCorrection=1/kt(this.options.speedFadeTime/1e3,2)}turnCamera(e=0,t=0,i=0){this.pointCameraTo(this.camera.orientation.x+e,this.camera.orientation.y+t,this.camera.orientation.z+i)}pointCameraTo(e=0,t=0,i=0){t=this.limitCameraRotationY(t);let r=e-this.camera.orientation.x,a=t-this.camera.orientation.y,n=i-this.camera.orientation.z;this.camera.orientation.x=e,this.camera.orientation.y=t,this.camera.orientation.z=i,this.lastCameraTurn={x:r,y:a,z:n},this.lastCameraTurnTS=Date.now()}setRotationSpeed(e,t,i){this.rotationSpeed.x=e!=null?e:this.rotationSpeed.x,this.rotationSpeed.y=t!=null?t:this.rotationSpeed.y,this.rotationSpeed.z=i!=null?i:this.rotationSpeed.z}startRotation(){this.rotating=!0}stopRotation(e=!1){e?(this.setRotationSpeed(0,0,0),this.fadeStartSpeed=null):this.startFading(this.rotationSpeed.x,this.rotationSpeed.y,this.rotationSpeed.z),this.rotating=!1}onCameraRelease(){if(this.lastCameraTurn&&this.lastCameraTurnTS){let e=Date.now()-this.lastCameraTurnTS;if(e<this.options.speedFadeThreshold){let t=(1-e/this.options.speedFadeThreshold)*this.options.rotationSpeedCorrection;this.startFading(this.lastCameraTurn.x*t,this.lastCameraTurn.y*t,this.lastCameraTurn.z*t)}}}startFading(e,t,i){this.setRotationSpeed(e,t,i),this.fadeStartSpeed=C({},this.rotationSpeed),this.fading=!0}stopFading(){this.fadeStartSpeed=null,this.fading=!0,this.fadeTime=0}limitCameraRotationY(e){return Math.max(-this.options.maxYawAngle,Math.min(e,this.options.maxYawAngle))}tick(e){if(!this.lastTickTS){this.lastTickTS=e,this.lastCameraTurnTS=Date.now();return}let t=e-this.lastTickTS,i=t/1e3;if(this.rotating)this.turnCamera(this.rotationSpeed.x*this.options.rotationSpeedCorrection*i,this.rotationSpeed.y*this.options.rotationSpeedCorrection*i,this.rotationSpeed.z*this.options.rotationSpeedCorrection*i);else if(this.fading&&this.fadeStartSpeed){let r=-this.fadeCorrection*kt(this.fadeTime/1e3,2)+1;this.setRotationSpeed(this.fadeStartSpeed.x*r,this.fadeStartSpeed.y*r,this.fadeStartSpeed.z*r),r>0?this.turnCamera(this.rotationSpeed.x*this.options.rotationSpeedCorrection*i,this.rotationSpeed.y*this.options.rotationSpeedCorrection*i,this.rotationSpeed.z*this.options.rotationSpeedCorrection*i):(this.stopRotation(!0),this.stopFading()),this.fadeTime=Math.min(this.fadeTime+t,this.options.speedFadeTime)}this.lastTickTS=e}};var ay=`attribute vec2 a_vertex;
124
+ `})|(?<privateuse2>${e}))$`.replace(/[\s\t\n]/g,"");return new RegExp(c,"i")}var HS=s=>{if(!(s!=null&&s.startsWith("P")))return;let e=(n,o)=>{let u=n?parseFloat(n.replace(",",".")):NaN;return(isNaN(u)?0:u)*o},i=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/.exec(s),r=(i==null?void 0:i[1])==="-"?-1:1,a={days:e(i==null?void 0:i[5],r),hours:e(i==null?void 0:i[6],r),minutes:e(i==null?void 0:i[7],r),seconds:e(i==null?void 0:i[8],r)};return a.days*24*60*60*1e3+a.hours*60*60*1e3+a.minutes*60*1e3+a.seconds*1e3},At=(s,e)=>{let t=s;t=(0,ec.default)(t,"$$","$");let i={RepresentationID:e.representationId,Number:e.segmentNumber,Bandwidth:e.bandwidth,Time:e.segmentTime};for(let[r,a]of(0,jS.default)(i)){let n=new RegExp(`\\$${r}(?:%0(\\d+)d)?\\$`,"g");t=(0,ec.default)(t,n,(o,u)=>(0,sa.isNullable)(a)?o:(0,sa.isNullable)(u)?a:(0,QS.default)(a,parseInt(u,10),"0"))}return t},Nn=(s,e)=>{var U,M,Q,H,Z,le,he,F,$,P,B,q,we,tt,Se,de,Ve,_e,Oe,it,qt,ti,yi,Ki,Fr,Lc,$c,Mc,Dc,Cc,Bc,Vc,_c,Oc,Fc,Nc,qc,Uc,Hc,jc,Qc,Wc,Gc,zc,Yc,Kc,Xc,Jc,Zc,ed,td,id,rd,sd,ad,nd,od,ud,ld,cd,dd;let i=new DOMParser().parseFromString(s,"application/xml"),r={video:[],audio:[],text:[]},a=i.children[0],n=Array.from(a.querySelectorAll("MPD > BaseURL").values()).map(gt=>{var ve,Ti;return(Ti=(ve=gt.textContent)==null?void 0:ve.trim())!=null?Ti:""}),o=(U=(0,WS.default)(n,0))!=null?U:"",u=a.getAttribute("type")==="dynamic",l=a.getAttribute("availabilityStartTime"),c=a.getAttribute("publishTime"),d=a.getElementsByTagName("vk:Attrs")[0],f=d==null?void 0:d.getElementsByTagName("vk:XLatestSegmentPublishTime")[0].textContent,p=d==null?void 0:d.getElementsByTagName("vk:XStreamIsLive")[0].textContent,h=d==null?void 0:d.getElementsByTagName("vk:XStreamIsUnpublished")[0].textContent,b=d==null?void 0:d.getElementsByTagName("vk:XPlaybackDuration")[0].textContent,S;u&&(S={availabilityStartTime:l?new Date(l).getTime():0,publishTime:c?new Date(c).getTime():0,latestSegmentPublishTime:f?new Date(f).getTime():0,streamIsAlive:p==="yes",streamIsUnpublished:h==="yes"});let g,y=a.getAttribute("mediaPresentationDuration"),A=[...a.getElementsByTagName("Period")],E=A.reduce((gt,ve)=>j(C({},gt),{[ve.id]:ve.children}),{}),w=A.reduce((gt,ve)=>j(C({},gt),{[ve.id]:ve.getAttribute("duration")}),{});y?g=HS(y):(0,tc.default)(w).filter(gt=>gt).length&&!u?g=(0,tc.default)(w).reduce((gt,ve)=>{var Ti;return gt+((Ti=HS(ve))!=null?Ti:0)},0):b&&(g=parseInt(b,10));let _=0,W=(Q=(M=a.getAttribute("profiles"))==null?void 0:M.split(","))!=null?Q:[];for(let gt of A.map(ve=>ve.id))for(let ve of E[gt]){let Ti=(H=ve.getAttribute("id"))!=null?H:"id"+(_++).toString(10),Nr=(Z=ve.getAttribute("mimeType"))!=null?Z:"",wo=(le=ve.getAttribute("codecs"))!=null?le:"",Ao=(he=ve.getAttribute("contentType"))!=null?he:Nr==null?void 0:Nr.split("/")[0],Uy=($=(F=ve.getAttribute("profiles"))==null?void 0:F.split(","))!=null?$:[],pd=(B=US((P=ve.getAttribute("lang"))!=null?P:""))!=null?B:{},Ia=(tt=(we=(q=ve.querySelector("Label"))==null?void 0:q.textContent)==null?void 0:we.trim())!=null?tt:void 0,Hy=ve.querySelectorAll("Representation"),jy=ve.querySelector("SegmentTemplate"),Qy=(de=(Se=ve.querySelector("Role"))==null?void 0:Se.getAttribute("value"))!=null?de:void 0,Xi=Ao,ke={id:Ti,language:pd.language,isDefault:Qy==="main",label:Ia,codecs:wo,hdr:Xi==="video"&&Zl(wo),mime:Nr,representations:[]};for(let me of Hy){let ii=(Ve=me.getAttribute("lang"))!=null?Ve:void 0,qr=(Oe=(_e=Ia!=null?Ia:ve.getAttribute("label"))!=null?_e:me.getAttribute("label"))!=null?Oe:void 0,Ea=(ti=(qt=(it=me.querySelector("BaseURL"))==null?void 0:it.textContent)==null?void 0:qt.trim())!=null?ti:"",Ii=new URL(Ea||o,e).toString(),ri=(yi=me.getAttribute("mimeType"))!=null?yi:Nr,xa=(Fr=(Ki=me.getAttribute("codecs"))!=null?Ki:wo)!=null?Fr:"",wa;if(Ao==="text"){let si=me.getAttribute("id")||"",Aa=((Lc=pd.privateuse)==null?void 0:Lc.includes("x-auto"))||si.includes("_auto"),Ei=me.querySelector("SegmentTemplate");if(Ei){let Ur={representationId:($c=me.getAttribute("id"))!=null?$c:void 0,bandwidth:(Mc=me.getAttribute("bandwidth"))!=null?Mc:void 0},Pa=parseInt((Dc=me.getAttribute("bandwidth"))!=null?Dc:"",10)/1e3,Ra=(Bc=parseInt((Cc=Ei.getAttribute("startNumber"))!=null?Cc:"",10))!=null?Bc:1,Ji=parseInt((Vc=Ei.getAttribute("timescale"))!=null?Vc:"",10),Po=(_c=Ei.querySelectorAll("SegmentTimeline S"))!=null?_c:[],Zi=Ei.getAttribute("media");if(!Zi)continue;let ka=[],La=0,$a="",er=0,Hr=Ra,Ue=0;for(let vt of Po){let xi=parseInt((Oc=vt.getAttribute("d"))!=null?Oc:"",10),dt=parseInt((Fc=vt.getAttribute("r"))!=null?Fc:"",10)||0,ai=parseInt((Nc=vt.getAttribute("t"))!=null?Nc:"",10);Ue=Number.isFinite(ai)?ai:Ue;let wi=xi/Ji*1e3,ni=Ue/Ji*1e3;for(let Pt=0;Pt<dt+1;Pt++){let oi=At(Zi,j(C({},Ur),{segmentNumber:Hr.toString(10),segmentTime:(Ue+Pt*xi).toString(10)})),tr=(ni!=null?ni:0)+Pt*wi,Qr=tr+wi;Hr++,ka.push({time:{from:tr,to:Qr},url:oi})}Ue+=(dt+1)*xi,La+=(dt+1)*wi}er=Ue/Ji*1e3,$a=At(Zi,j(C({},Ur),{segmentNumber:Hr.toString(10),segmentTime:Ue.toString(10)}));let jr={time:{from:er,to:1/0},url:$a},Ut={type:"template",baseUrl:Ii,segmentTemplateUrl:Zi,initUrl:"",totalSegmentsDurationMs:La,segments:ka,nextSegmentBeyondManifest:jr,timescale:Ji};wa={id:si,kind:"text",segmentReference:Ut,profiles:[],duration:g,bitrate:Pa,mime:"",codecs:"",width:0,height:0,isAuto:Aa}}else wa={id:si,isAuto:Aa,kind:"text",url:Ii}}else{let si=(Uc=(qc=me.getAttribute("contentType"))!=null?qc:ri==null?void 0:ri.split("/")[0])!=null?Uc:Ao,Aa=(jc=(Hc=ve.getAttribute("profiles"))==null?void 0:Hc.split(","))!=null?jc:[],Ei=parseInt((Qc=me.getAttribute("width"))!=null?Qc:"",10),Ur=parseInt((Wc=me.getAttribute("height"))!=null?Wc:"",10),Pa=parseInt((Gc=me.getAttribute("bandwidth"))!=null?Gc:"",10)/1e3,Ra=(zc=me.getAttribute("frameRate"))!=null?zc:"",Ji=(Yc=me.getAttribute("quality"))!=null?Yc:void 0,Po=Ra?qS(Ra):void 0,Zi=(Kc=me.getAttribute("id"))!=null?Kc:"id"+(_++).toString(10),ka=si==="video"?`${Ur}p`:si==="audio"?`${Pa}Kbps`:xa,La=`${Zi}@${ka}`,$a=[...W,...Uy,...Aa],er,Hr=me.querySelector("SegmentBase"),Ue=(Xc=me.querySelector("SegmentTemplate"))!=null?Xc:jy;if(Hr){let Ut=(Zc=(Jc=me.querySelector("SegmentBase Initialization"))==null?void 0:Jc.getAttribute("range"))!=null?Zc:"",[vt,xi]=Ut.split("-").map(oi=>parseInt(oi,10)),dt={from:vt,to:xi},ai=(ed=me.querySelector("SegmentBase"))==null?void 0:ed.getAttribute("indexRange"),[wi,ni]=ai?ai.split("-").map(oi=>parseInt(oi,10)):[],Pt=ai?{from:wi,to:ni}:void 0;er={type:"byteRange",url:Ii,initRange:dt,indexRange:Pt}}else if(Ue){let Ut={representationId:(td=me.getAttribute("id"))!=null?td:void 0,bandwidth:(id=me.getAttribute("bandwidth"))!=null?id:void 0},vt=parseInt((rd=Ue.getAttribute("timescale"))!=null?rd:"",10),xi=(sd=Ue.getAttribute("initialization"))!=null?sd:"",dt=Ue.getAttribute("media"),ai=(nd=parseInt((ad=Ue.getAttribute("startNumber"))!=null?ad:"",10))!=null?nd:1,wi=At(xi,Ut);if(!dt)throw new ReferenceError("No media attribute in SegmentTemplate");let ni=(od=Ue.querySelectorAll("SegmentTimeline S"))!=null?od:[],Pt=[],oi=0,tr="",Qr=0;if(ni.length){let Ma=ai,St=0;for(let ir of ni){let Rt=parseInt((ud=ir.getAttribute("d"))!=null?ud:"",10),Ai=parseInt((ld=ir.getAttribute("r"))!=null?ld:"",10)||0,Da=parseInt((cd=ir.getAttribute("t"))!=null?cd:"",10);St=Number.isFinite(Da)?Da:St;let Ro=Rt/vt*1e3,ko=St/vt*1e3;for(let Ca=0;Ca<Ai+1;Ca++){let Gy=At(dt,j(C({},Ut),{segmentNumber:Ma.toString(10),segmentTime:(St+Ca*Rt).toString(10)})),hd=(ko!=null?ko:0)+Ca*Ro,zy=hd+Ro;Ma++,Pt.push({time:{from:hd,to:zy},url:Gy})}St+=(Ai+1)*Rt,oi+=(Ai+1)*Ro}Qr=St/vt*1e3,tr=At(dt,j(C({},Ut),{segmentNumber:Ma.toString(10),segmentTime:St.toString(10)}))}else if((0,sa.isNonNullable)(g)){let St=parseInt((dd=Ue.getAttribute("duration"))!=null?dd:"",10)/vt*1e3,ir=Math.ceil(g/St),Rt=0;for(let Ai=1;Ai<ir;Ai++){let Da=At(dt,j(C({},Ut),{segmentNumber:Ai.toString(10),segmentTime:Rt.toString(10)}));Pt.push({time:{from:Rt,to:Rt+St},url:Da}),Rt+=St}Qr=Rt,tr=At(dt,j(C({},Ut),{segmentNumber:ir.toString(10),segmentTime:Rt.toString(10)}))}let Wy={time:{from:Qr,to:1/0},url:tr};er={type:"template",baseUrl:Ii,segmentTemplateUrl:dt,initUrl:wi,totalSegmentsDurationMs:oi,segments:Pt,nextSegmentBeyondManifest:Wy,timescale:vt}}else throw new ReferenceError("Unknown MPD segment referencing type");if(!si||!ri)continue;let jr={video:"video",audio:"audio",text:"text"}[si];if(!jr)continue;Xi||(Xi=jr),wa={id:La,kind:jr,segmentReference:er,profiles:$a,duration:g,bitrate:Pa,mime:ri,codecs:xa,width:Ei,height:Ur,fps:Po,quality:Ji}}ke.language||(ke.language=ii),ke.label||(ke.label=qr),ke.mime||(ke.mime=ri),ke.codecs||(ke.codecs=xa),ke.hdr||(ke.hdr=Xi==="video"&&Zl(xa)),ke.representations.push(wa)}if(Xi){let me=r[Xi].find(ii=>ii.id===ke.id);if(me&&ke.representations.every(ii=>ii.segmentReference.type==="template"))for(let ii of me.representations){let qr=ke.representations.find(ri=>ri.id===ii.id),Ea=qr==null?void 0:qr.segmentReference,Ii=ii.segmentReference;Ii.segments.push(...Ea.segments),Ii.nextSegmentBeyondManifest=Ea.nextSegmentBeyondManifest}else r[Xi].push(ke)}}return{duration:g,streams:r,baseUrls:n,live:S}};var ic=Y(xt(),1);var GS=require("@vkontakte/videoplayer-shared/es2015"),zS=({id:s,width:e,height:t,bitrate:i,fps:r,quality:a,streamId:n})=>{var u;let o=(u=a?hi(a):void 0)!=null?u:(0,GS.videoSizeToQuality)({width:e,height:t});return o&&{id:s,quality:o,bitrate:i,size:{width:e,height:t},fps:r,streamId:n}},YS=({id:s,bitrate:e})=>({id:s,bitrate:e}),KS=({language:s,label:e},{id:t,url:i,isAuto:r})=>({id:t,url:i,isAuto:r,type:"internal",language:s,label:e}),XS=({language:s,label:e,id:t,url:i,isAuto:r})=>({id:t,url:i,isAuto:r,type:"internal",language:s,label:e}),rc=({id:s,language:e,label:t,codecs:i,isDefault:r})=>({id:s,language:e,label:t,codec:(0,ic.default)(i.split("."),0),isDefault:r}),sc=({id:s,language:e,label:t,hdr:i,codecs:r})=>({id:s,language:e,hdr:i,label:t,codec:(0,ic.default)(r.split("."),0)}),ac=s=>"url"in s,ut=s=>s.type==="template";var nc=require("@vkontakte/videoplayer-shared/es2015"),te=(s,e)=>(0,nc.isNonNullable)(s)&&(0,nc.isNonNullable)(e)&&s.readyState==="open"&&g$(s,e);function g$(s,e){for(let t=0;t<s.activeSourceBuffers.length;++t)if(s.activeSourceBuffers[t]===e)return!0;return!1}var aa=class{constructor(e,t,i,{fetcher:r,tuning:a,getCurrentPosition:n,isActiveLowLatency:o,compatibilityMode:u=!1,manifest:l}){this.currentLiveSegmentServerLatency$=new k.ValueSubject(0);this.currentLowLatencySegmentLength$=new k.ValueSubject(0);this.currentSegmentLength$=new k.ValueSubject(0);this.onLastSegment$=new k.ValueSubject(!1);this.fullyBuffered$=new k.ValueSubject(!1);this.playingRepresentation$=new k.ValueSubject(void 0);this.playingRepresentationInit$=new k.ValueSubject(void 0);this.error$=new k.Subject;this.gaps=[];this.subscription=new k.Subscription;this.allInitsLoaded=!1;this.activeSegments=new Set;this.downloadAbortController=new fe;this.switchAbortController=new fe;this.destroyAbortController=new fe;this.bufferLimit=1/0;this.failedDownloads=0;this.baseUrls=[];this.baseUrlsIndex=0;this.isLive=!1;this.liveUpdateSegmentIndex=0;this.liveInitialAdditionalOffset=0;this.isSeekingLive=!1;this.index=0;this.lastDataObtainedTimestampMs=0;this.loadByteRangeSegmentsTimeoutId=0;this.startWith=(0,k.abortable)(this.destroyAbortController.signal,function(e){return oe(this,null,function*(){let t=this.representations.get(e);(0,k.assertNonNullable)(t,`Cannot find representation ${e}`),this.playingRepresentationId=e,this.downloadingRepresentationId=e,this.sourceBuffer=this.mediaSource.addSourceBuffer(`${t.mime}; codecs="${t.codecs}"`),this.sourceBufferTaskQueue=new Qv(this.sourceBuffer),this.subscription.add((0,k.fromEvent)(this.sourceBuffer,"updateend").subscribe(()=>{this.checkEjectedSegments(),this.maintain()},n=>{let o,u=this.mediaSource.readyState;u!=="open"&&(o={id:`SegmentEjection_source_${u}`,category:k.ErrorCategory.VIDEO_PIPELINE,message:"Error when trying to clear segments ejected by browser",thrown:n}),o!=null||(o={id:"SegmentEjection",category:k.ErrorCategory.VIDEO_PIPELINE,message:"Error when trying to clear segments ejected by browser",thrown:n}),this.error$.next(o)})),this.subscription.add((0,k.fromEvent)(this.sourceBuffer,"error").subscribe(()=>this.error$.next({id:"SourceBuffer",category:k.ErrorCategory.VIDEO_PIPELINE,message:"SourceBuffer Error event fired"}))),this.subscription.add(this.sourceBufferTaskQueue.bufferFull$.subscribe(n=>{let o=this.getCurrentPosition();if(!this.sourceBuffer||!o||!te(this.mediaSource,this.sourceBuffer))return;let u=Math.min(this.bufferLimit,kr(this.sourceBuffer.buffered)*.8);this.bufferLimit=u;let l=this.getForwardBufferDuration(o),c=Math.min(this.forwardBufferTarget,this.bufferLimit)*this.tuning.dash.minSafeBufferThreshold;this.pruneBuffer(o,n*2,l<c).catch(d=>{this.handleAsyncError(d,"pruneBuffer")})})),this.subscription.add(this.sourceBufferTaskQueue.error$.subscribe(n=>this.error$.next(n))),yield this.loadInit(t,"high",!0);let i=this.initData.get(t.id),r=this.segments.get(t.id),a=this.parsedInitData.get(t.id);(0,k.assertNonNullable)(i,"No init buffer for starting representation"),(0,k.assertNonNullable)(r,"No segments for starting representation"),i instanceof ArrayBuffer&&(this.searchGaps(r,t),yield this.sourceBufferTaskQueue.append(i,this.destroyAbortController.signal),this.playingRepresentation$.next(this.playingRepresentationId),this.playingRepresentationInit$.next(a))})}.bind(this));this.switchTo=(0,k.abortable)(this.destroyAbortController.signal,function(e,t=!1){return oe(this,null,function*(){if(!te(this.mediaSource,this.sourceBuffer)||e===this.downloadingRepresentationId||e===this.switchingToRepresentationId)return;this.switchingToRepresentationId=e;let i=this.representations.get(e);(0,k.assertNonNullable)(i,`No such representation ${e}`);let r=this.segments.get(e),a=this.initData.get(e);if((0,k.isNullable)(a)||(0,k.isNullable)(r)?yield this.loadInit(i,"high",!1):a instanceof Promise&&(yield a),r=this.segments.get(e),(0,k.assertNonNullable)(r,"No segments for starting representation"),a=this.initData.get(e),!(!a||!(a instanceof ArrayBuffer)||!this.sourceBuffer||!te(this.mediaSource,this.sourceBuffer))){if(yield this.abort(),yield this.sourceBufferTaskQueue.append(a,this.downloadAbortController.signal),t)this.switchingToRepresentationId=void 0,this.downloadingRepresentationId=e,yield this.dropBuffer();else{let n=this.getCurrentPosition();(0,k.isNonNullable)(n)&&!this.isLive&&(this.bufferLimit=1/0,yield new Pi(this.pruneBuffer(n,1/0,!0))),this.switchingToRepresentationId=void 0,this.downloadingRepresentationId=e}this.maintain()}})}.bind(this));this.switchToOld=(0,k.abortable)(this.destroyAbortController.signal,function(e,t=!1){return oe(this,null,function*(){if(!te(this.mediaSource,this.sourceBuffer)||e===this.downloadingRepresentationId||e===this.switchingToRepresentationId)return;this.switchingToRepresentationId=e;let i=this.representations.get(e);(0,k.assertNonNullable)(i,`No such representation ${e}`);let r=this.segments.get(e),a=this.initData.get(e);if((0,k.isNullable)(a)||(0,k.isNullable)(r)?yield this.loadInit(i,"high",!1):a instanceof Promise&&(yield a),r=this.segments.get(e),(0,k.assertNonNullable)(r,"No segments for starting representation"),a=this.initData.get(e),!(!a||!(a instanceof ArrayBuffer)||!this.sourceBuffer||!te(this.mediaSource,this.sourceBuffer)))if(yield this.abort(),yield this.sourceBufferTaskQueue.append(a,this.downloadAbortController.signal),t)this.switchingToRepresentationId=void 0,this.downloadingRepresentationId=e,yield this.dropBuffer(),this.maintain();else{let n=this.getCurrentPosition();(0,k.isNonNullable)(n)&&(this.isLive||(this.bufferLimit=1/0,yield new Pi(this.pruneBuffer(n,1/0,!0))),this.maintain(n)),this.switchingToRepresentationId=void 0,this.downloadingRepresentationId=e}})}.bind(this));this.seekLive=(0,k.abortable)(this.destroyAbortController.signal,function(e){return oe(this,null,function*(){var u,l;let t=(u=(0,Un.default)(e,c=>c.representations))!=null?u:[];if(this.isSeekingLive=!0,!this.downloadingRepresentationId||!t)return;for(let c of this.representations.keys()){let d=t.find(h=>h.id===c);d&&this.representations.set(c,d);let f=this.representations.get(c);if(!f||!ut(f.segmentReference))return;let p=this.getActualLiveStartingSegments(f.segmentReference);this.segments.set(f.id,p)}let i=(l=this.switchingToRepresentationId)!=null?l:this.downloadingRepresentationId,r=this.representations.get(i);(0,k.assertNonNullable)(r);let a=this.segments.get(i);(0,k.assertNonNullable)(a,"No segments for starting representation");let n=this.initData.get(i);if((0,k.assertNonNullable)(n,"No init buffer for starting representation"),!(n instanceof ArrayBuffer))return;let o=this.getDebugBufferState();this.liveUpdateSegmentIndex=0,yield this.abort(),o&&(yield this.sourceBufferTaskQueue.remove(o.from*1e3,o.to*1e3,this.destroyAbortController.signal)),this.searchGaps(a,r),yield this.sourceBufferTaskQueue.append(n,this.destroyAbortController.signal),this.isSeekingLive=!1})}.bind(this));var c;this.fetcher=r,this.tuning=a,this.compatibilityMode=u,this.forwardBufferTarget=a.dash.forwardBufferTargetAuto,this.getCurrentPosition=n,this.isActiveLowLatency=o,this.isLive=!!(l!=null&&l.live),this.baseUrls=(c=l==null?void 0:l.baseUrls)!=null?c:[],this.initData=new Map(i.map(d=>[d.id,null])),this.segments=new Map,this.parsedInitData=new Map,this.representations=new Map(i.map(d=>[d.id,d])),this.kind=e,this.mediaSource=t,this.sourceBuffer=null}switchToWithPreviousAbort(e,t=!1){!te(this.mediaSource,this.sourceBuffer)||e===this.downloadingRepresentationId||e===this.switchingToRepresentationId||(this.switchAbortController.abort(),this.switchAbortController=new fe,(0,k.abortable)(this.switchAbortController.signal,function(i,r=!1){return oe(this,null,function*(){this.switchingToRepresentationId=i;let a=this.representations.get(i);(0,k.assertNonNullable)(a,`No such representation ${i}`);let n=this.segments.get(i),o=this.initData.get(i);if((0,k.isNullable)(o)||(0,k.isNullable)(n)?yield this.loadInit(a,"high",!1):o instanceof Promise&&(yield o),n=this.segments.get(i),(0,k.assertNonNullable)(n,"No segments for starting representation"),o=this.initData.get(i),!(!(o instanceof ArrayBuffer)||!this.sourceBuffer||!te(this.mediaSource,this.sourceBuffer))){if(yield this.abort(),yield this.sourceBufferTaskQueue.append(o,this.downloadAbortController.signal),r)this.switchingToRepresentationId=void 0,this.downloadingRepresentationId=i,yield this.dropBuffer();else{let u=this.getCurrentPosition();(0,k.isNonNullable)(u)&&!this.isLive&&(this.bufferLimit=this.forwardBufferTarget,yield this.pruneBuffer(u,1/0,!0)),this.downloadingRepresentationId=i,this.switchingToRepresentationId=void 0}this.maintain()}})}.bind(this))(e,t))}warmUpMediaSource(){!(0,k.isNullable)(this.sourceBuffer)&&!this.sourceBuffer.updating&&(this.sourceBuffer.mode="segments")}abort(){return R(this,null,function*(){for(let e of this.activeSegments)this.abortSegment(e.segment);return this.activeSegments.clear(),this.downloadAbortController.abort(),this.downloadAbortController=new fe,this.abortBuffer()})}maintain(e=this.getCurrentPosition()){if((0,k.isNullable)(e)||(0,k.isNullable)(this.downloadingRepresentationId)||(0,k.isNullable)(this.playingRepresentationId)||(0,k.isNullable)(this.sourceBuffer)||!te(this.mediaSource,this.sourceBuffer)||(0,k.isNonNullable)(this.switchingToRepresentationId)||this.isSeekingLive)return;let t=this.representations.get(this.downloadingRepresentationId),i=this.segments.get(this.downloadingRepresentationId);if((0,k.assertNonNullable)(t,`No such representation ${this.downloadingRepresentationId}`),!i)return;let r=i.find(c=>e>=c.time.from&&e<c.time.to);(0,k.isNonNullable)(r)&&isFinite(r.time.from)&&isFinite(r.time.to)&&this.currentSegmentLength$.next((r==null?void 0:r.time.to)-r.time.from);let a=e,n=100;if(this.playingRepresentationId!==this.downloadingRepresentationId){let c=this.getForwardBufferDuration(e),d=r?r.time.to+n:-1/0;r&&r.time.to-e<this.tuning.dash.maxSegmentDurationLeftToSelectNextSegment&&c>=r.time.to-e+n&&(a=d)}if(isFinite(this.bufferLimit)&&kr(this.sourceBuffer.buffered)>=this.bufferLimit){let c=this.getForwardBufferDuration(e),d=Math.min(this.forwardBufferTarget,this.bufferLimit)*this.tuning.dash.minSafeBufferThreshold;this.pruneBuffer(e,1/0,c<d).catch(f=>{this.handleAsyncError(f,"pruneBuffer")});return}let u=[];if(!this.activeSegments.size&&(u=this.selectForwardBufferSegments(i,t.segmentReference.type,a),u.length)){let c="auto";if(this.tuning.dash.useFetchPriorityHints&&r)if((0,qn.default)(u,r))c="high";else{let d=(0,ji.default)(u,0);d&&d.time.from-r.time.to>=this.forwardBufferTarget/2&&(c="low")}this.loadSegments(u,t,c).catch(d=>{this.handleAsyncError(d,"loadSegments")})}(!this.preloadOnly&&!this.allInitsLoaded&&r&&r.status==="fed"&&!u.length&&this.getForwardBufferDuration(e)>3e3||this.isActiveLowLatency())&&this.loadNextInit();let l=(0,ji.default)(i,-1);!this.isLive&&l&&(this.fullyBuffered$.next(l.time.to-e-this.getForwardBufferDuration(e)<n),this.onLastSegment$.next(e-l.time.from>0))}get lastDataObtainedTimestamp(){return this.lastDataObtainedTimestampMs}searchGaps(e,t){this.gaps=[];let i=0,r=this.isLive?this.liveInitialAdditionalOffset:0;for(let a of e)Math.trunc(a.time.from-i)>0&&this.gaps.push({representation:t.id,from:i,to:a.time.from+r}),i=a.time.to;(0,k.isNonNullable)(t.duration)&&t.duration-i>0&&!this.isLive&&this.gaps.push({representation:t.id,from:i,to:t.duration})}getActualLiveStartingSegments(e){let t=e.segments,i=this.isActiveLowLatency()?this.tuning.dashCmafLive.lowLatency.maxTargetOffset:this.tuning.dashCmafLive.maxActiveLiveOffset,r=[],a=0,n=t.length-1;do r.unshift(t[n]),a+=t[n].time.to-t[n].time.from,n--;while(a<i&&n>=0);return this.liveInitialAdditionalOffset=a-i,this.isActiveLowLatency()?[r[0]]:r}getLiveSegmentsToLoadState(e){let t=(0,Un.default)(e==null?void 0:e.streams[this.kind],r=>r.representations).find(r=>r.id===this.downloadingRepresentationId);if(!t)return;let i=this.segments.get(t.id);if(i!=null&&i.length)return{from:i[0].time.from,to:i[i.length-1].time.to}}updateLive(e){var i,r,a,n;let t=(i=(0,Un.default)(e==null?void 0:e.streams[this.kind],o=>o.representations))!=null?i:[];if(![...this.segments.values()].every(o=>!o.length))for(let o of t){if(!o||!ut(o.segmentReference))return;let u=o.segmentReference.segments.map(p=>j(C({},p),{status:"none",size:void 0})),l=100,c=(r=this.segments.get(o.id))!=null?r:[],d=(n=(a=(0,ji.default)(c,-1))==null?void 0:a.time.to)!=null?n:0,f=u==null?void 0:u.findIndex(p=>d>=p.time.from+l&&d<=p.time.to+l);if(f===-1){this.liveUpdateSegmentIndex=0;let p=this.getActualLiveStartingSegments(o.segmentReference);this.segments.set(o.id,p)}else{let p=u.slice(f+1);this.segments.set(o.id,[...c,...p])}}}proceedLowLatencyLive(){let e=this.downloadingRepresentationId;(0,k.assertNonNullable)(e);let t=this.segments.get(e);if(t!=null&&t.length){let i=t[t.length-1];this.updateLowLatencyLiveIfNeeded(i)}}calculateDurationFromSegments(){var t;if(!this.playingRepresentationId)return 0;let e=this.segments.get(this.playingRepresentationId);return(e?(t=(0,ji.default)(e,-1))==null?void 0:t.time.to:0)||0}updateLowLatencyLiveIfNeeded(e){var i;let t=0;for(let r of this.representations.values()){let a=r.segmentReference;if(!ut(a))return;let n=(i=this.segments.get(r.id))!=null?i:[],o=n.find(l=>Math.floor(l.time.from)===Math.floor(e.time.from));if(o&&!isFinite(o.time.to)&&(o.time.to=e.time.to,t=o.time.to-o.time.from),!!!n.find(l=>Math.floor(l.time.from)===Math.floor(e.time.to))&&this.isActiveLowLatency()){let l=Math.round(e.time.to*a.timescale/1e3).toString(10),c=At(a.segmentTemplateUrl,{segmentTime:l});n.push({status:"none",time:{from:e.time.to,to:1/0},url:c})}}this.currentLowLatencySegmentLength$.next(t)}findSegmentStartTime(e){var a,n,o;let t=(n=(a=this.switchingToRepresentationId)!=null?a:this.downloadingRepresentationId)!=null?n:this.playingRepresentationId;if(!t)return;let i=this.segments.get(t);if(!i)return;let r=i.find(u=>u.time.from<=e&&u.time.to>=e);return(o=r==null?void 0:r.time.from)!=null?o:void 0}setTarget(e){this.forwardBufferTarget=e}setPreloadOnly(e){this.preloadOnly=e}destroy(){var e;if(this.initData.clear(),this.segments.clear(),this.parsedInitData.clear(),this.representations.clear(),(e=this.sourceBufferTaskQueue)==null||e.destroy(),this.gapDetectionIdleCallback&&_t&&_t(this.gapDetectionIdleCallback),this.initLoadIdleCallback&&_t&&_t(this.initLoadIdleCallback),this.subscription.unsubscribe(),this.sourceBuffer)try{this.mediaSource.removeSourceBuffer(this.sourceBuffer)}catch(t){if(!(t instanceof DOMException&&t.name==="NotFoundError"))throw t}this.sourceBuffer=null,this.downloadAbortController.abort(),this.switchAbortController.abort(),this.destroyAbortController.abort(),window.clearTimeout(this.loadByteRangeSegmentsTimeoutId)}selectForwardBufferSegments(e,t,i){return this.isLive?this.selectForwardBufferSegmentsLive(e,i):this.selectForwardBufferSegmentsRecord(e,t,i)}selectForwardBufferSegmentsLive(e,t){let i=e.findIndex(r=>t>=r.time.from&&t<r.time.to);return this.playingRepresentationId!==this.downloadingRepresentationId&&(this.liveUpdateSegmentIndex=i),this.liveUpdateSegmentIndex<e.length?e.slice(this.liveUpdateSegmentIndex++):[]}selectForwardBufferSegmentsRecord(e,t,i){let r=this.getForwardBufferDuration(i),a=e.findIndex(({status:f,time:{from:p,to:h}},b)=>{let S=p<=i&&h>=i,g=p>i||S||b===0&&i===0,y=Math.min(this.forwardBufferTarget,this.bufferLimit),A=this.preloadOnly&&p<=i+y||r<y&&h-p>=y||h<=i+y;return(f==="none"||f==="partially_ejected"&&g&&A&&this.sourceBuffer&&te(this.mediaSource,this.sourceBuffer)&&!(qe(this.sourceBuffer.buffered,p)&&qe(this.sourceBuffer.buffered,h)))&&g&&A});if(a===-1)return[];if(t!=="byteRange")return e.slice(a,a+1);let n=e,o=0,u=0,l=[],c=this.preloadOnly?0:this.tuning.dash.segmentRequestSize,d=this.preloadOnly?this.forwardBufferTarget:0;for(let f=a;f<n.length&&(o<=c||u<=d);f++){let p=n[f];if(o+=p.byte.to+1-p.byte.from,u+=p.time.to+1-p.time.from,p.status==="none"||p.status==="partially_ejected")l.push(p);else break}return l}loadSegments(e,t,i="auto"){return R(this,null,function*(){ut(t.segmentReference)?yield this.loadTemplateSegment(e[0],t,i):yield this.loadByteRangeSegments(e,t,i)})}loadTemplateSegment(e,t,i="auto"){return R(this,null,function*(){e.status="downloading";let r={segment:e,loadedBytes:0,feedingBytes:0,fedBytes:0,representationId:t.id};this.activeSegments.add(r);let{range:a,url:n,signal:o,onProgress:u,onProgressTasks:l}=this.prepareTemplateFetchSegmentParams(e,t);this.failedDownloads&&o&&(yield(0,k.abortable)(o,function(){return oe(this,null,function*(){let c=(0,k.getExponentialDelay)(this.failedDownloads,this.tuning.downloadBackoff);yield new Promise(d=>setTimeout(d,c))})}.bind(this))(),o.aborted&&this.abortActiveSegments([e]));try{let c=yield this.fetcher.fetch(n,{range:a,signal:o,onProgress:u,priority:i,isLowLatency:this.isActiveLowLatency(),bufferOptimisation:this.tuning.dash.fetcherBufferOptimisation});if(this.lastDataObtainedTimestampMs=(0,k.now)(),!c)return;let d=new DataView(c),f=Ot(t.mime);if(!isFinite(r.segment.time.to)){let b=t.segmentReference.timescale;r.segment.time.to=f.getChunkEndTime(d,b)}u&&r.feedingBytes&&l?yield Promise.all(l):yield this.sourceBufferTaskQueue.append(d,o);let{serverDataReceivedTimestamp:p,serverDataPreparedTime:h}=f.getServerLatencyTimestamps(d);p&&h&&this.currentLiveSegmentServerLatency$.next(h-p),r.segment.status="downloaded",this.onSegmentFullyAppended(r,t.id),this.failedDownloads=0}catch(c){this.abortActiveSegments([e]),Ft(c)||(this.failedDownloads++,this.updateRepresentationsBaseUrlIfNeeded())}})}updateRepresentationsBaseUrlIfNeeded(){if(!this.tuning.dash.enableBaseUrlSupport||!this.baseUrls.length||this.failedDownloads<=this.tuning.dash.maxSegmentRetryCount)return;this.baseUrlsIndex=(this.baseUrlsIndex+1)%this.baseUrls.length;let e=this.baseUrls[this.baseUrlsIndex];for(let t of this.representations.values())ut(t.segmentReference)?t.segmentReference.baseUrl=e:t.segmentReference.url=e}loadByteRangeSegments(e,t,i="auto"){return R(this,null,function*(){if(!e.length)return;for(let u of e)u.status="downloading",this.activeSegments.add({segment:u,loadedBytes:0,feedingBytes:0,fedBytes:0,representationId:t.id});let{range:r,url:a,signal:n,onProgress:o}=this.prepareByteRangeFetchSegmentParams(e,t);this.failedDownloads&&n&&(yield(0,k.abortable)(n,function(){return oe(this,null,function*(){let u=(0,k.getExponentialDelay)(this.failedDownloads,this.tuning.downloadBackoff);yield new Promise(l=>{this.loadByteRangeSegmentsTimeoutId=window.setTimeout(l,u),(0,k.fromEvent)(window,"online").pipe((0,k.once)()).subscribe(()=>{l(),window.clearTimeout(this.loadByteRangeSegmentsTimeoutId)})})})}.bind(this))(),n.aborted&&this.abortActiveSegments(e));try{yield this.fetcher.fetch(a,{range:r,onProgress:o,signal:n,priority:i,bufferOptimisation:this.tuning.dash.fetcherBufferOptimisation}),this.lastDataObtainedTimestampMs=(0,k.now)(),this.failedDownloads=0}catch(u){this.abortActiveSegments(e),Ft(u)||(this.failedDownloads++,this.updateRepresentationsBaseUrlIfNeeded())}})}prepareByteRangeFetchSegmentParams(e,t){if(ut(t.segmentReference))throw new Error("Representation is not byte range type");let i=t.segmentReference.url,r={from:(0,ji.default)(e,0).byte.from,to:(0,ji.default)(e,-1).byte.to},{signal:a}=this.downloadAbortController;return{url:i,range:r,signal:a,onProgress:(o,u)=>R(this,null,function*(){if(!a.aborted)try{this.lastDataObtainedTimestampMs=(0,k.now)(),yield this.onSomeByteRangesDataLoaded({dataView:o,loaded:u,signal:a,onSegmentAppendFailed:()=>this.abort(),globalFrom:r?r.from:0,representationId:t.id})}catch(l){this.error$.next({id:"SegmentFeeding",category:k.ErrorCategory.VIDEO_PIPELINE,message:"Error when feeding segments",thrown:l})}})}}prepareTemplateFetchSegmentParams(e,t){if(!ut(t.segmentReference))throw new Error("Representation is not template type");let i=new URL(e.url,t.segmentReference.baseUrl);this.isActiveLowLatency()&&i.searchParams.set("low-latency","yes");let r=i.toString(),{signal:a}=this.downloadAbortController,n=[],u=this.isActiveLowLatency()||this.tuning.dash.enableSubSegmentBufferFeeding&&this.liveUpdateSegmentIndex<3?(l,c)=>{if(!a.aborted)try{this.lastDataObtainedTimestampMs=(0,k.now)();let d=this.onSomeTemplateDataLoaded({dataView:l,loaded:c,signal:a,onSegmentAppendFailed:()=>this.abort(),representationId:t.id});n.push(d)}catch(d){this.error$.next({id:"SegmentFeeding",category:k.ErrorCategory.VIDEO_PIPELINE,message:"Error when feeding segments",thrown:d})}}:void 0;return{url:r,signal:a,onProgress:u,onProgressTasks:n}}abortActiveSegments(e){for(let t of this.activeSegments)(0,qn.default)(e,t.segment)&&this.abortSegment(t.segment)}onSomeTemplateDataLoaded(n){return R(this,arguments,function*({dataView:e,representationId:t,loaded:i,onSegmentAppendFailed:r,signal:a}){if(!this.activeSegments.size||!te(this.mediaSource,this.sourceBuffer))return;let o=this.representations.get(t);if(o)for(let u of this.activeSegments){let{segment:l}=u;if(u.representationId===t){if(a.aborted){r();continue}if(u.loadedBytes=i,u.loadedBytes>u.feedingBytes){let c=new DataView(e.buffer,e.byteOffset+u.feedingBytes,u.loadedBytes-u.feedingBytes),d=Ot(o.mime).parseFeedableSegmentChunk(c,this.isLive);d!=null&&d.byteLength&&(l.status="partially_fed",u.feedingBytes+=d.byteLength,yield this.sourceBufferTaskQueue.append(d),u.fedBytes+=d.byteLength)}}}})}onSomeByteRangesDataLoaded(o){return R(this,arguments,function*({dataView:e,representationId:t,globalFrom:i,loaded:r,signal:a,onSegmentAppendFailed:n}){if(!this.activeSegments.size||!te(this.mediaSource,this.sourceBuffer))return;let u=this.representations.get(t);if(u)for(let l of this.activeSegments){let{segment:c}=l;if(l.representationId!==t)continue;if(a.aborted){yield n();continue}let d=c.byte.from-i,f=c.byte.to-i,p=f-d+1,h=d<r,b=f<=r;if(!h)continue;let S=Ot(u.mime);if(c.status==="downloading"&&b){c.status="downloaded";let g=new DataView(e.buffer,e.byteOffset+d,p);(yield this.sourceBufferTaskQueue.append(g,a))&&!a.aborted?this.onSegmentFullyAppended(l,t):yield n()}else if(this.tuning.dash.enableSubSegmentBufferFeeding&&(c.status==="downloading"||c.status==="partially_fed")&&(l.loadedBytes=Math.min(p,r-d),l.loadedBytes>l.feedingBytes)){let g=new DataView(e.buffer,e.byteOffset+d+l.feedingBytes,l.loadedBytes-l.feedingBytes),y=l.loadedBytes===p?g:S.parseFeedableSegmentChunk(g);y!=null&&y.byteLength&&(c.status="partially_fed",l.feedingBytes+=y.byteLength,(yield this.sourceBufferTaskQueue.append(y,a))&&!a.aborted?(l.fedBytes+=y.byteLength,l.fedBytes===p&&this.onSegmentFullyAppended(l,t)):yield n())}}})}onSegmentFullyAppended(e,t){var i;if(!((0,k.isNullable)(this.sourceBuffer)||!te(this.mediaSource,this.sourceBuffer))){!this.isLive&&K.browser.isSafari&&this.tuning.useSafariEndlessRequestBugfix&&(qe(this.sourceBuffer.buffered,e.segment.time.from,100)&&qe(this.sourceBuffer.buffered,e.segment.time.to,100)||this.error$.next({id:"EmptyAppendBuffer",category:k.ErrorCategory.VIDEO_PIPELINE,message:"Browser stuck on empty result of adding segment to source buffer"})),this.playingRepresentationId=t,this.playingRepresentation$.next(this.playingRepresentationId),this.playingRepresentationInit$.next(this.parsedInitData.get(this.playingRepresentationId)),e.segment.status="fed",ac(e.segment)&&(e.segment.size=e.fedBytes);for(let r of this.representations.values())if(r.id!==t)for(let a of(i=this.segments.get(r.id))!=null?i:[])a.status==="fed"&&Math.round(a.time.from)===Math.round(e.segment.time.from)&&Math.round(a.time.to)===Math.round(e.segment.time.to)&&(a.status="none");this.updateLowLatencyLiveIfNeeded(e.segment),this.activeSegments.delete(e),this.detectGapsWhenIdle(t,[e.segment])}}abortSegment(e){e.status==="partially_fed"?e.status="partially_ejected":e.status!=="partially_ejected"&&(e.status="none");for(let t of this.activeSegments.values())if(t.segment===e){this.activeSegments.delete(t);break}}loadNextInit(){if(this.allInitsLoaded||this.initLoadIdleCallback)return;let e=null,t=!1;for(let[r,a]of this.initData.entries()){let n=a instanceof Promise;t||(t=n),a===null&&(e=r)}if(!e){this.allInitsLoaded=!0;return}if(t)return;let i=this.representations.get(e);i&&(this.initLoadIdleCallback=Rr(()=>(0,JS.default)(this.loadInit(i,"low",!1),()=>this.initLoadIdleCallback=null)))}loadInit(e,t="auto",i=!1){return R(this,null,function*(){let r=this.tuning.dash.useFetchPriorityHints?t:"auto",n=(!i&&this.failedDownloads>0?(0,k.abortable)(this.destroyAbortController.signal,function(){return oe(this,null,function*(){let o=(0,k.getExponentialDelay)(this.failedDownloads,this.tuning.downloadBackoff);yield new Promise(u=>setTimeout(u,o))})}.bind(this))():Promise.resolve()).then(()=>this.fetcher.fetchRepresentation(e.segmentReference,Ot(e.mime),r)).then(o=>R(this,null,function*(){if(!o)return;let{init:u,dataView:l,segments:c}=o,d=l.buffer.slice(l.byteOffset,l.byteOffset+l.byteLength);this.initData.set(e.id,d);let f=c;this.isLive&&ut(e.segmentReference)&&(f=this.getActualLiveStartingSegments(e.segmentReference)),(!this.isLive||!this.segments.has(e.id))&&this.segments.set(e.id,f),u&&this.parsedInitData.set(e.id,u)})).then(()=>this.failedDownloads=0,o=>{this.initData.set(e.id,null),i&&this.error$.next({id:"LoadInits",category:k.ErrorCategory.WTF,message:"loadInit threw",thrown:o})});return this.initData.set(e.id,n),n})}dropBuffer(){return R(this,null,function*(){for(let e of this.segments.values())for(let t of e)t.status="none";yield this.pruneBuffer(0,1/0,!0)})}pruneBuffer(e,t,i=!1){return R(this,null,function*(){if(!this.sourceBuffer||!te(this.mediaSource,this.sourceBuffer)||!this.playingRepresentationId||(0,k.isNullable)(e))return!1;let r=[],a=0,n=u=>{u.sort((c,d)=>c.from-d.from);let l=[u[0]];for(let c=1;c<u.length;c++){let{from:d,to:f}=u[c],p=l[l.length-1];p.to>=d?p.to=Math.max(p.to,f):l.push(u[c])}return l},o=u=>{var c;if(a>=t)return r;r.push(C({},u.time)),r=n(r);let l=ac(u)?(c=u.size)!=null?c:0:u.byte.to-u.byte.from;a+=l};for(let u of this.segments.values())for(let l of u){let c=l.time.to<=e-this.tuning.dash.bufferPruningSafeZone,d=l.time.from>=e+Math.min(this.forwardBufferTarget,this.bufferLimit);(c||d)&&l.status==="fed"&&o(l)}for(let u=0;u<this.sourceBuffer.buffered.length;u++){let l=this.sourceBuffer.buffered.start(u)*1e3,c=this.sourceBuffer.buffered.end(u)*1e3,d=0;for(let f of this.segments.values())for(let p of f)(0,qn.default)(["none","partially_ejected"],p.status)&&Math.round(p.time.from)<=Math.round(l)&&Math.round(p.time.to)>=Math.round(c)&&d++;if(d===this.segments.size){let f={time:{from:l,to:c},url:"",status:"none"};o(f)}}if(r.length&&i){let u=Math.min(this.forwardBufferTarget,this.bufferLimit)*this.tuning.dash.minSafeBufferThreshold;for(let l of this.segments.values())for(let c of l)c.time.from>=e+u&&c.status==="fed"&&o(c)}return r.length?(yield Promise.all(r.map(l=>this.sourceBufferTaskQueue.remove(l.from,l.to)))).reduce((l,c)=>l||c,!1):!1})}abortBuffer(){return R(this,null,function*(){if(!this.sourceBuffer||!te(this.mediaSource,this.sourceBuffer))return!1;let e=this.playingRepresentationId&&this.initData.get(this.playingRepresentationId),t=e instanceof ArrayBuffer?e:void 0;return this.sourceBufferTaskQueue.abort(t)})}getDebugBufferState(){if(!(!this.sourceBuffer||!te(this.mediaSource,this.sourceBuffer)||!this.sourceBuffer.buffered.length))return{from:this.sourceBuffer.buffered.start(0),to:this.sourceBuffer.buffered.end(this.sourceBuffer.buffered.length-1)}}getForwardBufferDuration(e=this.getCurrentPosition()){return!this.sourceBuffer||!te(this.mediaSource,this.sourceBuffer)||!this.sourceBuffer.buffered.length||(0,k.isNullable)(e)?0:Be(this.sourceBuffer.buffered,e)}detectGaps(e,t){if(!(!this.sourceBuffer||!te(this.mediaSource,this.sourceBuffer))){if(this.tuning.useRefactoredSearchGap)for(let i=0;i<this.sourceBuffer.buffered.length;i++)this.gaps=this.gaps.filter(r=>this.sourceBuffer&&(Math.round(r.from)<Math.round(this.sourceBuffer.buffered.start(i)*1e3)||Math.round(r.to)>Math.round(this.sourceBuffer.buffered.end(i)*1e3)));for(let i of t){let r={representation:e,from:i.time.from,to:i.time.to};for(let a=0;a<this.sourceBuffer.buffered.length;a++){let n=this.sourceBuffer.buffered.start(a)*1e3,o=this.sourceBuffer.buffered.end(a)*1e3;if(!(o<=i.time.from||n>=i.time.to)){if(n<=i.time.from&&o>=i.time.to){r=void 0;break}o>i.time.from&&o<i.time.to&&(r.from=o),n<i.time.to&&n>i.time.from&&(r.to=n)}}r&&r.to-r.from>1&&!this.gaps.some(a=>r&&a.from===r.from&&a.to===r.to)&&this.gaps.push(r)}}}detectGapsWhenIdle(e,t){if(!(this.gapDetectionIdleCallback||!this.sourceBuffer||!te(this.mediaSource,this.sourceBuffer))){if(!this.tuning.useRefactoredSearchGap)for(let i=0;i<this.sourceBuffer.buffered.length;i++)this.gaps=this.gaps.filter(r=>this.sourceBuffer&&(Math.round(r.from)<Math.round(this.sourceBuffer.buffered.start(i)*1e3)||Math.round(r.to)>Math.round(this.sourceBuffer.buffered.end(i)*1e3)));this.gapDetectionIdleCallback=Rr(()=>{try{this.detectGaps(e,t)}catch(i){this.error$.next({id:"GapDetection",category:k.ErrorCategory.WTF,message:"detectGaps threw",thrown:i})}finally{this.gapDetectionIdleCallback=null}})}}checkEjectedSegments(){if((0,k.isNullable)(this.sourceBuffer)||!te(this.mediaSource,this.sourceBuffer)||(0,k.isNullable)(this.playingRepresentationId))return;let e=[];for(let i=0;i<this.sourceBuffer.buffered.length;i++){let r=Math.floor(this.sourceBuffer.buffered.start(i)*1e3),a=Math.ceil(this.sourceBuffer.buffered.end(i)*1e3);e.push({from:r,to:a})}let t=100;for(let i of this.segments.values())for(let r of i){let{status:a}=r;if(a!=="fed"&&a!=="partially_ejected")continue;let n=Math.floor(r.time.from),o=Math.ceil(r.time.to),u=e.some(c=>c.from-t<=n&&c.to+t>=o),l=e.filter(c=>n>=c.from&&n<c.to-t||o>c.from+t&&o<=c.to);u||(l.length===1?r.status="partially_ejected":this.gaps.some(c=>c.from===r.time.from||c.to===r.time.to)?r.status="partially_ejected":r.status="none")}}handleAsyncError(e,t){this.error$.next({id:t,category:k.ErrorCategory.VIDEO_PIPELINE,thrown:e,message:"Something went wrong"})}};var gi=s=>{let e=new URL(s);return e.searchParams.set("quic","1"),e.toString()};var Hn=s=>{var a;let e=s.get("X-Delivery-Type"),t=s.get("X-Reused"),i=e===null?"http1":e!=null?e:void 0,r=t===null?void 0:(a={1:!0,0:!1}[t])!=null?a:void 0;return{type:i,reused:r}};var X=require("@vkontakte/videoplayer-shared/es2015");var jn=s=>{let e=new URL(s);return e.searchParams.set("enable-subtitles","yes"),e.toString()};var Wn=class{constructor({throughputEstimator:e,requestQuic:t,tracer:i,compatibilityMode:r=!1,useEnableSubtitlesParam:a=!1}){this.manifestRequested=new X.Subject;this.manifestReceived=new X.Subject;this.firstBytesRequested=new X.Subject;this.firstBytesReceived=new X.Subject;this.lastConnectionType$=new X.ValueSubject(void 0);this.lastConnectionReused$=new X.ValueSubject(void 0);this.lastRequestFirstBytes$=new X.ValueSubject(void 0);this.recoverableError$=new X.Subject;this.error$=new X.Subject;this.abortAllController=new fe;this.subscription=new X.SubscriptionRemovable;this.fetchManifest=(0,X.abortable)(this.abortAllController.signal,function(e){return oe(this,null,function*(){let t=this.tracer.createComponentTracer("FetchManifest"),i=e;this.requestQuic&&(i=gi(i)),!this.compatibilityMode&&this.useEnableSubtitlesParam&&(i=jn(i)),this.manifestRequested.next();let r=yield this.doFetch(i,{signal:this.abortAllController.signal}).catch(Qn);return r?(t.log("success",(0,X.flattenObject)({url:i,message:"Request successfully executed"})),t.end(),this.manifestReceived.next(),this.onHeadersReceived(r.headers),r.text()):(t.error("error",(0,X.flattenObject)({url:i,message:"No data in request manifest"})),t.end(),null)})}.bind(this));this.fetch=(0,X.abortable)(this.abortAllController.signal,function(c){return oe(this,arguments,function*(e,{rangeMethod:t=this.compatibilityMode?0:1,range:i,onProgress:r,priority:a="auto",signal:n,measureThroughput:o=!0,isLowLatency:u=!1,bufferOptimisation:l=!1}={}){var le,he,F;let d=e,f=new Headers,p=this.tracer.createComponentTracer("Fetch");if(i)switch(t){case 0:{f.append("Range",`bytes=${i.from}-${i.to}`);break}case 1:{let $=new URL(d,location.href);$.searchParams.append("bytes",`${i.from}-${i.to}`),d=$.toString();break}default:(0,X.assertNever)(t)}this.requestQuic&&(d=gi(d));let h=this.abortAllController.signal,b;if(n){let $=new fe;if(b=(0,X.merge)((0,X.fromEvent)(this.abortAllController.signal,"abort"),(0,X.fromEvent)(n,"abort")).subscribe(()=>{try{$.abort()}catch(P){Qn(P)}}),this.subscription.add(b),this.abortAllController.signal.aborted||n.aborted)try{$.abort()}catch(P){Qn(P)}h=$.signal}let S=0,g=(0,X.now)();p.log("startRequest",(0,X.flattenObject)({url:d,priority:a,rangeMethod:t,range:i,isLowLatency:u,requestStartedAt:g})),this.firstBytesRequested.next();let y=yield this.doFetch(d,{priority:a,headers:f,signal:h}),A=(0,X.now)();if(!y)return p.error("error",{message:"No response in request"}),p.end(),this.unsubscribeAbortSubscription(b),null;if((le=this.throughputEstimator)==null||le.addRawRtt(A-g),!y.ok||!y.body){this.unsubscribeAbortSubscription(b);let $=`Fetch error ${y.status}: ${y.statusText}`;return p.error("error",{message:$}),p.end(),Promise.reject(new Error(`Fetch error ${y.status}: ${y.statusText}`))}if(this.onHeadersReceived(y.headers),!r&&!o){this.unsubscribeAbortSubscription(b);let $=(0,X.now)(),P={requestStartedAt:g,requestEndedAt:$,duration:$-g};return p.log("endRequest",(0,X.flattenObject)(P)),p.end(),y.arrayBuffer()}let E=y.body;if(o){let $;[E,$]=y.body.tee(),(he=this.throughputEstimator)==null||he.trackStream($,u)}let w=E.getReader(),_,W=parseInt((F=y.headers.get("content-length"))!=null?F:"",10);Number.isFinite(W)&&(_=W),!_&&i&&(_=i.to-i.from+1);let O=_?new Uint8Array(_):new Uint8Array(0),U=!1,M=$=>{this.unsubscribeAbortSubscription(b),U=!0,Qn($)},Q=(0,X.abortable)(h,function(B){return oe(this,arguments,function*({done:$,value:P}){if(S===0&&(this.lastRequestFirstBytes$.next((0,X.now)()-g),this.firstBytesReceived.next()),h.aborted){this.unsubscribeAbortSubscription(b);return}if(!$&&P){if(l&&_)O.set(P,S),S+=P.byteLength;else{let q=new Uint8Array(O.length+P.length);q.set(O),q.set(P,O.length),O=q,S+=P.byteLength}r==null||r(new DataView(O.buffer),S),yield w==null?void 0:w.read().then(Q,M)}})}.bind(this));yield w==null?void 0:w.read().then(Q,M),this.unsubscribeAbortSubscription(b);let H=(0,X.now)(),Z={failed:U,requestStartedAt:g,requestEndedAt:H,duration:H-g};return U?(p.error("endRequest",(0,X.flattenObject)(Z)),p.end(),null):(p.log("endRequest",(0,X.flattenObject)(Z)),p.end(),O.buffer)})}.bind(this));this.fetchByteRangeRepresentation=(0,X.abortable)(this.abortAllController.signal,function(e,t,i){return oe(this,null,function*(){var g;if(e.type!=="byteRange")return null;let{from:r,to:a}=e.initRange,n=r,o=a,u=!1,l,c;e.indexRange&&(l=e.indexRange.from,c=e.indexRange.to,u=a+1===l,u&&(n=Math.min(l,r),o=Math.max(c,a))),n=Math.min(n,0);let d=yield this.fetch(e.url,{range:{from:n,to:o},priority:i,measureThroughput:!1});if(!d)return null;let f=new DataView(d,r-n,a-n+1);if(!t.validateData(f))throw new Error("Invalid media file");let p=t.parseInit(f),h=(g=e.indexRange)!=null?g:t.getIndexRange(p);if(!h)throw new ReferenceError("No way to load representation index");let b;if(u)b=new DataView(d,h.from-n,h.to-h.from+1);else{let y=yield this.fetch(e.url,{range:h,priority:i,measureThroughput:!1});if(!y)return null;b=new DataView(y)}let S=t.parseSegments(b,p,h);return{init:p,dataView:new DataView(d),segments:S}})}.bind(this));this.fetchTemplateRepresentation=(0,X.abortable)(this.abortAllController.signal,function(e,t){return oe(this,null,function*(){if(e.type!=="template")return null;let i=new URL(e.initUrl,e.baseUrl).toString(),r=yield this.fetch(i,{priority:t,measureThroughput:!1});return r?{init:null,segments:e.segments.map(n=>j(C({},n),{status:"none",size:void 0})),dataView:new DataView(r)}:null})}.bind(this));this.throughputEstimator=e,this.requestQuic=t,this.compatibilityMode=r,this.tracer=i.createComponentTracer("Fetcher"),this.useEnableSubtitlesParam=a}onHeadersReceived(e){let{type:t,reused:i}=Hn(e);this.lastConnectionType$.next(t),this.lastConnectionReused$.next(i)}fetchRepresentation(e,t,i="auto"){return R(this,null,function*(){var a,n;let{type:r}=e;switch(r){case"byteRange":return(a=yield this.fetchByteRangeRepresentation(e,t,i))!=null?a:null;case"template":return(n=yield this.fetchTemplateRepresentation(e,i))!=null?n:null;default:(0,X.assertNever)(r)}})}destroy(){this.abortAllController.abort(),this.subscription.unsubscribe(),this.tracer.end()}doFetch(e,t){return R(this,null,function*(){let i=yield mt(e,t);if(i.ok)return i;let r=yield i.text(),a=parseInt(r);if(!isNaN(a))switch(a){case 1:this.recoverableError$.next({id:"VideoDataLinkExpiredError",message:"Video data links have expired",category:X.ErrorCategory.FATAL});break;case 8:this.recoverableError$.next({id:"VideoDataLinkBlockedForFloodError",message:"Url blocked for flood",category:X.ErrorCategory.FATAL});break;case 18:this.recoverableError$.next({id:"VideoDataLinkIllegalIpChangeError",message:"Client IP has changed",category:X.ErrorCategory.FATAL});break;case 21:this.recoverableError$.next({id:"VideoDataLinkIllegalHostChangeError",message:"Request HOST has changed",category:X.ErrorCategory.FATAL});break;default:this.error$.next({id:"GeneralVideoDataFetchError",message:`Generic video data fetch error (${a})`,category:X.ErrorCategory.FATAL})}})}unsubscribeAbortSubscription(e){e&&(e.unsubscribe(),this.subscription.remove(e))}},Qn=s=>{if(!Ft(s))throw s};var Kt=(s,e,t)=>t*e+(1-t)*s,oc=(s,e)=>s.reduce((t,i)=>t+i,0)/e,ZS=(s,e,t,i)=>{let r=0,a=t,n=oc(s,e),o=e<i?e:i;for(let u=0;u<o;u++)s[a]>n?r++:r--,a=(s.length+a-1)%s.length;return Math.abs(r)===o};var na=require("@vkontakte/videoplayer-shared/es2015");var vi=class{constructor(e){this.prevReported=void 0;this.pastMeasures=[];this.takenMeasures=0;this.measuresCursor=0;var i;this.params=e,this.pastMeasures=Array(e.deviationDepth),this.smoothed=this.prevReported=e.initial,this.smoothed$=new na.ValueSubject(e.initial),this.debounced$=new na.ValueSubject(e.initial);let t=(i=e.label)!=null?i:"value"+Math.random().toString(16).substring(2,6);this.rawSeries$=new Qe(`raw_${t}`),this.smoothedSeries$=new Qe(`smoothed_${t}`),this.reportedSeries$=new Qe(`reported_${t}`),this.rawSeries$.next(e.initial),this.smoothedSeries$.next(e.initial),this.reportedSeries$.next(e.initial)}next(e){let t=0,i=0;for(let o=0;o<this.pastMeasures.length;o++)this.pastMeasures[o]!==void 0&&(t+=kt(this.pastMeasures[o]-this.smoothed,2),i++);this.takenMeasures=i,t/=i;let r=Math.sqrt(t),a=this.smoothed+this.params.deviationFactor*r,n=this.smoothed-this.params.deviationFactor*r;this.pastMeasures[this.measuresCursor]=e,this.measuresCursor=(this.measuresCursor+1)%this.pastMeasures.length,this.rawSeries$.next(e),this.updateSmoothedValue(e),this.smoothed$.next(this.smoothed),this.smoothedSeries$.next(this.smoothed),!(this.smoothed>a||this.smoothed<n)&&((0,na.isNullable)(this.prevReported)||Math.abs(this.smoothed-this.prevReported)/this.prevReported>=this.params.changeThreshold)&&(this.prevReported=this.smoothed,this.debounced$.next(this.smoothed),this.reportedSeries$.next(this.smoothed))}};var Gn=class extends vi{constructor(e){super(e),this.slow=this.fast=e.initial}updateSmoothedValue(e){this.slow=Kt(this.slow,e,this.params.emaAlphaSlow),this.fast=Kt(this.fast,e,this.params.emaAlphaFast);let t=this.params.fastDirection>0?Math.max:Math.min;this.smoothed=t(this.slow,this.fast)}};var zn=class extends vi{constructor(e){super(e),this.emaSmoothed=e.initial}updateSmoothedValue(e){let t=oc(this.pastMeasures,this.takenMeasures);this.emaSmoothed=Kt(this.emaSmoothed,e,this.params.emaAlpha);let i=ZS(this.pastMeasures,this.takenMeasures,this.measuresCursor-1,this.params.basisTrendChangeCount);this.smoothed=i?this.emaSmoothed:t}};var Yn=class extends vi{constructor(t){super(t);this.furtherValues=[];this.currentTopExtremumValue=0;this.extremumInterval=t.extremumInterval}next(t){this.currentTopExtremumValue<=t?(this.currentTopExtremumValue=t,this.furtherValues=[]):this.furtherValues.length===this.extremumInterval?(super.next(this.currentTopExtremumValue),this.currentTopExtremumValue=t,this.furtherValues=[]):this.furtherValues.push(t)}updateSmoothedValue(t){this.smoothed=this.smoothed?Kt(this.smoothed,t,this.params.emaAlpha):t}};var Xt=class{static getSmoothedValue(e,t,i){return i.type==="TwoEma"?new Gn({initial:e,emaAlphaSlow:i.emaAlphaSlow,emaAlphaFast:i.emaAlphaFast,changeThreshold:i.changeThreshold,fastDirection:t,deviationDepth:i.deviationDepth,deviationFactor:i.deviationFactor,label:"throughput"}):new zn({initial:e,emaAlpha:i.emaAlpha,basisTrendChangeCount:i.basisTrendChangeCount,changeThreshold:i.changeThreshold,deviationDepth:i.deviationDepth,deviationFactor:i.deviationFactor,label:"throughput"})}static getLiveBufferSmoothedValue(e,t){return new Yn(C({initial:e,label:"liveEdgeDelay"},t))}};var Cr=(s,e)=>{s&&s.playbackRate!==e&&(s.playbackRate=e)};var Kn=require("@vkontakte/videoplayer-shared/es2015");var oa=class s{constructor(e,t){this.currentRepresentation$=new Kn.ValueSubject(null);this.maxRepresentations=4;this.representationsCursor=0;this.representations=[];this.currentSegment=null;this.getCurrentPosition=t.getCurrentPosition,this.processStreams(e)}updateLive(e){this.processStreams(e==null?void 0:e.streams.text)}seekLive(e){this.processStreams(e)}maintain(e=this.getCurrentPosition()){var t;if(!(0,Kn.isNullable)(e))for(let i of this.representations)for(let r of i){let a=r.segmentReference,n=a.segments.length,o=a.segments[0].time.from,u=a.segments[n-1].time.to;if(e<o||e>u)continue;let l=a.segments.find(c=>c.time.from<=e&&c.time.to>=e);!l||((t=this.currentSegment)==null?void 0:t.time.from)===l.time.from&&this.currentSegment.time.to===l.time.to||(this.currentSegment=l,this.currentRepresentation$.next(j(C({},r),{label:"Live Text",language:"ru",isAuto:!0,url:new URL(l.url,a.baseUrl).toString()})))}}destroy(){this.currentRepresentation$.next(null),this.currentSegment=null,this.representations=[]}processStreams(e){for(let t of e!=null?e:[]){let i=s.filterRepresentations(t.representations);if(i){this.representations[this.representationsCursor]=i,this.representationsCursor=(this.representationsCursor+1)%this.maxRepresentations;break}}}static isSupported(e){return!!(e!=null&&e.some(t=>s.filterRepresentations(t.representations)))}static filterRepresentations(e){return e==null?void 0:e.filter(t=>t.kind==="text"&&"segmentReference"in t&&ut(t.segmentReference))}};var Jn=Y(xt(),1),uc=Y(je(),1),ua=require("@vkontakte/videoplayer-shared/es2015");var Xn=s=>{let{webmDecodingInfo:e}=K.video,t="DASH_WEBM",i="DASH_WEBM_AV1";switch(s){case"vp9":return[t,i];case"av1":return[i,t];case"none":return[];case"smooth":return e?e[i].smooth?[i,t]:e[t].smooth?[t,i]:[i,t]:[t,i];case"power_efficient":return e?e[i].powerEfficient?[i,t]:e[t].powerEfficient?[t,i]:[i,t]:[t,i];default:(0,ua.assertNever)(s)}return[t,i]},ey=({webmCodec:s,androidPreferredFormat:e,iosPreferredFormat:t,preferMultiStream:i})=>{let r=[...i?["DASH_STREAMS"]:[],...Xn(s),"DASH_SEP","DASH_ONDEMAND",...i?[]:["DASH_STREAMS"]],a=[...i?["DASH_STREAMS"]:[],"DASH_SEP","DASH_ONDEMAND",...i?[]:["DASH_STREAMS"]];if(K.device.isAndroid)switch(e){case"mpeg":return["MPEG",...r,"HLS","HLS_ONDEMAND"];case"hls":return["HLS","HLS_ONDEMAND",...r,"MPEG"];case"dash":return[...r,"HLS","HLS_ONDEMAND","MPEG"];case"dash_any_mpeg":return[...a,"MPEG",...Xn(s),"HLS","HLS_ONDEMAND"];case"dash_any_webm":return[...Xn(s),"MPEG",...a,"HLS","HLS_ONDEMAND"];case"dash_sep":return["DASH_SEP","MPEG",...Xn(s),...a,"HLS","HLS_ONDEMAND"];default:(0,ua.assertNever)(e)}if(K.video.nativeHlsSupported)switch(t){case"hls":return[...r,"HLS","HLS_FMP4","HLS_ONDEMAND","MPEG"];case"hls_fmp4":return[...r,"HLS_FMP4","HLS","HLS_ONDEMAND","MPEG"];default:(0,ua.assertNever)(t)}return[...r,"HLS","HLS_ONDEMAND","MPEG"]},ty=({androidPreferredFormat:s,preferCMAF:e,preferWebRTC:t})=>{let i=e?["DASH_LIVE_CMAF","DASH_LIVE"]:["DASH_LIVE","DASH_LIVE_CMAF"],r=e?["HLS_LIVE_CMAF","HLS_LIVE"]:["HLS_LIVE","HLS_LIVE_CMAF"],a=[...i,...r],n=[...r,...i],o,u=K.device.isMac&&K.browser.isSafari;if(K.device.isAndroid)switch(s){case"dash":case"dash_any_mpeg":case"dash_any_webm":case"dash_sep":{o=a;break}case"hls":case"mpeg":{o=n;break}default:(0,ua.assertNever)(s)}else K.video.nativeHlsSupported&&!u?o=n:u?o=e?["DASH_LIVE_CMAF","HLS_LIVE_CMAF","HLS_LIVE","DASH_LIVE"]:["HLS_LIVE","DASH_LIVE","DASH_LIVE_CMAF","HLS_LIVE_CMAF"]:o=a;return t?["WEB_RTC_LIVE",...o]:[...o,"WEB_RTC_LIVE"]},lc=s=>s?["HLS_LIVE","HLS_LIVE_CMAF","DASH_LIVE_CMAF"]:["DASH_WEBM","DASH_WEBM_AV1","DASH_SEP","DASH_ONDEMAND","HLS","HLS_ONDEMAND","MPEG"],Zn=s=>{if(s.size===0)return;if(s.size===1){let t=s.values().next();return(0,Jn.default)(t.value.split("."),0)}for(let t of s){let i=(0,Jn.default)(t.split("."),0);if(i==="opus"||i==="vp09"||i==="av01")return i}let e=s.values().next();return(0,Jn.default)(e.value.split("."),0)},eo=s=>{let e=s.map(i=>Br(i)),{codecs:t}=K.video;return T$().filter(i=>{if((0,uc.default)(e,i))switch(i){case"av1":return t.av1;case"vp9":return t.vp9;case"avc1":return t.h264;case"hev1":return t.h265;default:return!1}else return!1})},to=s=>{let e=s.map(i=>Br(i)),{codecs:t}=K.video;return I$().filter(i=>{if((0,uc.default)(e,i))switch(i){case"opus":return t.opus;case"mp4a":return t.aac;default:return!1}else return!1})},Br=s=>s.split(".")[0].replace("0",""),T$=()=>["av1","vp9","hev1","avc1"],I$=()=>["opus","mp4a"];var w$=["timeupdate","progress","play","seeked","stalled","waiting"],A$=["timeupdate","progress","loadeddata","playing","seeked"];var io=class{constructor(e){this.element=null;this.manifestUrlString="";this.source=null;this.manifest=null;this.bufferManagers=[];this.subscription=new I.Subscription;this.representationSubscription=new I.Subscription;this.state$=new ne("none");this.currentVideoRepresentation$=new I.ValueSubject(void 0);this.currentVideoRepresentationInit$=new I.ValueSubject(void 0);this.currentAudioRepresentation$=new I.ValueSubject(void 0);this.currentVideoSegmentLength$=new I.ValueSubject(0);this.currentAudioSegmentLength$=new I.ValueSubject(0);this.error$=new I.Subject;this.manifestRequested=new I.Subject;this.manifestReceived=new I.Subject;this.firstBytesRequested=new I.Subject;this.firstBytesReceived=new I.Subject;this.lastConnectionType$=new I.ValueSubject(void 0);this.lastConnectionReused$=new I.ValueSubject(void 0);this.lastRequestFirstBytes$=new I.ValueSubject(void 0);this.currentLiveTextRepresentation$=new I.ValueSubject(null);this.isLive$=new I.ValueSubject(!1);this.isActiveLive$=new I.ValueSubject(!1);this.isLowLatency$=new I.ValueSubject(!1);this.liveDuration$=new I.ValueSubject(0);this.liveSeekableDuration$=new I.ValueSubject(0);this.liveAvailabilityStartTime$=new I.ValueSubject(0);this.liveStreamStatus$=new I.ValueSubject(void 0);this.bufferLength$=new I.ValueSubject(0);this.liveLatency$=new I.ValueSubject(void 0);this.liveLoadBufferLength$=new I.ValueSubject(0);this.livePositionFromPlayer$=new I.ValueSubject(0);this.currentStallDuration$=new I.ValueSubject(0);this.videoLastDataObtainedTimestamp$=new I.ValueSubject(0);this.fetcherRecoverableError$=new I.Subject;this.fetcherError$=new I.Subject;this.liveStreamEndTimestamp=0;this.isUpdatingLive=!1;this.isJumpGapAfterSeekLive=!1;this.forceEnded$=new I.Subject;this.gapWatchdogActive=!1;this.destroyController=new fe;this.initManifest=(0,I.abortable)(this.destroyController.signal,function(e,t,i){return oe(this,null,function*(){var r;this.tracer.log("initManifest"),this.element=e,this.manifestUrlString=Re(t,i,2),this.state$.startTransitionTo("manifest_ready"),this.manifest=yield this.updateManifest(),(r=this.manifest)!=null&&r.streams.video.length?this.state$.setState("manifest_ready"):this.error$.next({id:"NoRepresentations",category:I.ErrorCategory.PARSER,message:"No playable video representations"})})}.bind(this));this.updateManifest=(0,I.abortable)(this.destroyController.signal,function(){return oe(this,null,function*(){var u,l;this.tracer.log("updateManifestStart",{manifestUrl:this.manifestUrlString});let e=yield this.fetcher.fetchManifest(this.manifestUrlString).catch(c=>{!this.manifest&&!this.bufferLength$.getValue()&&this.error$.next({id:"LoadManifest",category:I.ErrorCategory.NETWORK,message:"Failed to load manifest",thrown:c})});if(!e)return null;let t=null;try{t=Nn(e!=null?e:"",this.manifestUrlString)}catch(c){let d=(u=On(e))!=null?u:{id:"ManifestParsing",category:I.ErrorCategory.PARSER,message:"Failed to parse MPD manifest",thrown:c};this.error$.next(d)}if(!t)return null;let i=(c,d,f)=>{var p,h,b,S;return!!((h=(p=this.element)==null?void 0:p.canPlayType)!=null&&h.call(p,d)&&((S=(b=nt())==null?void 0:b.isTypeSupported)!=null&&S.call(b,`${d}; codecs="${f}"`))||c==="text")};if(t.live){this.isLive$.next(!!t.live);let{availabilityStartTime:c,latestSegmentPublishTime:d,streamIsUnpublished:f,streamIsAlive:p}=t.live,h=((l=t.duration)!=null?l:0)/1e3;this.liveSeekableDuration$.next(-1*h),this.liveDuration$.next((d-c)/1e3),this.liveAvailabilityStartTime$.next(t.live.availabilityStartTime);let b="active";p||(b=f?"unpublished":"unexpectedly_down"),this.liveStreamStatus$.next(b)}let r={text:t.streams.text,video:[],audio:[]},a,n;for(let c of["video","audio"]){let f=t.streams[c].filter(({mime:h,codecs:b})=>i(c,h,b));r[c]=f;let p;if(this.tuning.dash.codecsPrioritizeEnabled){let h=f.map(({codecs:b})=>b);c==="audio"&&(n=to(h),p=n[0]),c==="video"&&(a=eo(h),this.forceVideoCodec&&(0,sy.default)(a,this.forceVideoCodec)?p=this.forceVideoCodec:p=a[0]),p&&(r[c]=f.filter(({codecs:b})=>Br(b)===p))}else{let h=new Set(f.map(({codecs:b})=>b));p=Zn(h),p&&(r[c]=f.filter(({codecs:b})=>b.startsWith(p)))}if(c==="video"){let h=this.tuning.preferHDR,b=r.video.some(g=>g.hdr),S=r.video.some(g=>!g.hdr);K.display.isHDR&&h&&b?r.video=r.video.filter(g=>g.hdr):S&&(r.video=r.video.filter(g=>!g.hdr))}}let o=j(C({},t),{streams:r});return this.tuning.dash.codecsPrioritizeEnabled&&(o.codecs={video:a,audio:n}),this.tracer.log("updateManifestEnd",(0,I.flattenObject)(o)),o})}.bind(this));this.initRepresentations=(0,I.abortable)(this.destroyController.signal,function(e,t,i){return oe(this,null,function*(){var f;this.tracer.log("initRepresentationsStart",(0,I.flattenObject)({initialVideo:e,initialAudio:t,sourceHls:i})),(0,I.assertNonNullable)(this.manifest),(0,I.assertNonNullable)(this.element),this.representationSubscription.unsubscribe(),this.state$.startTransitionTo("representations_ready");let r=p=>{this.representationSubscription.add((0,I.fromEvent)(p,"error").pipe((0,I.filter)(h=>{var b;return!!((b=this.element)!=null&&b.played.length)})).subscribe(h=>{this.error$.next({id:"VideoSource",category:I.ErrorCategory.VIDEO_PIPELINE,message:"Unexpected video source error",thrown:h})}))};this.source=Tn();let a=document.createElement("source");if(r(a),a.src=URL.createObjectURL(this.source),this.element.appendChild(a),Tr())if(i){let p=document.createElement("source");r(p),p.type="application/x-mpegurl",p.src=i.url,this.element.appendChild(p)}else this.element.disableRemotePlayback=!0;this.isActiveLive$.next(this.isLive$.getValue());let n={fetcher:this.fetcher,tuning:this.tuning,getCurrentPosition:()=>this.element?this.element.currentTime*1e3:void 0,isActiveLowLatency:()=>this.isActiveLive$.getValue()&&this.isLowLatency$.getValue(),manifest:this.manifest},o=this.manifest.streams.video.reduce((p,h)=>[...p,...h.representations],[]);if(this.videoBufferManager=new aa("video",this.source,o,n),this.bufferManagers=[this.videoBufferManager],(0,I.isNonNullable)(t)){let p=this.manifest.streams.audio.reduce((h,b)=>[...h,...b.representations],[]);this.audioBufferManager=new aa("audio",this.source,p,n),this.bufferManagers.push(this.audioBufferManager)}oa.isSupported(this.manifest.streams.text)&&!this.isLowLatency$.getValue()&&(this.liveTextManager=new oa(this.manifest.streams.text,n)),this.representationSubscription.add(this.fetcher.manifestRequested.subscribe(this.manifestRequested)),this.representationSubscription.add(this.fetcher.manifestReceived.subscribe(this.manifestReceived)),this.representationSubscription.add(this.fetcher.firstBytesRequested.subscribe(this.firstBytesRequested)),this.representationSubscription.add(this.fetcher.firstBytesReceived.subscribe(this.firstBytesReceived)),this.representationSubscription.add(this.fetcher.lastConnectionType$.subscribe(this.lastConnectionType$)),this.representationSubscription.add(this.fetcher.lastConnectionReused$.subscribe(this.lastConnectionReused$)),this.representationSubscription.add(this.fetcher.lastRequestFirstBytes$.subscribe(this.lastRequestFirstBytes$));let u=()=>{var p;(p=this.stallWatchdogSubscription)==null||p.unsubscribe(),this.currentStallDuration$.next(0)};if(this.representationSubscription.add((0,I.merge)(...A$.map(p=>(0,I.fromEvent)(this.element,p))).pipe((0,I.map)(p=>this.element?Be(this.element.buffered,this.element.currentTime*1e3):0),(0,I.filterChanged)(),(0,I.tap)(p=>{p>this.tuning.dash.bufferEmptinessTolerance&&u()})).subscribe(this.bufferLength$)),this.representationSubscription.add((0,I.merge)((0,I.fromEvent)(this.element,"ended"),this.forceEnded$).subscribe(()=>{u()})),this.isLive$.getValue()){this.subscription.add(this.liveDuration$.pipe((0,I.filterChanged)()).subscribe(h=>this.liveStreamEndTimestamp=(0,I.now)())),this.subscription.add((0,I.fromEvent)(this.element,"pause").subscribe(()=>{this.livePauseWatchdogSubscription=(0,I.interval)(1e3).subscribe(h=>{let b=di(this.manifestUrlString,2);this.manifestUrlString=Re(this.manifestUrlString,b+1e3,2),this.liveStreamStatus$.getValue()==="active"&&this.updateManifest()}),this.subscription.add(this.livePauseWatchdogSubscription)})).add((0,I.fromEvent)(this.element,"play").subscribe(h=>{var b;return(b=this.livePauseWatchdogSubscription)==null?void 0:b.unsubscribe()})),this.representationSubscription.add((0,I.combine)({isActiveLive:this.isActiveLive$,isLowLatency:this.isLowLatency$}).pipe((0,I.map)(({isActiveLive:h,isLowLatency:b})=>h&&b),(0,I.filterChanged)()).subscribe(h=>{this.isManualDecreasePlaybackInLive()||Cr(this.element,1)})),this.representationSubscription.add((0,I.combine)({bufferLength:this.bufferLength$,isActiveLive:this.isActiveLive$,isLowLatency:this.isLowLatency$}).pipe((0,I.filter)(({bufferLength:h,isActiveLive:b,isLowLatency:S})=>b&&S&&!!h)).subscribe(({bufferLength:h})=>this.liveBuffer.next(h))),this.representationSubscription.add(this.videoBufferManager.currentLowLatencySegmentLength$.subscribe(h=>{if(!this.isActiveLive$.getValue()&&!this.isLowLatency$.getValue()&&!h)return;let b=this.liveSeekableDuration$.getValue()-h/1e3;this.liveSeekableDuration$.next(Math.max(b,-1*this.tuning.dashCmafLive.maxLiveDuration)),this.liveDuration$.next(this.liveDuration$.getValue()+h/1e3)})),this.representationSubscription.add((0,I.combine)({isLive:this.isLive$,rtt:this.throughputEstimator.rtt$,bufferLength:this.bufferLength$,segmentServerLatency:this.videoBufferManager.currentLiveSegmentServerLatency$}).pipe((0,I.filter)(({isLive:h})=>h),(0,I.filterChanged)((h,b)=>b.bufferLength<h.bufferLength),(0,I.map)(({rtt:h,bufferLength:b,segmentServerLatency:S})=>{let g=di(this.manifestUrlString,2);return(h/2+b+S+g)/1e3})).subscribe(this.liveLatency$)),this.representationSubscription.add((0,I.combine)({liveBuffer:this.liveBuffer.smoothed$,isActiveLive:this.isActiveLive$,isLowLatency:this.isLowLatency$}).subscribe(({liveBuffer:h,isActiveLive:b,isLowLatency:S})=>{if(!S||!b)return;let g=this.tuning.dashCmafLive.lowLatency.maxTargetOffset,y=this.tuning.dashCmafLive.lowLatency.maxTargetOffsetDeviation,A=this.tuning.dashCmafLive.lowLatency.playbackCatchupSpeedup,E=h-g;if(this.isManualDecreasePlaybackInLive())return;let w=1;Math.abs(E)>y&&(w=1+Math.sign(E)*A),Cr(this.element,w)})),this.representationSubscription.add(this.bufferLength$.subscribe(h=>{var S,g;let b=0;if(h){let y=((g=(S=this.element)==null?void 0:S.currentTime)!=null?g:0)*1e3;b=Math.min(...this.bufferManagers.map(E=>{var w,_;return(_=(w=E.getLiveSegmentsToLoadState(this.manifest))==null?void 0:w.to)!=null?_:y}))-y}this.liveLoadBufferLength$.getValue()!==b&&this.liveLoadBufferLength$.next(b)}));let p=0;this.representationSubscription.add((0,I.combine)({liveLoadBufferLength:this.liveLoadBufferLength$,bufferLength:this.bufferLength$}).pipe((0,I.throttle)(1e3)).subscribe(S=>R(this,[S],function*({liveLoadBufferLength:h,bufferLength:b}){if(!this.element||this.isUpdatingLive)return;let g=this.element.playbackRate,y=di(this.manifestUrlString,2),A=Math.abs(this.livePositionFromPlayer$.getValue())*1e3,E=Math.min(A,this.tuning.dashCmafLive.normalizedTargetMinBufferSize*g),w=this.tuning.dashCmafLive.normalizedActualBufferOffset*g,_=this.tuning.dashCmafLive.normalizedLiveMinBufferSize*g,W=isFinite(h)?h:b,O=this.isActiveLive$.getValue()&&this.isLowLatency$.getValue(),U=A<=this.tuning.live.activeLiveDelay;this.isActiveLive$.next(U);let M="none";if(O?M="active_low_latency":this.isLowLatency$.getValue()&&U?(this.bufferManagers.forEach(Q=>Q.proceedLowLatencyLive()),M="active_low_latency"):y!==0&&W<E?M="live_forward_buffering":W<E+_&&(M="live_with_target_offset"),isFinite(h)&&(p=h>p?h:p),M==="live_forward_buffering"||M==="live_with_target_offset"){let Q=p-(E+w),H=this.normolizeLiveOffset(Math.trunc(y+Q/g)),Z=Math.abs(H-y),le=0;!h||Z<=this.tuning.dashCmafLive.offsetCalculationError?le=y:H>0&&Z>this.tuning.dashCmafLive.offsetCalculationError&&(le=H),this.manifestUrlString=Re(this.manifestUrlString,le,2)}(M==="live_with_target_offset"||M==="live_forward_buffering")&&(p=0,yield this.updateLive())}),h=>{this.error$.next({id:"updateLive",category:I.ErrorCategory.VIDEO_PIPELINE,thrown:h,message:"Failed to update live with subscription"})}))}let l=(0,I.merge)(...this.bufferManagers.map(p=>p.fullyBuffered$)).pipe((0,I.map)(()=>this.bufferManagers.every(p=>p.fullyBuffered$.getValue()))),c=(0,I.merge)(...this.bufferManagers.map(p=>p.onLastSegment$)).pipe((0,I.map)(()=>this.bufferManagers.some(p=>p.onLastSegment$.getValue()))),d=(0,I.combine)({allBuffersFull:l,someBufferEnded:c}).pipe((0,I.filterChanged)(),(0,I.map)(({allBuffersFull:p,someBufferEnded:h})=>p&&h),(0,I.filter)(p=>p));if(this.representationSubscription.add((0,I.merge)(this.forceEnded$,d).subscribe(()=>{var p;if(this.source&&this.source.readyState==="open"&&Array.from(this.source.sourceBuffers).every(h=>!h.updating))try{(p=this.source)==null||p.endOfStream()}catch(h){this.error$.next({id:"EndOfStream",category:I.ErrorCategory.VIDEO_PIPELINE,message:"Failed to end MediaSource stream",thrown:h})}})),this.representationSubscription.add((0,I.merge)(...this.bufferManagers.map(p=>p.error$)).subscribe(this.error$)),this.representationSubscription.add(this.videoBufferManager.playingRepresentation$.subscribe(this.currentVideoRepresentation$)),this.representationSubscription.add(this.videoBufferManager.playingRepresentationInit$.subscribe(this.currentVideoRepresentationInit$)),this.representationSubscription.add(this.videoBufferManager.currentSegmentLength$.subscribe(this.currentVideoSegmentLength$)),this.audioBufferManager&&(this.representationSubscription.add(this.audioBufferManager.playingRepresentation$.subscribe(this.currentAudioRepresentation$)),this.representationSubscription.add(this.audioBufferManager.currentSegmentLength$.subscribe(this.currentAudioSegmentLength$))),this.liveTextManager&&this.representationSubscription.add(this.liveTextManager.currentRepresentation$.subscribe(this.currentLiveTextRepresentation$)),this.source.readyState!=="open"){let p=this.tuning.dash.sourceOpenTimeout>=0;yield new Promise(h=>{var b;p&&(this.timeoutSourceOpenId=setTimeout(()=>{var S;if(((S=this.source)==null?void 0:S.readyState)==="open"){h();return}this.error$.next({id:"OpenOfStream",category:I.ErrorCategory.VIDEO_PIPELINE,message:"Failed to open MediaSource",thrown:new Error("Timeout reject when wait sourceopen event"),traceAsLog:!0})},this.tuning.dash.sourceOpenTimeout)),(b=this.source)==null||b.addEventListener("sourceopen",()=>{this.timeoutSourceOpenId&&clearTimeout(this.timeoutSourceOpenId),h()},{once:!0})})}if(!this.isLive$.getValue()){let p=[(f=this.manifest.duration)!=null?f:0,...(0,dc.default)((0,dc.default)([...this.manifest.streams.audio,...this.manifest.streams.video],h=>h.representations),h=>{let b=[];return h.duration&&b.push(h.duration),ut(h.segmentReference)&&h.segmentReference.totalSegmentsDurationMs&&b.push(h.segmentReference.totalSegmentsDurationMs),b})];this.source.duration=Math.max(...p)/1e3}this.audioBufferManager&&(0,I.isNonNullable)(t)?yield Promise.all([this.videoBufferManager.startWith(e),this.audioBufferManager.startWith(t)]):yield this.videoBufferManager.startWith(e),this.state$.setState("representations_ready"),this.tracer.log("initRepresentationsEnd")})}.bind(this));this.tick=()=>{var t,i,r,a;if(!this.element||!this.videoBufferManager||((t=this.source)==null?void 0:t.readyState)!=="open")return;let e=this.element.currentTime*1e3;this.videoBufferManager.maintain(e),(i=this.audioBufferManager)==null||i.maintain(e),(r=this.liveTextManager)==null||r.maintain(e),(this.videoBufferManager.gaps.length||(a=this.audioBufferManager)!=null&&a.gaps.length)&&!this.gapWatchdogActive&&(this.gapWatchdogActive=!0,this.gapWatchdogSubscription=(0,I.interval)(this.tuning.gapWatchdogInterval).subscribe(()=>this.jumpGap(),n=>{this.error$.next({id:"GapWatchdog",category:I.ErrorCategory.WTF,message:"Error handling gaps",thrown:n})}),this.subscription.add(this.gapWatchdogSubscription))};this.throughputEstimator=e.throughputEstimator,this.tuning=e.tuning,this.tracer=e.tracer.createComponentTracer(this.constructor.name),this.forceVideoCodec=e.forceVideoCodec,this.fetcher=new Wn({throughputEstimator:this.throughputEstimator,requestQuic:this.tuning.requestQuick,compatibilityMode:e.compatibilityMode,tracer:this.tracer,useEnableSubtitlesParam:e.tuning.useEnableSubtitlesParam}),this.subscription.add(this.fetcher.recoverableError$.subscribe(this.fetcherRecoverableError$)),this.subscription.add(this.fetcher.error$.subscribe(this.fetcherError$)),this.liveBuffer=Xt.getLiveBufferSmoothedValue(this.tuning.dashCmafLive.lowLatency.maxTargetOffset,C({},e.tuning.dashCmafLive.lowLatency.bufferEstimator)),this.initTracerSubscription()}seekLive(e){return R(this,null,function*(){var r,a,n;(0,I.assertNonNullable)(this.element);let t=this.liveStreamStatus$.getValue()!=="active"?(0,I.now)()-this.liveStreamEndTimestamp:0,i=this.normolizeLiveOffset(e+t);this.isActiveLive$.next(i===0),this.manifestUrlString=Re(this.manifestUrlString,i,2),this.manifest=yield this.updateManifest(),this.manifest&&(this.isJumpGapAfterSeekLive=!0,yield(r=this.videoBufferManager)==null?void 0:r.seekLive(this.manifest.streams.video),yield(a=this.audioBufferManager)==null?void 0:a.seekLive(this.manifest.streams.audio),(n=this.liveTextManager)==null||n.seekLive(this.manifest.streams.text))})}initBuffer(){(0,I.assertNonNullable)(this.element),this.state$.setState("running"),this.subscription.add((0,I.merge)(...w$.map(e=>(0,I.fromEvent)(this.element,e)),(0,I.fromEvent)(window,"online")).subscribe(()=>this.tick(),e=>{this.error$.next({id:"DashVKPlayer",category:I.ErrorCategory.WTF,message:"Internal logic error",thrown:e})})),this.subscription.add((0,I.fromEvent)(this.element,"progress").subscribe(()=>{this.element&&this.element.readyState===2&&!this.element.seeking&&(this.element.currentTime=this.element.currentTime)})),this.subscription.add((0,I.fromEvent)(this.element,"waiting").subscribe(()=>{var t;this.element&&this.element.readyState===2&&!this.element.seeking&&qe(this.element.buffered,this.element.currentTime*1e3)&&(this.element.currentTime=this.element.currentTime);let e=()=>{var p,h,b,S,g,y,A,E,w,_,W;if(!this.element||((p=this.source)==null?void 0:p.readyState)!=="open")return;let i=this.currentStallDuration$.getValue();i+=50,this.currentStallDuration$.next(i);let r={timeInWaiting:i},a=(0,I.now)(),n=100,o=(b=(h=this.videoBufferManager)==null?void 0:h.lastDataObtainedTimestamp)!=null?b:0;this.videoLastDataObtainedTimestamp$.next(o);let u=(g=(S=this.audioBufferManager)==null?void 0:S.lastDataObtainedTimestamp)!=null?g:0,l=(A=(y=this.videoBufferManager)==null?void 0:y.getForwardBufferDuration())!=null?A:0,c=(w=(E=this.audioBufferManager)==null?void 0:E.getForwardBufferDuration())!=null?w:0,d=l<n&&a-o>this.tuning.dash.crashOnStallTWithoutDataTimeout,f=this.audioBufferManager&&c<n&&a-u>this.tuning.dash.crashOnStallTWithoutDataTimeout;if((d||f)&&i>this.tuning.dash.crashOnStallTWithoutDataTimeout||i>=this.tuning.dash.crashOnStallTimeout)throw new Error(`Stall timeout exceeded: ${i} ms`);if(this.isLive$.getValue()&&i%2e3===0){let O=this.normolizeLiveOffset(-1*this.livePositionFromPlayer$.getValue()*1e3);this.seekLive(O).catch(U=>{this.error$.next({id:"stallIntervalCallback",category:I.ErrorCategory.VIDEO_PIPELINE,message:"stallIntervalCallback failed",thrown:U})}),r.liveLastOffset=O}else{let O=this.element.currentTime*1e3;(_=this.videoBufferManager)==null||_.maintain(O),(W=this.audioBufferManager)==null||W.maintain(O),r.position=O}this.tracer.log("stallIntervalCallback",(0,I.flattenObject)(r))};(t=this.stallWatchdogSubscription)==null||t.unsubscribe(),this.stallWatchdogSubscription=(0,I.interval)(50).subscribe(e,i=>{this.error$.next({id:"StallWatchdogCallback",category:I.ErrorCategory.NETWORK,message:"Can't restore DASH after stall.",thrown:i})}),this.subscription.add(this.stallWatchdogSubscription)})),this.tick()}switchRepresentation(e,t,i=!1){return R(this,null,function*(){let r={video:this.videoBufferManager,audio:this.audioBufferManager,text:null}[e];return this.tuning.useNewSwitchTo?this.currentStallDuration$.getValue()>0?r==null?void 0:r.switchToWithPreviousAbort(t,i):r==null?void 0:r.switchTo(t,i):r==null?void 0:r.switchToOld(t,i)})}seek(e,t){return R(this,null,function*(){var r,a,n,o,u;(0,I.assertNonNullable)(this.element),(0,I.assertNonNullable)(this.videoBufferManager);let i;t||this.element.duration*1e3<=this.tuning.dashSeekInSegmentDurationThreshold||Math.abs(this.element.currentTime*1e3-e)<=this.tuning.dashSeekInSegmentAlwaysSeekDelta?i=e:i=Math.max((r=this.videoBufferManager.findSegmentStartTime(e))!=null?r:e,(n=(a=this.audioBufferManager)==null?void 0:a.findSegmentStartTime(e))!=null?n:e),this.warmUpMediaSourceIfNeeded(i),qe(this.element.buffered,i)||(yield Promise.all([this.videoBufferManager.abort(),(o=this.audioBufferManager)==null?void 0:o.abort()])),!((0,I.isNullable)(this.element)||(0,I.isNullable)(this.videoBufferManager))&&(this.videoBufferManager.maintain(i),(u=this.audioBufferManager)==null||u.maintain(i),this.element.currentTime=i/1e3,this.tracer.log("seek",(0,I.flattenObject)({requestedPosition:e,forcePrecise:t,position:i})))})}warmUpMediaSourceIfNeeded(e=(t=>(t=this.element)==null?void 0:t.currentTime)()){var i;(0,I.isNonNullable)(this.element)&&(0,I.isNonNullable)(this.source)&&(0,I.isNonNullable)(e)&&((i=this.source)==null?void 0:i.readyState)==="ended"&&this.element.duration*1e3-e>this.tuning.dash.seekBiasInTheEnd&&this.bufferManagers.forEach(r=>r.warmUpMediaSource())}get isStreamEnded(){var e;return((e=this.source)==null?void 0:e.readyState)==="ended"}stop(){var e,t,i;this.tracer.log("stop"),(e=this.element)==null||e.querySelectorAll("source").forEach(r=>{URL.revokeObjectURL(r.src),r.remove()}),this.element=null,this.source=null,this.manifest=null,this.currentVideoRepresentation$.next(void 0),(t=this.videoBufferManager)==null||t.destroy(),this.videoBufferManager=null,(i=this.audioBufferManager)==null||i.destroy(),this.audioBufferManager=null,this.bufferManagers=[],this.state$.setState("none")}setBufferTarget(e){for(let t of this.bufferManagers)t.setTarget(e)}getStreams(){var e;return(e=this.manifest)==null?void 0:e.streams}getCodecs(){var e;return(e=this.manifest)==null?void 0:e.codecs}setPreloadOnly(e){for(let t of this.bufferManagers)t.setPreloadOnly(e)}destroy(){var e;this.subscription.unsubscribe(),this.representationSubscription.unsubscribe(),this.timeoutSourceOpenId&&clearTimeout(this.timeoutSourceOpenId),this.destroyController.abort(),this.fetcher.destroy(),this.stop(),((e=this.source)==null?void 0:e.readyState)==="open"&&Array.from(this.source.sourceBuffers).every(t=>!t.updating)&&this.source.endOfStream(),this.source=null,this.tracer.end()}initTracerSubscription(){let e=(0,I.getTraceSubscriptionMethod)(this.tracer.error.bind(this.tracer));this.subscription.add(this.error$.subscribe(e("error")))}isManualDecreasePlaybackInLive(){if(!this.element||!this.isLive$.getValue())return!1;let e=1-this.element.playbackRate;return Number(e.toFixed(2))>Number(this.tuning.dashCmafLive.lowLatency.playbackCatchupSpeedup.toFixed(2))}normolizeLiveOffset(e){return Math.trunc(e/1e3)*1e3}updateLive(){return R(this,null,function*(){var e;this.isUpdatingLive=!0,this.manifest=yield this.updateManifest(),this.manifest&&(this.bufferManagers.forEach(t=>t.updateLive(this.manifest)),(e=this.liveTextManager)==null||e.updateLive(this.manifest)),this.isUpdatingLive=!1})}jumpGap(){if(!this.element||!this.videoBufferManager)return;let e=this.videoBufferManager.getDebugBufferState();if(!e)return;let t=this.isActiveLive$.getValue()&&this.isLowLatency$.getValue(),i={isJumpGapAfterSeekLive:this.isJumpGapAfterSeekLive,isActiveLowLatency:t,initialCurrentTime:this.element.currentTime};this.isJumpGapAfterSeekLive&&!t&&this.element.currentTime>e.to&&(this.isJumpGapAfterSeekLive=!1,this.element.currentTime=0);let r=this.element.currentTime*1e3,a=[],n=this.element.readyState===1?this.tuning.endGapTolerance:0;for(let o of this.bufferManagers)for(let u of o.gaps)o.playingRepresentation$.getValue()===u.representation&&u.from-n<=r&&u.to+n>r&&(this.element.duration*1e3-u.to<this.tuning.endGapTolerance?a.push(1/0):a.push(u.to));if(a.length){let o=Math.max(...a)+10;this.gapWatchdogSubscription.unsubscribe(),this.gapWatchdogActive=!1,o===1/0?this.forceEnded$.next():(this.element.currentTime=o/1e3,i=j(C({},i),{gapEnds:a,jumpTo:o,resultCurrentTime:this.element.currentTime}),this.tracer.log("jumpGap",(0,I.flattenObject)(i)))}}calculateDurationFromSegments(){var e,t;return Math.max(((e=this.videoBufferManager)==null?void 0:e.calculateDurationFromSegments())||0,((t=this.audioBufferManager)==null?void 0:t.calculateDurationFromSegments())||0)}};var ro=class{constructor(e,t){this.fov=e,this.orientation=t}};var so=class{constructor(e,t){this.rotating=!1;this.fading=!1;this.lastTickTS=0;this.lastCameraTurnTS=0;this.fadeStartSpeed=null;this.fadeTime=0;this.camera=e,this.options=t,this.rotationSpeed={x:0,y:0,z:0},this.fadeCorrection=1/kt(this.options.speedFadeTime/1e3,2)}turnCamera(e=0,t=0,i=0){this.pointCameraTo(this.camera.orientation.x+e,this.camera.orientation.y+t,this.camera.orientation.z+i)}pointCameraTo(e=0,t=0,i=0){t=this.limitCameraRotationY(t);let r=e-this.camera.orientation.x,a=t-this.camera.orientation.y,n=i-this.camera.orientation.z;this.camera.orientation.x=e,this.camera.orientation.y=t,this.camera.orientation.z=i,this.lastCameraTurn={x:r,y:a,z:n},this.lastCameraTurnTS=Date.now()}setRotationSpeed(e,t,i){this.rotationSpeed.x=e!=null?e:this.rotationSpeed.x,this.rotationSpeed.y=t!=null?t:this.rotationSpeed.y,this.rotationSpeed.z=i!=null?i:this.rotationSpeed.z}startRotation(){this.rotating=!0}stopRotation(e=!1){e?(this.setRotationSpeed(0,0,0),this.fadeStartSpeed=null):this.startFading(this.rotationSpeed.x,this.rotationSpeed.y,this.rotationSpeed.z),this.rotating=!1}onCameraRelease(){if(this.lastCameraTurn&&this.lastCameraTurnTS){let e=Date.now()-this.lastCameraTurnTS;if(e<this.options.speedFadeThreshold){let t=(1-e/this.options.speedFadeThreshold)*this.options.rotationSpeedCorrection;this.startFading(this.lastCameraTurn.x*t,this.lastCameraTurn.y*t,this.lastCameraTurn.z*t)}}}startFading(e,t,i){this.setRotationSpeed(e,t,i),this.fadeStartSpeed=C({},this.rotationSpeed),this.fading=!0}stopFading(){this.fadeStartSpeed=null,this.fading=!0,this.fadeTime=0}limitCameraRotationY(e){return Math.max(-this.options.maxYawAngle,Math.min(e,this.options.maxYawAngle))}tick(e){if(!this.lastTickTS){this.lastTickTS=e,this.lastCameraTurnTS=Date.now();return}let t=e-this.lastTickTS,i=t/1e3;if(this.rotating)this.turnCamera(this.rotationSpeed.x*this.options.rotationSpeedCorrection*i,this.rotationSpeed.y*this.options.rotationSpeedCorrection*i,this.rotationSpeed.z*this.options.rotationSpeedCorrection*i);else if(this.fading&&this.fadeStartSpeed){let r=-this.fadeCorrection*kt(this.fadeTime/1e3,2)+1;this.setRotationSpeed(this.fadeStartSpeed.x*r,this.fadeStartSpeed.y*r,this.fadeStartSpeed.z*r),r>0?this.turnCamera(this.rotationSpeed.x*this.options.rotationSpeedCorrection*i,this.rotationSpeed.y*this.options.rotationSpeedCorrection*i,this.rotationSpeed.z*this.options.rotationSpeedCorrection*i):(this.stopRotation(!0),this.stopFading()),this.fadeTime=Math.min(this.fadeTime+t,this.options.speedFadeTime)}this.lastTickTS=e}};var ay=`attribute vec2 a_vertex;
125
125
  attribute vec2 a_texel;
126
126
 
127
127
  varying vec2 v_texel;