@vkontakte/videoplayer-statistics 1.0.29 → 1.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es2015.cjs.js +4 -4
- package/es2015.esm.js +4 -4
- package/es2018.cjs.js +4 -4
- package/es2018.esm.js +4 -4
- package/esnext.cjs.js +4 -4
- package/esnext.esm.js +4 -4
- package/index.d.ts +308 -3
- package/package.json +3 -3
- package/Api.d.ts +0 -68
- package/ApiTransport.d.ts +0 -27
- package/Logger.d.ts +0 -39
- package/OneStat.d.ts +0 -228
- package/build/polyfills/runtime/abortableFetch.d.ts +0 -4
- package/env.d.ts +0 -8
- package/es2015.cjs.d.ts +0 -3
- package/es2015.esm.d.ts +0 -3
- package/es2018.cjs.d.ts +0 -3
- package/es2018.esm.d.ts +0 -3
- package/esnext.esm.d.ts +0 -3
- package/types.d.ts +0 -50
- package/utils/coreMappers.d.ts +0 -5
- package/utils/storage.d.ts +0 -11
- package/utils/timeSynchronisation.d.ts +0 -10
- package/utils/uuid.d.ts +0 -1
- package/utils/vsid.d.ts +0 -1
package/es2015.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-statistics v1.0.
|
|
3
|
-
*
|
|
4
|
-
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-
|
|
2
|
+
* @vkontakte/videoplayer-statistics v1.0.31
|
|
3
|
+
* Thu, 02 Feb 2023 10:22:17 GMT
|
|
4
|
+
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-31/doc/
|
|
5
5
|
*/
|
|
6
|
-
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var t=require('@vkontakte/videoplayer-shared/es2015.cjs.js'),e=require('@vkontakte/videoplayer-core/es2015.cjs.js');function r(t){return t&&'object'==typeof t&&'default'in t?t:{default:t}}var o=r(require('lodash/debounce.js'));function n(t,e,r,o){return new(r||(r=Promise))((function(n,i){function s(t){try{u(o.next(t))}catch(t){i(t)}}function a(t){try{u(o.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((o=o.apply(t,e||[])).next())}))}var i='undefined'!=typeof globalThis?globalThis:'undefined'!=typeof window?window:'undefined'!=typeof global?global:'undefined'!=typeof self?self:{},s=function(t){return t&&t.Math==Math&&t},a=s('object'==typeof globalThis&&globalThis)||s('object'==typeof window&&window)||s('object'==typeof self&&self)||s('object'==typeof i&&i)||function(){return this}()||Function('return this')(),u=function(t){try{return!!t()}catch(t){return!0}},c=!u((function(){var t=function(){}.bind();return'function'!=typeof t||t.hasOwnProperty('prototype')})),h=c,l=Function.prototype,d=l.apply,p=l.call,f='object'==typeof Reflect&&Reflect.apply||(h?p.bind(d):function(){return p.apply(d,arguments)}),y=c,v=Function.prototype,m=v.bind,g=v.call,b=y&&m.bind(g,g),w=y?function(t){return t&&b(t)}:function(t){return t&&function(){return g.apply(t,arguments)}},T=function(t){return'function'==typeof t},E={},S=!u((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),A=c,P=Function.prototype.call,_=A?P.bind(P):function(){return P.apply(P,arguments)},O={},C={}.propertyIsEnumerable,x=Object.getOwnPropertyDescriptor,R=x&&!C.call({1:2},1);O.f=R?function(t){var e=x(this,t);return!!e&&e.enumerable}:C;var N,k,j=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},I=w,L=I({}.toString),Q=I(''.slice),D=function(t){return Q(L(t),8,-1)},$=u,M=D,F=Object,B=w(''.split),q=$((function(){return!F('z').propertyIsEnumerable(0)}))?function(t){return'String'==M(t)?B(t,''):F(t)}:F,U=TypeError,H=function(t){if(null==t)throw U('Can\'t call method on '+t);return t},V=q,z=H,K=T,W=function(t){return'object'==typeof t?null!==t:K(t)},G={},Y=G,J=a,X=T,Z=function(t){return X(t)?t:void 0},tt=function(t,e){return arguments.length<2?Z(Y[t])||Z(J[t]):Y[t]&&Y[t][e]||J[t]&&J[t][e]},et=w({}.isPrototypeOf),rt=tt('navigator','userAgent')||'',ot=a,nt=rt,it=ot.process,st=ot.Deno,at=it&&it.versions||st&&st.version,ut=at&&at.v8;ut&&(k=(N=ut.split('.'))[0]>0&&N[0]<4?1:+(N[0]+N[1])),!k&&nt&&(!(N=nt.match(/Edge\/(\d+)/))||N[1]>=74)&&(N=nt.match(/Chrome\/(\d+)/))&&(k=+N[1]);var ct=k,ht=ct,lt=u,dt=!!Object.getOwnPropertySymbols&&!lt((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&ht&&ht<41})),pt=dt&&!Symbol.sham&&'symbol'==typeof Symbol.iterator,ft=tt,yt=T,vt=et,mt=Object,gt=pt?function(t){return'symbol'==typeof t}:function(t){var e=ft('Symbol');return yt(e)&&vt(e.prototype,mt(t))},bt=String,wt=function(t){try{return bt(t)}catch(t){return'Object'}},Tt=T,Et=wt,St=TypeError,At=function(t){if(Tt(t))return t;throw St(Et(t)+' is not a function')},Pt=At,_t=function(t,e){var r=t[e];return null==r?void 0:Pt(r)},Ot=_,Ct=T,xt=W,Rt=TypeError,Nt={exports:{}},kt=a,jt=Object.defineProperty,It=function(t,e){try{jt(kt,t,{value:e,configurable:!0,writable:!0})}catch(r){kt[t]=e}return e},Lt=a['__core-js_shared__']||It('__core-js_shared__',{}),Qt=Lt;(Nt.exports=function(t,e){return Qt[t]||(Qt[t]=void 0!==e?e:{})})('versions',[]).push({version:'3.24.1',mode:'pure',copyright:'© 2014-2022 Denis Pushkarev (zloirock.ru)',license:'https://github.com/zloirock/core-js/blob/v3.24.1/LICENSE',source:'https://github.com/zloirock/core-js'});var Dt=H,$t=Object,Mt=function(t){return $t(Dt(t))},Ft=w({}.hasOwnProperty),Bt=Object.hasOwn||function(t,e){return Ft(Mt(t),e)},qt=w,Ut=0,Ht=Math.random(),Vt=qt(1..toString),zt=function(t){return'Symbol('+(void 0===t?'':t)+')_'+Vt(++Ut+Ht,36)},Kt=a,Wt=Nt.exports,Gt=Bt,Yt=zt,Jt=dt,Xt=pt,Zt=Wt('wks'),te=Kt.Symbol,ee=te&&te.for,re=Xt?te:te&&te.withoutSetter||Yt,oe=function(t){if(!Gt(Zt,t)||!Jt&&'string'!=typeof Zt[t]){var e='Symbol.'+t;Jt&&Gt(te,t)?Zt[t]=te[t]:Zt[t]=Xt&&ee?ee(e):re(e)}return Zt[t]},ne=_,ie=W,se=gt,ae=_t,ue=function(t,e){var r,o;if('string'===e&&Ct(r=t.toString)&&!xt(o=Ot(r,t)))return o;if(Ct(r=t.valueOf)&&!xt(o=Ot(r,t)))return o;if('string'!==e&&Ct(r=t.toString)&&!xt(o=Ot(r,t)))return o;throw Rt('Can\'t convert object to primitive value')},ce=TypeError,he=oe('toPrimitive'),le=function(t,e){if(!ie(t)||se(t))return t;var r,o=ae(t,he);if(o){if(void 0===e&&(e='default'),r=ne(o,t,e),!ie(r)||se(r))return r;throw ce('Can\'t convert object to primitive value')}return void 0===e&&(e='number'),ue(t,e)},de=gt,pe=function(t){var e=le(t,'string');return de(e)?e:e+''},fe=W,ye=a.document,ve=fe(ye)&&fe(ye.createElement),me=function(t){return ve?ye.createElement(t):{}},ge=me,be=!S&&!u((function(){return 7!=Object.defineProperty(ge('div'),'a',{get:function(){return 7}}).a})),we=S,Te=_,Ee=O,Se=j,Ae=function(t){return V(z(t))},Pe=pe,_e=Bt,Oe=be,Ce=Object.getOwnPropertyDescriptor;E.f=we?Ce:function(t,e){if(t=Ae(t),e=Pe(e),Oe)try{return Ce(t,e)}catch(t){}if(_e(t,e))return Se(!Te(Ee.f,t,e),t[e])};var xe=u,Re=T,Ne=/#|\.prototype\./,ke=function(t,e){var r=Ie[je(t)];return r==Qe||r!=Le&&(Re(e)?xe(e):!!e)},je=ke.normalize=function(t){return String(t).replace(Ne,'.').toLowerCase()},Ie=ke.data={},Le=ke.NATIVE='N',Qe=ke.POLYFILL='P',De=ke,$e=At,Me=c,Fe=w(w.bind),Be=function(t,e){return $e(t),void 0===e?t:Me?Fe(t,e):function(){return t.apply(e,arguments)}},qe={},Ue=S&&u((function(){return 42!=Object.defineProperty((function(){}),'prototype',{value:42,writable:!1}).prototype})),He=W,Ve=String,ze=TypeError,Ke=function(t){if(He(t))return t;throw ze(Ve(t)+' is not an object')},We=S,Ge=be,Ye=Ue,Je=Ke,Xe=pe,Ze=TypeError,tr=Object.defineProperty,er=Object.getOwnPropertyDescriptor;qe.f=We?Ye?function(t,e,r){if(Je(t),e=Xe(e),Je(r),'function'==typeof t&&'prototype'===e&&'value'in r&&'writable'in r&&!r.writable){var o=er(t,e);o&&o.writable&&(t[e]=r.value,r={configurable:'configurable'in r?r.configurable:o.configurable,enumerable:'enumerable'in r?r.enumerable:o.enumerable,writable:!1})}return tr(t,e,r)}:tr:function(t,e,r){if(Je(t),e=Xe(e),Je(r),Ge)try{return tr(t,e,r)}catch(t){}if('get'in r||'set'in r)throw Ze('Accessors not supported');return'value'in r&&(t[e]=r.value),t};var rr=qe,or=j,nr=S?function(t,e,r){return rr.f(t,e,or(1,r))}:function(t,e,r){return t[e]=r,t},ir=a,sr=f,ar=w,ur=T,cr=E.f,hr=De,lr=G,dr=Be,pr=nr,fr=Bt,yr=function(t){var e=function(r,o,n){if(this instanceof e){switch(arguments.length){case 0:return new t;case 1:return new t(r);case 2:return new t(r,o)}return new t(r,o,n)}return sr(t,this,arguments)};return e.prototype=t.prototype,e},vr=function(t,e){var r,o,n,i,s,a,u,c,h=t.target,l=t.global,d=t.stat,p=t.proto,f=l?ir:d?ir[h]:(ir[h]||{}).prototype,y=l?lr:lr[h]||pr(lr,h,{})[h],v=y.prototype;for(n in e)r=!hr(l?n:h+(d?'.':'#')+n,t.forced)&&f&&fr(f,n),s=y[n],r&&(a=t.dontCallGetSet?(c=cr(f,n))&&c.value:f[n]),i=r&&a?a:e[n],r&&typeof s==typeof i||(u=t.bind&&r?dr(i,ir):t.wrap&&r?yr(i):p&&ur(i)?ar(i):i,(t.sham||i&&i.sham||s&&s.sham)&&pr(u,'sham',!0),pr(y,n,u),p&&(fr(lr,o=h+'Prototype')||pr(lr,o,{}),pr(lr[o],n,i),t.real&&v&&!v[n]&&pr(v,n,i)))},mr='process'==D(a.process),gr=nr,br=(TypeError,w);Object.setPrototypeOf||'__proto__'in{}&&function(){var t,e=!1,r={};try{(t=br(Object.getOwnPropertyDescriptor(Object.prototype,'__proto__').set))(r,[]),e=r instanceof Array}catch(t){}}();var wr={};wr[oe('toStringTag')]='z';var Tr='[object z]'===String(wr),Er=Tr,Sr=T,Ar=D,Pr=oe('toStringTag'),_r=Object,Or='Arguments'==Ar(function(){return arguments}()),Cr=Er?Ar:function(t){var e,r,o;return void 0===t?'Undefined':null===t?'Null':'string'==typeof(r=function(t,e){try{return t[e]}catch(t){}}(e=_r(t),Pr))?r:Or?Ar(e):'Object'==(o=Ar(e))&&Sr(e.callee)?'Arguments':o},xr=Cr,Rr=Tr?{}.toString:function(){return'[object '+xr(this)+']'},Nr=Tr,kr=qe.f,jr=nr,Ir=Bt,Lr=Rr,Qr=oe('toStringTag'),Dr=tt,$r=qe,Mr=S,Fr=oe('species'),Br=et,qr=TypeError,Ur=T,Hr=Lt,Vr=w(Function.toString);Ur(Hr.inspectSource)||(Hr.inspectSource=function(t){return Vr(t)});var zr=Hr.inspectSource,Kr=w,Wr=u,Gr=T,Yr=Cr,Jr=zr,Xr=function(){},Zr=[],to=tt('Reflect','construct'),eo=/^\s*(?:class|function)\b/,ro=Kr(eo.exec),oo=!eo.exec(Xr),no=function(t){if(!Gr(t))return!1;try{return to(Xr,Zr,t),!0}catch(t){return!1}},io=function(t){if(!Gr(t))return!1;switch(Yr(t)){case'AsyncFunction':case'GeneratorFunction':case'AsyncGeneratorFunction':return!1}try{return oo||!!ro(eo,Jr(t))}catch(t){return!0}};io.sham=!0;var so,ao,uo,co,ho=!to||Wr((function(){var t;return no(no.call)||!no(Object)||!no((function(){t=!0}))||t}))?io:no,lo=wt,po=TypeError,fo=Ke,yo=function(t){if(ho(t))return t;throw po(lo(t)+' is not a constructor')},vo=oe('species'),mo=function(t,e){var r,o=fo(t).constructor;return void 0===o||null==(r=fo(o)[vo])?e:yo(r)},go=tt('document','documentElement'),bo=w([].slice),wo=TypeError,To=/(?:ipad|iphone|ipod).*applewebkit/i.test(rt),Eo=a,So=f,Ao=Be,Po=T,_o=Bt,Oo=u,Co=go,xo=bo,Ro=me,No=function(t,e){if(t<e)throw wo('Not enough arguments');return t},ko=To,jo=mr,Io=Eo.setImmediate,Lo=Eo.clearImmediate,Qo=Eo.process,Do=Eo.Dispatch,$o=Eo.Function,Mo=Eo.MessageChannel,Fo=Eo.String,Bo=0,qo={};try{so=Eo.location}catch(t){}var Uo=function(t){if(_o(qo,t)){var e=qo[t];delete qo[t],e()}},Ho=function(t){return function(){Uo(t)}},Vo=function(t){Uo(t.data)},zo=function(t){Eo.postMessage(Fo(t),so.protocol+'//'+so.host)};Io&&Lo||(Io=function(t){No(arguments.length,1);var e=Po(t)?t:$o(t),r=xo(arguments,1);return qo[++Bo]=function(){So(e,void 0,r)},ao(Bo),Bo},Lo=function(t){delete qo[t]},jo?ao=function(t){Qo.nextTick(Ho(t))}:Do&&Do.now?ao=function(t){Do.now(Ho(t))}:Mo&&!ko?(co=(uo=new Mo).port2,uo.port1.onmessage=Vo,ao=Ao(co.postMessage,co)):Eo.addEventListener&&Po(Eo.postMessage)&&!Eo.importScripts&&so&&'file:'!==so.protocol&&!Oo(zo)?(ao=zo,Eo.addEventListener('message',Vo,!1)):ao='onreadystatechange'in Ro('script')?function(t){Co.appendChild(Ro('script')).onreadystatechange=function(){Co.removeChild(this),Uo(t)}}:function(t){setTimeout(Ho(t),0)});var Ko,Wo,Go,Yo,Jo,Xo,Zo,tn,en={set:Io,clear:Lo},rn=a,on=/ipad|iphone|ipod/i.test(rt)&&void 0!==rn.Pebble,nn=/web0s(?!.*chrome)/i.test(rt),sn=a,an=Be,un=E.f,cn=en.set,hn=To,ln=on,dn=nn,pn=mr,fn=sn.MutationObserver||sn.WebKitMutationObserver,yn=sn.document,vn=sn.process,mn=sn.Promise,gn=un(sn,'queueMicrotask'),bn=gn&&gn.value;bn||(Ko=function(){var t,e;for(pn&&(t=vn.domain)&&t.exit();Wo;){e=Wo.fn,Wo=Wo.next;try{e()}catch(t){throw Wo?Yo():Go=void 0,t}}Go=void 0,t&&t.enter()},hn||pn||dn||!fn||!yn?!ln&&mn&&mn.resolve?((Zo=mn.resolve(void 0)).constructor=mn,tn=an(Zo.then,Zo),Yo=function(){tn(Ko)}):pn?Yo=function(){vn.nextTick(Ko)}:(cn=an(cn,sn),Yo=function(){cn(Ko)}):(Jo=!0,Xo=yn.createTextNode(''),new fn(Ko).observe(Xo,{characterData:!0}),Yo=function(){Xo.data=Jo=!Jo}));var wn=bn||function(t){var e={fn:t,next:void 0};Go&&(Go.next=e),Wo||(Wo=e,Yo()),Go=e},Tn=a,En=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}},Sn=function(){this.head=null,this.tail=null};Sn.prototype={add:function(t){var e={item:t,next:null};this.head?this.tail.next=e:this.head=e,this.tail=e},get:function(){var t=this.head;if(t)return this.head=t.next,this.tail===t&&(this.tail=null),t.item}};var An,Pn,_n,On=Sn,Cn=T,xn=zr,Rn=a.WeakMap,Nn=Cn(Rn)&&/native code/.test(xn(Rn)),kn=Nt.exports,jn=zt,In=kn('keys'),Ln=Nn,Qn=a,Dn=w,$n=W,Mn=nr,Fn=Bt,Bn=Lt,qn=function(t){return In[t]||(In[t]=jn(t))},Un=Qn.TypeError,Hn=Qn.WeakMap;if(Ln||Bn.state){var Vn=Bn.state||(Bn.state=new Hn),zn=Dn(Vn.get),Kn=Dn(Vn.has),Wn=Dn(Vn.set);An=function(t,e){if(Kn(Vn,t))throw new Un('Object already initialized');return e.facade=t,Wn(Vn,t,e),e},Pn=function(t){return zn(Vn,t)||{}},_n=function(t){return Kn(Vn,t)}}else{var Gn=qn('state');An=function(t,e){if(Fn(t,Gn))throw new Un('Object already initialized');return e.facade=t,Mn(t,Gn,e),e},Pn=function(t){return Fn(t,Gn)?t[Gn]:{}},_n=function(t){return Fn(t,Gn)}}var Yn={set:An,get:Pn,has:_n,enforce:function(t){return _n(t)?Pn(t):An(t,{})},getterFor:function(t){return function(e){var r;if(!$n(e)||(r=Pn(e)).type!==t)throw Un('Incompatible receiver, '+t+' required');return r}}},Jn=a.Promise,Xn='object'==typeof Deno&&Deno&&'object'==typeof Deno.version,Zn=!Xn&&!mr&&'object'==typeof window&&'object'==typeof document,ti=a,ei=Jn,ri=T,oi=De,ni=zr,ii=oe,si=Zn,ai=Xn,ui=ct,ci=ei&&ei.prototype,hi=ii('species'),li=!1,di=ri(ti.PromiseRejectionEvent),pi={CONSTRUCTOR:oi('Promise',(function(){var t=ni(ei),e=t!==String(ei);if(!e&&66===ui)return!0;if(!ci.catch||!ci.finally)return!0;if(!ui||ui<51||!/native code/.test(t)){var r=new ei((function(t){t(1)})),o=function(t){t((function(){}),(function(){}))};if((r.constructor={})[hi]=o,!(li=r.then((function(){}))instanceof o))return!0}return!e&&(si||ai)&&!di})),REJECTION_EVENT:di,SUBCLASSING:li},fi={},yi=At,vi=function(t){var e,r;this.promise=new t((function(t,o){if(void 0!==e||void 0!==r)throw TypeError('Bad Promise constructor');e=t,r=o})),this.resolve=yi(e),this.reject=yi(r)};fi.f=function(t){return new vi(t)};var mi,gi,bi=vr,wi=mr,Ti=a,Ei=_,Si=function(t,e,r,o){return o&&o.enumerable?t[e]=r:gr(t,e,r),t},Ai=function(t,e,r,o){if(t){var n=r?t:t.prototype;Ir(n,Qr)||kr(n,Qr,{configurable:!0,value:e}),o&&!Nr&&jr(n,'toString',Lr)}},Pi=function(t){var e=Dr(t),r=$r.f;Mr&&e&&!e[Fr]&&r(e,Fr,{configurable:!0,get:function(){return this}})},_i=At,Oi=T,Ci=W,xi=function(t,e){if(Br(e,t))return t;throw qr('Incorrect invocation')},Ri=mo,Ni=en.set,ki=wn,ji=function(t,e){var r=Tn.console;r&&r.error&&(1==arguments.length?r.error(t):r.error(t,e))},Ii=En,Li=On,Qi=Yn,Di=Jn,$i=fi,Mi=pi.CONSTRUCTOR,Fi=pi.REJECTION_EVENT,Bi=Qi.getterFor('Promise'),qi=Qi.set,Ui=Di&&Di.prototype,Hi=Di,Vi=Ui,zi=Ti.TypeError,Ki=Ti.document,Wi=Ti.process,Gi=$i.f,Yi=Gi,Ji=!!(Ki&&Ki.createEvent&&Ti.dispatchEvent),Xi=function(t){var e;return!(!Ci(t)||!Oi(e=t.then))&&e},Zi=function(t,e){var r,o,n,i=e.value,s=1==e.state,a=s?t.ok:t.fail,u=t.resolve,c=t.reject,h=t.domain;try{a?(s||(2===e.rejection&&ns(e),e.rejection=1),!0===a?r=i:(h&&h.enter(),r=a(i),h&&(h.exit(),n=!0)),r===t.promise?c(zi('Promise-chain cycle')):(o=Xi(r))?Ei(o,r,u,c):u(r)):c(i)}catch(t){h&&!n&&h.exit(),c(t)}},ts=function(t,e){t.notified||(t.notified=!0,ki((function(){for(var r,o=t.reactions;r=o.get();)Zi(r,t);t.notified=!1,e&&!t.rejection&&rs(t)})))},es=function(t,e,r){var o,n;Ji?((o=Ki.createEvent('Event')).promise=e,o.reason=r,o.initEvent(t,!1,!0),Ti.dispatchEvent(o)):o={promise:e,reason:r},!Fi&&(n=Ti['on'+t])?n(o):'unhandledrejection'===t&&ji('Unhandled promise rejection',r)},rs=function(t){Ei(Ni,Ti,(function(){var e,r=t.facade,o=t.value;if(os(t)&&(e=Ii((function(){wi?Wi.emit('unhandledRejection',o,r):es('unhandledrejection',r,o)})),t.rejection=wi||os(t)?2:1,e.error))throw e.value}))},os=function(t){return 1!==t.rejection&&!t.parent},ns=function(t){Ei(Ni,Ti,(function(){var e=t.facade;wi?Wi.emit('rejectionHandled',e):es('rejectionhandled',e,t.value)}))},is=function(t,e,r){return function(o){t(e,o,r)}},ss=function(t,e,r){t.done||(t.done=!0,r&&(t=r),t.value=e,t.state=2,ts(t,!0))},as=function(t,e,r){if(!t.done){t.done=!0,r&&(t=r);try{if(t.facade===e)throw zi('Promise can\'t be resolved itself');var o=Xi(e);o?ki((function(){var r={done:!1};try{Ei(o,e,is(as,r,t),is(ss,r,t))}catch(e){ss(r,e,t)}})):(t.value=e,t.state=1,ts(t,!1))}catch(e){ss({done:!1},e,t)}}};Mi&&(Vi=(Hi=function(t){xi(this,Vi),_i(t),Ei(mi,this);var e=Bi(this);try{t(is(as,e),is(ss,e))}catch(t){ss(e,t)}}).prototype,(mi=function(t){qi(this,{type:'Promise',done:!1,notified:!1,parent:!1,reactions:new Li,rejection:!1,state:0,value:void 0})}).prototype=Si(Vi,'then',(function(t,e){var r=Bi(this),o=Gi(Ri(this,Hi));return r.parent=!0,o.ok=!Oi(t)||t,o.fail=Oi(e)&&e,o.domain=wi?Wi.domain:void 0,0==r.state?r.reactions.add(o):ki((function(){Zi(o,r)})),o.promise})),gi=function(){var t=new mi,e=Bi(t);this.promise=t,this.resolve=is(as,e),this.reject=is(ss,e)},$i.f=Gi=function(t){return t===Hi||undefined===t?new gi(t):Yi(t)}),bi({global:!0,constructor:!0,wrap:!0,forced:Mi},{Promise:Hi}),Ai(Hi,'Promise',!1,!0),Pi('Promise');var us={},cs=us,hs=oe('iterator'),ls=Array.prototype,ds=Math.ceil,ps=Math.floor,fs=Math.trunc||function(t){var e=+t;return(e>0?ps:ds)(e)},ys=function(t){var e=+t;return e!=e||0===e?0:fs(e)},vs=Math.min,ms=function(t){return t>0?vs(ys(t),9007199254740991):0},gs=Cr,bs=_t,ws=us,Ts=oe('iterator'),Es=function(t){if(null!=t)return bs(t,Ts)||bs(t,'@@iterator')||ws[gs(t)]},Ss=_,As=At,Ps=Ke,_s=wt,Os=Es,Cs=TypeError,xs=_,Rs=Ke,Ns=_t,ks=Be,js=_,Is=Ke,Ls=wt,Qs=function(t){return void 0!==t&&(cs.Array===t||ls[hs]===t)},Ds=function(t){return ms(t.length)},$s=et,Ms=function(t,e){var r=arguments.length<2?Os(t):e;if(As(r))return Ps(Ss(r,t));throw Cs(_s(t)+' is not iterable')},Fs=Es,Bs=function(t,e,r){var o,n;Rs(t);try{if(!(o=Ns(t,'return'))){if('throw'===e)throw r;return r}o=xs(o,t)}catch(t){n=!0,o=t}if('throw'===e)throw r;if(n)throw o;return Rs(o),r},qs=TypeError,Us=function(t,e){this.stopped=t,this.result=e},Hs=Us.prototype,Vs=function(t,e,r){var o,n,i,s,a,u,c,h=r&&r.that,l=!(!r||!r.AS_ENTRIES),d=!(!r||!r.IS_RECORD),p=!(!r||!r.IS_ITERATOR),f=!(!r||!r.INTERRUPTED),y=ks(e,h),v=function(t){return o&&Bs(o,'normal',t),new Us(!0,t)},m=function(t){return l?(Is(t),f?y(t[0],t[1],v):y(t[0],t[1])):f?y(t,v):y(t)};if(d)o=t.iterator;else if(p)o=t;else{if(!(n=Fs(t)))throw qs(Ls(t)+' is not iterable');if(Qs(n)){for(i=0,s=Ds(t);s>i;i++)if((a=m(t[i]))&&$s(Hs,a))return a;return new Us(!1)}o=Ms(t,n)}for(u=d?t.next:o.next;!(c=js(u,o)).done;){try{a=m(c.value)}catch(t){Bs(o,'throw',t)}if('object'==typeof a&&a&&$s(Hs,a))return a}return new Us(!1)},zs=oe('iterator'),Ks=!1;try{var Ws=0,Gs={next:function(){return{done:!!Ws++}},return:function(){Ks=!0}};Gs[zs]=function(){return this},Array.from(Gs,(function(){throw 2}))}catch(t){}var Ys=Jn,Js=pi.CONSTRUCTOR||!function(t,e){if(!e&&!Ks)return!1;var r=!1;try{var o={};o[zs]=function(){return{next:function(){return{done:r=!0}}}},t(o)}catch(t){}return r}((function(t){Ys.all(t).then(void 0,(function(){}))})),Xs=_,Zs=At,ta=fi,ea=En,ra=Vs;vr({target:'Promise',stat:!0,forced:Js},{all:function(t){var e=this,r=ta.f(e),o=r.resolve,n=r.reject,i=ea((function(){var r=Zs(e.resolve),i=[],s=0,a=1;ra(t,(function(t){var u=s++,c=!1;a++,Xs(r,e,t).then((function(t){c||(c=!0,i[u]=t,--a||o(i))}),n)})),--a||o(i)}));return i.error&&n(i.value),r.promise}});var oa=vr,na=pi.CONSTRUCTOR;Jn&&Jn.prototype,oa({target:'Promise',proto:!0,forced:na,real:!0},{catch:function(t){return this.then(void 0,t)}});var ia=_,sa=At,aa=fi,ua=En,ca=Vs;vr({target:'Promise',stat:!0,forced:Js},{race:function(t){var e=this,r=aa.f(e),o=r.reject,n=ua((function(){var n=sa(e.resolve);ca(t,(function(t){ia(n,e,t).then(r.resolve,o)}))}));return n.error&&o(n.value),r.promise}});var ha=_,la=fi;vr({target:'Promise',stat:!0,forced:pi.CONSTRUCTOR},{reject:function(t){var e=la.f(this);return ha(e.reject,void 0,t),e.promise}});var da=Ke,pa=W,fa=fi,ya=function(t,e){if(da(t),pa(e)&&e.constructor===t)return e;var r=fa.f(t);return(0,r.resolve)(e),r.promise},va=vr,ma=Jn,ga=pi.CONSTRUCTOR,ba=ya,wa=tt('Promise'),Ta=!ga;va({target:'Promise',stat:!0,forced:true},{resolve:function(t){return ba(Ta&&this===wa?ma:this,t)}});var Ea=vr,Sa=Jn,Aa=u,Pa=tt,_a=T,Oa=mo,Ca=ya,xa=Sa&&Sa.prototype;Ea({target:'Promise',proto:!0,real:!0,forced:!!Sa&&Aa((function(){xa.finally.call({then:function(){}},(function(){}))}))},{finally:function(t){var e=Oa(this,Pa('Promise')),r=_a(t);return this.then(r?function(r){return Ca(e,t()).then((function(){return r}))}:t,r?function(r){return Ca(e,t()).then((function(){throw r}))}:t)}});var Ra=tt('Promise','finally');const Na=(()=>{try{const t=Date.now().toString(),e=window.localStorage;e.setItem(t,t);const r=e.getItem(t)===t;return e.removeItem(t),r?e:null}catch(t){return null}})();var ka,ja,Ia,La,Qa,Da,$a,Ma={get:t=>function(t){const e=Na?Na.getItem('_one-stat_'+t):null;if(null===e)return null;try{return JSON.parse(e)}catch(t){return null}}(t)||null,set(t,e){!function(t,e){try{Na&&Na.setItem('_one-stat_'+t,JSON.stringify(e))}catch(t){}}(t,e)},remove(t){!function(t){Na&&Na.removeItem('_one-stat_'+t)}(t)}};exports.ApiEnv=void 0,(ka=exports.ApiEnv||(exports.ApiEnv={})).PROD='prod',ka.VK_ALIAS='vk_alias',ka.VIDEOTEST='videotest',ka.TEST='test',ka.AUTO='auto',exports.Quality=void 0,(ja=exports.Quality||(exports.Quality={})).Q144P='144',ja.Q240P='240',ja.Q360P='360',ja.Q480P='480',ja.Q720P='720',ja.Q1080P='1080',ja.Q1440P='1440',ja.Q2160P='2160',ja.Q4320P='4320',ja.UNKNOWN='unknown',exports.ScreenDestination=void 0,(Ia=exports.ScreenDestination||(exports.ScreenDestination={})).CHROMECAST='chromecast',Ia.APPLE_TV='appletv',Ia.PIP='pip',Ia.HEADPHONES='externalHeadphones',Ia.SCREEN='',exports.ContentType=void 0,(La=exports.ContentType||(exports.ContentType={})).MP4='mp4',La.DASH='dash',La.DASH_SEP='dash_sep',La.ONDEMAND_DASH='ondemand_dash',La.HLS='hls',La.ONDEMAND_HLS='ondemand_hls',La.WEBM='webm',La.RTMP='rtmp',La.UNKNOWN='unknown',function(t){t.AUTO='auto',t.MANUAL=''}(Qa||(Qa={})),exports.ConnectionType=void 0,(Da=exports.ConnectionType||(exports.ConnectionType={})).HTTP1='http1',Da.HTTP2='http2',Da.HTTP3='http3',function(t){t[t.YES=1]='YES',t[t.NO=0]='NO'}($a||($a={}));const Fa={[exports.ApiEnv.PROD]:'https://api.ok.ru',[exports.ApiEnv.VK_ALIAS]:'https://api.mycdn.me',[exports.ApiEnv.VIDEOTEST]:'https://videotestapi.ok.ru/api',[exports.ApiEnv.TEST]:'https://apitest.ok.ru',[exports.ApiEnv.AUTO]:''},Ba={start:1e3,factor:1.5,max:3e5,random:.1};var qa;!function(t){t[t.PARAM_SESSION_EXPIRED=102]='PARAM_SESSION_EXPIRED',t[t.PARAM_SESSION_KEY=103]='PARAM_SESSION_KEY',t[t.PARAM_SIGNATURE=104]='PARAM_SIGNATURE',t[t.AUTH_LOGIN=401]='AUTH_LOGIN'}(qa||(qa={}));class Ua{constructor(e){this.consequentAuthErrors=0,this.authorized$=new t.ValueSubject(!1),this.params=e;const r=Ma.get('uuid');r?this.uuid=String(r):(this.uuid=function(){const t='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''),e=new Array(36);let r,o,n=0;for(o=0;o<36;o++)8===o||13===o||18===o||23===o?e[o]='-':14===o?e[o]='4':(n<=2&&(n=33554432+16777216*Math.random()|0),r=15&n,n>>=4,e[o]=t[19===o?3&r|8:r]);return e.join('')}(),Ma.set('uuid',this.uuid))}authorize(t){return n(this,void 0,void 0,(function*(){return this.authToken=null!=t?t:yield this.refreshAuthToken(),this._authorizeWithBackoff()}))}logBeacon(t){const e=this.createLogParams(t),r=this.sessionKey;if(!r)return;this.params.apiTransport.sendBeacon('log.externalLog',e,r)||this.logRequest(t)}logRequest(e){var r;return n(this,void 0,void 0,(function*(){const o='log.externalLog',i=this.createLogParams(e),s=null!==(r=this.sessionKey)&&void 0!==r?r:yield this._authorizeWithBackoff();if(!s)return;const a=(e,r=this.params.requestRetryCount)=>n(this,void 0,void 0,(function*(){try{return yield this.params.apiTransport.sendRequest(o,i,s)}catch(n){if(!n||!('error_code'in n))return void this.params.error$.next({id:'logRequestUnknown',category:t.ErrorCategory.NETWORK,message:`Unknown ${o} error`,thrown:n});const i=null==n?void 0:n.error_code;switch(i){case qa.PARAM_SESSION_EXPIRED:case qa.PARAM_SESSION_KEY:case qa.PARAM_SIGNATURE:return this.authorized$.next(!1),this.sessionKey=yield this._authorizeWithBackoff(),r>0?a(e,r-1):void 0;case qa.AUTH_LOGIN:return this.authorized$.next(!1),this.authToken=yield this.refreshAuthToken(),this.sessionKey=yield this._authorizeWithBackoff(),r>0?a(e,r-1):void 0;default:return void this.params.error$.next({id:`LogRequest#${i}`,category:t.ErrorCategory.EXTERNAL_API,message:`${o} error`,data:n})}}}));return a(e)}))}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}refreshAuthToken(){return n(this,void 0,void 0,(function*(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=Ra(this.params.refreshAuthToken(),(()=>{this.refreshAuthTokenPromise=void 0}))),this.refreshAuthTokenPromise}))}createLogParams(t){return{collector:'ok.mobile.apps.video',data:JSON.stringify({application:'@vkontakte/videoplayer-statistics:1.0.29',platform:'WEB',items:t.map((t=>Object.assign(Object.assign({},t),{time:0,type:1})))})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();const e=t.getExponentialDelay(this.consequentAuthErrors,Ba);return new Promise((r=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout((()=>{Ra(this._authorize().then(r).catch((e=>this.params.error$.next({id:'AuthorizeBackoff',category:t.ErrorCategory.NETWORK,message:'Otherwise unhandle errror in authrization',thrown:e}))),(()=>this.backoffTimeoutId=0))}),e))}))}_authorize(){return n(this,void 0,void 0,(function*(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);const e={session_data:{version:2,device_id:this.uuid,client_version:'1.0.29'.split('-')[0],client_type:'SDK_JS'}};return void 0!==this.authToken&&(e.session_data.auth_token=this.authToken,e.session_data.version=3),this.authorizePromise=Ra(this.params.apiTransport.sendRequest('auth.anonymLogin',e).then((e=>{var r;return e&&e.session_key||this.params.error$.next({id:'AuthorizeFailed',category:t.ErrorCategory.EXTERNAL_API,message:'No session key',data:e}),this.sessionKey=null!==(r=null==e?void 0:e.session_key)&&void 0!==r?r:void 0,this.sessionKey})).catch((e=>n(this,void 0,void 0,(function*(){this.sessionKey=void 0;const r=null==e?void 0:e.error_code;switch(r){case qa.AUTH_LOGIN:return this.authToken=yield this.refreshAuthToken(),this._authorizeWithBackoff()}r?this.params.error$.next({id:`Authorize#${r}`,category:t.ErrorCategory.EXTERNAL_API,message:'authorize error',data:e}):this.params.error$.next({id:'AuthorizeUnknown',category:t.ErrorCategory.NETWORK,message:'authorize error',thrown:e})})))),(()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(void 0!==this.sessionKey)})),this.authorizePromise}))}}function Ha(t){return t.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log('__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill'),!0):'function'==typeof t.Request&&!t.Request.prototype.hasOwnProperty('signal')||!t.AbortController}const Va=Ha({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),za=Va?function(t){'function'==typeof t&&(t={fetch:t});const{fetch:e,Request:r=e.Request,AbortController:o,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n=!1}=t;if(!Ha({fetch:e,Request:r,AbortController:o,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n}))return{fetch:e,Request:i};let i=r;(i&&!i.prototype.hasOwnProperty('signal')||n)&&(i=function(t,e){let o;e&&e.signal&&(o=e.signal,delete e.signal);const n=new r(t,e);return o&&Object.defineProperty(n,'signal',{writable:!1,enumerable:!1,configurable:!0,value:o}),n},i.prototype=r.prototype);const s=e;return{fetch:(t,e)=>{const r=i&&i.prototype.isPrototypeOf(t)?t.signal:e?e.signal:void 0;if(r){let o;try{o=new DOMException('Aborted','AbortError')}catch(t){o=new Error('Aborted'),o.name='AbortError'}if(r.aborted)return Promise.reject(o);const n=new Promise(((t,e)=>{r.addEventListener('abort',(()=>e(o)),{once:!0})}));return e&&e.signal&&delete e.signal,Promise.race([n,s(t,e)])}return s(t,e)},Request:i}}({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,Ka=Va?za.fetch:window.fetch;Va?za.Request:window.Request;class Wa{constructor(t){this.params=t,this.apiKey=t.apiKey,this.apiEnv=t.apiEnv,this.apiBaseUrl=t.apiBaseUrl,this.timeSynchronisation=t.timeSynchronisation,this.isApiBaseUrlFetched=!1}resolveApiBaseUrl(){var e;return n(this,void 0,void 0,(function*(){if(this.apiEnv!==exports.ApiEnv.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const t=atob('aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ='),r=yield Ka(t,{method:'GET',mode:'cors',cache:'no-cache'}),o=yield r.json(),n=null===(e=null==o?void 0:o.Answer[0])||void 0===e?void 0:e.data;if(!n)throw new Error('Wrong DNS response');return n}catch(e){return this.params.error$.next({id:'OneStat:ApiTransport:resolveApiBaseUrl',category:t.ErrorCategory.NETWORK,message:'Unhandled resolve api base url error',thrown:e}),Fa[exports.ApiEnv.VK_ALIAS]}finally{this.isApiBaseUrlFetched=!0}}))}sendBeacon(e,r,o){if(!window.Blob||!window.navigator.sendBeacon)return!1;const n=this._prepareQueryParams({method:e,queryParams:r,sessionKey:o}),i=new window.Blob([n.toString()],{type:'application/x-www-form-urlencoded'});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,i)}catch(o){this.params.error$.next({id:'OneStat:ApiTransport:sendBeacon',category:t.ErrorCategory.NETWORK,message:'Unhandled beacon error',thrown:o,data:{method:e,params:r}})}return!1}sendRequest(e,r,o){return n(this,void 0,void 0,(function*(){const n=t.now(),i=i=>{i instanceof TypeError&&['Failed to fetch','NetworkError when attempting to fetch resource.'].includes(i.message)?this.params.error$.next({id:'Network',category:t.ErrorCategory.NETWORK,message:'Request failed',thrown:i}):this.params.error$.next({id:'OneStat:ApiTransport:sendRequest',category:t.ErrorCategory.NETWORK,message:'Unhandled request error',thrown:i,data:{method:e,params:r,sessionKey:o,time:t.now()-n}})};return this.apiBaseUrl=yield this.resolveApiBaseUrl(),Ka(`${this.apiBaseUrl}/fb.do`,{method:'post',headers:{'Content-type':'application/x-www-form-urlencoded'},body:this._prepareQueryParams({method:e,queryParams:r,sessionKey:o})}).then((e=>{var r;const o=0===Number(e.headers.get('content-length')),s=new Date(null!==(r=e.headers.get('date'))&&void 0!==r?r:'').getTime(),a=t.now()-n;if(isFinite(s)&&this.timeSynchronisation.addServerTime(s,a),!o)return e.json().then((t=>Object.prototype.hasOwnProperty.call(t,'error_msg')?Promise.reject(t):t),i)}),i)}))}_prepareQueryParams(t){const e=new URLSearchParams({format:'JSON',method:t.method,application_key:this.apiKey});return void 0!==t.sessionKey&&e.append('session_key',t.sessionKey),Object.entries(t.queryParams).forEach((([t,r])=>e.append(t,'string'==typeof r?r:JSON.stringify(r)))),e}}class Ga{constructor(e){this.requestQueue=[],this.isPaused=!1,this.debouncedFlush=o.default((()=>{var e;try{this.flush()}catch(r){this.error$.next({id:'LoggerError',category:t.ErrorCategory.WTF,message:null!==(e=String(r))&&void 0!==e?e:'Unknown logger error',thrown:r})}}),3e3,{maxWait:15e3}),this.api=e.api,this.error$=e.error$,this.subscription=this.api.authorized$.subscribe((t=>{t&&this.debouncedFlush()}))}log(t){this.requestQueue.push(t),this.isPaused||this.debouncedFlush()}flush(t=!1){0!==this.requestQueue.length&&(this.api.authorized$.getValue()?(t?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[]):t||this.api.authorize(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe()}}class Ya{constructor(t){this.offset=void 0,this.offset=t}getOffset(){var t;return null!==(t=this.offset)&&void 0!==t?t:0}setOffset(t){this.offset=t}now(){var t;return Date.now()+(null!==(t=this.offset)&&void 0!==t?t:0)}date(t=new Date){var e;return t.setTime(t.getTime()+(null!==(e=this.offset)&&void 0!==e?e:0)),t}addServerTime(t,e){const r=t-Date.now()-e/2;if(Math.abs(r)<1e3)this.offset=0;else if(void 0===this.offset)this.offset=Math.round(r);else{const t=.2;this.offset=Math.round(t*r+(1-t)*this.offset)}}}const Ja=()=>Math.floor(Math.random()*Math.pow(2,32)).toString(36).padStart(8,'0'),Xa=t=>t&&{[e.HttpConnectionType.HTTP1]:exports.ConnectionType.HTTP1,[e.HttpConnectionType.HTTP2]:exports.ConnectionType.HTTP2,[e.HttpConnectionType.QUIC]:exports.ConnectionType.HTTP3}[t],Za=r=>{if(void 0!==r)switch(r){case e.VideoFormat.MPEG:return exports.ContentType.MP4;case e.VideoFormat.DASH:case e.VideoFormat.DASH_LIVE:return exports.ContentType.DASH;case e.VideoFormat.DASH_SEP:return exports.ContentType.DASH_SEP;case e.VideoFormat.DASH_ONDEMAND:return exports.ContentType.ONDEMAND_DASH;case e.VideoFormat.DASH_WEBM:case e.VideoFormat.DASH_LIVE_WEBM:return exports.ContentType.WEBM;case e.VideoFormat.HLS:case e.VideoFormat.HLS_LIVE:return exports.ContentType.HLS;case e.VideoFormat.HLS_ONDEMAND:return exports.ContentType.ONDEMAND_HLS;case e.VideoFormat.WEB_RTC_LIVE:return exports.ContentType.RTMP;default:return t.assertNever(r)}};exports.OneStat=class{constructor(e,r){var o;this.subscription=new t.Subscription,this.timeSynchronisation=new Ya,this.vsid=Ja(),this.fieldBlacklist=[],this.statContext=e,this.config=Object.assign(Object.assign({},null!==(o=r.config)&&void 0!==o?o:{}),{requestRetryCount:1});const n=new t.Subject;this.experimental={error$:n};const i=new Wa({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:Fa[r.apiEnv],apiEnv:r.apiEnv,error$:n,timeSynchronisation:this.timeSynchronisation});this.api=new Ua({apiTransport:i,refreshAuthToken:r.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:n}),this.logger=new Ga({api:this.api,error$:n}),this.subscription.add(t.fromEvent(window,'beforeunload').subscribe((()=>this.logger.flush(!0))))}updateContext(t){this.statContext=Object.assign(Object.assign({},this.statContext),t)}attachTo(r){let o;return(new t.Subscription).add(r.events.started$.subscribe((()=>{this.logStarted({position:r.info.position$.getValue()})}))).add(r.events.looped$.subscribe((()=>{this.resetViewSession(),this.logStarted({position:r.info.position$.getValue()})}))).add(r.events.seeked$.subscribe((()=>{this.logSeek()}))).add(r.events.willPause$.subscribe((()=>{this.logPause({position:r.info.position$.getValue()})}))).add(r.events.willResume$.subscribe((()=>{this.logPlay()}))).add(r.events.managedError$.subscribe((({id:t})=>{this.logError({errorType:t})}))).add(r.events.fatalError$.subscribe((({id:t})=>{this.logError({errorType:t})}))).add(r.events.inited$.subscribe((()=>{this.logInited()}))).add(r.events.canplay$.subscribe((t=>{this.logReady({time:t})}))).add(r.events.firstBytes$.subscribe((t=>{this.logFirstBytes({time:t})}))).add(r.events.firstFrame$.subscribe((t=>{this.logFirstFrame({time:t})}))).add(r.events.watchCoverageRecord$.subscribe((t=>{this.logWatchCoverageRecord(t)}))).add(r.events.watchCoverageLive$.subscribe((t=>{this.logWatchCoverageLive(t)}))).add(r.info.isStalled$.subscribe((e=>{e?o=t.now():(t.isNonNullable(o)&&this.logEmptyBuffer({duration:t.now()-o}),o=void 0)}))).add(r.events.ended$.subscribe((()=>{const e=r.info.throughputEstimation$.getValue();t.isNonNullable(e)&&this.logDownloadSpeed({speed:e/8})}))).add(r.info.hostname$.subscribe((t=>{this.updateContext({cdnHostname:t})}))).add(r.info.httpConnectionType$.subscribe((t=>{this.updateContext({connectionType:Xa(t)})}))).add(r.info.httpConnectionReused$.subscribe((t=>{this.updateContext({connectionReused:t})}))).add(r.info.currentQuality$.subscribe((t=>{var r;this.updateContext({quality:(r=t,r&&{[e.VideoQuality.INVARIANT]:exports.Quality.UNKNOWN,[e.VideoQuality.Q_144P]:exports.Quality.Q144P,[e.VideoQuality.Q_240P]:exports.Quality.Q240P,[e.VideoQuality.Q_360P]:exports.Quality.Q360P,[e.VideoQuality.Q_480P]:exports.Quality.Q480P,[e.VideoQuality.Q_720P]:exports.Quality.Q720P,[e.VideoQuality.Q_1080P]:exports.Quality.Q1080P,[e.VideoQuality.Q_1440P]:exports.Quality.Q1440P,[e.VideoQuality.Q_2160P]:exports.Quality.Q2160P,[e.VideoQuality.Q_4320P]:exports.Quality.Q4320P}[r])})}))).add(r.info.currentFormat$.subscribe((t=>{this.updateContext({contentType:Za(t)})}))).add(r.info.chromecastState$.subscribe((t=>{this.updateContext({destination:t===e.ChromecastState.CONNECTED?exports.ScreenDestination.CHROMECAST:exports.ScreenDestination.SCREEN})})))}authorize(t){return this.api.authorize(t)}pause(){this.logger.pause()}resume(){this.logger.resume()}destroy(){this.logger.flush(),this.subscription.unsubscribe(),this.api.destroy(),this.logger.destroy()}resetViewSession(){this.vsid=Ja()}setFieldBlacklist(t=[]){this.fieldBlacklist=t}logInited(){this.log({operation:'init'})}logReady(t){this.log({operation:'player_ready',param:String(t.time)})}logStarted(t){this.log({operation:'play',param:String(Math.round(t.position))})}logPlay(){this.log({operation:'play_toggle'})}logPause(t){this.log({operation:'pause',param:String(Math.round(t.position))})}logSeek(){this.log({operation:'seek'})}logFirstBytes(t){this.log({operation:'first_bytes',param:String(t.time)})}logFirstFrame(t){this.log({operation:'first_frame',param:String(t.time)})}logError(t){this.log({operation:'error',param:t.errorType})}logWatchCoverageRecord(t){this.log({operation:'watch_coverage_record',param:`${t.start}-${t.end}`}),this.logger.flush(!0)}logWatchCoverageLive(t){const e=t.start+this.timeSynchronisation.getOffset(),r=t.end+this.timeSynchronisation.getOffset();this.log({operation:'watch_coverage_live',param:`${e}-${r}`}),this.logger.flush(!0)}logEmptyBuffer(t){this.log({operation:'empty_buffer',param:String(t.duration)})}logDownloadSpeed(t){this.log({operation:'download_speed',param:String(t.speed)})}logAdSlotRequest(){this.log({operation:'adv',param:'slot_request'})}logAdStarted(t){this.log({operation:'adv',param:t})}logAdPaused(){this.log({operation:'adv',param:'pause'})}logAdResumed(){this.log({operation:'adv',param:'resume'})}logAdEnded(){this.log({operation:'adv',param:'ended'})}logAdSkipped(){this.log({operation:'adv',param:'skip'})}logAdClicked(){this.log({operation:'adv',param:'click'})}log(t){const e=this.createLogItem(t);this.logger.log(e)}createLogItem({operation:t,param:e}){const r=this.timeSynchronisation.now(),o={vsid:this.vsid,vid:this.statContext.movieId,quality:this.statContext.quality,dst:this.statContext.destination,ct:this.statContext.contentType,aid:this.statContext.albumId,place:this.statContext.place,cdn_host:this.statContext.cdnHostname,connection_type:this.statContext.connectionType,connection_reused:!0===this.statContext.connectionReused?$a.YES:!1===this.statContext.connectionReused?$a.NO:void 0,stat_type:!0===this.statContext.autoplay?Qa.AUTO:!1===this.statContext.autoplay?Qa.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode};void 0!==e&&(o.param=e);for(const t of this.fieldBlacklist)delete o[t];return{operation:t,timestamp:r,custom:o}}};
|
|
6
|
+
"use strict";var h=require("@vkontakte/videoplayer-shared/es2015.cjs.js"),d=require("@vkontakte/videoplayer-core/es2015.cjs.js"),ho=require("lodash/debounce.js");function w(e,r,t,n){function o(a){return a instanceof t?a:new t(function(i){i(a)})}return new(t||(t=Promise))(function(a,i){function v(c){try{s(n.next(c))}catch(l){i(l)}}function u(c){try{s(n.throw(c))}catch(l){i(l)}}function s(c){c.done?a(c.value):o(c.value).then(v,u)}s((n=n.apply(e,r||[])).next())})}var Hr=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},ue=function(e){return e&&e.Math==Math&&e},g=ue(typeof globalThis=="object"&&globalThis)||ue(typeof window=="object"&&window)||ue(typeof self=="object"&&self)||ue(typeof Hr=="object"&&Hr)||function(){return this}()||Function("return this")(),T=function(e){try{return!!e()}catch(r){return!0}},po=T,Ae=!po(function(){var e=function(){}.bind();return typeof e!="function"||e.hasOwnProperty("prototype")}),yo=Ae,Xt=Function.prototype,qr=Xt.apply,Kr=Xt.call,Zt=typeof Reflect=="object"&&Reflect.apply||(yo?Kr.bind(qr):function(){return Kr.apply(qr,arguments)}),en=Ae,rn=Function.prototype,dr=rn.call,go=en&&rn.bind.bind(dr,dr),O=en?go:function(e){return function(){return dr.apply(e,arguments)}},tn=O,bo=tn({}.toString),$o=tn("".slice),Ne=function(e){return $o(bo(e),8,-1)},mo=Ne,Eo=O,nn=function(e){if(mo(e)==="Function")return Eo(e)},hr=typeof document=="object"&&document.all,So=typeof hr=="undefined"&&hr!==void 0,on={all:hr,IS_HTMLDDA:So},an=on,To=an.all,y=an.IS_HTMLDDA?function(e){return typeof e=="function"||e===To}:function(e){return typeof e=="function"},Ir={},Oo=T,J=!Oo(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),_o=Ae,le=Function.prototype.call,_=_o?le.bind(le):function(){return le.apply(le,arguments)},sn={},cn={}.propertyIsEnumerable,un=Object.getOwnPropertyDescriptor,Po=un&&!cn.call({1:2},1);sn.f=Po?function(r){var t=un(this,r);return!!t&&t.enumerable}:cn;var ln=function(e,r){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:r}},Io=O,wo=T,Ro=Ne,xe=Object,Co=Io("".split),Ao=wo(function(){return!xe("z").propertyIsEnumerable(0)})?function(e){return Ro(e)=="String"?Co(e,""):xe(e)}:xe,De=function(e){return e==null},No=De,Do=TypeError,vn=function(e){if(No(e))throw Do("Can't call method on "+e);return e},jo=Ao,Lo=vn,Mo=function(e){return jo(Lo(e))},Qr=y,fn=on,Uo=fn.all,M=fn.IS_HTMLDDA?function(e){return typeof e=="object"?e!==null:Qr(e)||e===Uo}:function(e){return typeof e=="object"?e!==null:Qr(e)},dn={},Ve=dn,He=g,ko=y,Wr=function(e){return ko(e)?e:void 0},C=function(e,r){return arguments.length<2?Wr(Ve[e])||Wr(He[e]):Ve[e]&&Ve[e][r]||He[e]&&He[e][r]},Bo=O,wr=Bo({}.isPrototypeOf),je=typeof navigator!="undefined"&&String(navigator.userAgent)||"",hn=g,qe=je,Gr=hn.process,zr=hn.Deno,Yr=Gr&&Gr.versions||zr&&zr.version,Jr=Yr&&Yr.v8,E,Se;Jr&&(E=Jr.split("."),Se=E[0]>0&&E[0]<4?1:+(E[0]+E[1]));!Se&&qe&&(E=qe.match(/Edge\/(\d+)/),(!E||E[1]>=74)&&(E=qe.match(/Chrome\/(\d+)/),E&&(Se=+E[1])));var pn=Se,Xr=pn,Fo=T,yn=!!Object.getOwnPropertySymbols&&!Fo(function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&Xr&&Xr<41}),xo=yn,gn=xo&&!Symbol.sham&&typeof Symbol.iterator=="symbol",Vo=C,Ho=y,qo=wr,Ko=gn,Qo=Object,bn=Ko?function(e){return typeof e=="symbol"}:function(e){var r=Vo("Symbol");return Ho(r)&&qo(r.prototype,Qo(e))},Wo=String,Le=function(e){try{return Wo(e)}catch(r){return"Object"}},Go=y,zo=Le,Yo=TypeError,U=function(e){if(Go(e))return e;throw Yo(zo(e)+" is not a function")},Jo=U,Xo=De,Rr=function(e,r){var t=e[r];return Xo(t)?void 0:Jo(t)},Ke=_,Qe=y,We=M,Zo=TypeError,ea=function(e,r){var t,n;if(r==="string"&&Qe(t=e.toString)&&!We(n=Ke(t,e))||Qe(t=e.valueOf)&&!We(n=Ke(t,e))||r!=="string"&&Qe(t=e.toString)&&!We(n=Ke(t,e)))return n;throw Zo("Can't convert object to primitive value")},Te={},ra={get exports(){return Te},set exports(e){Te=e}},ie=!0,Zr=g,ta=Object.defineProperty,na=function(e,r){try{ta(Zr,e,{value:r,configurable:!0,writable:!0})}catch(t){Zr[e]=r}return r},oa=g,aa=na,et="__core-js_shared__",ia=oa[et]||aa(et,{}),Cr=ia,rt=Cr;(ra.exports=function(e,r){return rt[e]||(rt[e]=r!==void 0?r:{})})("versions",[]).push({version:"3.27.2",mode:"pure",copyright:"\xA9 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.27.2/LICENSE",source:"https://github.com/zloirock/core-js"});var sa=vn,ca=Object,ua=function(e){return ca(sa(e))},la=O,va=ua,fa=la({}.hasOwnProperty),X=Object.hasOwn||function(r,t){return fa(va(r),t)},da=O,ha=0,pa=Math.random(),ya=da(1 .toString),$n=function(e){return"Symbol("+(e===void 0?"":e)+")_"+ya(++ha+pa,36)},ga=g,ba=Te,tt=X,$a=$n,ma=yn,Ea=gn,Q=ga.Symbol,Ge=ba("wks"),Sa=Ea?Q.for||Q:Q&&Q.withoutSetter||$a,P=function(e){return tt(Ge,e)||(Ge[e]=ma&&tt(Q,e)?Q[e]:Sa("Symbol."+e)),Ge[e]},Ta=_,nt=M,ot=bn,Oa=Rr,_a=ea,Pa=P,Ia=TypeError,wa=Pa("toPrimitive"),Ra=function(e,r){if(!nt(e)||ot(e))return e;var t=Oa(e,wa),n;if(t){if(r===void 0&&(r="default"),n=Ta(t,e,r),!nt(n)||ot(n))return n;throw Ia("Can't convert object to primitive value")}return r===void 0&&(r="number"),_a(e,r)},Ca=Ra,Aa=bn,mn=function(e){var r=Ca(e,"string");return Aa(r)?r:r+""},Na=g,at=M,pr=Na.document,Da=at(pr)&&at(pr.createElement),En=function(e){return Da?pr.createElement(e):{}},ja=J,La=T,Ma=En,Sn=!ja&&!La(function(){return Object.defineProperty(Ma("div"),"a",{get:function(){return 7}}).a!=7}),Ua=J,ka=_,Ba=sn,Fa=ln,xa=Mo,Va=mn,Ha=X,qa=Sn,it=Object.getOwnPropertyDescriptor;Ir.f=Ua?it:function(r,t){if(r=xa(r),t=Va(t),qa)try{return it(r,t)}catch(n){}if(Ha(r,t))return Fa(!ka(Ba.f,r,t),r[t])};var Ka=T,Qa=y,Wa=/#|\.prototype\./,se=function(e,r){var t=za[Ga(e)];return t==Ja?!0:t==Ya?!1:Qa(r)?Ka(r):!!r},Ga=se.normalize=function(e){return String(e).replace(Wa,".").toLowerCase()},za=se.data={},Ya=se.NATIVE="N",Ja=se.POLYFILL="P",Tn=se,st=nn,Xa=U,Za=Ae,ei=st(st.bind),Me=function(e,r){return Xa(e),r===void 0?e:Za?ei(e,r):function(){return e.apply(r,arguments)}},Ue={},ri=J,ti=T,ni=ri&&ti(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),oi=M,ai=String,ii=TypeError,k=function(e){if(oi(e))return e;throw ii(ai(e)+" is not an object")},si=J,ci=Sn,ui=ni,ve=k,ct=mn,li=TypeError,ze=Object.defineProperty,vi=Object.getOwnPropertyDescriptor,Ye="enumerable",Je="configurable",Xe="writable";Ue.f=si?ui?function(r,t,n){if(ve(r),t=ct(t),ve(n),typeof r=="function"&&t==="prototype"&&"value"in n&&Xe in n&&!n[Xe]){var o=vi(r,t);o&&o[Xe]&&(r[t]=n.value,n={configurable:Je in n?n[Je]:o[Je],enumerable:Ye in n?n[Ye]:o[Ye],writable:!1})}return ze(r,t,n)}:ze:function(r,t,n){if(ve(r),t=ct(t),ve(n),ci)try{return ze(r,t,n)}catch(o){}if("get"in n||"set"in n)throw li("Accessors not supported");return"value"in n&&(r[t]=n.value),r};var fi=J,di=Ue,hi=ln,ke=fi?function(e,r,t){return di.f(e,r,hi(1,t))}:function(e,r,t){return e[r]=t,e},fe=g,pi=Zt,yi=nn,gi=y,bi=Ir.f,$i=Tn,x=dn,mi=Me,V=ke,ut=X,Ei=function(e){var r=function(t,n,o){if(this instanceof r){switch(arguments.length){case 0:return new e;case 1:return new e(t);case 2:return new e(t,n)}return new e(t,n,o)}return pi(e,this,arguments)};return r.prototype=e.prototype,r},B=function(e,r){var t=e.target,n=e.global,o=e.stat,a=e.proto,i=n?fe:o?fe[t]:(fe[t]||{}).prototype,v=n?x:x[t]||V(x,t,{})[t],u=v.prototype,s,c,l,p,f,m,A,I,F;for(p in r)s=$i(n?p:t+(o?".":"#")+p,e.forced),c=!s&&i&&ut(i,p),m=v[p],c&&(e.dontCallGetSet?(F=bi(i,p),A=F&&F.value):A=i[p]),f=c&&A?A:r[p],!(c&&typeof m==typeof f)&&(e.bind&&c?I=mi(f,fe):e.wrap&&c?I=Ei(f):a&&gi(f)?I=yi(f):I=f,(e.sham||f&&f.sham||m&&m.sham)&&V(I,"sham",!0),V(v,p,I),a&&(l=t+"Prototype",ut(x,l)||V(x,l,{}),V(x[l],p,f),e.real&&u&&(s||!u[p])&&V(u,p,f)))},Si=Ne,Be=typeof process!="undefined"&&Si(process)=="process",Ti=ke,Ar=function(e,r,t,n){return n&&n.enumerable?e[r]=t:Ti(e,r,t),e},Oi=y,_i=String,Pi=TypeError,Ii=function(e){if(typeof e=="object"||Oi(e))return e;throw Pi("Can't set "+_i(e)+" as a prototype")},wi=O,Ri=k,Ci=Ii,Ai=Object.setPrototypeOf||("__proto__"in{}?function(){var e=!1,r={},t;try{t=wi(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set),t(r,[]),e=r instanceof Array}catch(n){}return function(o,a){return Ri(o),Ci(a),e?t(o,a):o.__proto__=a,o}}():void 0),Ni=P,Di=Ni("toStringTag"),On={};On[Di]="z";var Nr=String(On)==="[object z]",ji=Nr,Li=y,$e=Ne,Mi=P,Ui=Mi("toStringTag"),ki=Object,Bi=$e(function(){return arguments}())=="Arguments",Fi=function(e,r){try{return e[r]}catch(t){}},Dr=ji?$e:function(e){var r,t,n;return e===void 0?"Undefined":e===null?"Null":typeof(t=Fi(r=ki(e),Ui))=="string"?t:Bi?$e(r):(n=$e(r))=="Object"&&Li(r.callee)?"Arguments":n},xi=Nr,Vi=Dr,Hi=xi?{}.toString:function(){return"[object "+Vi(this)+"]"},qi=Nr,Ki=Ue.f,Qi=ke,Wi=X,Gi=Hi,zi=P,lt=zi("toStringTag"),Yi=function(e,r,t,n){if(e){var o=t?e:e.prototype;Wi(o,lt)||Ki(o,lt,{configurable:!0,value:r}),n&&!qi&&Qi(o,"toString",Gi)}},Ji=C,Xi=Ue,Zi=P,es=J,vt=Zi("species"),rs=function(e){var r=Ji(e),t=Xi.f;es&&r&&!r[vt]&&t(r,vt,{configurable:!0,get:function(){return this}})},ts=wr,ns=TypeError,os=function(e,r){if(ts(r,e))return e;throw ns("Incorrect invocation")},as=O,is=y,yr=Cr,ss=as(Function.toString);is(yr.inspectSource)||(yr.inspectSource=function(e){return ss(e)});var _n=yr.inspectSource,cs=O,us=T,Pn=y,ls=Dr,vs=C,fs=_n,In=function(){},ds=[],wn=vs("Reflect","construct"),jr=/^\s*(?:class|function)\b/,hs=cs(jr.exec),ps=!jr.exec(In),re=function(r){if(!Pn(r))return!1;try{return wn(In,ds,r),!0}catch(t){return!1}},Rn=function(r){if(!Pn(r))return!1;switch(ls(r)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return ps||!!hs(jr,fs(r))}catch(t){return!0}};Rn.sham=!0;var ys=!wn||us(function(){var e;return re(re.call)||!re(Object)||!re(function(){e=!0})||e})?Rn:re,gs=ys,bs=Le,$s=TypeError,ms=function(e){if(gs(e))return e;throw $s(bs(e)+" is not a constructor")},ft=k,Es=ms,Ss=De,Ts=P,Os=Ts("species"),Cn=function(e,r){var t=ft(e).constructor,n;return t===void 0||Ss(n=ft(t)[Os])?r:Es(n)},_s=C,Ps=_s("document","documentElement"),Is=O,ws=Is([].slice),Rs=TypeError,Cs=function(e,r){if(e<r)throw Rs("Not enough arguments");return e},As=je,An=/(?:ipad|iphone|ipod).*applewebkit/i.test(As),b=g,Ns=Zt,Ds=Me,dt=y,js=X,Nn=T,ht=Ps,Ls=ws,pt=En,Ms=Cs,Us=An,ks=Be,gr=b.setImmediate,br=b.clearImmediate,Bs=b.process,Ze=b.Dispatch,Fs=b.Function,yt=b.MessageChannel,xs=b.String,er=0,te={},gt="onreadystatechange",oe,N,rr,tr;Nn(function(){oe=b.location});var Lr=function(e){if(js(te,e)){var r=te[e];delete te[e],r()}},nr=function(e){return function(){Lr(e)}},bt=function(e){Lr(e.data)},$t=function(e){b.postMessage(xs(e),oe.protocol+"//"+oe.host)};(!gr||!br)&&(gr=function(r){Ms(arguments.length,1);var t=dt(r)?r:Fs(r),n=Ls(arguments,1);return te[++er]=function(){Ns(t,void 0,n)},N(er),er},br=function(r){delete te[r]},ks?N=function(e){Bs.nextTick(nr(e))}:Ze&&Ze.now?N=function(e){Ze.now(nr(e))}:yt&&!Us?(rr=new yt,tr=rr.port2,rr.port1.onmessage=bt,N=Ds(tr.postMessage,tr)):b.addEventListener&&dt(b.postMessage)&&!b.importScripts&&oe&&oe.protocol!=="file:"&&!Nn($t)?(N=$t,b.addEventListener("message",bt,!1)):gt in pt("script")?N=function(e){ht.appendChild(pt("script"))[gt]=function(){ht.removeChild(this),Lr(e)}}:N=function(e){setTimeout(nr(e),0)});var Dn={set:gr,clear:br},jn=function(){this.head=null,this.tail=null};jn.prototype={add:function(e){var r={item:e,next:null},t=this.tail;t?t.next=r:this.head=r,this.tail=r},get:function(){var e=this.head;if(e){var r=this.head=e.next;return r===null&&(this.tail=null),e.item}}};var Ln=jn,Vs=je,Hs=/ipad|iphone|ipod/i.test(Vs)&&typeof Pebble!="undefined",qs=je,Ks=/web0s(?!.*chrome)/i.test(qs),L=g,mt=Me,Qs=Ir.f,or=Dn.set,Ws=Ln,Gs=An,zs=Hs,Ys=Ks,ar=Be,Et=L.MutationObserver||L.WebKitMutationObserver,St=L.document,Tt=L.process,de=L.Promise,Ot=Qs(L,"queueMicrotask"),$r=Ot&&Ot.value,H,ir,sr,he,_t;if(!$r){var pe=new Ws,ye=function(){var e,r;for(ar&&(e=Tt.domain)&&e.exit();r=pe.get();)try{r()}catch(t){throw pe.head&&H(),t}e&&e.enter()};!Gs&&!ar&&!Ys&&Et&&St?(ir=!0,sr=St.createTextNode(""),new Et(ye).observe(sr,{characterData:!0}),H=function(){sr.data=ir=!ir}):!zs&&de&&de.resolve?(he=de.resolve(void 0),he.constructor=de,_t=mt(he.then,he),H=function(){_t(ye)}):ar?H=function(){Tt.nextTick(ye)}:(or=mt(or,L),H=function(){or(ye)}),$r=function(e){pe.head||H(),pe.add(e)}}var Js=$r,Xs=function(e,r){try{arguments.length==1?console.error(e):console.error(e,r)}catch(t){}},Mr=function(e){try{return{error:!1,value:e()}}catch(r){return{error:!0,value:r}}},Zs=g,ec=y,Pt=Zs.WeakMap,rc=ec(Pt)&&/native code/.test(String(Pt)),tc=Te,nc=$n,It=tc("keys"),oc=function(e){return It[e]||(It[e]=nc(e))},ac={},ic=rc,Mn=g,sc=M,cc=ke,cr=X,ur=Cr,uc=oc,lc=ac,wt="Object already initialized",mr=Mn.TypeError,vc=Mn.WeakMap,Oe,ae,_e,fc=function(e){return _e(e)?ae(e):Oe(e,{})},dc=function(e){return function(r){var t;if(!sc(r)||(t=ae(r)).type!==e)throw mr("Incompatible receiver, "+e+" required");return t}};if(ic||ur.state){var S=ur.state||(ur.state=new vc);S.get=S.get,S.has=S.has,S.set=S.set,Oe=function(e,r){if(S.has(e))throw mr(wt);return r.facade=e,S.set(e,r),r},ae=function(e){return S.get(e)||{}},_e=function(e){return S.has(e)}}else{var q=uc("state");lc[q]=!0,Oe=function(e,r){if(cr(e,q))throw mr(wt);return r.facade=e,cc(e,q,r),r},ae=function(e){return cr(e,q)?e[q]:{}},_e=function(e){return cr(e,q)}}var hc={set:Oe,get:ae,has:_e,enforce:fc,getterFor:dc},pc=g,Z=pc.Promise,Un=typeof Deno=="object"&&Deno&&typeof Deno.version=="object",yc=Un,gc=Be,bc=!yc&&!gc&&typeof window=="object"&&typeof document=="object",$c=g,ne=Z,mc=y,Ec=Tn,Sc=_n,Tc=P,Oc=bc,_c=Un,Pc=ie,lr=pn,Rt=ne&&ne.prototype,Ic=Tc("species"),Er=!1,kn=mc($c.PromiseRejectionEvent),wc=Ec("Promise",function(){var e=Sc(ne),r=e!==String(ne);if(!r&&lr===66||Pc&&!(Rt.catch&&Rt.finally))return!0;if(!lr||lr<51||!/native code/.test(e)){var t=new ne(function(a){a(1)}),n=function(a){a(function(){},function(){})},o=t.constructor={};if(o[Ic]=n,Er=t.then(function(){})instanceof n,!Er)return!0}return!r&&(Oc||_c)&&!kn}),ce={CONSTRUCTOR:wc,REJECTION_EVENT:kn,SUBCLASSING:Er},ee={},Ct=U,Rc=TypeError,Cc=function(e){var r,t;this.promise=new e(function(n,o){if(r!==void 0||t!==void 0)throw Rc("Bad Promise constructor");r=n,t=o}),this.resolve=Ct(r),this.reject=Ct(t)};ee.f=function(e){return new Cc(e)};var Ac=B,Nc=ie,Pe=Be,R=g,z=_,At=Ar,Nt=Ai,Dc=Yi,jc=rs,Lc=U,me=y,Mc=M,Uc=os,kc=Cn,Bn=Dn.set,Ur=Js,Bc=Xs,Fc=Mr,xc=Ln,Fn=hc,Ie=Z,kr=ce,xn=ee,Fe="Promise",Vn=kr.CONSTRUCTOR,Vc=kr.REJECTION_EVENT,Hc=kr.SUBCLASSING,vr=Fn.getterFor(Fe),qc=Fn.set,K=Ie&&Ie.prototype,D=Ie,ge=K,Hn=R.TypeError,Sr=R.document,Br=R.process,Tr=xn.f,Kc=Tr,Qc=!!(Sr&&Sr.createEvent&&R.dispatchEvent),qn="unhandledrejection",Wc="rejectionhandled",Dt=0,Kn=1,Gc=2,Fr=1,Qn=2,be,jt,zc,Lt,Wn=function(e){var r;return Mc(e)&&me(r=e.then)?r:!1},Gn=function(e,r){var t=r.value,n=r.state==Kn,o=n?e.ok:e.fail,a=e.resolve,i=e.reject,v=e.domain,u,s,c;try{o?(n||(r.rejection===Qn&&Jc(r),r.rejection=Fr),o===!0?u=t:(v&&v.enter(),u=o(t),v&&(v.exit(),c=!0)),u===e.promise?i(Hn("Promise-chain cycle")):(s=Wn(u))?z(s,u,a,i):a(u)):i(t)}catch(l){v&&!c&&v.exit(),i(l)}},zn=function(e,r){e.notified||(e.notified=!0,Ur(function(){for(var t=e.reactions,n;n=t.get();)Gn(n,e);e.notified=!1,r&&!e.rejection&&Yc(e)}))},Yn=function(e,r,t){var n,o;Qc?(n=Sr.createEvent("Event"),n.promise=r,n.reason=t,n.initEvent(e,!1,!0),R.dispatchEvent(n)):n={promise:r,reason:t},!Vc&&(o=R["on"+e])?o(n):e===qn&&Bc("Unhandled promise rejection",t)},Yc=function(e){z(Bn,R,function(){var r=e.facade,t=e.value,n=Mt(e),o;if(n&&(o=Fc(function(){Pe?Br.emit("unhandledRejection",t,r):Yn(qn,r,t)}),e.rejection=Pe||Mt(e)?Qn:Fr,o.error))throw o.value})},Mt=function(e){return e.rejection!==Fr&&!e.parent},Jc=function(e){z(Bn,R,function(){var r=e.facade;Pe?Br.emit("rejectionHandled",r):Yn(Wc,r,e.value)})},W=function(e,r,t){return function(n){e(r,n,t)}},G=function(e,r,t){e.done||(e.done=!0,t&&(e=t),e.value=r,e.state=Gc,zn(e,!0))},Or=function(e,r,t){if(!e.done){e.done=!0,t&&(e=t);try{if(e.facade===r)throw Hn("Promise can't be resolved itself");var n=Wn(r);n?Ur(function(){var o={done:!1};try{z(n,r,W(Or,o,e),W(G,o,e))}catch(a){G(o,a,e)}}):(e.value=r,e.state=Kn,zn(e,!1))}catch(o){G({done:!1},o,e)}}};if(Vn&&(D=function(r){Uc(this,ge),Lc(r),z(be,this);var t=vr(this);try{r(W(Or,t),W(G,t))}catch(n){G(t,n)}},ge=D.prototype,be=function(r){qc(this,{type:Fe,done:!1,notified:!1,parent:!1,reactions:new xc,rejection:!1,state:Dt,value:void 0})},be.prototype=At(ge,"then",function(r,t){var n=vr(this),o=Tr(kc(this,D));return n.parent=!0,o.ok=me(r)?r:!0,o.fail=me(t)&&t,o.domain=Pe?Br.domain:void 0,n.state==Dt?n.reactions.add(o):Ur(function(){Gn(o,n)}),o.promise}),jt=function(){var e=new be,r=vr(e);this.promise=e,this.resolve=W(Or,r),this.reject=W(G,r)},xn.f=Tr=function(e){return e===D||e===zc?new jt(e):Kc(e)},!Nc&&me(Ie)&&K!==Object.prototype)){Lt=K.then,Hc||At(K,"then",function(r,t){var n=this;return new D(function(o,a){z(Lt,n,o,a)}).then(r,t)},{unsafe:!0});try{delete K.constructor}catch(e){}Nt&&Nt(K,ge)}Ac({global:!0,constructor:!0,wrap:!0,forced:Vn},{Promise:D});Dc(D,Fe,!1,!0);jc(Fe);var Jn={},Xc=P,Zc=Jn,eu=Xc("iterator"),ru=Array.prototype,tu=function(e){return e!==void 0&&(Zc.Array===e||ru[eu]===e)},nu=Math.ceil,ou=Math.floor,au=Math.trunc||function(r){var t=+r;return(t>0?ou:nu)(t)},iu=au,su=function(e){var r=+e;return r!==r||r===0?0:iu(r)},cu=su,uu=Math.min,lu=function(e){return e>0?uu(cu(e),9007199254740991):0},vu=lu,fu=function(e){return vu(e.length)},du=Dr,Ut=Rr,hu=De,pu=Jn,yu=P,gu=yu("iterator"),Xn=function(e){if(!hu(e))return Ut(e,gu)||Ut(e,"@@iterator")||pu[du(e)]},bu=_,$u=U,mu=k,Eu=Le,Su=Xn,Tu=TypeError,Ou=function(e,r){var t=arguments.length<2?Su(e):r;if($u(t))return mu(bu(t,e));throw Tu(Eu(e)+" is not iterable")},_u=_,kt=k,Pu=Rr,Iu=function(e,r,t){var n,o;kt(e);try{if(n=Pu(e,"return"),!n){if(r==="throw")throw t;return t}n=_u(n,e)}catch(a){o=!0,n=a}if(r==="throw")throw t;if(o)throw n;return kt(n),t},wu=Me,Ru=_,Cu=k,Au=Le,Nu=tu,Du=fu,Bt=wr,ju=Ou,Lu=Xn,Ft=Iu,Mu=TypeError,Ee=function(e,r){this.stopped=e,this.result=r},xt=Ee.prototype,Zn=function(e,r,t){var n=t&&t.that,o=!!(t&&t.AS_ENTRIES),a=!!(t&&t.IS_RECORD),i=!!(t&&t.IS_ITERATOR),v=!!(t&&t.INTERRUPTED),u=wu(r,n),s,c,l,p,f,m,A,I=function($){return s&&Ft(s,"normal",$),new Ee(!0,$)},F=function($){return o?(Cu($),v?u($[0],$[1],I):u($[0],$[1])):v?u($,I):u($)};if(a)s=e.iterator;else if(i)s=e;else{if(c=Lu(e),!c)throw Mu(Au(e)+" is not iterable");if(Nu(c)){for(l=0,p=Du(e);p>l;l++)if(f=F(e[l]),f&&Bt(xt,f))return f;return new Ee(!1)}s=ju(e,c)}for(m=a?e.next:s.next;!(A=Ru(m,s)).done;){try{f=F(A.value)}catch($){Ft(s,"throw",$)}if(typeof f=="object"&&f&&Bt(xt,f))return f}return new Ee(!1)},Uu=P,eo=Uu("iterator"),ro=!1;try{var ku=0,Vt={next:function(){return{done:!!ku++}},return:function(){ro=!0}};Vt[eo]=function(){return this},Array.from(Vt,function(){throw 2})}catch(e){}var Bu=function(e,r){if(!r&&!ro)return!1;var t=!1;try{var n={};n[eo]=function(){return{next:function(){return{done:t=!0}}}},e(n)}catch(o){}return t},Fu=Z,xu=Bu,Vu=ce.CONSTRUCTOR,to=Vu||!xu(function(e){Fu.all(e).then(void 0,function(){})}),Hu=B,qu=_,Ku=U,Qu=ee,Wu=Mr,Gu=Zn,zu=to;Hu({target:"Promise",stat:!0,forced:zu},{all:function(r){var t=this,n=Qu.f(t),o=n.resolve,a=n.reject,i=Wu(function(){var v=Ku(t.resolve),u=[],s=0,c=1;Gu(r,function(l){var p=s++,f=!1;c++,qu(v,t,l).then(function(m){f||(f=!0,u[p]=m,--c||o(u))},a)}),--c||o(u)});return i.error&&a(i.value),n.promise}});var Yu=B,Ju=ie,Xu=ce.CONSTRUCTOR,_r=Z,Zu=C,el=y,rl=Ar,Ht=_r&&_r.prototype;Yu({target:"Promise",proto:!0,forced:Xu,real:!0},{catch:function(e){return this.then(void 0,e)}});if(!Ju&&el(_r)){var qt=Zu("Promise").prototype.catch;Ht.catch!==qt&&rl(Ht,"catch",qt,{unsafe:!0})}var tl=B,nl=_,ol=U,al=ee,il=Mr,sl=Zn,cl=to;tl({target:"Promise",stat:!0,forced:cl},{race:function(r){var t=this,n=al.f(t),o=n.reject,a=il(function(){var i=ol(t.resolve);sl(r,function(v){nl(i,t,v).then(n.resolve,o)})});return a.error&&o(a.value),n.promise}});var ul=B,ll=_,vl=ee,fl=ce.CONSTRUCTOR;ul({target:"Promise",stat:!0,forced:fl},{reject:function(r){var t=vl.f(this);return ll(t.reject,void 0,r),t.promise}});var dl=k,hl=M,pl=ee,no=function(e,r){if(dl(e),hl(r)&&r.constructor===e)return r;var t=pl.f(e),n=t.resolve;return n(r),t.promise},yl=B,gl=C,oo=ie,bl=Z,ao=ce.CONSTRUCTOR,$l=no,ml=gl("Promise"),El=oo&&!ao;yl({target:"Promise",stat:!0,forced:oo||ao},{resolve:function(r){return $l(El&&this===ml?bl:this,r)}});var Sl=B,Tl=ie,we=Z,Ol=T,io=C,so=y,_l=Cn,Kt=no,Pl=Ar,Pr=we&&we.prototype,Il=!!we&&Ol(function(){Pr.finally.call({then:function(){}},function(){})});Sl({target:"Promise",proto:!0,real:!0,forced:Il},{finally:function(e){var r=_l(this,io("Promise")),t=so(e);return this.then(t?function(n){return Kt(r,e()).then(function(){return n})}:e,t?function(n){return Kt(r,e()).then(function(){throw n})}:e)}});if(!Tl&&so(we)){var Qt=io("Promise").prototype.finally;Pr.finally!==Qt&&Pl(Pr,"finally",Qt,{unsafe:!0})}var wl=C,Rl=wl,Cl=Rl,Al=Cl("Promise","finally"),Nl=Al,Dl=Nl,jl=Dl,Ll=jl,fr=Ll;const xr="_one-stat_",Y=(()=>{try{const e=Date.now().toString(),r=window.localStorage;r.setItem(e,e);const t=r.getItem(e)===e;return r.removeItem(e),t?r:null}catch(e){return null}})();function Ml(e){const r=Y?Y.getItem(xr+e):null;if(r===null)return null;try{return JSON.parse(r)}catch(t){return null}}function Ul(e,r){try{Y&&Y.setItem(xr+e,JSON.stringify(r))}catch(t){}}function kl(e){Y&&Y.removeItem(xr+e)}var Wt={get(e){return Ml(e)||null},set(e,r){Ul(e,r)},remove(e){kl(e)}};function Bl(){const e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),r=new Array(36);let t=0,n,o;for(o=0;o<36;o++)o===8||o===13||o===18||o===23?r[o]="-":o===14?r[o]="4":(t<=2&&(t=33554432+Math.random()*16777216|0),n=t&15,t=t>>4,r[o]=e[o===19?n&3|8:n]);return r.join("")}exports.ApiEnv=void 0;(function(e){e.PROD="prod",e.VK_ALIAS="vk_alias",e.VIDEOTEST="videotest",e.TEST="test",e.AUTO="auto"})(exports.ApiEnv||(exports.ApiEnv={}));exports.Quality=void 0;(function(e){e.Q144P="144",e.Q240P="240",e.Q360P="360",e.Q480P="480",e.Q720P="720",e.Q1080P="1080",e.Q1440P="1440",e.Q2160P="2160",e.Q4320P="4320",e.UNKNOWN="unknown"})(exports.Quality||(exports.Quality={}));exports.ScreenDestination=void 0;(function(e){e.CHROMECAST="chromecast",e.APPLE_TV="appletv",e.PIP="pip",e.HEADPHONES="externalHeadphones",e.SCREEN=""})(exports.ScreenDestination||(exports.ScreenDestination={}));exports.ContentType=void 0;(function(e){e.MP4="mp4",e.DASH="dash",e.DASH_SEP="dash_sep",e.ONDEMAND_DASH="ondemand_dash",e.HLS="hls",e.ONDEMAND_HLS="ondemand_hls",e.WEBM="webm",e.RTMP="rtmp",e.UNKNOWN="unknown"})(exports.ContentType||(exports.ContentType={}));var Re;(function(e){e.AUTO="auto",e.MANUAL=""})(Re||(Re={}));exports.ConnectionType=void 0;(function(e){e.HTTP1="http1",e.HTTP2="http2",e.HTTP3="http3"})(exports.ConnectionType||(exports.ConnectionType={}));var Ce;(function(e){e[e.YES=1]="YES",e[e.NO=0]="NO"})(Ce||(Ce={}));const Gt="1.0.31",Fl="@vkontakte/videoplayer-statistics",xl="CIOPGQJGDIHBABABA",co={[exports.ApiEnv.PROD]:"https://api.ok.ru",[exports.ApiEnv.VK_ALIAS]:"https://api.mycdn.me",[exports.ApiEnv.VIDEOTEST]:"https://videotestapi.ok.ru/api",[exports.ApiEnv.TEST]:"https://apitest.ok.ru",[exports.ApiEnv.AUTO]:""},Vl={start:1e3,factor:1.5,max:5*60*1e3,random:.1};var j;(function(e){e[e.PARAM_SESSION_EXPIRED=102]="PARAM_SESSION_EXPIRED",e[e.PARAM_SESSION_KEY=103]="PARAM_SESSION_KEY",e[e.PARAM_SIGNATURE=104]="PARAM_SIGNATURE",e[e.AUTH_LOGIN=401]="AUTH_LOGIN"})(j||(j={}));class Hl{constructor(r){this.consequentAuthErrors=0,this.authorized$=new h.ValueSubject(!1),this.params=r;const t=Wt.get("uuid");t?this.uuid=String(t):(this.uuid=Bl(),Wt.set("uuid",this.uuid))}authorize(r){return w(this,void 0,void 0,function*(){return this.authToken=r!=null?r:yield this.refreshAuthToken(),this._authorizeWithBackoff()})}logBeacon(r){const t="log.externalLog",n=this.createLogParams(r),o=this.sessionKey;if(!o)return;this.params.apiTransport.sendBeacon(t,n,o)||this.logRequest(r)}logRequest(r){var t;return w(this,void 0,void 0,function*(){const n="log.externalLog",o=this.createLogParams(r),a=(t=this.sessionKey)!==null&&t!==void 0?t:yield this._authorizeWithBackoff();if(!a)return;const i=(v,u=this.params.requestRetryCount)=>w(this,void 0,void 0,function*(){try{return yield this.params.apiTransport.sendRequest(n,o,a)}catch(s){if(!s||!("error_code"in s)){this.params.error$.next({id:"logRequestUnknown",category:h.ErrorCategory.NETWORK,message:`Unknown ${n} error`,thrown:s});return}const c=s==null?void 0:s.error_code;switch(c){case j.PARAM_SESSION_EXPIRED:case j.PARAM_SESSION_KEY:case j.PARAM_SIGNATURE:return this.authorized$.next(!1),this.sessionKey=yield this._authorizeWithBackoff(),u>0?i(v,u-1):void 0;case j.AUTH_LOGIN:return this.authorized$.next(!1),this.authToken=yield this.refreshAuthToken(),this.sessionKey=yield this._authorizeWithBackoff(),u>0?i(v,u-1):void 0;default:{this.params.error$.next({id:`LogRequest#${c}`,category:h.ErrorCategory.EXTERNAL_API,message:`${n} error`,data:s});return}}}});return i(r)})}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}refreshAuthToken(){return w(this,void 0,void 0,function*(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=fr(this.params.refreshAuthToken(),()=>{this.refreshAuthTokenPromise=void 0})),this.refreshAuthTokenPromise})}createLogParams(r){return{collector:"ok.mobile.apps.video",data:JSON.stringify({application:`${Fl}:${Gt}`,platform:"WEB",items:r.map(t=>Object.assign(Object.assign({},t),{time:0,type:1}))})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();const r=h.getExponentialDelay(this.consequentAuthErrors,Vl);return new Promise(t=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout(()=>{fr(this._authorize().then(t).catch(n=>this.params.error$.next({id:"AuthorizeBackoff",category:h.ErrorCategory.NETWORK,message:"Otherwise unhandle errror in authrization",thrown:n})),()=>this.backoffTimeoutId=0)},r))})}_authorize(){return w(this,void 0,void 0,function*(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);const r="auth.anonymLogin",t={session_data:{version:2,device_id:this.uuid,client_version:Gt.split("-")[0],client_type:"SDK_JS"}};return this.authToken!==void 0&&(t.session_data.auth_token=this.authToken,t.session_data.version=3),this.authorizePromise=fr(this.params.apiTransport.sendRequest(r,t).then(n=>{var o;return(!n||!n.session_key)&&this.params.error$.next({id:"AuthorizeFailed",category:h.ErrorCategory.EXTERNAL_API,message:"No session key",data:n}),this.sessionKey=(o=n==null?void 0:n.session_key)!==null&&o!==void 0?o:void 0,this.sessionKey}).catch(n=>w(this,void 0,void 0,function*(){this.sessionKey=void 0;const o=n==null?void 0:n.error_code;switch(o){case j.AUTH_LOGIN:return this.authToken=yield this.refreshAuthToken(),this._authorizeWithBackoff()}o?this.params.error$.next({id:`Authorize#${o}`,category:h.ErrorCategory.EXTERNAL_API,message:"authorize error",data:n}):this.params.error$.next({id:"AuthorizeUnknown",category:h.ErrorCategory.NETWORK,message:"authorize error",thrown:n})})),()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(this.sessionKey!==void 0)}),this.authorizePromise})}}class zt{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(r,t,n){r in this.listeners||(this.listeners[r]=[]),this.listeners[r].push({callback:t,options:n})}removeEventListener(r,t){if(!(r in this.listeners))return;const n=this.listeners[r];for(let o=0,a=n.length;o<a;o++)if(n[o].callback===t){n.splice(o,1);return}}dispatchEvent(r){if(!(r.type in this.listeners))return;const n=this.listeners[r.type].slice();for(let o=0,a=n.length;o<a;o++){const i=n[o];try{i.callback.call(this,r)}catch(v){Promise.resolve().then(()=>{throw v})}i.options&&i.options.once&&this.removeEventListener(r.type,i.callback)}return!r.defaultPrevented}}class uo extends zt{constructor(){super(),this.listeners||zt.call(this),Object.defineProperty(this,"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,"reason",{value:void 0,writable:!0,configurable:!0})}toString(){return"[object AbortSignal]"}dispatchEvent(r){r.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,r)),super.dispatchEvent(r)}}class ql{constructor(){Object.defineProperty(this,"signal",{value:new uo,writable:!0,configurable:!0})}abort(r){let t;try{t=new Event("abort")}catch(o){typeof document!="undefined"?document.createEvent?(t=document.createEvent("Event"),t.initEvent("abort",!1,!1)):(t=document.createEventObject(),t.type="abort"):t={type:"abort",bubbles:!1,cancelable:!1}}let n=r;if(n===void 0)if(typeof document=="undefined")n=new Error("This operation was aborted"),n.name="AbortError";else try{n=new DOMException("signal is aborted without reason")}catch(o){n=new Error("This operation was aborted"),n.name="AbortError"}this.signal.reason=n,this.signal.dispatchEvent(t)}toString(){return"[object AbortController]"}}typeof Symbol!="undefined"&&Symbol.toStringTag&&(ql.prototype[Symbol.toStringTag]="AbortController",uo.prototype[Symbol.toStringTag]="AbortSignal");function lo(e){return e.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):typeof e.Request=="function"&&!e.Request.prototype.hasOwnProperty("signal")||!e.AbortController}function Kl(e){typeof e=="function"&&(e={fetch:e});const{fetch:r,Request:t=r.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o=!1}=e;if(!lo({fetch:r,Request:t,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o}))return{fetch:r,Request:a};let a=t;(a&&!a.prototype.hasOwnProperty("signal")||o)&&(a=function(s,c){let l;c&&c.signal&&(l=c.signal,delete c.signal);const p=new t(s,c);return l&&Object.defineProperty(p,"signal",{writable:!1,enumerable:!1,configurable:!0,value:l}),p},a.prototype=t.prototype);const i=r;return{fetch:(u,s)=>{const c=a&&a.prototype.isPrototypeOf(u)?u.signal:s?s.signal:void 0;if(c){let l;try{l=new DOMException("Aborted","AbortError")}catch(f){l=new Error("Aborted"),l.name="AbortError"}if(c.aborted)return Promise.reject(l);const p=new Promise((f,m)=>{c.addEventListener("abort",()=>m(l),{once:!0})});return s&&s.signal&&delete s.signal,Promise.race([p,i(u,s)])}return i(u,s)},Request:a}}const Vr=lo({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),vo=Vr?Kl({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,Yt=Vr?vo.fetch:window.fetch;Vr?vo.Request:window.Request;class Ql{constructor(r){this.params=r,this.apiKey=r.apiKey,this.apiEnv=r.apiEnv,this.apiBaseUrl=r.apiBaseUrl,this.timeSynchronisation=r.timeSynchronisation,this.isApiBaseUrlFetched=!1}resolveApiBaseUrl(){var r;return w(this,void 0,void 0,function*(){if(this.apiEnv!==exports.ApiEnv.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const t=atob("aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ="),o=yield(yield Yt(t,{method:"GET",mode:"cors",cache:"no-cache"})).json(),a=(r=o==null?void 0:o.Answer[0])===null||r===void 0?void 0:r.data;if(!a)throw new Error("Wrong DNS response");return a}catch(t){return this.params.error$.next({id:"OneStat:ApiTransport:resolveApiBaseUrl",category:h.ErrorCategory.NETWORK,message:"Unhandled resolve api base url error",thrown:t}),co[exports.ApiEnv.VK_ALIAS]}finally{this.isApiBaseUrlFetched=!0}})}sendBeacon(r,t,n){if(!window.Blob||!window.navigator.sendBeacon)return!1;const o=this._prepareQueryParams({method:r,queryParams:t,sessionKey:n}),a=new window.Blob([o.toString()],{type:"application/x-www-form-urlencoded"});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,a)}catch(i){this.params.error$.next({id:"OneStat:ApiTransport:sendBeacon",category:h.ErrorCategory.NETWORK,message:"Unhandled beacon error",thrown:i,data:{method:r,params:t}})}return!1}sendRequest(r,t,n){return w(this,void 0,void 0,function*(){const o=h.now(),a=i=>{if(i instanceof TypeError&&["Failed to fetch","NetworkError when attempting to fetch resource."].includes(i.message)){this.params.error$.next({id:"Network",category:h.ErrorCategory.NETWORK,message:"Request failed",thrown:i});return}this.params.error$.next({id:"OneStat:ApiTransport:sendRequest",category:h.ErrorCategory.NETWORK,message:"Unhandled request error",thrown:i,data:{method:r,params:t,sessionKey:n,time:h.now()-o}})};return this.apiBaseUrl=yield this.resolveApiBaseUrl(),Yt(`${this.apiBaseUrl}/fb.do`,{method:"post",headers:{"Content-type":"application/x-www-form-urlencoded"},body:this._prepareQueryParams({method:r,queryParams:t,sessionKey:n})}).then(i=>{var v;const u=Number(i.headers.get("content-length"))===0,s=new Date((v=i.headers.get("date"))!==null&&v!==void 0?v:"").getTime(),c=h.now()-o;if(isFinite(s)&&this.timeSynchronisation.addServerTime(s,c),!u)return i.json().then(l=>Object.prototype.hasOwnProperty.call(l,"error_msg")?Promise.reject(l):l,a)},a)})}_prepareQueryParams(r){const t=new URLSearchParams({format:"JSON",method:r.method,application_key:this.apiKey});return r.sessionKey!==void 0&&t.append("session_key",r.sessionKey),Object.entries(r.queryParams).forEach(([n,o])=>t.append(n,typeof o=="string"?o:JSON.stringify(o))),t}}const fo=3e3,Wl=fo*5;class Gl{constructor(r){this.requestQueue=[],this.isPaused=!1,this.debouncedFlush=ho(()=>{var t;try{this.flush()}catch(n){this.error$.next({id:"LoggerError",category:h.ErrorCategory.WTF,message:(t=String(n))!==null&&t!==void 0?t:"Unknown logger error",thrown:n})}},fo,{maxWait:Wl}),this.api=r.api,this.error$=r.error$,this.subscription=this.api.authorized$.subscribe(t=>{t&&this.debouncedFlush()})}log(r){this.requestQueue.push(r),this.isPaused||this.debouncedFlush()}flush(r=!1){this.requestQueue.length!==0&&(this.api.authorized$.getValue()?(r?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[]):r||this.api.authorize(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe()}}class zl{constructor(r){this.offset=void 0,this.offset=r}getOffset(){var r;return(r=this.offset)!==null&&r!==void 0?r:0}setOffset(r){this.offset=r}now(){var r;return Date.now()+((r=this.offset)!==null&&r!==void 0?r:0)}date(r=new Date){var t;return r.setTime(r.getTime()+((t=this.offset)!==null&&t!==void 0?t:0)),r}addServerTime(r,t){const n=Date.now(),o=r-n-t/2;if(Math.abs(o)<1e3){this.offset=0;return}this.offset===void 0?this.offset=Math.round(o):this.offset=Math.round(.2*o+(1-.2)*this.offset)}}const Jt=()=>Math.floor(Math.random()*Math.pow(2,32)).toString(36).padStart(8,"0"),Yl=e=>e&&{[d.VideoQuality.INVARIANT]:exports.Quality.UNKNOWN,[d.VideoQuality.Q_144P]:exports.Quality.Q144P,[d.VideoQuality.Q_240P]:exports.Quality.Q240P,[d.VideoQuality.Q_360P]:exports.Quality.Q360P,[d.VideoQuality.Q_480P]:exports.Quality.Q480P,[d.VideoQuality.Q_720P]:exports.Quality.Q720P,[d.VideoQuality.Q_1080P]:exports.Quality.Q1080P,[d.VideoQuality.Q_1440P]:exports.Quality.Q1440P,[d.VideoQuality.Q_2160P]:exports.Quality.Q2160P,[d.VideoQuality.Q_4320P]:exports.Quality.Q4320P}[e],Jl=e=>e&&{[d.HttpConnectionType.HTTP1]:exports.ConnectionType.HTTP1,[d.HttpConnectionType.HTTP2]:exports.ConnectionType.HTTP2,[d.HttpConnectionType.QUIC]:exports.ConnectionType.HTTP3}[e],Xl=e=>{if(e!==void 0)switch(e){case d.VideoFormat.MPEG:return exports.ContentType.MP4;case d.VideoFormat.DASH:case d.VideoFormat.DASH_LIVE:return exports.ContentType.DASH;case d.VideoFormat.DASH_SEP:return exports.ContentType.DASH_SEP;case d.VideoFormat.DASH_ONDEMAND:return exports.ContentType.ONDEMAND_DASH;case d.VideoFormat.DASH_WEBM:case d.VideoFormat.DASH_LIVE_WEBM:return exports.ContentType.WEBM;case d.VideoFormat.HLS:case d.VideoFormat.HLS_LIVE:return exports.ContentType.HLS;case d.VideoFormat.HLS_ONDEMAND:return exports.ContentType.ONDEMAND_HLS;case d.VideoFormat.WEB_RTC_LIVE:return exports.ContentType.RTMP;default:return h.assertNever(e)}};class Zl{constructor(r,t){var n;this.subscription=new h.Subscription,this.timeSynchronisation=new zl,this.vsid=Jt(),this.fieldBlacklist=[],this.statContext=r,this.config=Object.assign(Object.assign({},(n=t.config)!==null&&n!==void 0?n:{}),{requestRetryCount:1});const o=new h.Subject;this.experimental={error$:o};const a=new Ql({apiKey:xl,apiBaseUrl:co[t.apiEnv],apiEnv:t.apiEnv,error$:o,timeSynchronisation:this.timeSynchronisation});this.api=new Hl({apiTransport:a,refreshAuthToken:t.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:o}),this.logger=new Gl({api:this.api,error$:o}),this.subscription.add(h.fromEvent(window,"beforeunload").subscribe(()=>this.logger.flush(!0)))}updateContext(r){this.statContext=Object.assign(Object.assign({},this.statContext),r)}attachTo(r){let t;return new h.Subscription().add(r.events.started$.subscribe(()=>{this.logStarted({position:r.info.position$.getValue()})})).add(r.events.looped$.subscribe(()=>{this.resetViewSession(),this.logStarted({position:r.info.position$.getValue()})})).add(r.events.seeked$.subscribe(()=>{this.logSeek()})).add(r.events.willPause$.subscribe(()=>{this.logPause({position:r.info.position$.getValue()})})).add(r.events.willResume$.subscribe(()=>{this.logPlay()})).add(r.events.managedError$.subscribe(({id:n})=>{this.logError({errorType:n})})).add(r.events.fatalError$.subscribe(({id:n})=>{this.logError({errorType:n})})).add(r.events.inited$.subscribe(()=>{this.logInited()})).add(r.events.canplay$.subscribe(n=>{this.logReady({time:n})})).add(r.events.firstBytes$.subscribe(n=>{this.logFirstBytes({time:n})})).add(r.events.firstFrame$.subscribe(n=>{this.logFirstFrame({time:n})})).add(r.events.watchCoverageRecord$.subscribe(n=>{this.logWatchCoverageRecord(n)})).add(r.events.watchCoverageLive$.subscribe(n=>{this.logWatchCoverageLive(n)})).add(r.info.isStalled$.subscribe(n=>{n?t=h.now():(h.isNonNullable(t)&&this.logEmptyBuffer({duration:h.now()-t}),t=void 0)})).add(r.events.ended$.subscribe(()=>{const n=r.info.throughputEstimation$.getValue();h.isNonNullable(n)&&this.logDownloadSpeed({speed:n/8})})).add(r.info.hostname$.subscribe(n=>{this.updateContext({cdnHostname:n})})).add(r.info.httpConnectionType$.subscribe(n=>{this.updateContext({connectionType:Jl(n)})})).add(r.info.httpConnectionReused$.subscribe(n=>{this.updateContext({connectionReused:n})})).add(r.info.currentQuality$.subscribe(n=>{this.updateContext({quality:Yl(n)})})).add(r.info.currentFormat$.subscribe(n=>{this.updateContext({contentType:Xl(n)})})).add(r.info.chromecastState$.subscribe(n=>{this.updateContext({destination:n===d.ChromecastState.CONNECTED?exports.ScreenDestination.CHROMECAST:exports.ScreenDestination.SCREEN})}))}authorize(r){return this.api.authorize(r)}pause(){this.logger.pause()}resume(){this.logger.resume()}destroy(){this.logger.flush(),this.subscription.unsubscribe(),this.api.destroy(),this.logger.destroy()}resetViewSession(){this.vsid=Jt()}setFieldBlacklist(r=[]){this.fieldBlacklist=r}logInited(){this.log({operation:"init"})}logReady(r){this.log({operation:"player_ready",param:String(r.time)})}logStarted(r){this.log({operation:"play",param:String(Math.round(r.position))})}logPlay(){this.log({operation:"play_toggle"})}logPause(r){this.log({operation:"pause",param:String(Math.round(r.position))})}logSeek(){this.log({operation:"seek"})}logFirstBytes(r){this.log({operation:"first_bytes",param:String(r.time)})}logFirstFrame(r){this.log({operation:"first_frame",param:String(r.time)})}logError(r){this.log({operation:"error",param:r.errorType})}logWatchCoverageRecord(r){this.log({operation:"watch_coverage_record",param:`${r.start}-${r.end}`}),this.logger.flush(!0)}logWatchCoverageLive(r){const t=r.start+this.timeSynchronisation.getOffset(),n=r.end+this.timeSynchronisation.getOffset();this.log({operation:"watch_coverage_live",param:`${t}-${n}`}),this.logger.flush(!0)}logEmptyBuffer(r){this.log({operation:"empty_buffer",param:String(r.duration)})}logDownloadSpeed(r){this.log({operation:"download_speed",param:String(r.speed)})}logAdSlotRequest(){this.log({operation:"adv",param:"slot_request"})}logAdStarted(r){this.log({operation:"adv",param:r})}logAdPaused(){this.log({operation:"adv",param:"pause"})}logAdResumed(){this.log({operation:"adv",param:"resume"})}logAdEnded(){this.log({operation:"adv",param:"ended"})}logAdSkipped(){this.log({operation:"adv",param:"skip"})}logAdClicked(){this.log({operation:"adv",param:"click"})}log(r){const t=this.createLogItem(r);this.logger.log(t)}createLogItem({operation:r,param:t}){const n=this.timeSynchronisation.now(),o={vsid:this.vsid,vid:this.statContext.movieId,quality:this.statContext.quality,dst:this.statContext.destination,ct:this.statContext.contentType,aid:this.statContext.albumId,place:this.statContext.place,cdn_host:this.statContext.cdnHostname,connection_type:this.statContext.connectionType,connection_reused:this.statContext.connectionReused===!0?Ce.YES:this.statContext.connectionReused===!1?Ce.NO:void 0,stat_type:this.statContext.autoplay===!0?Re.AUTO:this.statContext.autoplay===!1?Re.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode};t!==void 0&&(o.param=t);for(const a of this.fieldBlacklist)delete o[a];return{operation:r,timestamp:n,custom:o}}}exports.OneStat=Zl;
|
package/es2015.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-statistics v1.0.
|
|
3
|
-
*
|
|
4
|
-
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-
|
|
2
|
+
* @vkontakte/videoplayer-statistics v1.0.31
|
|
3
|
+
* Thu, 02 Feb 2023 10:22:17 GMT
|
|
4
|
+
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-31/doc/
|
|
5
5
|
*/
|
|
6
|
-
import{ValueSubject as t,getExponentialDelay as e,ErrorCategory as r,now as n,assertNever as o,Subscription as i,Subject as s,fromEvent as a,isNonNullable as u}from'@vkontakte/videoplayer-shared/es2015.esm.js';import{VideoQuality as c,HttpConnectionType as h,VideoFormat as l,ChromecastState as f}from'@vkontakte/videoplayer-core/es2015.esm.js';import d from'lodash/debounce.js';function p(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))}var v='undefined'!=typeof globalThis?globalThis:'undefined'!=typeof window?window:'undefined'!=typeof global?global:'undefined'!=typeof self?self:{},m=function(t){return t&&t.Math==Math&&t},y=m('object'==typeof globalThis&&globalThis)||m('object'==typeof window&&window)||m('object'==typeof self&&self)||m('object'==typeof v&&v)||function(){return this}()||Function('return this')(),g=function(t){try{return!!t()}catch(t){return!0}},b=!g((function(){var t=function(){}.bind();return'function'!=typeof t||t.hasOwnProperty('prototype')})),w=b,T=Function.prototype,S=T.apply,E=T.call,P='object'==typeof Reflect&&Reflect.apply||(w?E.bind(S):function(){return E.apply(S,arguments)}),_=b,A=Function.prototype,O=A.bind,R=A.call,N=_&&O.bind(R,R),C=_?function(t){return t&&N(t)}:function(t){return t&&function(){return R.apply(t,arguments)}},k=function(t){return'function'==typeof t},j={},I=!g((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),L=b,x=Function.prototype.call,$=L?x.bind(x):function(){return x.apply(x,arguments)},D={},M={}.propertyIsEnumerable,B=Object.getOwnPropertyDescriptor,U=B&&!M.call({1:2},1);D.f=U?function(t){var e=B(this,t);return!!e&&e.enumerable}:M;var q,F,H=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},z=C,Q=z({}.toString),K=z(''.slice),W=function(t){return K(Q(t),8,-1)},V=g,G=W,Y=Object,J=C(''.split),X=V((function(){return!Y('z').propertyIsEnumerable(0)}))?function(t){return'String'==G(t)?J(t,''):Y(t)}:Y,Z=TypeError,tt=function(t){if(null==t)throw Z('Can\'t call method on '+t);return t},et=X,rt=tt,nt=k,ot=function(t){return'object'==typeof t?null!==t:nt(t)},it={},st=it,at=y,ut=k,ct=function(t){return ut(t)?t:void 0},ht=function(t,e){return arguments.length<2?ct(st[t])||ct(at[t]):st[t]&&st[t][e]||at[t]&&at[t][e]},lt=C({}.isPrototypeOf),ft=ht('navigator','userAgent')||'',dt=y,pt=ft,vt=dt.process,mt=dt.Deno,yt=vt&&vt.versions||mt&&mt.version,gt=yt&&yt.v8;gt&&(F=(q=gt.split('.'))[0]>0&&q[0]<4?1:+(q[0]+q[1])),!F&&pt&&(!(q=pt.match(/Edge\/(\d+)/))||q[1]>=74)&&(q=pt.match(/Chrome\/(\d+)/))&&(F=+q[1]);var bt=F,wt=bt,Tt=g,St=!!Object.getOwnPropertySymbols&&!Tt((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&wt&&wt<41})),Et=St&&!Symbol.sham&&'symbol'==typeof Symbol.iterator,Pt=ht,_t=k,At=lt,Ot=Object,Rt=Et?function(t){return'symbol'==typeof t}:function(t){var e=Pt('Symbol');return _t(e)&&At(e.prototype,Ot(t))},Nt=String,Ct=function(t){try{return Nt(t)}catch(t){return'Object'}},kt=k,jt=Ct,It=TypeError,Lt=function(t){if(kt(t))return t;throw It(jt(t)+' is not a function')},xt=Lt,$t=function(t,e){var r=t[e];return null==r?void 0:xt(r)},Dt=$,Mt=k,Bt=ot,Ut=TypeError,qt={exports:{}},Ft=y,Ht=Object.defineProperty,zt=function(t,e){try{Ht(Ft,t,{value:e,configurable:!0,writable:!0})}catch(r){Ft[t]=e}return e},Qt=y['__core-js_shared__']||zt('__core-js_shared__',{}),Kt=Qt;(qt.exports=function(t,e){return Kt[t]||(Kt[t]=void 0!==e?e:{})})('versions',[]).push({version:'3.24.1',mode:'pure',copyright:'© 2014-2022 Denis Pushkarev (zloirock.ru)',license:'https://github.com/zloirock/core-js/blob/v3.24.1/LICENSE',source:'https://github.com/zloirock/core-js'});var Wt=tt,Vt=Object,Gt=function(t){return Vt(Wt(t))},Yt=C({}.hasOwnProperty),Jt=Object.hasOwn||function(t,e){return Yt(Gt(t),e)},Xt=C,Zt=0,te=Math.random(),ee=Xt(1..toString),re=function(t){return'Symbol('+(void 0===t?'':t)+')_'+ee(++Zt+te,36)},ne=y,oe=qt.exports,ie=Jt,se=re,ae=St,ue=Et,ce=oe('wks'),he=ne.Symbol,le=he&&he.for,fe=ue?he:he&&he.withoutSetter||se,de=function(t){if(!ie(ce,t)||!ae&&'string'!=typeof ce[t]){var e='Symbol.'+t;ae&&ie(he,t)?ce[t]=he[t]:ce[t]=ue&&le?le(e):fe(e)}return ce[t]},pe=$,ve=ot,me=Rt,ye=$t,ge=function(t,e){var r,n;if('string'===e&&Mt(r=t.toString)&&!Bt(n=Dt(r,t)))return n;if(Mt(r=t.valueOf)&&!Bt(n=Dt(r,t)))return n;if('string'!==e&&Mt(r=t.toString)&&!Bt(n=Dt(r,t)))return n;throw Ut('Can\'t convert object to primitive value')},be=TypeError,we=de('toPrimitive'),Te=function(t,e){if(!ve(t)||me(t))return t;var r,n=ye(t,we);if(n){if(void 0===e&&(e='default'),r=pe(n,t,e),!ve(r)||me(r))return r;throw be('Can\'t convert object to primitive value')}return void 0===e&&(e='number'),ge(t,e)},Se=Rt,Ee=function(t){var e=Te(t,'string');return Se(e)?e:e+''},Pe=ot,_e=y.document,Ae=Pe(_e)&&Pe(_e.createElement),Oe=function(t){return Ae?_e.createElement(t):{}},Re=Oe,Ne=!I&&!g((function(){return 7!=Object.defineProperty(Re('div'),'a',{get:function(){return 7}}).a})),Ce=I,ke=$,je=D,Ie=H,Le=function(t){return et(rt(t))},xe=Ee,$e=Jt,De=Ne,Me=Object.getOwnPropertyDescriptor;j.f=Ce?Me:function(t,e){if(t=Le(t),e=xe(e),De)try{return Me(t,e)}catch(t){}if($e(t,e))return Ie(!ke(je.f,t,e),t[e])};var Be=g,Ue=k,qe=/#|\.prototype\./,Fe=function(t,e){var r=ze[He(t)];return r==Ke||r!=Qe&&(Ue(e)?Be(e):!!e)},He=Fe.normalize=function(t){return String(t).replace(qe,'.').toLowerCase()},ze=Fe.data={},Qe=Fe.NATIVE='N',Ke=Fe.POLYFILL='P',We=Fe,Ve=Lt,Ge=b,Ye=C(C.bind),Je=function(t,e){return Ve(t),void 0===e?t:Ge?Ye(t,e):function(){return t.apply(e,arguments)}},Xe={},Ze=I&&g((function(){return 42!=Object.defineProperty((function(){}),'prototype',{value:42,writable:!1}).prototype})),tr=ot,er=String,rr=TypeError,nr=function(t){if(tr(t))return t;throw rr(er(t)+' is not an object')},or=I,ir=Ne,sr=Ze,ar=nr,ur=Ee,cr=TypeError,hr=Object.defineProperty,lr=Object.getOwnPropertyDescriptor;Xe.f=or?sr?function(t,e,r){if(ar(t),e=ur(e),ar(r),'function'==typeof t&&'prototype'===e&&'value'in r&&'writable'in r&&!r.writable){var n=lr(t,e);n&&n.writable&&(t[e]=r.value,r={configurable:'configurable'in r?r.configurable:n.configurable,enumerable:'enumerable'in r?r.enumerable:n.enumerable,writable:!1})}return hr(t,e,r)}:hr:function(t,e,r){if(ar(t),e=ur(e),ar(r),ir)try{return hr(t,e,r)}catch(t){}if('get'in r||'set'in r)throw cr('Accessors not supported');return'value'in r&&(t[e]=r.value),t};var fr=Xe,dr=H,pr=I?function(t,e,r){return fr.f(t,e,dr(1,r))}:function(t,e,r){return t[e]=r,t},vr=y,mr=P,yr=C,gr=k,br=j.f,wr=We,Tr=it,Sr=Je,Er=pr,Pr=Jt,_r=function(t){var e=function(r,n,o){if(this instanceof e){switch(arguments.length){case 0:return new t;case 1:return new t(r);case 2:return new t(r,n)}return new t(r,n,o)}return mr(t,this,arguments)};return e.prototype=t.prototype,e},Ar=function(t,e){var r,n,o,i,s,a,u,c,h=t.target,l=t.global,f=t.stat,d=t.proto,p=l?vr:f?vr[h]:(vr[h]||{}).prototype,v=l?Tr:Tr[h]||Er(Tr,h,{})[h],m=v.prototype;for(o in e)r=!wr(l?o:h+(f?'.':'#')+o,t.forced)&&p&&Pr(p,o),s=v[o],r&&(a=t.dontCallGetSet?(c=br(p,o))&&c.value:p[o]),i=r&&a?a:e[o],r&&typeof s==typeof i||(u=t.bind&&r?Sr(i,vr):t.wrap&&r?_r(i):d&&gr(i)?yr(i):i,(t.sham||i&&i.sham||s&&s.sham)&&Er(u,'sham',!0),Er(v,o,u),d&&(Pr(Tr,n=h+'Prototype')||Er(Tr,n,{}),Er(Tr[n],o,i),t.real&&m&&!m[o]&&Er(m,o,i)))},Or='process'==W(y.process),Rr=pr,Nr=(TypeError,C);Object.setPrototypeOf||'__proto__'in{}&&function(){var t,e=!1,r={};try{(t=Nr(Object.getOwnPropertyDescriptor(Object.prototype,'__proto__').set))(r,[]),e=r instanceof Array}catch(t){}}();var Cr={};Cr[de('toStringTag')]='z';var kr='[object z]'===String(Cr),jr=kr,Ir=k,Lr=W,xr=de('toStringTag'),$r=Object,Dr='Arguments'==Lr(function(){return arguments}()),Mr=jr?Lr:function(t){var e,r,n;return void 0===t?'Undefined':null===t?'Null':'string'==typeof(r=function(t,e){try{return t[e]}catch(t){}}(e=$r(t),xr))?r:Dr?Lr(e):'Object'==(n=Lr(e))&&Ir(e.callee)?'Arguments':n},Br=Mr,Ur=kr?{}.toString:function(){return'[object '+Br(this)+']'},qr=kr,Fr=Xe.f,Hr=pr,zr=Jt,Qr=Ur,Kr=de('toStringTag'),Wr=ht,Vr=Xe,Gr=I,Yr=de('species'),Jr=lt,Xr=TypeError,Zr=k,tn=Qt,en=C(Function.toString);Zr(tn.inspectSource)||(tn.inspectSource=function(t){return en(t)});var rn=tn.inspectSource,nn=C,on=g,sn=k,an=Mr,un=rn,cn=function(){},hn=[],ln=ht('Reflect','construct'),fn=/^\s*(?:class|function)\b/,dn=nn(fn.exec),pn=!fn.exec(cn),vn=function(t){if(!sn(t))return!1;try{return ln(cn,hn,t),!0}catch(t){return!1}},mn=function(t){if(!sn(t))return!1;switch(an(t)){case'AsyncFunction':case'GeneratorFunction':case'AsyncGeneratorFunction':return!1}try{return pn||!!dn(fn,un(t))}catch(t){return!0}};mn.sham=!0;var yn,gn,bn,wn,Tn=!ln||on((function(){var t;return vn(vn.call)||!vn(Object)||!vn((function(){t=!0}))||t}))?mn:vn,Sn=Ct,En=TypeError,Pn=nr,_n=function(t){if(Tn(t))return t;throw En(Sn(t)+' is not a constructor')},An=de('species'),On=function(t,e){var r,n=Pn(t).constructor;return void 0===n||null==(r=Pn(n)[An])?e:_n(r)},Rn=ht('document','documentElement'),Nn=C([].slice),Cn=TypeError,kn=/(?:ipad|iphone|ipod).*applewebkit/i.test(ft),jn=y,In=P,Ln=Je,xn=k,$n=Jt,Dn=g,Mn=Rn,Bn=Nn,Un=Oe,qn=function(t,e){if(t<e)throw Cn('Not enough arguments');return t},Fn=kn,Hn=Or,zn=jn.setImmediate,Qn=jn.clearImmediate,Kn=jn.process,Wn=jn.Dispatch,Vn=jn.Function,Gn=jn.MessageChannel,Yn=jn.String,Jn=0,Xn={};try{yn=jn.location}catch(t){}var Zn=function(t){if($n(Xn,t)){var e=Xn[t];delete Xn[t],e()}},to=function(t){return function(){Zn(t)}},eo=function(t){Zn(t.data)},ro=function(t){jn.postMessage(Yn(t),yn.protocol+'//'+yn.host)};zn&&Qn||(zn=function(t){qn(arguments.length,1);var e=xn(t)?t:Vn(t),r=Bn(arguments,1);return Xn[++Jn]=function(){In(e,void 0,r)},gn(Jn),Jn},Qn=function(t){delete Xn[t]},Hn?gn=function(t){Kn.nextTick(to(t))}:Wn&&Wn.now?gn=function(t){Wn.now(to(t))}:Gn&&!Fn?(wn=(bn=new Gn).port2,bn.port1.onmessage=eo,gn=Ln(wn.postMessage,wn)):jn.addEventListener&&xn(jn.postMessage)&&!jn.importScripts&&yn&&'file:'!==yn.protocol&&!Dn(ro)?(gn=ro,jn.addEventListener('message',eo,!1)):gn='onreadystatechange'in Un('script')?function(t){Mn.appendChild(Un('script')).onreadystatechange=function(){Mn.removeChild(this),Zn(t)}}:function(t){setTimeout(to(t),0)});var no,oo,io,so,ao,uo,co,ho,lo={set:zn,clear:Qn},fo=y,po=/ipad|iphone|ipod/i.test(ft)&&void 0!==fo.Pebble,vo=/web0s(?!.*chrome)/i.test(ft),mo=y,yo=Je,go=j.f,bo=lo.set,wo=kn,To=po,So=vo,Eo=Or,Po=mo.MutationObserver||mo.WebKitMutationObserver,_o=mo.document,Ao=mo.process,Oo=mo.Promise,Ro=go(mo,'queueMicrotask'),No=Ro&&Ro.value;No||(no=function(){var t,e;for(Eo&&(t=Ao.domain)&&t.exit();oo;){e=oo.fn,oo=oo.next;try{e()}catch(t){throw oo?so():io=void 0,t}}io=void 0,t&&t.enter()},wo||Eo||So||!Po||!_o?!To&&Oo&&Oo.resolve?((co=Oo.resolve(void 0)).constructor=Oo,ho=yo(co.then,co),so=function(){ho(no)}):Eo?so=function(){Ao.nextTick(no)}:(bo=yo(bo,mo),so=function(){bo(no)}):(ao=!0,uo=_o.createTextNode(''),new Po(no).observe(uo,{characterData:!0}),so=function(){uo.data=ao=!ao}));var Co=No||function(t){var e={fn:t,next:void 0};io&&(io.next=e),oo||(oo=e,so()),io=e},ko=y,jo=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}},Io=function(){this.head=null,this.tail=null};Io.prototype={add:function(t){var e={item:t,next:null};this.head?this.tail.next=e:this.head=e,this.tail=e},get:function(){var t=this.head;if(t)return this.head=t.next,this.tail===t&&(this.tail=null),t.item}};var Lo,xo,$o,Do=Io,Mo=k,Bo=rn,Uo=y.WeakMap,qo=Mo(Uo)&&/native code/.test(Bo(Uo)),Fo=qt.exports,Ho=re,zo=Fo('keys'),Qo=qo,Ko=y,Wo=C,Vo=ot,Go=pr,Yo=Jt,Jo=Qt,Xo=function(t){return zo[t]||(zo[t]=Ho(t))},Zo=Ko.TypeError,ti=Ko.WeakMap;if(Qo||Jo.state){var ei=Jo.state||(Jo.state=new ti),ri=Wo(ei.get),ni=Wo(ei.has),oi=Wo(ei.set);Lo=function(t,e){if(ni(ei,t))throw new Zo('Object already initialized');return e.facade=t,oi(ei,t,e),e},xo=function(t){return ri(ei,t)||{}},$o=function(t){return ni(ei,t)}}else{var ii=Xo('state');Lo=function(t,e){if(Yo(t,ii))throw new Zo('Object already initialized');return e.facade=t,Go(t,ii,e),e},xo=function(t){return Yo(t,ii)?t[ii]:{}},$o=function(t){return Yo(t,ii)}}var si={set:Lo,get:xo,has:$o,enforce:function(t){return $o(t)?xo(t):Lo(t,{})},getterFor:function(t){return function(e){var r;if(!Vo(e)||(r=xo(e)).type!==t)throw Zo('Incompatible receiver, '+t+' required');return r}}},ai=y.Promise,ui='object'==typeof Deno&&Deno&&'object'==typeof Deno.version,ci=!ui&&!Or&&'object'==typeof window&&'object'==typeof document,hi=y,li=ai,fi=k,di=We,pi=rn,vi=de,mi=ci,yi=ui,gi=bt,bi=li&&li.prototype,wi=vi('species'),Ti=!1,Si=fi(hi.PromiseRejectionEvent),Ei={CONSTRUCTOR:di('Promise',(function(){var t=pi(li),e=t!==String(li);if(!e&&66===gi)return!0;if(!bi.catch||!bi.finally)return!0;if(!gi||gi<51||!/native code/.test(t)){var r=new li((function(t){t(1)})),n=function(t){t((function(){}),(function(){}))};if((r.constructor={})[wi]=n,!(Ti=r.then((function(){}))instanceof n))return!0}return!e&&(mi||yi)&&!Si})),REJECTION_EVENT:Si,SUBCLASSING:Ti},Pi={},_i=Lt,Ai=function(t){var e,r;this.promise=new t((function(t,n){if(void 0!==e||void 0!==r)throw TypeError('Bad Promise constructor');e=t,r=n})),this.resolve=_i(e),this.reject=_i(r)};Pi.f=function(t){return new Ai(t)};var Oi,Ri,Ni=Ar,Ci=Or,ki=y,ji=$,Ii=function(t,e,r,n){return n&&n.enumerable?t[e]=r:Rr(t,e,r),t},Li=function(t,e,r,n){if(t){var o=r?t:t.prototype;zr(o,Kr)||Fr(o,Kr,{configurable:!0,value:e}),n&&!qr&&Hr(o,'toString',Qr)}},xi=function(t){var e=Wr(t),r=Vr.f;Gr&&e&&!e[Yr]&&r(e,Yr,{configurable:!0,get:function(){return this}})},$i=Lt,Di=k,Mi=ot,Bi=function(t,e){if(Jr(e,t))return t;throw Xr('Incorrect invocation')},Ui=On,qi=lo.set,Fi=Co,Hi=function(t,e){var r=ko.console;r&&r.error&&(1==arguments.length?r.error(t):r.error(t,e))},zi=jo,Qi=Do,Ki=si,Wi=ai,Vi=Pi,Gi=Ei.CONSTRUCTOR,Yi=Ei.REJECTION_EVENT,Ji=Ki.getterFor('Promise'),Xi=Ki.set,Zi=Wi&&Wi.prototype,ts=Wi,es=Zi,rs=ki.TypeError,ns=ki.document,os=ki.process,is=Vi.f,ss=is,as=!!(ns&&ns.createEvent&&ki.dispatchEvent),us=function(t){var e;return!(!Mi(t)||!Di(e=t.then))&&e},cs=function(t,e){var r,n,o,i=e.value,s=1==e.state,a=s?t.ok:t.fail,u=t.resolve,c=t.reject,h=t.domain;try{a?(s||(2===e.rejection&&ps(e),e.rejection=1),!0===a?r=i:(h&&h.enter(),r=a(i),h&&(h.exit(),o=!0)),r===t.promise?c(rs('Promise-chain cycle')):(n=us(r))?ji(n,r,u,c):u(r)):c(i)}catch(t){h&&!o&&h.exit(),c(t)}},hs=function(t,e){t.notified||(t.notified=!0,Fi((function(){for(var r,n=t.reactions;r=n.get();)cs(r,t);t.notified=!1,e&&!t.rejection&&fs(t)})))},ls=function(t,e,r){var n,o;as?((n=ns.createEvent('Event')).promise=e,n.reason=r,n.initEvent(t,!1,!0),ki.dispatchEvent(n)):n={promise:e,reason:r},!Yi&&(o=ki['on'+t])?o(n):'unhandledrejection'===t&&Hi('Unhandled promise rejection',r)},fs=function(t){ji(qi,ki,(function(){var e,r=t.facade,n=t.value;if(ds(t)&&(e=zi((function(){Ci?os.emit('unhandledRejection',n,r):ls('unhandledrejection',r,n)})),t.rejection=Ci||ds(t)?2:1,e.error))throw e.value}))},ds=function(t){return 1!==t.rejection&&!t.parent},ps=function(t){ji(qi,ki,(function(){var e=t.facade;Ci?os.emit('rejectionHandled',e):ls('rejectionhandled',e,t.value)}))},vs=function(t,e,r){return function(n){t(e,n,r)}},ms=function(t,e,r){t.done||(t.done=!0,r&&(t=r),t.value=e,t.state=2,hs(t,!0))},ys=function(t,e,r){if(!t.done){t.done=!0,r&&(t=r);try{if(t.facade===e)throw rs('Promise can\'t be resolved itself');var n=us(e);n?Fi((function(){var r={done:!1};try{ji(n,e,vs(ys,r,t),vs(ms,r,t))}catch(e){ms(r,e,t)}})):(t.value=e,t.state=1,hs(t,!1))}catch(e){ms({done:!1},e,t)}}};Gi&&(es=(ts=function(t){Bi(this,es),$i(t),ji(Oi,this);var e=Ji(this);try{t(vs(ys,e),vs(ms,e))}catch(t){ms(e,t)}}).prototype,(Oi=function(t){Xi(this,{type:'Promise',done:!1,notified:!1,parent:!1,reactions:new Qi,rejection:!1,state:0,value:void 0})}).prototype=Ii(es,'then',(function(t,e){var r=Ji(this),n=is(Ui(this,ts));return r.parent=!0,n.ok=!Di(t)||t,n.fail=Di(e)&&e,n.domain=Ci?os.domain:void 0,0==r.state?r.reactions.add(n):Fi((function(){cs(n,r)})),n.promise})),Ri=function(){var t=new Oi,e=Ji(t);this.promise=t,this.resolve=vs(ys,e),this.reject=vs(ms,e)},Vi.f=is=function(t){return t===ts||undefined===t?new Ri(t):ss(t)}),Ni({global:!0,constructor:!0,wrap:!0,forced:Gi},{Promise:ts}),Li(ts,'Promise',!1,!0),xi('Promise');var gs={},bs=gs,ws=de('iterator'),Ts=Array.prototype,Ss=Math.ceil,Es=Math.floor,Ps=Math.trunc||function(t){var e=+t;return(e>0?Es:Ss)(e)},_s=function(t){var e=+t;return e!=e||0===e?0:Ps(e)},As=Math.min,Os=function(t){return t>0?As(_s(t),9007199254740991):0},Rs=Mr,Ns=$t,Cs=gs,ks=de('iterator'),js=function(t){if(null!=t)return Ns(t,ks)||Ns(t,'@@iterator')||Cs[Rs(t)]},Is=$,Ls=Lt,xs=nr,$s=Ct,Ds=js,Ms=TypeError,Bs=$,Us=nr,qs=$t,Fs=Je,Hs=$,zs=nr,Qs=Ct,Ks=function(t){return void 0!==t&&(bs.Array===t||Ts[ws]===t)},Ws=function(t){return Os(t.length)},Vs=lt,Gs=function(t,e){var r=arguments.length<2?Ds(t):e;if(Ls(r))return xs(Is(r,t));throw Ms($s(t)+' is not iterable')},Ys=js,Js=function(t,e,r){var n,o;Us(t);try{if(!(n=qs(t,'return'))){if('throw'===e)throw r;return r}n=Bs(n,t)}catch(t){o=!0,n=t}if('throw'===e)throw r;if(o)throw n;return Us(n),r},Xs=TypeError,Zs=function(t,e){this.stopped=t,this.result=e},ta=Zs.prototype,ea=function(t,e,r){var n,o,i,s,a,u,c,h=r&&r.that,l=!(!r||!r.AS_ENTRIES),f=!(!r||!r.IS_RECORD),d=!(!r||!r.IS_ITERATOR),p=!(!r||!r.INTERRUPTED),v=Fs(e,h),m=function(t){return n&&Js(n,'normal',t),new Zs(!0,t)},y=function(t){return l?(zs(t),p?v(t[0],t[1],m):v(t[0],t[1])):p?v(t,m):v(t)};if(f)n=t.iterator;else if(d)n=t;else{if(!(o=Ys(t)))throw Xs(Qs(t)+' is not iterable');if(Ks(o)){for(i=0,s=Ws(t);s>i;i++)if((a=y(t[i]))&&Vs(ta,a))return a;return new Zs(!1)}n=Gs(t,o)}for(u=f?t.next:n.next;!(c=Hs(u,n)).done;){try{a=y(c.value)}catch(t){Js(n,'throw',t)}if('object'==typeof a&&a&&Vs(ta,a))return a}return new Zs(!1)},ra=de('iterator'),na=!1;try{var oa=0,ia={next:function(){return{done:!!oa++}},return:function(){na=!0}};ia[ra]=function(){return this},Array.from(ia,(function(){throw 2}))}catch(t){}var sa=ai,aa=Ei.CONSTRUCTOR||!function(t,e){if(!e&&!na)return!1;var r=!1;try{var n={};n[ra]=function(){return{next:function(){return{done:r=!0}}}},t(n)}catch(t){}return r}((function(t){sa.all(t).then(void 0,(function(){}))})),ua=$,ca=Lt,ha=Pi,la=jo,fa=ea;Ar({target:'Promise',stat:!0,forced:aa},{all:function(t){var e=this,r=ha.f(e),n=r.resolve,o=r.reject,i=la((function(){var r=ca(e.resolve),i=[],s=0,a=1;fa(t,(function(t){var u=s++,c=!1;a++,ua(r,e,t).then((function(t){c||(c=!0,i[u]=t,--a||n(i))}),o)})),--a||n(i)}));return i.error&&o(i.value),r.promise}});var da=Ar,pa=Ei.CONSTRUCTOR;ai&&ai.prototype,da({target:'Promise',proto:!0,forced:pa,real:!0},{catch:function(t){return this.then(void 0,t)}});var va=$,ma=Lt,ya=Pi,ga=jo,ba=ea;Ar({target:'Promise',stat:!0,forced:aa},{race:function(t){var e=this,r=ya.f(e),n=r.reject,o=ga((function(){var o=ma(e.resolve);ba(t,(function(t){va(o,e,t).then(r.resolve,n)}))}));return o.error&&n(o.value),r.promise}});var wa=$,Ta=Pi;Ar({target:'Promise',stat:!0,forced:Ei.CONSTRUCTOR},{reject:function(t){var e=Ta.f(this);return wa(e.reject,void 0,t),e.promise}});var Sa=nr,Ea=ot,Pa=Pi,_a=function(t,e){if(Sa(t),Ea(e)&&e.constructor===t)return e;var r=Pa.f(t);return(0,r.resolve)(e),r.promise},Aa=Ar,Oa=ai,Ra=Ei.CONSTRUCTOR,Na=_a,Ca=ht('Promise'),ka=!Ra;Aa({target:'Promise',stat:!0,forced:true},{resolve:function(t){return Na(ka&&this===Ca?Oa:this,t)}});var ja=Ar,Ia=ai,La=g,xa=ht,$a=k,Da=On,Ma=_a,Ba=Ia&&Ia.prototype;ja({target:'Promise',proto:!0,real:!0,forced:!!Ia&&La((function(){Ba.finally.call({then:function(){}},(function(){}))}))},{finally:function(t){var e=Da(this,xa('Promise')),r=$a(t);return this.then(r?function(r){return Ma(e,t()).then((function(){return r}))}:t,r?function(r){return Ma(e,t()).then((function(){throw r}))}:t)}});var Ua=ht('Promise','finally');const qa=(()=>{try{const t=Date.now().toString(),e=window.localStorage;e.setItem(t,t);const r=e.getItem(t)===t;return e.removeItem(t),r?e:null}catch(t){return null}})();var Fa,Ha,za,Qa,Ka,Wa,Va,Ga={get:t=>function(t){const e=qa?qa.getItem('_one-stat_'+t):null;if(null===e)return null;try{return JSON.parse(e)}catch(t){return null}}(t)||null,set(t,e){!function(t,e){try{qa&&qa.setItem('_one-stat_'+t,JSON.stringify(e))}catch(t){}}(t,e)},remove(t){!function(t){qa&&qa.removeItem('_one-stat_'+t)}(t)}};!function(t){t.PROD='prod',t.VK_ALIAS='vk_alias',t.VIDEOTEST='videotest',t.TEST='test',t.AUTO='auto'}(Fa||(Fa={})),function(t){t.Q144P='144',t.Q240P='240',t.Q360P='360',t.Q480P='480',t.Q720P='720',t.Q1080P='1080',t.Q1440P='1440',t.Q2160P='2160',t.Q4320P='4320',t.UNKNOWN='unknown'}(Ha||(Ha={})),function(t){t.CHROMECAST='chromecast',t.APPLE_TV='appletv',t.PIP='pip',t.HEADPHONES='externalHeadphones',t.SCREEN=''}(za||(za={})),function(t){t.MP4='mp4',t.DASH='dash',t.DASH_SEP='dash_sep',t.ONDEMAND_DASH='ondemand_dash',t.HLS='hls',t.ONDEMAND_HLS='ondemand_hls',t.WEBM='webm',t.RTMP='rtmp',t.UNKNOWN='unknown'}(Qa||(Qa={})),function(t){t.AUTO='auto',t.MANUAL=''}(Ka||(Ka={})),function(t){t.HTTP1='http1',t.HTTP2='http2',t.HTTP3='http3'}(Wa||(Wa={})),function(t){t[t.YES=1]='YES',t[t.NO=0]='NO'}(Va||(Va={}));const Ya={[Fa.PROD]:'https://api.ok.ru',[Fa.VK_ALIAS]:'https://api.mycdn.me',[Fa.VIDEOTEST]:'https://videotestapi.ok.ru/api',[Fa.TEST]:'https://apitest.ok.ru',[Fa.AUTO]:''},Ja={start:1e3,factor:1.5,max:3e5,random:.1};var Xa;!function(t){t[t.PARAM_SESSION_EXPIRED=102]='PARAM_SESSION_EXPIRED',t[t.PARAM_SESSION_KEY=103]='PARAM_SESSION_KEY',t[t.PARAM_SIGNATURE=104]='PARAM_SIGNATURE',t[t.AUTH_LOGIN=401]='AUTH_LOGIN'}(Xa||(Xa={}));class Za{constructor(e){this.consequentAuthErrors=0,this.authorized$=new t(!1),this.params=e;const r=Ga.get('uuid');r?this.uuid=String(r):(this.uuid=function(){const t='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''),e=new Array(36);let r,n,o=0;for(n=0;n<36;n++)8===n||13===n||18===n||23===n?e[n]='-':14===n?e[n]='4':(o<=2&&(o=33554432+16777216*Math.random()|0),r=15&o,o>>=4,e[n]=t[19===n?3&r|8:r]);return e.join('')}(),Ga.set('uuid',this.uuid))}authorize(t){return p(this,void 0,void 0,(function*(){return this.authToken=null!=t?t:yield this.refreshAuthToken(),this._authorizeWithBackoff()}))}logBeacon(t){const e=this.createLogParams(t),r=this.sessionKey;if(!r)return;this.params.apiTransport.sendBeacon('log.externalLog',e,r)||this.logRequest(t)}logRequest(t){var e;return p(this,void 0,void 0,(function*(){const n='log.externalLog',o=this.createLogParams(t),i=null!==(e=this.sessionKey)&&void 0!==e?e:yield this._authorizeWithBackoff();if(!i)return;const s=(t,e=this.params.requestRetryCount)=>p(this,void 0,void 0,(function*(){try{return yield this.params.apiTransport.sendRequest(n,o,i)}catch(o){if(!o||!('error_code'in o))return void this.params.error$.next({id:'logRequestUnknown',category:r.NETWORK,message:`Unknown ${n} error`,thrown:o});const i=null==o?void 0:o.error_code;switch(i){case Xa.PARAM_SESSION_EXPIRED:case Xa.PARAM_SESSION_KEY:case Xa.PARAM_SIGNATURE:return this.authorized$.next(!1),this.sessionKey=yield this._authorizeWithBackoff(),e>0?s(t,e-1):void 0;case Xa.AUTH_LOGIN:return this.authorized$.next(!1),this.authToken=yield this.refreshAuthToken(),this.sessionKey=yield this._authorizeWithBackoff(),e>0?s(t,e-1):void 0;default:return void this.params.error$.next({id:`LogRequest#${i}`,category:r.EXTERNAL_API,message:`${n} error`,data:o})}}}));return s(t)}))}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}refreshAuthToken(){return p(this,void 0,void 0,(function*(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=Ua(this.params.refreshAuthToken(),(()=>{this.refreshAuthTokenPromise=void 0}))),this.refreshAuthTokenPromise}))}createLogParams(t){return{collector:'ok.mobile.apps.video',data:JSON.stringify({application:'@vkontakte/videoplayer-statistics:1.0.29',platform:'WEB',items:t.map((t=>Object.assign(Object.assign({},t),{time:0,type:1})))})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();const t=e(this.consequentAuthErrors,Ja);return new Promise((e=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout((()=>{Ua(this._authorize().then(e).catch((t=>this.params.error$.next({id:'AuthorizeBackoff',category:r.NETWORK,message:'Otherwise unhandle errror in authrization',thrown:t}))),(()=>this.backoffTimeoutId=0))}),t))}))}_authorize(){return p(this,void 0,void 0,(function*(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);const t={session_data:{version:2,device_id:this.uuid,client_version:'1.0.29'.split('-')[0],client_type:'SDK_JS'}};return void 0!==this.authToken&&(t.session_data.auth_token=this.authToken,t.session_data.version=3),this.authorizePromise=Ua(this.params.apiTransport.sendRequest('auth.anonymLogin',t).then((t=>{var e;return t&&t.session_key||this.params.error$.next({id:'AuthorizeFailed',category:r.EXTERNAL_API,message:'No session key',data:t}),this.sessionKey=null!==(e=null==t?void 0:t.session_key)&&void 0!==e?e:void 0,this.sessionKey})).catch((t=>p(this,void 0,void 0,(function*(){this.sessionKey=void 0;const e=null==t?void 0:t.error_code;switch(e){case Xa.AUTH_LOGIN:return this.authToken=yield this.refreshAuthToken(),this._authorizeWithBackoff()}e?this.params.error$.next({id:`Authorize#${e}`,category:r.EXTERNAL_API,message:'authorize error',data:t}):this.params.error$.next({id:'AuthorizeUnknown',category:r.NETWORK,message:'authorize error',thrown:t})})))),(()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(void 0!==this.sessionKey)})),this.authorizePromise}))}}function tu(t){return t.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log('__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill'),!0):'function'==typeof t.Request&&!t.Request.prototype.hasOwnProperty('signal')||!t.AbortController}const eu=tu({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),ru=eu?function(t){'function'==typeof t&&(t={fetch:t});const{fetch:e,Request:r=e.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o=!1}=t;if(!tu({fetch:e,Request:r,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o}))return{fetch:e,Request:i};let i=r;(i&&!i.prototype.hasOwnProperty('signal')||o)&&(i=function(t,e){let n;e&&e.signal&&(n=e.signal,delete e.signal);const o=new r(t,e);return n&&Object.defineProperty(o,'signal',{writable:!1,enumerable:!1,configurable:!0,value:n}),o},i.prototype=r.prototype);const s=e;return{fetch:(t,e)=>{const r=i&&i.prototype.isPrototypeOf(t)?t.signal:e?e.signal:void 0;if(r){let n;try{n=new DOMException('Aborted','AbortError')}catch(t){n=new Error('Aborted'),n.name='AbortError'}if(r.aborted)return Promise.reject(n);const o=new Promise(((t,e)=>{r.addEventListener('abort',(()=>e(n)),{once:!0})}));return e&&e.signal&&delete e.signal,Promise.race([o,s(t,e)])}return s(t,e)},Request:i}}({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,nu=eu?ru.fetch:window.fetch;eu?ru.Request:window.Request;class ou{constructor(t){this.params=t,this.apiKey=t.apiKey,this.apiEnv=t.apiEnv,this.apiBaseUrl=t.apiBaseUrl,this.timeSynchronisation=t.timeSynchronisation,this.isApiBaseUrlFetched=!1}resolveApiBaseUrl(){var t;return p(this,void 0,void 0,(function*(){if(this.apiEnv!==Fa.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const e=atob('aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ='),r=yield nu(e,{method:'GET',mode:'cors',cache:'no-cache'}),n=yield r.json(),o=null===(t=null==n?void 0:n.Answer[0])||void 0===t?void 0:t.data;if(!o)throw new Error('Wrong DNS response');return o}catch(t){return this.params.error$.next({id:'OneStat:ApiTransport:resolveApiBaseUrl',category:r.NETWORK,message:'Unhandled resolve api base url error',thrown:t}),Ya[Fa.VK_ALIAS]}finally{this.isApiBaseUrlFetched=!0}}))}sendBeacon(t,e,n){if(!window.Blob||!window.navigator.sendBeacon)return!1;const o=this._prepareQueryParams({method:t,queryParams:e,sessionKey:n}),i=new window.Blob([o.toString()],{type:'application/x-www-form-urlencoded'});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,i)}catch(n){this.params.error$.next({id:'OneStat:ApiTransport:sendBeacon',category:r.NETWORK,message:'Unhandled beacon error',thrown:n,data:{method:t,params:e}})}return!1}sendRequest(t,e,o){return p(this,void 0,void 0,(function*(){const i=n(),s=s=>{s instanceof TypeError&&['Failed to fetch','NetworkError when attempting to fetch resource.'].includes(s.message)?this.params.error$.next({id:'Network',category:r.NETWORK,message:'Request failed',thrown:s}):this.params.error$.next({id:'OneStat:ApiTransport:sendRequest',category:r.NETWORK,message:'Unhandled request error',thrown:s,data:{method:t,params:e,sessionKey:o,time:n()-i}})};return this.apiBaseUrl=yield this.resolveApiBaseUrl(),nu(`${this.apiBaseUrl}/fb.do`,{method:'post',headers:{'Content-type':'application/x-www-form-urlencoded'},body:this._prepareQueryParams({method:t,queryParams:e,sessionKey:o})}).then((t=>{var e;const r=0===Number(t.headers.get('content-length')),o=new Date(null!==(e=t.headers.get('date'))&&void 0!==e?e:'').getTime(),a=n()-i;if(isFinite(o)&&this.timeSynchronisation.addServerTime(o,a),!r)return t.json().then((t=>Object.prototype.hasOwnProperty.call(t,'error_msg')?Promise.reject(t):t),s)}),s)}))}_prepareQueryParams(t){const e=new URLSearchParams({format:'JSON',method:t.method,application_key:this.apiKey});return void 0!==t.sessionKey&&e.append('session_key',t.sessionKey),Object.entries(t.queryParams).forEach((([t,r])=>e.append(t,'string'==typeof r?r:JSON.stringify(r)))),e}}class iu{constructor(t){this.requestQueue=[],this.isPaused=!1,this.debouncedFlush=d((()=>{var t;try{this.flush()}catch(e){this.error$.next({id:'LoggerError',category:r.WTF,message:null!==(t=String(e))&&void 0!==t?t:'Unknown logger error',thrown:e})}}),3e3,{maxWait:15e3}),this.api=t.api,this.error$=t.error$,this.subscription=this.api.authorized$.subscribe((t=>{t&&this.debouncedFlush()}))}log(t){this.requestQueue.push(t),this.isPaused||this.debouncedFlush()}flush(t=!1){0!==this.requestQueue.length&&(this.api.authorized$.getValue()?(t?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[]):t||this.api.authorize(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe()}}class su{constructor(t){this.offset=void 0,this.offset=t}getOffset(){var t;return null!==(t=this.offset)&&void 0!==t?t:0}setOffset(t){this.offset=t}now(){var t;return Date.now()+(null!==(t=this.offset)&&void 0!==t?t:0)}date(t=new Date){var e;return t.setTime(t.getTime()+(null!==(e=this.offset)&&void 0!==e?e:0)),t}addServerTime(t,e){const r=t-Date.now()-e/2;if(Math.abs(r)<1e3)this.offset=0;else if(void 0===this.offset)this.offset=Math.round(r);else{const t=.2;this.offset=Math.round(t*r+(1-t)*this.offset)}}}const au=()=>Math.floor(Math.random()*Math.pow(2,32)).toString(36).padStart(8,'0'),uu=t=>t&&{[h.HTTP1]:Wa.HTTP1,[h.HTTP2]:Wa.HTTP2,[h.QUIC]:Wa.HTTP3}[t],cu=t=>{if(void 0!==t)switch(t){case l.MPEG:return Qa.MP4;case l.DASH:case l.DASH_LIVE:return Qa.DASH;case l.DASH_SEP:return Qa.DASH_SEP;case l.DASH_ONDEMAND:return Qa.ONDEMAND_DASH;case l.DASH_WEBM:case l.DASH_LIVE_WEBM:return Qa.WEBM;case l.HLS:case l.HLS_LIVE:return Qa.HLS;case l.HLS_ONDEMAND:return Qa.ONDEMAND_HLS;case l.WEB_RTC_LIVE:return Qa.RTMP;default:return o(t)}};class hu{constructor(t,e){var r;this.subscription=new i,this.timeSynchronisation=new su,this.vsid=au(),this.fieldBlacklist=[],this.statContext=t,this.config=Object.assign(Object.assign({},null!==(r=e.config)&&void 0!==r?r:{}),{requestRetryCount:1});const n=new s;this.experimental={error$:n};const o=new ou({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:Ya[e.apiEnv],apiEnv:e.apiEnv,error$:n,timeSynchronisation:this.timeSynchronisation});this.api=new Za({apiTransport:o,refreshAuthToken:e.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:n}),this.logger=new iu({api:this.api,error$:n}),this.subscription.add(a(window,'beforeunload').subscribe((()=>this.logger.flush(!0))))}updateContext(t){this.statContext=Object.assign(Object.assign({},this.statContext),t)}attachTo(t){let e;return(new i).add(t.events.started$.subscribe((()=>{this.logStarted({position:t.info.position$.getValue()})}))).add(t.events.looped$.subscribe((()=>{this.resetViewSession(),this.logStarted({position:t.info.position$.getValue()})}))).add(t.events.seeked$.subscribe((()=>{this.logSeek()}))).add(t.events.willPause$.subscribe((()=>{this.logPause({position:t.info.position$.getValue()})}))).add(t.events.willResume$.subscribe((()=>{this.logPlay()}))).add(t.events.managedError$.subscribe((({id:t})=>{this.logError({errorType:t})}))).add(t.events.fatalError$.subscribe((({id:t})=>{this.logError({errorType:t})}))).add(t.events.inited$.subscribe((()=>{this.logInited()}))).add(t.events.canplay$.subscribe((t=>{this.logReady({time:t})}))).add(t.events.firstBytes$.subscribe((t=>{this.logFirstBytes({time:t})}))).add(t.events.firstFrame$.subscribe((t=>{this.logFirstFrame({time:t})}))).add(t.events.watchCoverageRecord$.subscribe((t=>{this.logWatchCoverageRecord(t)}))).add(t.events.watchCoverageLive$.subscribe((t=>{this.logWatchCoverageLive(t)}))).add(t.info.isStalled$.subscribe((t=>{t?e=n():(u(e)&&this.logEmptyBuffer({duration:n()-e}),e=void 0)}))).add(t.events.ended$.subscribe((()=>{const e=t.info.throughputEstimation$.getValue();u(e)&&this.logDownloadSpeed({speed:e/8})}))).add(t.info.hostname$.subscribe((t=>{this.updateContext({cdnHostname:t})}))).add(t.info.httpConnectionType$.subscribe((t=>{this.updateContext({connectionType:uu(t)})}))).add(t.info.httpConnectionReused$.subscribe((t=>{this.updateContext({connectionReused:t})}))).add(t.info.currentQuality$.subscribe((t=>{var e;this.updateContext({quality:(e=t,e&&{[c.INVARIANT]:Ha.UNKNOWN,[c.Q_144P]:Ha.Q144P,[c.Q_240P]:Ha.Q240P,[c.Q_360P]:Ha.Q360P,[c.Q_480P]:Ha.Q480P,[c.Q_720P]:Ha.Q720P,[c.Q_1080P]:Ha.Q1080P,[c.Q_1440P]:Ha.Q1440P,[c.Q_2160P]:Ha.Q2160P,[c.Q_4320P]:Ha.Q4320P}[e])})}))).add(t.info.currentFormat$.subscribe((t=>{this.updateContext({contentType:cu(t)})}))).add(t.info.chromecastState$.subscribe((t=>{this.updateContext({destination:t===f.CONNECTED?za.CHROMECAST:za.SCREEN})})))}authorize(t){return this.api.authorize(t)}pause(){this.logger.pause()}resume(){this.logger.resume()}destroy(){this.logger.flush(),this.subscription.unsubscribe(),this.api.destroy(),this.logger.destroy()}resetViewSession(){this.vsid=au()}setFieldBlacklist(t=[]){this.fieldBlacklist=t}logInited(){this.log({operation:'init'})}logReady(t){this.log({operation:'player_ready',param:String(t.time)})}logStarted(t){this.log({operation:'play',param:String(Math.round(t.position))})}logPlay(){this.log({operation:'play_toggle'})}logPause(t){this.log({operation:'pause',param:String(Math.round(t.position))})}logSeek(){this.log({operation:'seek'})}logFirstBytes(t){this.log({operation:'first_bytes',param:String(t.time)})}logFirstFrame(t){this.log({operation:'first_frame',param:String(t.time)})}logError(t){this.log({operation:'error',param:t.errorType})}logWatchCoverageRecord(t){this.log({operation:'watch_coverage_record',param:`${t.start}-${t.end}`}),this.logger.flush(!0)}logWatchCoverageLive(t){const e=t.start+this.timeSynchronisation.getOffset(),r=t.end+this.timeSynchronisation.getOffset();this.log({operation:'watch_coverage_live',param:`${e}-${r}`}),this.logger.flush(!0)}logEmptyBuffer(t){this.log({operation:'empty_buffer',param:String(t.duration)})}logDownloadSpeed(t){this.log({operation:'download_speed',param:String(t.speed)})}logAdSlotRequest(){this.log({operation:'adv',param:'slot_request'})}logAdStarted(t){this.log({operation:'adv',param:t})}logAdPaused(){this.log({operation:'adv',param:'pause'})}logAdResumed(){this.log({operation:'adv',param:'resume'})}logAdEnded(){this.log({operation:'adv',param:'ended'})}logAdSkipped(){this.log({operation:'adv',param:'skip'})}logAdClicked(){this.log({operation:'adv',param:'click'})}log(t){const e=this.createLogItem(t);this.logger.log(e)}createLogItem({operation:t,param:e}){const r=this.timeSynchronisation.now(),n={vsid:this.vsid,vid:this.statContext.movieId,quality:this.statContext.quality,dst:this.statContext.destination,ct:this.statContext.contentType,aid:this.statContext.albumId,place:this.statContext.place,cdn_host:this.statContext.cdnHostname,connection_type:this.statContext.connectionType,connection_reused:!0===this.statContext.connectionReused?Va.YES:!1===this.statContext.connectionReused?Va.NO:void 0,stat_type:!0===this.statContext.autoplay?Ka.AUTO:!1===this.statContext.autoplay?Ka.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode};void 0!==e&&(n.param=e);for(const t of this.fieldBlacklist)delete n[t];return{operation:t,timestamp:r,custom:n}}}export{Fa as ApiEnv,Wa as ConnectionType,Qa as ContentType,hu as OneStat,Ha as Quality,za as ScreenDestination};
|
|
6
|
+
import{ValueSubject as Oo,getExponentialDelay as Po,ErrorCategory as E,now as ie,assertNever as _o,Subscription as Jr,Subject as Io,fromEvent as wo,isNonNullable as Xr}from"@vkontakte/videoplayer-shared/es2015.esm.js";import{VideoQuality as T,HttpConnectionType as ze,VideoFormat as m,ChromecastState as Ro}from"@vkontakte/videoplayer-core/es2015.esm.js";import Ao from"lodash/debounce.js";function N(e,r,t,n){function o(a){return a instanceof t?a:new t(function(i){i(a)})}return new(t||(t=Promise))(function(a,i){function v(c){try{s(n.next(c))}catch(l){i(l)}}function u(c){try{s(n.throw(c))}catch(l){i(l)}}function s(c){c.done?a(c.value):o(c.value).then(v,u)}s((n=n.apply(e,r||[])).next())})}var Zr=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},pe=function(e){return e&&e.Math==Math&&e},p=pe(typeof globalThis=="object"&&globalThis)||pe(typeof window=="object"&&window)||pe(typeof self=="object"&&self)||pe(typeof Zr=="object"&&Zr)||function(){return this}()||Function("return this")(),_=function(e){try{return!!e()}catch(r){return!0}},Co=_,ke=!Co(function(){var e=function(){}.bind();return typeof e!="function"||e.hasOwnProperty("prototype")}),No=ke,un=Function.prototype,et=un.apply,rt=un.call,ln=typeof Reflect=="object"&&Reflect.apply||(No?rt.bind(et):function(){return rt.apply(et,arguments)}),vn=ke,fn=Function.prototype,Er=fn.call,Do=vn&&fn.bind.bind(Er,Er),I=vn?Do:function(e){return function(){return Er.apply(e,arguments)}},hn=I,jo=hn({}.toString),Lo=hn("".slice),Be=function(e){return Lo(jo(e),8,-1)},Mo=Be,Uo=I,dn=function(e){if(Mo(e)==="Function")return Uo(e)},Sr=typeof document=="object"&&document.all,ko=typeof Sr=="undefined"&&Sr!==void 0,pn={all:Sr,IS_HTMLDDA:ko},yn=pn,Bo=yn.all,d=yn.IS_HTMLDDA?function(e){return typeof e=="function"||e===Bo}:function(e){return typeof e=="function"},Lr={},xo=_,re=!xo(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),Fo=ke,ye=Function.prototype.call,w=Fo?ye.bind(ye):function(){return ye.apply(ye,arguments)},gn={},$n={}.propertyIsEnumerable,bn=Object.getOwnPropertyDescriptor,Ho=bn&&!$n.call({1:2},1);gn.f=Ho?function(r){var t=bn(this,r);return!!t&&t.enumerable}:$n;var mn=function(e,r){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:r}},Ko=I,qo=_,Wo=Be,Qe=Object,Vo=Ko("".split),Go=qo(function(){return!Qe("z").propertyIsEnumerable(0)})?function(e){return Wo(e)=="String"?Vo(e,""):Qe(e)}:Qe,xe=function(e){return e==null},zo=xe,Qo=TypeError,En=function(e){if(zo(e))throw Qo("Can't call method on "+e);return e},Yo=Go,Jo=En,Xo=function(e){return Yo(Jo(e))},tt=d,Sn=pn,Zo=Sn.all,x=Sn.IS_HTMLDDA?function(e){return typeof e=="object"?e!==null:tt(e)||e===Zo}:function(e){return typeof e=="object"?e!==null:tt(e)},Tn={},Ye=Tn,Je=p,ea=d,nt=function(e){return ea(e)?e:void 0},j=function(e,r){return arguments.length<2?nt(Ye[e])||nt(Je[e]):Ye[e]&&Ye[e][r]||Je[e]&&Je[e][r]},ra=I,Mr=ra({}.isPrototypeOf),Fe=typeof navigator!="undefined"&&String(navigator.userAgent)||"",On=p,Xe=Fe,ot=On.process,at=On.Deno,it=ot&&ot.versions||at&&at.version,st=it&&it.v8,S,we;st&&(S=st.split("."),we=S[0]>0&&S[0]<4?1:+(S[0]+S[1]));!we&&Xe&&(S=Xe.match(/Edge\/(\d+)/),(!S||S[1]>=74)&&(S=Xe.match(/Chrome\/(\d+)/),S&&(we=+S[1])));var Pn=we,ct=Pn,ta=_,_n=!!Object.getOwnPropertySymbols&&!ta(function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&ct&&ct<41}),na=_n,In=na&&!Symbol.sham&&typeof Symbol.iterator=="symbol",oa=j,aa=d,ia=Mr,sa=In,ca=Object,wn=sa?function(e){return typeof e=="symbol"}:function(e){var r=oa("Symbol");return aa(r)&&ia(r.prototype,ca(e))},ua=String,He=function(e){try{return ua(e)}catch(r){return"Object"}},la=d,va=He,fa=TypeError,F=function(e){if(la(e))return e;throw fa(va(e)+" is not a function")},ha=F,da=xe,Ur=function(e,r){var t=e[r];return da(t)?void 0:ha(t)},Ze=w,er=d,rr=x,pa=TypeError,ya=function(e,r){var t,n;if(r==="string"&&er(t=e.toString)&&!rr(n=Ze(t,e))||er(t=e.valueOf)&&!rr(n=Ze(t,e))||r!=="string"&&er(t=e.toString)&&!rr(n=Ze(t,e)))return n;throw pa("Can't convert object to primitive value")},Re={},ga={get exports(){return Re},set exports(e){Re=e}},fe=!0,ut=p,$a=Object.defineProperty,ba=function(e,r){try{$a(ut,e,{value:r,configurable:!0,writable:!0})}catch(t){ut[e]=r}return r},ma=p,Ea=ba,lt="__core-js_shared__",Sa=ma[lt]||Ea(lt,{}),kr=Sa,vt=kr;(ga.exports=function(e,r){return vt[e]||(vt[e]=r!==void 0?r:{})})("versions",[]).push({version:"3.27.2",mode:"pure",copyright:"\xA9 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.27.2/LICENSE",source:"https://github.com/zloirock/core-js"});var Ta=En,Oa=Object,Pa=function(e){return Oa(Ta(e))},_a=I,Ia=Pa,wa=_a({}.hasOwnProperty),te=Object.hasOwn||function(r,t){return wa(Ia(r),t)},Ra=I,Aa=0,Ca=Math.random(),Na=Ra(1 .toString),Rn=function(e){return"Symbol("+(e===void 0?"":e)+")_"+Na(++Aa+Ca,36)},Da=p,ja=Re,ft=te,La=Rn,Ma=_n,Ua=In,Y=Da.Symbol,tr=ja("wks"),ka=Ua?Y.for||Y:Y&&Y.withoutSetter||La,R=function(e){return ft(tr,e)||(tr[e]=Ma&&ft(Y,e)?Y[e]:ka("Symbol."+e)),tr[e]},Ba=w,ht=x,dt=wn,xa=Ur,Fa=ya,Ha=R,Ka=TypeError,qa=Ha("toPrimitive"),Wa=function(e,r){if(!ht(e)||dt(e))return e;var t=xa(e,qa),n;if(t){if(r===void 0&&(r="default"),n=Ba(t,e,r),!ht(n)||dt(n))return n;throw Ka("Can't convert object to primitive value")}return r===void 0&&(r="number"),Fa(e,r)},Va=Wa,Ga=wn,An=function(e){var r=Va(e,"string");return Ga(r)?r:r+""},za=p,pt=x,Tr=za.document,Qa=pt(Tr)&&pt(Tr.createElement),Cn=function(e){return Qa?Tr.createElement(e):{}},Ya=re,Ja=_,Xa=Cn,Nn=!Ya&&!Ja(function(){return Object.defineProperty(Xa("div"),"a",{get:function(){return 7}}).a!=7}),Za=re,ei=w,ri=gn,ti=mn,ni=Xo,oi=An,ai=te,ii=Nn,yt=Object.getOwnPropertyDescriptor;Lr.f=Za?yt:function(r,t){if(r=ni(r),t=oi(t),ii)try{return yt(r,t)}catch(n){}if(ai(r,t))return ti(!ei(ri.f,r,t),r[t])};var si=_,ci=d,ui=/#|\.prototype\./,he=function(e,r){var t=vi[li(e)];return t==hi?!0:t==fi?!1:ci(r)?si(r):!!r},li=he.normalize=function(e){return String(e).replace(ui,".").toLowerCase()},vi=he.data={},fi=he.NATIVE="N",hi=he.POLYFILL="P",Dn=he,gt=dn,di=F,pi=ke,yi=gt(gt.bind),Ke=function(e,r){return di(e),r===void 0?e:pi?yi(e,r):function(){return e.apply(r,arguments)}},qe={},gi=re,$i=_,bi=gi&&$i(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),mi=x,Ei=String,Si=TypeError,H=function(e){if(mi(e))return e;throw Si(Ei(e)+" is not an object")},Ti=re,Oi=Nn,Pi=bi,ge=H,$t=An,_i=TypeError,nr=Object.defineProperty,Ii=Object.getOwnPropertyDescriptor,or="enumerable",ar="configurable",ir="writable";qe.f=Ti?Pi?function(r,t,n){if(ge(r),t=$t(t),ge(n),typeof r=="function"&&t==="prototype"&&"value"in n&&ir in n&&!n[ir]){var o=Ii(r,t);o&&o[ir]&&(r[t]=n.value,n={configurable:ar in n?n[ar]:o[ar],enumerable:or in n?n[or]:o[or],writable:!1})}return nr(r,t,n)}:nr:function(r,t,n){if(ge(r),t=$t(t),ge(n),Oi)try{return nr(r,t,n)}catch(o){}if("get"in n||"set"in n)throw _i("Accessors not supported");return"value"in n&&(r[t]=n.value),r};var wi=re,Ri=qe,Ai=mn,We=wi?function(e,r,t){return Ri.f(e,r,Ai(1,t))}:function(e,r,t){return e[r]=t,e},$e=p,Ci=ln,Ni=dn,Di=d,ji=Lr.f,Li=Dn,W=Tn,Mi=Ke,V=We,bt=te,Ui=function(e){var r=function(t,n,o){if(this instanceof r){switch(arguments.length){case 0:return new e;case 1:return new e(t);case 2:return new e(t,n)}return new e(t,n,o)}return Ci(e,this,arguments)};return r.prototype=e.prototype,r},K=function(e,r){var t=e.target,n=e.global,o=e.stat,a=e.proto,i=n?$e:o?$e[t]:($e[t]||{}).prototype,v=n?W:W[t]||V(W,t,{})[t],u=v.prototype,s,c,l,h,f,b,L,A,q;for(h in r)s=Li(n?h:t+(o?".":"#")+h,e.forced),c=!s&&i&&bt(i,h),b=v[h],c&&(e.dontCallGetSet?(q=ji(i,h),L=q&&q.value):L=i[h]),f=c&&L?L:r[h],!(c&&typeof b==typeof f)&&(e.bind&&c?A=Mi(f,$e):e.wrap&&c?A=Ui(f):a&&Di(f)?A=Ni(f):A=f,(e.sham||f&&f.sham||b&&b.sham)&&V(A,"sham",!0),V(v,h,A),a&&(l=t+"Prototype",bt(W,l)||V(W,l,{}),V(W[l],h,f),e.real&&u&&(s||!u[h])&&V(u,h,f)))},ki=Be,Ve=typeof process!="undefined"&&ki(process)=="process",Bi=We,Br=function(e,r,t,n){return n&&n.enumerable?e[r]=t:Bi(e,r,t),e},xi=d,Fi=String,Hi=TypeError,Ki=function(e){if(typeof e=="object"||xi(e))return e;throw Hi("Can't set "+Fi(e)+" as a prototype")},qi=I,Wi=H,Vi=Ki,Gi=Object.setPrototypeOf||("__proto__"in{}?function(){var e=!1,r={},t;try{t=qi(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set),t(r,[]),e=r instanceof Array}catch(n){}return function(o,a){return Wi(o),Vi(a),e?t(o,a):o.__proto__=a,o}}():void 0),zi=R,Qi=zi("toStringTag"),jn={};jn[Qi]="z";var xr=String(jn)==="[object z]",Yi=xr,Ji=d,Pe=Be,Xi=R,Zi=Xi("toStringTag"),es=Object,rs=Pe(function(){return arguments}())=="Arguments",ts=function(e,r){try{return e[r]}catch(t){}},Fr=Yi?Pe:function(e){var r,t,n;return e===void 0?"Undefined":e===null?"Null":typeof(t=ts(r=es(e),Zi))=="string"?t:rs?Pe(r):(n=Pe(r))=="Object"&&Ji(r.callee)?"Arguments":n},ns=xr,os=Fr,as=ns?{}.toString:function(){return"[object "+os(this)+"]"},is=xr,ss=qe.f,cs=We,us=te,ls=as,vs=R,mt=vs("toStringTag"),fs=function(e,r,t,n){if(e){var o=t?e:e.prototype;us(o,mt)||ss(o,mt,{configurable:!0,value:r}),n&&!is&&cs(o,"toString",ls)}},hs=j,ds=qe,ps=R,ys=re,Et=ps("species"),gs=function(e){var r=hs(e),t=ds.f;ys&&r&&!r[Et]&&t(r,Et,{configurable:!0,get:function(){return this}})},$s=Mr,bs=TypeError,ms=function(e,r){if($s(r,e))return e;throw bs("Incorrect invocation")},Es=I,Ss=d,Or=kr,Ts=Es(Function.toString);Ss(Or.inspectSource)||(Or.inspectSource=function(e){return Ts(e)});var Ln=Or.inspectSource,Os=I,Ps=_,Mn=d,_s=Fr,Is=j,ws=Ln,Un=function(){},Rs=[],kn=Is("Reflect","construct"),Hr=/^\s*(?:class|function)\b/,As=Os(Hr.exec),Cs=!Hr.exec(Un),ae=function(r){if(!Mn(r))return!1;try{return kn(Un,Rs,r),!0}catch(t){return!1}},Bn=function(r){if(!Mn(r))return!1;switch(_s(r)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Cs||!!As(Hr,ws(r))}catch(t){return!0}};Bn.sham=!0;var Ns=!kn||Ps(function(){var e;return ae(ae.call)||!ae(Object)||!ae(function(){e=!0})||e})?Bn:ae,Ds=Ns,js=He,Ls=TypeError,Ms=function(e){if(Ds(e))return e;throw Ls(js(e)+" is not a constructor")},St=H,Us=Ms,ks=xe,Bs=R,xs=Bs("species"),xn=function(e,r){var t=St(e).constructor,n;return t===void 0||ks(n=St(t)[xs])?r:Us(n)},Fs=j,Hs=Fs("document","documentElement"),Ks=I,qs=Ks([].slice),Ws=TypeError,Vs=function(e,r){if(e<r)throw Ws("Not enough arguments");return e},Gs=Fe,Fn=/(?:ipad|iphone|ipod).*applewebkit/i.test(Gs),y=p,zs=ln,Qs=Ke,Tt=d,Ys=te,Hn=_,Ot=Hs,Js=qs,Pt=Cn,Xs=Vs,Zs=Fn,ec=Ve,Pr=y.setImmediate,_r=y.clearImmediate,rc=y.process,sr=y.Dispatch,tc=y.Function,_t=y.MessageChannel,nc=y.String,cr=0,se={},It="onreadystatechange",le,M,ur,lr;Hn(function(){le=y.location});var Kr=function(e){if(Ys(se,e)){var r=se[e];delete se[e],r()}},vr=function(e){return function(){Kr(e)}},wt=function(e){Kr(e.data)},Rt=function(e){y.postMessage(nc(e),le.protocol+"//"+le.host)};(!Pr||!_r)&&(Pr=function(r){Xs(arguments.length,1);var t=Tt(r)?r:tc(r),n=Js(arguments,1);return se[++cr]=function(){zs(t,void 0,n)},M(cr),cr},_r=function(r){delete se[r]},ec?M=function(e){rc.nextTick(vr(e))}:sr&&sr.now?M=function(e){sr.now(vr(e))}:_t&&!Zs?(ur=new _t,lr=ur.port2,ur.port1.onmessage=wt,M=Qs(lr.postMessage,lr)):y.addEventListener&&Tt(y.postMessage)&&!y.importScripts&&le&&le.protocol!=="file:"&&!Hn(Rt)?(M=Rt,y.addEventListener("message",wt,!1)):It in Pt("script")?M=function(e){Ot.appendChild(Pt("script"))[It]=function(){Ot.removeChild(this),Kr(e)}}:M=function(e){setTimeout(vr(e),0)});var Kn={set:Pr,clear:_r},qn=function(){this.head=null,this.tail=null};qn.prototype={add:function(e){var r={item:e,next:null},t=this.tail;t?t.next=r:this.head=r,this.tail=r},get:function(){var e=this.head;if(e){var r=this.head=e.next;return r===null&&(this.tail=null),e.item}}};var Wn=qn,oc=Fe,ac=/ipad|iphone|ipod/i.test(oc)&&typeof Pebble!="undefined",ic=Fe,sc=/web0s(?!.*chrome)/i.test(ic),B=p,At=Ke,cc=Lr.f,fr=Kn.set,uc=Wn,lc=Fn,vc=ac,fc=sc,hr=Ve,Ct=B.MutationObserver||B.WebKitMutationObserver,Nt=B.document,Dt=B.process,be=B.Promise,jt=cc(B,"queueMicrotask"),Ir=jt&&jt.value,G,dr,pr,me,Lt;if(!Ir){var Ee=new uc,Se=function(){var e,r;for(hr&&(e=Dt.domain)&&e.exit();r=Ee.get();)try{r()}catch(t){throw Ee.head&&G(),t}e&&e.enter()};!lc&&!hr&&!fc&&Ct&&Nt?(dr=!0,pr=Nt.createTextNode(""),new Ct(Se).observe(pr,{characterData:!0}),G=function(){pr.data=dr=!dr}):!vc&&be&&be.resolve?(me=be.resolve(void 0),me.constructor=be,Lt=At(me.then,me),G=function(){Lt(Se)}):hr?G=function(){Dt.nextTick(Se)}:(fr=At(fr,B),G=function(){fr(Se)}),Ir=function(e){Ee.head||G(),Ee.add(e)}}var hc=Ir,dc=function(e,r){try{arguments.length==1?console.error(e):console.error(e,r)}catch(t){}},qr=function(e){try{return{error:!1,value:e()}}catch(r){return{error:!0,value:r}}},pc=p,yc=d,Mt=pc.WeakMap,gc=yc(Mt)&&/native code/.test(String(Mt)),$c=Re,bc=Rn,Ut=$c("keys"),mc=function(e){return Ut[e]||(Ut[e]=bc(e))},Ec={},Sc=gc,Vn=p,Tc=x,Oc=We,yr=te,gr=kr,Pc=mc,_c=Ec,kt="Object already initialized",wr=Vn.TypeError,Ic=Vn.WeakMap,Ae,ve,Ce,wc=function(e){return Ce(e)?ve(e):Ae(e,{})},Rc=function(e){return function(r){var t;if(!Tc(r)||(t=ve(r)).type!==e)throw wr("Incompatible receiver, "+e+" required");return t}};if(Sc||gr.state){var O=gr.state||(gr.state=new Ic);O.get=O.get,O.has=O.has,O.set=O.set,Ae=function(e,r){if(O.has(e))throw wr(kt);return r.facade=e,O.set(e,r),r},ve=function(e){return O.get(e)||{}},Ce=function(e){return O.has(e)}}else{var z=Pc("state");_c[z]=!0,Ae=function(e,r){if(yr(e,z))throw wr(kt);return r.facade=e,Oc(e,z,r),r},ve=function(e){return yr(e,z)?e[z]:{}},Ce=function(e){return yr(e,z)}}var Ac={set:Ae,get:ve,has:Ce,enforce:wc,getterFor:Rc},Cc=p,ne=Cc.Promise,Gn=typeof Deno=="object"&&Deno&&typeof Deno.version=="object",Nc=Gn,Dc=Ve,jc=!Nc&&!Dc&&typeof window=="object"&&typeof document=="object",Lc=p,ce=ne,Mc=d,Uc=Dn,kc=Ln,Bc=R,xc=jc,Fc=Gn,Hc=fe,$r=Pn,Bt=ce&&ce.prototype,Kc=Bc("species"),Rr=!1,zn=Mc(Lc.PromiseRejectionEvent),qc=Uc("Promise",function(){var e=kc(ce),r=e!==String(ce);if(!r&&$r===66||Hc&&!(Bt.catch&&Bt.finally))return!0;if(!$r||$r<51||!/native code/.test(e)){var t=new ce(function(a){a(1)}),n=function(a){a(function(){},function(){})},o=t.constructor={};if(o[Kc]=n,Rr=t.then(function(){})instanceof n,!Rr)return!0}return!r&&(xc||Fc)&&!zn}),de={CONSTRUCTOR:qc,REJECTION_EVENT:zn,SUBCLASSING:Rr},oe={},xt=F,Wc=TypeError,Vc=function(e){var r,t;this.promise=new e(function(n,o){if(r!==void 0||t!==void 0)throw Wc("Bad Promise constructor");r=n,t=o}),this.resolve=xt(r),this.reject=xt(t)};oe.f=function(e){return new Vc(e)};var Gc=K,zc=fe,Ne=Ve,D=p,Z=w,Ft=Br,Ht=Gi,Qc=fs,Yc=gs,Jc=F,_e=d,Xc=x,Zc=ms,eu=xn,Qn=Kn.set,Wr=hc,ru=dc,tu=qr,nu=Wn,Yn=Ac,De=ne,Vr=de,Jn=oe,Ge="Promise",Xn=Vr.CONSTRUCTOR,ou=Vr.REJECTION_EVENT,au=Vr.SUBCLASSING,br=Yn.getterFor(Ge),iu=Yn.set,Q=De&&De.prototype,U=De,Te=Q,Zn=D.TypeError,Ar=D.document,Gr=D.process,Cr=Jn.f,su=Cr,cu=!!(Ar&&Ar.createEvent&&D.dispatchEvent),eo="unhandledrejection",uu="rejectionhandled",Kt=0,ro=1,lu=2,zr=1,to=2,Oe,qt,vu,Wt,no=function(e){var r;return Xc(e)&&_e(r=e.then)?r:!1},oo=function(e,r){var t=r.value,n=r.state==ro,o=n?e.ok:e.fail,a=e.resolve,i=e.reject,v=e.domain,u,s,c;try{o?(n||(r.rejection===to&&hu(r),r.rejection=zr),o===!0?u=t:(v&&v.enter(),u=o(t),v&&(v.exit(),c=!0)),u===e.promise?i(Zn("Promise-chain cycle")):(s=no(u))?Z(s,u,a,i):a(u)):i(t)}catch(l){v&&!c&&v.exit(),i(l)}},ao=function(e,r){e.notified||(e.notified=!0,Wr(function(){for(var t=e.reactions,n;n=t.get();)oo(n,e);e.notified=!1,r&&!e.rejection&&fu(e)}))},io=function(e,r,t){var n,o;cu?(n=Ar.createEvent("Event"),n.promise=r,n.reason=t,n.initEvent(e,!1,!0),D.dispatchEvent(n)):n={promise:r,reason:t},!ou&&(o=D["on"+e])?o(n):e===eo&&ru("Unhandled promise rejection",t)},fu=function(e){Z(Qn,D,function(){var r=e.facade,t=e.value,n=Vt(e),o;if(n&&(o=tu(function(){Ne?Gr.emit("unhandledRejection",t,r):io(eo,r,t)}),e.rejection=Ne||Vt(e)?to:zr,o.error))throw o.value})},Vt=function(e){return e.rejection!==zr&&!e.parent},hu=function(e){Z(Qn,D,function(){var r=e.facade;Ne?Gr.emit("rejectionHandled",r):io(uu,r,e.value)})},J=function(e,r,t){return function(n){e(r,n,t)}},X=function(e,r,t){e.done||(e.done=!0,t&&(e=t),e.value=r,e.state=lu,ao(e,!0))},Nr=function(e,r,t){if(!e.done){e.done=!0,t&&(e=t);try{if(e.facade===r)throw Zn("Promise can't be resolved itself");var n=no(r);n?Wr(function(){var o={done:!1};try{Z(n,r,J(Nr,o,e),J(X,o,e))}catch(a){X(o,a,e)}}):(e.value=r,e.state=ro,ao(e,!1))}catch(o){X({done:!1},o,e)}}};if(Xn&&(U=function(r){Zc(this,Te),Jc(r),Z(Oe,this);var t=br(this);try{r(J(Nr,t),J(X,t))}catch(n){X(t,n)}},Te=U.prototype,Oe=function(r){iu(this,{type:Ge,done:!1,notified:!1,parent:!1,reactions:new nu,rejection:!1,state:Kt,value:void 0})},Oe.prototype=Ft(Te,"then",function(r,t){var n=br(this),o=Cr(eu(this,U));return n.parent=!0,o.ok=_e(r)?r:!0,o.fail=_e(t)&&t,o.domain=Ne?Gr.domain:void 0,n.state==Kt?n.reactions.add(o):Wr(function(){oo(o,n)}),o.promise}),qt=function(){var e=new Oe,r=br(e);this.promise=e,this.resolve=J(Nr,r),this.reject=J(X,r)},Jn.f=Cr=function(e){return e===U||e===vu?new qt(e):su(e)},!zc&&_e(De)&&Q!==Object.prototype)){Wt=Q.then,au||Ft(Q,"then",function(r,t){var n=this;return new U(function(o,a){Z(Wt,n,o,a)}).then(r,t)},{unsafe:!0});try{delete Q.constructor}catch(e){}Ht&&Ht(Q,Te)}Gc({global:!0,constructor:!0,wrap:!0,forced:Xn},{Promise:U});Qc(U,Ge,!1,!0);Yc(Ge);var so={},du=R,pu=so,yu=du("iterator"),gu=Array.prototype,$u=function(e){return e!==void 0&&(pu.Array===e||gu[yu]===e)},bu=Math.ceil,mu=Math.floor,Eu=Math.trunc||function(r){var t=+r;return(t>0?mu:bu)(t)},Su=Eu,Tu=function(e){var r=+e;return r!==r||r===0?0:Su(r)},Ou=Tu,Pu=Math.min,_u=function(e){return e>0?Pu(Ou(e),9007199254740991):0},Iu=_u,wu=function(e){return Iu(e.length)},Ru=Fr,Gt=Ur,Au=xe,Cu=so,Nu=R,Du=Nu("iterator"),co=function(e){if(!Au(e))return Gt(e,Du)||Gt(e,"@@iterator")||Cu[Ru(e)]},ju=w,Lu=F,Mu=H,Uu=He,ku=co,Bu=TypeError,xu=function(e,r){var t=arguments.length<2?ku(e):r;if(Lu(t))return Mu(ju(t,e));throw Bu(Uu(e)+" is not iterable")},Fu=w,zt=H,Hu=Ur,Ku=function(e,r,t){var n,o;zt(e);try{if(n=Hu(e,"return"),!n){if(r==="throw")throw t;return t}n=Fu(n,e)}catch(a){o=!0,n=a}if(r==="throw")throw t;if(o)throw n;return zt(n),t},qu=Ke,Wu=w,Vu=H,Gu=He,zu=$u,Qu=wu,Qt=Mr,Yu=xu,Ju=co,Yt=Ku,Xu=TypeError,Ie=function(e,r){this.stopped=e,this.result=r},Jt=Ie.prototype,uo=function(e,r,t){var n=t&&t.that,o=!!(t&&t.AS_ENTRIES),a=!!(t&&t.IS_RECORD),i=!!(t&&t.IS_ITERATOR),v=!!(t&&t.INTERRUPTED),u=qu(r,n),s,c,l,h,f,b,L,A=function(g){return s&&Yt(s,"normal",g),new Ie(!0,g)},q=function(g){return o?(Vu(g),v?u(g[0],g[1],A):u(g[0],g[1])):v?u(g,A):u(g)};if(a)s=e.iterator;else if(i)s=e;else{if(c=Ju(e),!c)throw Xu(Gu(e)+" is not iterable");if(zu(c)){for(l=0,h=Qu(e);h>l;l++)if(f=q(e[l]),f&&Qt(Jt,f))return f;return new Ie(!1)}s=Yu(e,c)}for(b=a?e.next:s.next;!(L=Wu(b,s)).done;){try{f=q(L.value)}catch(g){Yt(s,"throw",g)}if(typeof f=="object"&&f&&Qt(Jt,f))return f}return new Ie(!1)},Zu=R,lo=Zu("iterator"),vo=!1;try{var el=0,Xt={next:function(){return{done:!!el++}},return:function(){vo=!0}};Xt[lo]=function(){return this},Array.from(Xt,function(){throw 2})}catch(e){}var rl=function(e,r){if(!r&&!vo)return!1;var t=!1;try{var n={};n[lo]=function(){return{next:function(){return{done:t=!0}}}},e(n)}catch(o){}return t},tl=ne,nl=rl,ol=de.CONSTRUCTOR,fo=ol||!nl(function(e){tl.all(e).then(void 0,function(){})}),al=K,il=w,sl=F,cl=oe,ul=qr,ll=uo,vl=fo;al({target:"Promise",stat:!0,forced:vl},{all:function(r){var t=this,n=cl.f(t),o=n.resolve,a=n.reject,i=ul(function(){var v=sl(t.resolve),u=[],s=0,c=1;ll(r,function(l){var h=s++,f=!1;c++,il(v,t,l).then(function(b){f||(f=!0,u[h]=b,--c||o(u))},a)}),--c||o(u)});return i.error&&a(i.value),n.promise}});var fl=K,hl=fe,dl=de.CONSTRUCTOR,Dr=ne,pl=j,yl=d,gl=Br,Zt=Dr&&Dr.prototype;fl({target:"Promise",proto:!0,forced:dl,real:!0},{catch:function(e){return this.then(void 0,e)}});if(!hl&&yl(Dr)){var en=pl("Promise").prototype.catch;Zt.catch!==en&&gl(Zt,"catch",en,{unsafe:!0})}var $l=K,bl=w,ml=F,El=oe,Sl=qr,Tl=uo,Ol=fo;$l({target:"Promise",stat:!0,forced:Ol},{race:function(r){var t=this,n=El.f(t),o=n.reject,a=Sl(function(){var i=ml(t.resolve);Tl(r,function(v){bl(i,t,v).then(n.resolve,o)})});return a.error&&o(a.value),n.promise}});var Pl=K,_l=w,Il=oe,wl=de.CONSTRUCTOR;Pl({target:"Promise",stat:!0,forced:wl},{reject:function(r){var t=Il.f(this);return _l(t.reject,void 0,r),t.promise}});var Rl=H,Al=x,Cl=oe,ho=function(e,r){if(Rl(e),Al(r)&&r.constructor===e)return r;var t=Cl.f(e),n=t.resolve;return n(r),t.promise},Nl=K,Dl=j,po=fe,jl=ne,yo=de.CONSTRUCTOR,Ll=ho,Ml=Dl("Promise"),Ul=po&&!yo;Nl({target:"Promise",stat:!0,forced:po||yo},{resolve:function(r){return Ll(Ul&&this===Ml?jl:this,r)}});var kl=K,Bl=fe,je=ne,xl=_,go=j,$o=d,Fl=xn,rn=ho,Hl=Br,jr=je&&je.prototype,Kl=!!je&&xl(function(){jr.finally.call({then:function(){}},function(){})});kl({target:"Promise",proto:!0,real:!0,forced:Kl},{finally:function(e){var r=Fl(this,go("Promise")),t=$o(e);return this.then(t?function(n){return rn(r,e()).then(function(){return n})}:e,t?function(n){return rn(r,e()).then(function(){throw n})}:e)}});if(!Bl&&$o(je)){var tn=go("Promise").prototype.finally;jr.finally!==tn&&Hl(jr,"finally",tn,{unsafe:!0})}var ql=j,Wl=ql,Vl=Wl,Gl=Vl("Promise","finally"),zl=Gl,Ql=zl,Yl=Ql,Jl=Yl,mr=Jl;const Qr="_one-stat_",ee=(()=>{try{const e=Date.now().toString(),r=window.localStorage;r.setItem(e,e);const t=r.getItem(e)===e;return r.removeItem(e),t?r:null}catch(e){return null}})();function Xl(e){const r=ee?ee.getItem(Qr+e):null;if(r===null)return null;try{return JSON.parse(r)}catch(t){return null}}function Zl(e,r){try{ee&&ee.setItem(Qr+e,JSON.stringify(r))}catch(t){}}function ev(e){ee&&ee.removeItem(Qr+e)}var nn={get(e){return Xl(e)||null},set(e,r){Zl(e,r)},remove(e){ev(e)}};function rv(){const e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),r=new Array(36);let t=0,n,o;for(o=0;o<36;o++)o===8||o===13||o===18||o===23?r[o]="-":o===14?r[o]="4":(t<=2&&(t=33554432+Math.random()*16777216|0),n=t&15,t=t>>4,r[o]=e[o===19?n&3|8:n]);return r.join("")}var C;(function(e){e.PROD="prod",e.VK_ALIAS="vk_alias",e.VIDEOTEST="videotest",e.TEST="test",e.AUTO="auto"})(C||(C={}));var $;(function(e){e.Q144P="144",e.Q240P="240",e.Q360P="360",e.Q480P="480",e.Q720P="720",e.Q1080P="1080",e.Q1440P="1440",e.Q2160P="2160",e.Q4320P="4320",e.UNKNOWN="unknown"})($||($={}));var Le;(function(e){e.CHROMECAST="chromecast",e.APPLE_TV="appletv",e.PIP="pip",e.HEADPHONES="externalHeadphones",e.SCREEN=""})(Le||(Le={}));var P;(function(e){e.MP4="mp4",e.DASH="dash",e.DASH_SEP="dash_sep",e.ONDEMAND_DASH="ondemand_dash",e.HLS="hls",e.ONDEMAND_HLS="ondemand_hls",e.WEBM="webm",e.RTMP="rtmp",e.UNKNOWN="unknown"})(P||(P={}));var Me;(function(e){e.AUTO="auto",e.MANUAL=""})(Me||(Me={}));var ue;(function(e){e.HTTP1="http1",e.HTTP2="http2",e.HTTP3="http3"})(ue||(ue={}));var Ue;(function(e){e[e.YES=1]="YES",e[e.NO=0]="NO"})(Ue||(Ue={}));const on="1.0.31",tv="@vkontakte/videoplayer-statistics",nv="CIOPGQJGDIHBABABA",bo={[C.PROD]:"https://api.ok.ru",[C.VK_ALIAS]:"https://api.mycdn.me",[C.VIDEOTEST]:"https://videotestapi.ok.ru/api",[C.TEST]:"https://apitest.ok.ru",[C.AUTO]:""},ov={start:1e3,factor:1.5,max:5*60*1e3,random:.1};var k;(function(e){e[e.PARAM_SESSION_EXPIRED=102]="PARAM_SESSION_EXPIRED",e[e.PARAM_SESSION_KEY=103]="PARAM_SESSION_KEY",e[e.PARAM_SIGNATURE=104]="PARAM_SIGNATURE",e[e.AUTH_LOGIN=401]="AUTH_LOGIN"})(k||(k={}));class av{constructor(r){this.consequentAuthErrors=0,this.authorized$=new Oo(!1),this.params=r;const t=nn.get("uuid");t?this.uuid=String(t):(this.uuid=rv(),nn.set("uuid",this.uuid))}authorize(r){return N(this,void 0,void 0,function*(){return this.authToken=r!=null?r:yield this.refreshAuthToken(),this._authorizeWithBackoff()})}logBeacon(r){const t="log.externalLog",n=this.createLogParams(r),o=this.sessionKey;if(!o)return;this.params.apiTransport.sendBeacon(t,n,o)||this.logRequest(r)}logRequest(r){var t;return N(this,void 0,void 0,function*(){const n="log.externalLog",o=this.createLogParams(r),a=(t=this.sessionKey)!==null&&t!==void 0?t:yield this._authorizeWithBackoff();if(!a)return;const i=(v,u=this.params.requestRetryCount)=>N(this,void 0,void 0,function*(){try{return yield this.params.apiTransport.sendRequest(n,o,a)}catch(s){if(!s||!("error_code"in s)){this.params.error$.next({id:"logRequestUnknown",category:E.NETWORK,message:`Unknown ${n} error`,thrown:s});return}const c=s==null?void 0:s.error_code;switch(c){case k.PARAM_SESSION_EXPIRED:case k.PARAM_SESSION_KEY:case k.PARAM_SIGNATURE:return this.authorized$.next(!1),this.sessionKey=yield this._authorizeWithBackoff(),u>0?i(v,u-1):void 0;case k.AUTH_LOGIN:return this.authorized$.next(!1),this.authToken=yield this.refreshAuthToken(),this.sessionKey=yield this._authorizeWithBackoff(),u>0?i(v,u-1):void 0;default:{this.params.error$.next({id:`LogRequest#${c}`,category:E.EXTERNAL_API,message:`${n} error`,data:s});return}}}});return i(r)})}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}refreshAuthToken(){return N(this,void 0,void 0,function*(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=mr(this.params.refreshAuthToken(),()=>{this.refreshAuthTokenPromise=void 0})),this.refreshAuthTokenPromise})}createLogParams(r){return{collector:"ok.mobile.apps.video",data:JSON.stringify({application:`${tv}:${on}`,platform:"WEB",items:r.map(t=>Object.assign(Object.assign({},t),{time:0,type:1}))})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();const r=Po(this.consequentAuthErrors,ov);return new Promise(t=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout(()=>{mr(this._authorize().then(t).catch(n=>this.params.error$.next({id:"AuthorizeBackoff",category:E.NETWORK,message:"Otherwise unhandle errror in authrization",thrown:n})),()=>this.backoffTimeoutId=0)},r))})}_authorize(){return N(this,void 0,void 0,function*(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);const r="auth.anonymLogin",t={session_data:{version:2,device_id:this.uuid,client_version:on.split("-")[0],client_type:"SDK_JS"}};return this.authToken!==void 0&&(t.session_data.auth_token=this.authToken,t.session_data.version=3),this.authorizePromise=mr(this.params.apiTransport.sendRequest(r,t).then(n=>{var o;return(!n||!n.session_key)&&this.params.error$.next({id:"AuthorizeFailed",category:E.EXTERNAL_API,message:"No session key",data:n}),this.sessionKey=(o=n==null?void 0:n.session_key)!==null&&o!==void 0?o:void 0,this.sessionKey}).catch(n=>N(this,void 0,void 0,function*(){this.sessionKey=void 0;const o=n==null?void 0:n.error_code;switch(o){case k.AUTH_LOGIN:return this.authToken=yield this.refreshAuthToken(),this._authorizeWithBackoff()}o?this.params.error$.next({id:`Authorize#${o}`,category:E.EXTERNAL_API,message:"authorize error",data:n}):this.params.error$.next({id:"AuthorizeUnknown",category:E.NETWORK,message:"authorize error",thrown:n})})),()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(this.sessionKey!==void 0)}),this.authorizePromise})}}class an{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(r,t,n){r in this.listeners||(this.listeners[r]=[]),this.listeners[r].push({callback:t,options:n})}removeEventListener(r,t){if(!(r in this.listeners))return;const n=this.listeners[r];for(let o=0,a=n.length;o<a;o++)if(n[o].callback===t){n.splice(o,1);return}}dispatchEvent(r){if(!(r.type in this.listeners))return;const n=this.listeners[r.type].slice();for(let o=0,a=n.length;o<a;o++){const i=n[o];try{i.callback.call(this,r)}catch(v){Promise.resolve().then(()=>{throw v})}i.options&&i.options.once&&this.removeEventListener(r.type,i.callback)}return!r.defaultPrevented}}class mo extends an{constructor(){super(),this.listeners||an.call(this),Object.defineProperty(this,"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,"reason",{value:void 0,writable:!0,configurable:!0})}toString(){return"[object AbortSignal]"}dispatchEvent(r){r.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,r)),super.dispatchEvent(r)}}class iv{constructor(){Object.defineProperty(this,"signal",{value:new mo,writable:!0,configurable:!0})}abort(r){let t;try{t=new Event("abort")}catch(o){typeof document!="undefined"?document.createEvent?(t=document.createEvent("Event"),t.initEvent("abort",!1,!1)):(t=document.createEventObject(),t.type="abort"):t={type:"abort",bubbles:!1,cancelable:!1}}let n=r;if(n===void 0)if(typeof document=="undefined")n=new Error("This operation was aborted"),n.name="AbortError";else try{n=new DOMException("signal is aborted without reason")}catch(o){n=new Error("This operation was aborted"),n.name="AbortError"}this.signal.reason=n,this.signal.dispatchEvent(t)}toString(){return"[object AbortController]"}}typeof Symbol!="undefined"&&Symbol.toStringTag&&(iv.prototype[Symbol.toStringTag]="AbortController",mo.prototype[Symbol.toStringTag]="AbortSignal");function Eo(e){return e.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):typeof e.Request=="function"&&!e.Request.prototype.hasOwnProperty("signal")||!e.AbortController}function sv(e){typeof e=="function"&&(e={fetch:e});const{fetch:r,Request:t=r.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o=!1}=e;if(!Eo({fetch:r,Request:t,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o}))return{fetch:r,Request:a};let a=t;(a&&!a.prototype.hasOwnProperty("signal")||o)&&(a=function(s,c){let l;c&&c.signal&&(l=c.signal,delete c.signal);const h=new t(s,c);return l&&Object.defineProperty(h,"signal",{writable:!1,enumerable:!1,configurable:!0,value:l}),h},a.prototype=t.prototype);const i=r;return{fetch:(u,s)=>{const c=a&&a.prototype.isPrototypeOf(u)?u.signal:s?s.signal:void 0;if(c){let l;try{l=new DOMException("Aborted","AbortError")}catch(f){l=new Error("Aborted"),l.name="AbortError"}if(c.aborted)return Promise.reject(l);const h=new Promise((f,b)=>{c.addEventListener("abort",()=>b(l),{once:!0})});return s&&s.signal&&delete s.signal,Promise.race([h,i(u,s)])}return i(u,s)},Request:a}}const Yr=Eo({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),So=Yr?sv({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,sn=Yr?So.fetch:window.fetch;Yr?So.Request:window.Request;class cv{constructor(r){this.params=r,this.apiKey=r.apiKey,this.apiEnv=r.apiEnv,this.apiBaseUrl=r.apiBaseUrl,this.timeSynchronisation=r.timeSynchronisation,this.isApiBaseUrlFetched=!1}resolveApiBaseUrl(){var r;return N(this,void 0,void 0,function*(){if(this.apiEnv!==C.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const t=atob("aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ="),o=yield(yield sn(t,{method:"GET",mode:"cors",cache:"no-cache"})).json(),a=(r=o==null?void 0:o.Answer[0])===null||r===void 0?void 0:r.data;if(!a)throw new Error("Wrong DNS response");return a}catch(t){return this.params.error$.next({id:"OneStat:ApiTransport:resolveApiBaseUrl",category:E.NETWORK,message:"Unhandled resolve api base url error",thrown:t}),bo[C.VK_ALIAS]}finally{this.isApiBaseUrlFetched=!0}})}sendBeacon(r,t,n){if(!window.Blob||!window.navigator.sendBeacon)return!1;const o=this._prepareQueryParams({method:r,queryParams:t,sessionKey:n}),a=new window.Blob([o.toString()],{type:"application/x-www-form-urlencoded"});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,a)}catch(i){this.params.error$.next({id:"OneStat:ApiTransport:sendBeacon",category:E.NETWORK,message:"Unhandled beacon error",thrown:i,data:{method:r,params:t}})}return!1}sendRequest(r,t,n){return N(this,void 0,void 0,function*(){const o=ie(),a=i=>{if(i instanceof TypeError&&["Failed to fetch","NetworkError when attempting to fetch resource."].includes(i.message)){this.params.error$.next({id:"Network",category:E.NETWORK,message:"Request failed",thrown:i});return}this.params.error$.next({id:"OneStat:ApiTransport:sendRequest",category:E.NETWORK,message:"Unhandled request error",thrown:i,data:{method:r,params:t,sessionKey:n,time:ie()-o}})};return this.apiBaseUrl=yield this.resolveApiBaseUrl(),sn(`${this.apiBaseUrl}/fb.do`,{method:"post",headers:{"Content-type":"application/x-www-form-urlencoded"},body:this._prepareQueryParams({method:r,queryParams:t,sessionKey:n})}).then(i=>{var v;const u=Number(i.headers.get("content-length"))===0,s=new Date((v=i.headers.get("date"))!==null&&v!==void 0?v:"").getTime(),c=ie()-o;if(isFinite(s)&&this.timeSynchronisation.addServerTime(s,c),!u)return i.json().then(l=>Object.prototype.hasOwnProperty.call(l,"error_msg")?Promise.reject(l):l,a)},a)})}_prepareQueryParams(r){const t=new URLSearchParams({format:"JSON",method:r.method,application_key:this.apiKey});return r.sessionKey!==void 0&&t.append("session_key",r.sessionKey),Object.entries(r.queryParams).forEach(([n,o])=>t.append(n,typeof o=="string"?o:JSON.stringify(o))),t}}const To=3e3,uv=To*5;class lv{constructor(r){this.requestQueue=[],this.isPaused=!1,this.debouncedFlush=Ao(()=>{var t;try{this.flush()}catch(n){this.error$.next({id:"LoggerError",category:E.WTF,message:(t=String(n))!==null&&t!==void 0?t:"Unknown logger error",thrown:n})}},To,{maxWait:uv}),this.api=r.api,this.error$=r.error$,this.subscription=this.api.authorized$.subscribe(t=>{t&&this.debouncedFlush()})}log(r){this.requestQueue.push(r),this.isPaused||this.debouncedFlush()}flush(r=!1){this.requestQueue.length!==0&&(this.api.authorized$.getValue()?(r?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[]):r||this.api.authorize(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe()}}class vv{constructor(r){this.offset=void 0,this.offset=r}getOffset(){var r;return(r=this.offset)!==null&&r!==void 0?r:0}setOffset(r){this.offset=r}now(){var r;return Date.now()+((r=this.offset)!==null&&r!==void 0?r:0)}date(r=new Date){var t;return r.setTime(r.getTime()+((t=this.offset)!==null&&t!==void 0?t:0)),r}addServerTime(r,t){const n=Date.now(),o=r-n-t/2;if(Math.abs(o)<1e3){this.offset=0;return}this.offset===void 0?this.offset=Math.round(o):this.offset=Math.round(.2*o+(1-.2)*this.offset)}}const cn=()=>Math.floor(Math.random()*Math.pow(2,32)).toString(36).padStart(8,"0"),fv=e=>e&&{[T.INVARIANT]:$.UNKNOWN,[T.Q_144P]:$.Q144P,[T.Q_240P]:$.Q240P,[T.Q_360P]:$.Q360P,[T.Q_480P]:$.Q480P,[T.Q_720P]:$.Q720P,[T.Q_1080P]:$.Q1080P,[T.Q_1440P]:$.Q1440P,[T.Q_2160P]:$.Q2160P,[T.Q_4320P]:$.Q4320P}[e],hv=e=>e&&{[ze.HTTP1]:ue.HTTP1,[ze.HTTP2]:ue.HTTP2,[ze.QUIC]:ue.HTTP3}[e],dv=e=>{if(e!==void 0)switch(e){case m.MPEG:return P.MP4;case m.DASH:case m.DASH_LIVE:return P.DASH;case m.DASH_SEP:return P.DASH_SEP;case m.DASH_ONDEMAND:return P.ONDEMAND_DASH;case m.DASH_WEBM:case m.DASH_LIVE_WEBM:return P.WEBM;case m.HLS:case m.HLS_LIVE:return P.HLS;case m.HLS_ONDEMAND:return P.ONDEMAND_HLS;case m.WEB_RTC_LIVE:return P.RTMP;default:return _o(e)}};class $v{constructor(r,t){var n;this.subscription=new Jr,this.timeSynchronisation=new vv,this.vsid=cn(),this.fieldBlacklist=[],this.statContext=r,this.config=Object.assign(Object.assign({},(n=t.config)!==null&&n!==void 0?n:{}),{requestRetryCount:1});const o=new Io;this.experimental={error$:o};const a=new cv({apiKey:nv,apiBaseUrl:bo[t.apiEnv],apiEnv:t.apiEnv,error$:o,timeSynchronisation:this.timeSynchronisation});this.api=new av({apiTransport:a,refreshAuthToken:t.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:o}),this.logger=new lv({api:this.api,error$:o}),this.subscription.add(wo(window,"beforeunload").subscribe(()=>this.logger.flush(!0)))}updateContext(r){this.statContext=Object.assign(Object.assign({},this.statContext),r)}attachTo(r){let t;return new Jr().add(r.events.started$.subscribe(()=>{this.logStarted({position:r.info.position$.getValue()})})).add(r.events.looped$.subscribe(()=>{this.resetViewSession(),this.logStarted({position:r.info.position$.getValue()})})).add(r.events.seeked$.subscribe(()=>{this.logSeek()})).add(r.events.willPause$.subscribe(()=>{this.logPause({position:r.info.position$.getValue()})})).add(r.events.willResume$.subscribe(()=>{this.logPlay()})).add(r.events.managedError$.subscribe(({id:n})=>{this.logError({errorType:n})})).add(r.events.fatalError$.subscribe(({id:n})=>{this.logError({errorType:n})})).add(r.events.inited$.subscribe(()=>{this.logInited()})).add(r.events.canplay$.subscribe(n=>{this.logReady({time:n})})).add(r.events.firstBytes$.subscribe(n=>{this.logFirstBytes({time:n})})).add(r.events.firstFrame$.subscribe(n=>{this.logFirstFrame({time:n})})).add(r.events.watchCoverageRecord$.subscribe(n=>{this.logWatchCoverageRecord(n)})).add(r.events.watchCoverageLive$.subscribe(n=>{this.logWatchCoverageLive(n)})).add(r.info.isStalled$.subscribe(n=>{n?t=ie():(Xr(t)&&this.logEmptyBuffer({duration:ie()-t}),t=void 0)})).add(r.events.ended$.subscribe(()=>{const n=r.info.throughputEstimation$.getValue();Xr(n)&&this.logDownloadSpeed({speed:n/8})})).add(r.info.hostname$.subscribe(n=>{this.updateContext({cdnHostname:n})})).add(r.info.httpConnectionType$.subscribe(n=>{this.updateContext({connectionType:hv(n)})})).add(r.info.httpConnectionReused$.subscribe(n=>{this.updateContext({connectionReused:n})})).add(r.info.currentQuality$.subscribe(n=>{this.updateContext({quality:fv(n)})})).add(r.info.currentFormat$.subscribe(n=>{this.updateContext({contentType:dv(n)})})).add(r.info.chromecastState$.subscribe(n=>{this.updateContext({destination:n===Ro.CONNECTED?Le.CHROMECAST:Le.SCREEN})}))}authorize(r){return this.api.authorize(r)}pause(){this.logger.pause()}resume(){this.logger.resume()}destroy(){this.logger.flush(),this.subscription.unsubscribe(),this.api.destroy(),this.logger.destroy()}resetViewSession(){this.vsid=cn()}setFieldBlacklist(r=[]){this.fieldBlacklist=r}logInited(){this.log({operation:"init"})}logReady(r){this.log({operation:"player_ready",param:String(r.time)})}logStarted(r){this.log({operation:"play",param:String(Math.round(r.position))})}logPlay(){this.log({operation:"play_toggle"})}logPause(r){this.log({operation:"pause",param:String(Math.round(r.position))})}logSeek(){this.log({operation:"seek"})}logFirstBytes(r){this.log({operation:"first_bytes",param:String(r.time)})}logFirstFrame(r){this.log({operation:"first_frame",param:String(r.time)})}logError(r){this.log({operation:"error",param:r.errorType})}logWatchCoverageRecord(r){this.log({operation:"watch_coverage_record",param:`${r.start}-${r.end}`}),this.logger.flush(!0)}logWatchCoverageLive(r){const t=r.start+this.timeSynchronisation.getOffset(),n=r.end+this.timeSynchronisation.getOffset();this.log({operation:"watch_coverage_live",param:`${t}-${n}`}),this.logger.flush(!0)}logEmptyBuffer(r){this.log({operation:"empty_buffer",param:String(r.duration)})}logDownloadSpeed(r){this.log({operation:"download_speed",param:String(r.speed)})}logAdSlotRequest(){this.log({operation:"adv",param:"slot_request"})}logAdStarted(r){this.log({operation:"adv",param:r})}logAdPaused(){this.log({operation:"adv",param:"pause"})}logAdResumed(){this.log({operation:"adv",param:"resume"})}logAdEnded(){this.log({operation:"adv",param:"ended"})}logAdSkipped(){this.log({operation:"adv",param:"skip"})}logAdClicked(){this.log({operation:"adv",param:"click"})}log(r){const t=this.createLogItem(r);this.logger.log(t)}createLogItem({operation:r,param:t}){const n=this.timeSynchronisation.now(),o={vsid:this.vsid,vid:this.statContext.movieId,quality:this.statContext.quality,dst:this.statContext.destination,ct:this.statContext.contentType,aid:this.statContext.albumId,place:this.statContext.place,cdn_host:this.statContext.cdnHostname,connection_type:this.statContext.connectionType,connection_reused:this.statContext.connectionReused===!0?Ue.YES:this.statContext.connectionReused===!1?Ue.NO:void 0,stat_type:this.statContext.autoplay===!0?Me.AUTO:this.statContext.autoplay===!1?Me.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode};t!==void 0&&(o.param=t);for(const a of this.fieldBlacklist)delete o[a];return{operation:r,timestamp:n,custom:o}}}export{C as ApiEnv,ue as ConnectionType,P as ContentType,$v as OneStat,$ as Quality,Le as ScreenDestination};
|
package/es2018.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-statistics v1.0.
|
|
3
|
-
*
|
|
4
|
-
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-
|
|
2
|
+
* @vkontakte/videoplayer-statistics v1.0.31
|
|
3
|
+
* Thu, 02 Feb 2023 10:22:17 GMT
|
|
4
|
+
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-31/doc/
|
|
5
5
|
*/
|
|
6
|
-
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var t=require('@vkontakte/videoplayer-shared/es2018.cjs.js'),e=require('@vkontakte/videoplayer-core/es2018.cjs.js');function o(t){return t&&'object'==typeof t&&'default'in t?t:{default:t}}var s=o(require('lodash/debounce.js'));const r=(()=>{try{const t=Date.now().toString(),e=window.localStorage;e.setItem(t,t);const o=e.getItem(t)===t;return e.removeItem(t),o?e:null}catch(t){return null}})();var i,n,a,h,u,d,l,c={get:t=>function(t){const e=r?r.getItem('_one-stat_'+t):null;if(null===e)return null;try{return JSON.parse(e)}catch(t){return null}}(t)||null,set(t,e){!function(t,e){try{r&&r.setItem('_one-stat_'+t,JSON.stringify(e))}catch(t){}}(t,e)},remove(t){!function(t){r&&r.removeItem('_one-stat_'+t)}(t)}};exports.ApiEnv=void 0,(i=exports.ApiEnv||(exports.ApiEnv={})).PROD='prod',i.VK_ALIAS='vk_alias',i.VIDEOTEST='videotest',i.TEST='test',i.AUTO='auto',exports.Quality=void 0,(n=exports.Quality||(exports.Quality={})).Q144P='144',n.Q240P='240',n.Q360P='360',n.Q480P='480',n.Q720P='720',n.Q1080P='1080',n.Q1440P='1440',n.Q2160P='2160',n.Q4320P='4320',n.UNKNOWN='unknown',exports.ScreenDestination=void 0,(a=exports.ScreenDestination||(exports.ScreenDestination={})).CHROMECAST='chromecast',a.APPLE_TV='appletv',a.PIP='pip',a.HEADPHONES='externalHeadphones',a.SCREEN='',exports.ContentType=void 0,(h=exports.ContentType||(exports.ContentType={})).MP4='mp4',h.DASH='dash',h.DASH_SEP='dash_sep',h.ONDEMAND_DASH='ondemand_dash',h.HLS='hls',h.ONDEMAND_HLS='ondemand_hls',h.WEBM='webm',h.RTMP='rtmp',h.UNKNOWN='unknown',function(t){t.AUTO='auto',t.MANUAL=''}(u||(u={})),exports.ConnectionType=void 0,(d=exports.ConnectionType||(exports.ConnectionType={})).HTTP1='http1',d.HTTP2='http2',d.HTTP3='http3',function(t){t[t.YES=1]='YES',t[t.NO=0]='NO'}(l||(l={}));const p={[exports.ApiEnv.PROD]:'https://api.ok.ru',[exports.ApiEnv.VK_ALIAS]:'https://api.mycdn.me',[exports.ApiEnv.VIDEOTEST]:'https://videotestapi.ok.ru/api',[exports.ApiEnv.TEST]:'https://apitest.ok.ru',[exports.ApiEnv.AUTO]:''},y={start:1e3,factor:1.5,max:3e5,random:.1};var g;!function(t){t[t.PARAM_SESSION_EXPIRED=102]='PARAM_SESSION_EXPIRED',t[t.PARAM_SESSION_KEY=103]='PARAM_SESSION_KEY',t[t.PARAM_SIGNATURE=104]='PARAM_SIGNATURE',t[t.AUTH_LOGIN=401]='AUTH_LOGIN'}(g||(g={}));class m{constructor(e){this.consequentAuthErrors=0,this.authorized$=new t.ValueSubject(!1),this.params=e;const o=c.get('uuid');o?this.uuid=String(o):(this.uuid=function(){const t='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''),e=new Array(36);let o,s,r=0;for(s=0;s<36;s++)8===s||13===s||18===s||23===s?e[s]='-':14===s?e[s]='4':(r<=2&&(r=33554432+16777216*Math.random()|0),o=15&r,r>>=4,e[s]=t[19===s?3&o|8:o]);return e.join('')}(),c.set('uuid',this.uuid))}async authorize(t){return this.authToken=null!=t?t:await this.refreshAuthToken(),this._authorizeWithBackoff()}logBeacon(t){const e=this.createLogParams(t),o=this.sessionKey;if(!o)return;this.params.apiTransport.sendBeacon('log.externalLog',e,o)||this.logRequest(t)}async logRequest(e){var o;const s='log.externalLog',r=this.createLogParams(e),i=null!==(o=this.sessionKey)&&void 0!==o?o:await this._authorizeWithBackoff();if(!i)return;const n=async(e,o=this.params.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(s,r,i)}catch(r){if(!r||!('error_code'in r))return void this.params.error$.next({id:'logRequestUnknown',category:t.ErrorCategory.NETWORK,message:`Unknown ${s} error`,thrown:r});const i=null==r?void 0:r.error_code;switch(i){case g.PARAM_SESSION_EXPIRED:case g.PARAM_SESSION_KEY:case g.PARAM_SIGNATURE:return this.authorized$.next(!1),this.sessionKey=await this._authorizeWithBackoff(),o>0?n(e,o-1):void 0;case g.AUTH_LOGIN:return this.authorized$.next(!1),this.authToken=await this.refreshAuthToken(),this.sessionKey=await this._authorizeWithBackoff(),o>0?n(e,o-1):void 0;default:return void this.params.error$.next({id:`LogRequest#${i}`,category:t.ErrorCategory.EXTERNAL_API,message:`${s} error`,data:r})}}};return n(e)}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}async refreshAuthToken(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=this.params.refreshAuthToken().finally((()=>{this.refreshAuthTokenPromise=void 0}))),this.refreshAuthTokenPromise}createLogParams(t){return{collector:'ok.mobile.apps.video',data:JSON.stringify({application:'@vkontakte/videoplayer-statistics:1.0.29',platform:'WEB',items:t.map((t=>({...t,time:0,type:1})))})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();const e=t.getExponentialDelay(this.consequentAuthErrors,y);return new Promise((o=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout((()=>{this._authorize().then(o).catch((e=>this.params.error$.next({id:'AuthorizeBackoff',category:t.ErrorCategory.NETWORK,message:'Otherwise unhandle errror in authrization',thrown:e}))).finally((()=>this.backoffTimeoutId=0))}),e))}))}async _authorize(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);const e={session_data:{version:2,device_id:this.uuid,client_version:'1.0.29'.split('-')[0],client_type:'SDK_JS'}};return void 0!==this.authToken&&(e.session_data.auth_token=this.authToken,e.session_data.version=3),this.authorizePromise=this.params.apiTransport.sendRequest('auth.anonymLogin',e).then((e=>{var o;return e&&e.session_key||this.params.error$.next({id:'AuthorizeFailed',category:t.ErrorCategory.EXTERNAL_API,message:'No session key',data:e}),this.sessionKey=null!==(o=null==e?void 0:e.session_key)&&void 0!==o?o:void 0,this.sessionKey})).catch((async e=>{this.sessionKey=void 0;const o=null==e?void 0:e.error_code;switch(o){case g.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this._authorizeWithBackoff()}o?this.params.error$.next({id:`Authorize#${o}`,category:t.ErrorCategory.EXTERNAL_API,message:'authorize error',data:e}):this.params.error$.next({id:'AuthorizeUnknown',category:t.ErrorCategory.NETWORK,message:'authorize error',thrown:e})})).finally((()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(void 0!==this.sessionKey)})),this.authorizePromise}}function f(t){return t.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log('__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill'),!0):'function'==typeof t.Request&&!t.Request.prototype.hasOwnProperty('signal')||!t.AbortController}const v=f({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),A=v?function(t){'function'==typeof t&&(t={fetch:t});const{fetch:e,Request:o=e.Request,AbortController:s,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:r=!1}=t;if(!f({fetch:e,Request:o,AbortController:s,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:r}))return{fetch:e,Request:i};let i=o;(i&&!i.prototype.hasOwnProperty('signal')||r)&&(i=function(t,e){let s;e&&e.signal&&(s=e.signal,delete e.signal);const r=new o(t,e);return s&&Object.defineProperty(r,'signal',{writable:!1,enumerable:!1,configurable:!0,value:s}),r},i.prototype=o.prototype);const n=e;return{fetch:(t,e)=>{const o=i&&i.prototype.isPrototypeOf(t)?t.signal:e?e.signal:void 0;if(o){let s;try{s=new DOMException('Aborted','AbortError')}catch(t){s=new Error('Aborted'),s.name='AbortError'}if(o.aborted)return Promise.reject(s);const r=new Promise(((t,e)=>{o.addEventListener('abort',(()=>e(s)),{once:!0})}));return e&&e.signal&&delete e.signal,Promise.race([r,n(t,e)])}return n(t,e)},Request:i}}({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,T=v?A.fetch:window.fetch;v?A.Request:window.Request;class E{constructor(t){this.params=t,this.apiKey=t.apiKey,this.apiEnv=t.apiEnv,this.apiBaseUrl=t.apiBaseUrl,this.timeSynchronisation=t.timeSynchronisation,this.isApiBaseUrlFetched=!1}async resolveApiBaseUrl(){var e;if(this.apiEnv!==exports.ApiEnv.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const t=atob('aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ='),o=await T(t,{method:'GET',mode:'cors',cache:'no-cache'}),s=await o.json(),r=null===(e=null==s?void 0:s.Answer[0])||void 0===e?void 0:e.data;if(!r)throw new Error('Wrong DNS response');return r}catch(e){return this.params.error$.next({id:'OneStat:ApiTransport:resolveApiBaseUrl',category:t.ErrorCategory.NETWORK,message:'Unhandled resolve api base url error',thrown:e}),p[exports.ApiEnv.VK_ALIAS]}finally{this.isApiBaseUrlFetched=!0}}sendBeacon(e,o,s){if(!window.Blob||!window.navigator.sendBeacon)return!1;const r=this._prepareQueryParams({method:e,queryParams:o,sessionKey:s}),i=new window.Blob([r.toString()],{type:'application/x-www-form-urlencoded'});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,i)}catch(s){this.params.error$.next({id:'OneStat:ApiTransport:sendBeacon',category:t.ErrorCategory.NETWORK,message:'Unhandled beacon error',thrown:s,data:{method:e,params:o}})}return!1}async sendRequest(e,o,s){const r=t.now(),i=i=>{i instanceof TypeError&&['Failed to fetch','NetworkError when attempting to fetch resource.'].includes(i.message)?this.params.error$.next({id:'Network',category:t.ErrorCategory.NETWORK,message:'Request failed',thrown:i}):this.params.error$.next({id:'OneStat:ApiTransport:sendRequest',category:t.ErrorCategory.NETWORK,message:'Unhandled request error',thrown:i,data:{method:e,params:o,sessionKey:s,time:t.now()-r}})};return this.apiBaseUrl=await this.resolveApiBaseUrl(),T(`${this.apiBaseUrl}/fb.do`,{method:'post',headers:{'Content-type':'application/x-www-form-urlencoded'},body:this._prepareQueryParams({method:e,queryParams:o,sessionKey:s})}).then((e=>{var o;const s=0===Number(e.headers.get('content-length')),n=new Date(null!==(o=e.headers.get('date'))&&void 0!==o?o:'').getTime(),a=t.now()-r;if(isFinite(n)&&this.timeSynchronisation.addServerTime(n,a),!s)return e.json().then((t=>Object.prototype.hasOwnProperty.call(t,'error_msg')?Promise.reject(t):t),i)}),i)}_prepareQueryParams(t){const e=new URLSearchParams({format:'JSON',method:t.method,application_key:this.apiKey});return void 0!==t.sessionKey&&e.append('session_key',t.sessionKey),Object.entries(t.queryParams).forEach((([t,o])=>e.append(t,'string'==typeof o?o:JSON.stringify(o)))),e}}class _{constructor(e){this.requestQueue=[],this.isPaused=!1,this.debouncedFlush=s.default((()=>{var e;try{this.flush()}catch(o){this.error$.next({id:'LoggerError',category:t.ErrorCategory.WTF,message:null!==(e=String(o))&&void 0!==e?e:'Unknown logger error',thrown:o})}}),3e3,{maxWait:15e3}),this.api=e.api,this.error$=e.error$,this.subscription=this.api.authorized$.subscribe((t=>{t&&this.debouncedFlush()}))}log(t){this.requestQueue.push(t),this.isPaused||this.debouncedFlush()}flush(t=!1){0!==this.requestQueue.length&&(this.api.authorized$.getValue()?(t?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[]):t||this.api.authorize(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe()}}class S{constructor(t){this.offset=void 0,this.offset=t}getOffset(){var t;return null!==(t=this.offset)&&void 0!==t?t:0}setOffset(t){this.offset=t}now(){var t;return Date.now()+(null!==(t=this.offset)&&void 0!==t?t:0)}date(t=new Date){var e;return t.setTime(t.getTime()+(null!==(e=this.offset)&&void 0!==e?e:0)),t}addServerTime(t,e){const o=t-Date.now()-e/2;if(Math.abs(o)<1e3)this.offset=0;else if(void 0===this.offset)this.offset=Math.round(o);else{const t=.2;this.offset=Math.round(t*o+(1-t)*this.offset)}}}const w=()=>Math.floor(Math.random()*2**32).toString(36).padStart(8,'0'),b=t=>t&&{[e.HttpConnectionType.HTTP1]:exports.ConnectionType.HTTP1,[e.HttpConnectionType.HTTP2]:exports.ConnectionType.HTTP2,[e.HttpConnectionType.QUIC]:exports.ConnectionType.HTTP3}[t],P=o=>{if(void 0!==o)switch(o){case e.VideoFormat.MPEG:return exports.ContentType.MP4;case e.VideoFormat.DASH:case e.VideoFormat.DASH_LIVE:return exports.ContentType.DASH;case e.VideoFormat.DASH_SEP:return exports.ContentType.DASH_SEP;case e.VideoFormat.DASH_ONDEMAND:return exports.ContentType.ONDEMAND_DASH;case e.VideoFormat.DASH_WEBM:case e.VideoFormat.DASH_LIVE_WEBM:return exports.ContentType.WEBM;case e.VideoFormat.HLS:case e.VideoFormat.HLS_LIVE:return exports.ContentType.HLS;case e.VideoFormat.HLS_ONDEMAND:return exports.ContentType.ONDEMAND_HLS;case e.VideoFormat.WEB_RTC_LIVE:return exports.ContentType.RTMP;default:return t.assertNever(o)}};exports.OneStat=class{constructor(e,o){var s;this.subscription=new t.Subscription,this.timeSynchronisation=new S,this.vsid=w(),this.fieldBlacklist=[],this.statContext=e,this.config={...null!==(s=o.config)&&void 0!==s?s:{},requestRetryCount:1};const r=new t.Subject;this.experimental={error$:r};const i=new E({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:p[o.apiEnv],apiEnv:o.apiEnv,error$:r,timeSynchronisation:this.timeSynchronisation});this.api=new m({apiTransport:i,refreshAuthToken:o.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:r}),this.logger=new _({api:this.api,error$:r}),this.subscription.add(t.fromEvent(window,'beforeunload').subscribe((()=>this.logger.flush(!0))))}updateContext(t){this.statContext={...this.statContext,...t}}attachTo(o){let s;return(new t.Subscription).add(o.events.started$.subscribe((()=>{this.logStarted({position:o.info.position$.getValue()})}))).add(o.events.looped$.subscribe((()=>{this.resetViewSession(),this.logStarted({position:o.info.position$.getValue()})}))).add(o.events.seeked$.subscribe((()=>{this.logSeek()}))).add(o.events.willPause$.subscribe((()=>{this.logPause({position:o.info.position$.getValue()})}))).add(o.events.willResume$.subscribe((()=>{this.logPlay()}))).add(o.events.managedError$.subscribe((({id:t})=>{this.logError({errorType:t})}))).add(o.events.fatalError$.subscribe((({id:t})=>{this.logError({errorType:t})}))).add(o.events.inited$.subscribe((()=>{this.logInited()}))).add(o.events.canplay$.subscribe((t=>{this.logReady({time:t})}))).add(o.events.firstBytes$.subscribe((t=>{this.logFirstBytes({time:t})}))).add(o.events.firstFrame$.subscribe((t=>{this.logFirstFrame({time:t})}))).add(o.events.watchCoverageRecord$.subscribe((t=>{this.logWatchCoverageRecord(t)}))).add(o.events.watchCoverageLive$.subscribe((t=>{this.logWatchCoverageLive(t)}))).add(o.info.isStalled$.subscribe((e=>{e?s=t.now():(t.isNonNullable(s)&&this.logEmptyBuffer({duration:t.now()-s}),s=void 0)}))).add(o.events.ended$.subscribe((()=>{const e=o.info.throughputEstimation$.getValue();t.isNonNullable(e)&&this.logDownloadSpeed({speed:e/8})}))).add(o.info.hostname$.subscribe((t=>{this.updateContext({cdnHostname:t})}))).add(o.info.httpConnectionType$.subscribe((t=>{this.updateContext({connectionType:b(t)})}))).add(o.info.httpConnectionReused$.subscribe((t=>{this.updateContext({connectionReused:t})}))).add(o.info.currentQuality$.subscribe((t=>{var o;this.updateContext({quality:(o=t,o&&{[e.VideoQuality.INVARIANT]:exports.Quality.UNKNOWN,[e.VideoQuality.Q_144P]:exports.Quality.Q144P,[e.VideoQuality.Q_240P]:exports.Quality.Q240P,[e.VideoQuality.Q_360P]:exports.Quality.Q360P,[e.VideoQuality.Q_480P]:exports.Quality.Q480P,[e.VideoQuality.Q_720P]:exports.Quality.Q720P,[e.VideoQuality.Q_1080P]:exports.Quality.Q1080P,[e.VideoQuality.Q_1440P]:exports.Quality.Q1440P,[e.VideoQuality.Q_2160P]:exports.Quality.Q2160P,[e.VideoQuality.Q_4320P]:exports.Quality.Q4320P}[o])})}))).add(o.info.currentFormat$.subscribe((t=>{this.updateContext({contentType:P(t)})}))).add(o.info.chromecastState$.subscribe((t=>{this.updateContext({destination:t===e.ChromecastState.CONNECTED?exports.ScreenDestination.CHROMECAST:exports.ScreenDestination.SCREEN})})))}authorize(t){return this.api.authorize(t)}pause(){this.logger.pause()}resume(){this.logger.resume()}destroy(){this.logger.flush(),this.subscription.unsubscribe(),this.api.destroy(),this.logger.destroy()}resetViewSession(){this.vsid=w()}setFieldBlacklist(t=[]){this.fieldBlacklist=t}logInited(){this.log({operation:'init'})}logReady(t){this.log({operation:'player_ready',param:String(t.time)})}logStarted(t){this.log({operation:'play',param:String(Math.round(t.position))})}logPlay(){this.log({operation:'play_toggle'})}logPause(t){this.log({operation:'pause',param:String(Math.round(t.position))})}logSeek(){this.log({operation:'seek'})}logFirstBytes(t){this.log({operation:'first_bytes',param:String(t.time)})}logFirstFrame(t){this.log({operation:'first_frame',param:String(t.time)})}logError(t){this.log({operation:'error',param:t.errorType})}logWatchCoverageRecord(t){this.log({operation:'watch_coverage_record',param:`${t.start}-${t.end}`}),this.logger.flush(!0)}logWatchCoverageLive(t){const e=t.start+this.timeSynchronisation.getOffset(),o=t.end+this.timeSynchronisation.getOffset();this.log({operation:'watch_coverage_live',param:`${e}-${o}`}),this.logger.flush(!0)}logEmptyBuffer(t){this.log({operation:'empty_buffer',param:String(t.duration)})}logDownloadSpeed(t){this.log({operation:'download_speed',param:String(t.speed)})}logAdSlotRequest(){this.log({operation:'adv',param:'slot_request'})}logAdStarted(t){this.log({operation:'adv',param:t})}logAdPaused(){this.log({operation:'adv',param:'pause'})}logAdResumed(){this.log({operation:'adv',param:'resume'})}logAdEnded(){this.log({operation:'adv',param:'ended'})}logAdSkipped(){this.log({operation:'adv',param:'skip'})}logAdClicked(){this.log({operation:'adv',param:'click'})}log(t){const e=this.createLogItem(t);this.logger.log(e)}createLogItem({operation:t,param:e}){const o=this.timeSynchronisation.now(),s={vsid:this.vsid,vid:this.statContext.movieId,quality:this.statContext.quality,dst:this.statContext.destination,ct:this.statContext.contentType,aid:this.statContext.albumId,place:this.statContext.place,cdn_host:this.statContext.cdnHostname,connection_type:this.statContext.connectionType,connection_reused:!0===this.statContext.connectionReused?l.YES:!1===this.statContext.connectionReused?l.NO:void 0,stat_type:!0===this.statContext.autoplay?u.AUTO:!1===this.statContext.autoplay?u.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode};void 0!==e&&(s.param=e);for(const t of this.fieldBlacklist)delete s[t];return{operation:t,timestamp:o,custom:s}}};
|
|
6
|
+
"use strict";var a=require("@vkontakte/videoplayer-shared/es2018.cjs.js"),n=require("@vkontakte/videoplayer-core/es2018.cjs.js"),L=require("lodash/debounce.js");const A="_one-stat_",g=(()=>{try{const t=Date.now().toString(),e=window.localStorage;e.setItem(t,t);const o=e.getItem(t)===t;return e.removeItem(t),o?e:null}catch(t){return null}})();function x(t){const e=g?g.getItem(A+t):null;if(e===null)return null;try{return JSON.parse(e)}catch(o){return null}}function $(t,e){try{g&&g.setItem(A+t,JSON.stringify(e))}catch(o){}}function q(t){g&&g.removeItem(A+t)}var _={get(t){return x(t)||null},set(t,e){$(t,e)},remove(t){q(t)}};function Q(){const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),e=new Array(36);let o=0,s,r;for(r=0;r<36;r++)r===8||r===13||r===18||r===23?e[r]="-":r===14?e[r]="4":(o<=2&&(o=33554432+Math.random()*16777216|0),s=o&15,o=o>>4,e[r]=t[r===19?s&3|8:s]);return e.join("")}exports.ApiEnv=void 0;(function(t){t.PROD="prod",t.VK_ALIAS="vk_alias",t.VIDEOTEST="videotest",t.TEST="test",t.AUTO="auto"})(exports.ApiEnv||(exports.ApiEnv={}));exports.Quality=void 0;(function(t){t.Q144P="144",t.Q240P="240",t.Q360P="360",t.Q480P="480",t.Q720P="720",t.Q1080P="1080",t.Q1440P="1440",t.Q2160P="2160",t.Q4320P="4320",t.UNKNOWN="unknown"})(exports.Quality||(exports.Quality={}));exports.ScreenDestination=void 0;(function(t){t.CHROMECAST="chromecast",t.APPLE_TV="appletv",t.PIP="pip",t.HEADPHONES="externalHeadphones",t.SCREEN=""})(exports.ScreenDestination||(exports.ScreenDestination={}));exports.ContentType=void 0;(function(t){t.MP4="mp4",t.DASH="dash",t.DASH_SEP="dash_sep",t.ONDEMAND_DASH="ondemand_dash",t.HLS="hls",t.ONDEMAND_HLS="ondemand_hls",t.WEBM="webm",t.RTMP="rtmp",t.UNKNOWN="unknown"})(exports.ContentType||(exports.ContentType={}));var y;(function(t){t.AUTO="auto",t.MANUAL=""})(y||(y={}));exports.ConnectionType=void 0;(function(t){t.HTTP1="http1",t.HTTP2="http2",t.HTTP3="http3"})(exports.ConnectionType||(exports.ConnectionType={}));var b;(function(t){t[t.YES=1]="YES",t[t.NO=0]="NO"})(b||(b={}));const v="1.0.31",B="@vkontakte/videoplayer-statistics",D="CIOPGQJGDIHBABABA",P={[exports.ApiEnv.PROD]:"https://api.ok.ru",[exports.ApiEnv.VK_ALIAS]:"https://api.mycdn.me",[exports.ApiEnv.VIDEOTEST]:"https://videotestapi.ok.ru/api",[exports.ApiEnv.TEST]:"https://apitest.ok.ru",[exports.ApiEnv.AUTO]:""},F={start:1e3,factor:1.5,max:5*60*1e3,random:.1};var p;(function(t){t[t.PARAM_SESSION_EXPIRED=102]="PARAM_SESSION_EXPIRED",t[t.PARAM_SESSION_KEY=103]="PARAM_SESSION_KEY",t[t.PARAM_SIGNATURE=104]="PARAM_SIGNATURE",t[t.AUTH_LOGIN=401]="AUTH_LOGIN"})(p||(p={}));class H{constructor(e){this.consequentAuthErrors=0,this.authorized$=new a.ValueSubject(!1),this.params=e;const o=_.get("uuid");o?this.uuid=String(o):(this.uuid=Q(),_.set("uuid",this.uuid))}async authorize(e){return this.authToken=e!=null?e:await this.refreshAuthToken(),this._authorizeWithBackoff()}logBeacon(e){const o="log.externalLog",s=this.createLogParams(e),r=this.sessionKey;if(!r)return;this.params.apiTransport.sendBeacon(o,s,r)||this.logRequest(e)}async logRequest(e){var o;const s="log.externalLog",r=this.createLogParams(e),i=(o=this.sessionKey)!==null&&o!==void 0?o:await this._authorizeWithBackoff();if(!i)return;const u=async(f,d=this.params.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(s,r,i)}catch(h){if(!h||!("error_code"in h)){this.params.error$.next({id:"logRequestUnknown",category:a.ErrorCategory.NETWORK,message:`Unknown ${s} error`,thrown:h});return}const c=h==null?void 0:h.error_code;switch(c){case p.PARAM_SESSION_EXPIRED:case p.PARAM_SESSION_KEY:case p.PARAM_SIGNATURE:return this.authorized$.next(!1),this.sessionKey=await this._authorizeWithBackoff(),d>0?u(f,d-1):void 0;case p.AUTH_LOGIN:return this.authorized$.next(!1),this.authToken=await this.refreshAuthToken(),this.sessionKey=await this._authorizeWithBackoff(),d>0?u(f,d-1):void 0;default:{this.params.error$.next({id:`LogRequest#${c}`,category:a.ErrorCategory.EXTERNAL_API,message:`${s} error`,data:h});return}}}};return u(e)}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}async refreshAuthToken(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=this.params.refreshAuthToken().finally(()=>{this.refreshAuthTokenPromise=void 0})),this.refreshAuthTokenPromise}createLogParams(e){return{collector:"ok.mobile.apps.video",data:JSON.stringify({application:`${B}:${v}`,platform:"WEB",items:e.map(o=>({...o,time:0,type:1}))})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();const e=a.getExponentialDelay(this.consequentAuthErrors,F);return new Promise(o=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout(()=>{this._authorize().then(o).catch(s=>this.params.error$.next({id:"AuthorizeBackoff",category:a.ErrorCategory.NETWORK,message:"Otherwise unhandle errror in authrization",thrown:s})).finally(()=>this.backoffTimeoutId=0)},e))})}async _authorize(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);const e="auth.anonymLogin",o={session_data:{version:2,device_id:this.uuid,client_version:v.split("-")[0],client_type:"SDK_JS"}};return this.authToken!==void 0&&(o.session_data.auth_token=this.authToken,o.session_data.version=3),this.authorizePromise=this.params.apiTransport.sendRequest(e,o).then(s=>{var r;return(!s||!s.session_key)&&this.params.error$.next({id:"AuthorizeFailed",category:a.ErrorCategory.EXTERNAL_API,message:"No session key",data:s}),this.sessionKey=(r=s==null?void 0:s.session_key)!==null&&r!==void 0?r:void 0,this.sessionKey}).catch(async s=>{this.sessionKey=void 0;const r=s==null?void 0:s.error_code;switch(r){case p.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this._authorizeWithBackoff()}r?this.params.error$.next({id:`Authorize#${r}`,category:a.ErrorCategory.EXTERNAL_API,message:"authorize error",data:s}):this.params.error$.next({id:"AuthorizeUnknown",category:a.ErrorCategory.NETWORK,message:"authorize error",thrown:s})}).finally(()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(this.sessionKey!==void 0)}),this.authorizePromise}}class S{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,o,s){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:o,options:s})}removeEventListener(e,o){if(!(e in this.listeners))return;const s=this.listeners[e];for(let r=0,i=s.length;r<i;r++)if(s[r].callback===o){s.splice(r,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;const s=this.listeners[e.type].slice();for(let r=0,i=s.length;r<i;r++){const u=s[r];try{u.callback.call(this,e)}catch(f){Promise.resolve().then(()=>{throw f})}u.options&&u.options.once&&this.removeEventListener(e.type,u.callback)}return!e.defaultPrevented}}class O extends S{constructor(){super(),this.listeners||S.call(this),Object.defineProperty(this,"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,"reason",{value:void 0,writable:!0,configurable:!0})}toString(){return"[object AbortSignal]"}dispatchEvent(e){e.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,e)),super.dispatchEvent(e)}}class U{constructor(){Object.defineProperty(this,"signal",{value:new O,writable:!0,configurable:!0})}abort(e){let o;try{o=new Event("abort")}catch(r){typeof document!="undefined"?document.createEvent?(o=document.createEvent("Event"),o.initEvent("abort",!1,!1)):(o=document.createEventObject(),o.type="abort"):o={type:"abort",bubbles:!1,cancelable:!1}}let s=e;if(s===void 0)if(typeof document=="undefined")s=new Error("This operation was aborted"),s.name="AbortError";else try{s=new DOMException("signal is aborted without reason")}catch(r){s=new Error("This operation was aborted"),s.name="AbortError"}this.signal.reason=s,this.signal.dispatchEvent(o)}toString(){return"[object AbortController]"}}typeof Symbol!="undefined"&&Symbol.toStringTag&&(U.prototype[Symbol.toStringTag]="AbortController",O.prototype[Symbol.toStringTag]="AbortSignal");function R(t){return t.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):typeof t.Request=="function"&&!t.Request.prototype.hasOwnProperty("signal")||!t.AbortController}function M(t){typeof t=="function"&&(t={fetch:t});const{fetch:e,Request:o=e.Request,AbortController:s,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:r=!1}=t;if(!R({fetch:e,Request:o,AbortController:s,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:r}))return{fetch:e,Request:i};let i=o;(i&&!i.prototype.hasOwnProperty("signal")||r)&&(i=function(h,c){let l;c&&c.signal&&(l=c.signal,delete c.signal);const m=new o(h,c);return l&&Object.defineProperty(m,"signal",{writable:!1,enumerable:!1,configurable:!0,value:l}),m},i.prototype=o.prototype);const u=e;return{fetch:(d,h)=>{const c=i&&i.prototype.isPrototypeOf(d)?d.signal:h?h.signal:void 0;if(c){let l;try{l=new DOMException("Aborted","AbortError")}catch(k){l=new Error("Aborted"),l.name="AbortError"}if(c.aborted)return Promise.reject(l);const m=new Promise((k,I)=>{c.addEventListener("abort",()=>I(l),{once:!0})});return h&&h.signal&&delete h.signal,Promise.race([m,u(d,h)])}return u(d,h)},Request:i}}const E=R({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),C=E?M({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,w=E?C.fetch:window.fetch;E?C.Request:window.Request;class V{constructor(e){this.params=e,this.apiKey=e.apiKey,this.apiEnv=e.apiEnv,this.apiBaseUrl=e.apiBaseUrl,this.timeSynchronisation=e.timeSynchronisation,this.isApiBaseUrlFetched=!1}async resolveApiBaseUrl(){var e;if(this.apiEnv!==exports.ApiEnv.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const o=atob("aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ="),r=await(await w(o,{method:"GET",mode:"cors",cache:"no-cache"})).json(),i=(e=r==null?void 0:r.Answer[0])===null||e===void 0?void 0:e.data;if(!i)throw new Error("Wrong DNS response");return i}catch(o){return this.params.error$.next({id:"OneStat:ApiTransport:resolveApiBaseUrl",category:a.ErrorCategory.NETWORK,message:"Unhandled resolve api base url error",thrown:o}),P[exports.ApiEnv.VK_ALIAS]}finally{this.isApiBaseUrlFetched=!0}}sendBeacon(e,o,s){if(!window.Blob||!window.navigator.sendBeacon)return!1;const r=this._prepareQueryParams({method:e,queryParams:o,sessionKey:s}),i=new window.Blob([r.toString()],{type:"application/x-www-form-urlencoded"});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,i)}catch(u){this.params.error$.next({id:"OneStat:ApiTransport:sendBeacon",category:a.ErrorCategory.NETWORK,message:"Unhandled beacon error",thrown:u,data:{method:e,params:o}})}return!1}async sendRequest(e,o,s){const r=a.now(),i=u=>{if(u instanceof TypeError&&["Failed to fetch","NetworkError when attempting to fetch resource."].includes(u.message)){this.params.error$.next({id:"Network",category:a.ErrorCategory.NETWORK,message:"Request failed",thrown:u});return}this.params.error$.next({id:"OneStat:ApiTransport:sendRequest",category:a.ErrorCategory.NETWORK,message:"Unhandled request error",thrown:u,data:{method:e,params:o,sessionKey:s,time:a.now()-r}})};return this.apiBaseUrl=await this.resolveApiBaseUrl(),w(`${this.apiBaseUrl}/fb.do`,{method:"post",headers:{"Content-type":"application/x-www-form-urlencoded"},body:this._prepareQueryParams({method:e,queryParams:o,sessionKey:s})}).then(u=>{var f;const d=Number(u.headers.get("content-length"))===0,h=new Date((f=u.headers.get("date"))!==null&&f!==void 0?f:"").getTime(),c=a.now()-r;if(isFinite(h)&&this.timeSynchronisation.addServerTime(h,c),!d)return u.json().then(l=>Object.prototype.hasOwnProperty.call(l,"error_msg")?Promise.reject(l):l,i)},i)}_prepareQueryParams(e){const o=new URLSearchParams({format:"JSON",method:e.method,application_key:this.apiKey});return e.sessionKey!==void 0&&o.append("session_key",e.sessionKey),Object.entries(e.queryParams).forEach(([s,r])=>o.append(s,typeof r=="string"?r:JSON.stringify(r))),o}}const N=3e3,K=N*5;class W{constructor(e){this.requestQueue=[],this.isPaused=!1,this.debouncedFlush=L(()=>{var o;try{this.flush()}catch(s){this.error$.next({id:"LoggerError",category:a.ErrorCategory.WTF,message:(o=String(s))!==null&&o!==void 0?o:"Unknown logger error",thrown:s})}},N,{maxWait:K}),this.api=e.api,this.error$=e.error$,this.subscription=this.api.authorized$.subscribe(o=>{o&&this.debouncedFlush()})}log(e){this.requestQueue.push(e),this.isPaused||this.debouncedFlush()}flush(e=!1){this.requestQueue.length!==0&&(this.api.authorized$.getValue()?(e?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[]):e||this.api.authorize(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe()}}class z{constructor(e){this.offset=void 0,this.offset=e}getOffset(){var e;return(e=this.offset)!==null&&e!==void 0?e:0}setOffset(e){this.offset=e}now(){var e;return Date.now()+((e=this.offset)!==null&&e!==void 0?e:0)}date(e=new Date){var o;return e.setTime(e.getTime()+((o=this.offset)!==null&&o!==void 0?o:0)),e}addServerTime(e,o){const s=Date.now(),r=e-s-o/2;if(Math.abs(r)<1e3){this.offset=0;return}this.offset===void 0?this.offset=Math.round(r):this.offset=Math.round(.2*r+(1-.2)*this.offset)}}const T=()=>Math.floor(Math.random()*2**32).toString(36).padStart(8,"0"),j=t=>t&&{[n.VideoQuality.INVARIANT]:exports.Quality.UNKNOWN,[n.VideoQuality.Q_144P]:exports.Quality.Q144P,[n.VideoQuality.Q_240P]:exports.Quality.Q240P,[n.VideoQuality.Q_360P]:exports.Quality.Q360P,[n.VideoQuality.Q_480P]:exports.Quality.Q480P,[n.VideoQuality.Q_720P]:exports.Quality.Q720P,[n.VideoQuality.Q_1080P]:exports.Quality.Q1080P,[n.VideoQuality.Q_1440P]:exports.Quality.Q1440P,[n.VideoQuality.Q_2160P]:exports.Quality.Q2160P,[n.VideoQuality.Q_4320P]:exports.Quality.Q4320P}[t],G=t=>t&&{[n.HttpConnectionType.HTTP1]:exports.ConnectionType.HTTP1,[n.HttpConnectionType.HTTP2]:exports.ConnectionType.HTTP2,[n.HttpConnectionType.QUIC]:exports.ConnectionType.HTTP3}[t],Y=t=>{if(t!==void 0)switch(t){case n.VideoFormat.MPEG:return exports.ContentType.MP4;case n.VideoFormat.DASH:case n.VideoFormat.DASH_LIVE:return exports.ContentType.DASH;case n.VideoFormat.DASH_SEP:return exports.ContentType.DASH_SEP;case n.VideoFormat.DASH_ONDEMAND:return exports.ContentType.ONDEMAND_DASH;case n.VideoFormat.DASH_WEBM:case n.VideoFormat.DASH_LIVE_WEBM:return exports.ContentType.WEBM;case n.VideoFormat.HLS:case n.VideoFormat.HLS_LIVE:return exports.ContentType.HLS;case n.VideoFormat.HLS_ONDEMAND:return exports.ContentType.ONDEMAND_HLS;case n.VideoFormat.WEB_RTC_LIVE:return exports.ContentType.RTMP;default:return a.assertNever(t)}};class J{constructor(e,o){var s;this.subscription=new a.Subscription,this.timeSynchronisation=new z,this.vsid=T(),this.fieldBlacklist=[],this.statContext=e,this.config={...(s=o.config)!==null&&s!==void 0?s:{},requestRetryCount:1};const r=new a.Subject;this.experimental={error$:r};const i=new V({apiKey:D,apiBaseUrl:P[o.apiEnv],apiEnv:o.apiEnv,error$:r,timeSynchronisation:this.timeSynchronisation});this.api=new H({apiTransport:i,refreshAuthToken:o.refreshAuthToken,requestRetryCount:this.config.requestRetryCount,error$:r}),this.logger=new W({api:this.api,error$:r}),this.subscription.add(a.fromEvent(window,"beforeunload").subscribe(()=>this.logger.flush(!0)))}updateContext(e){this.statContext={...this.statContext,...e}}attachTo(e){let o;return new a.Subscription().add(e.events.started$.subscribe(()=>{this.logStarted({position:e.info.position$.getValue()})})).add(e.events.looped$.subscribe(()=>{this.resetViewSession(),this.logStarted({position:e.info.position$.getValue()})})).add(e.events.seeked$.subscribe(()=>{this.logSeek()})).add(e.events.willPause$.subscribe(()=>{this.logPause({position:e.info.position$.getValue()})})).add(e.events.willResume$.subscribe(()=>{this.logPlay()})).add(e.events.managedError$.subscribe(({id:s})=>{this.logError({errorType:s})})).add(e.events.fatalError$.subscribe(({id:s})=>{this.logError({errorType:s})})).add(e.events.inited$.subscribe(()=>{this.logInited()})).add(e.events.canplay$.subscribe(s=>{this.logReady({time:s})})).add(e.events.firstBytes$.subscribe(s=>{this.logFirstBytes({time:s})})).add(e.events.firstFrame$.subscribe(s=>{this.logFirstFrame({time:s})})).add(e.events.watchCoverageRecord$.subscribe(s=>{this.logWatchCoverageRecord(s)})).add(e.events.watchCoverageLive$.subscribe(s=>{this.logWatchCoverageLive(s)})).add(e.info.isStalled$.subscribe(s=>{s?o=a.now():(a.isNonNullable(o)&&this.logEmptyBuffer({duration:a.now()-o}),o=void 0)})).add(e.events.ended$.subscribe(()=>{const s=e.info.throughputEstimation$.getValue();a.isNonNullable(s)&&this.logDownloadSpeed({speed:s/8})})).add(e.info.hostname$.subscribe(s=>{this.updateContext({cdnHostname:s})})).add(e.info.httpConnectionType$.subscribe(s=>{this.updateContext({connectionType:G(s)})})).add(e.info.httpConnectionReused$.subscribe(s=>{this.updateContext({connectionReused:s})})).add(e.info.currentQuality$.subscribe(s=>{this.updateContext({quality:j(s)})})).add(e.info.currentFormat$.subscribe(s=>{this.updateContext({contentType:Y(s)})})).add(e.info.chromecastState$.subscribe(s=>{this.updateContext({destination:s===n.ChromecastState.CONNECTED?exports.ScreenDestination.CHROMECAST:exports.ScreenDestination.SCREEN})}))}authorize(e){return this.api.authorize(e)}pause(){this.logger.pause()}resume(){this.logger.resume()}destroy(){this.logger.flush(),this.subscription.unsubscribe(),this.api.destroy(),this.logger.destroy()}resetViewSession(){this.vsid=T()}setFieldBlacklist(e=[]){this.fieldBlacklist=e}logInited(){this.log({operation:"init"})}logReady(e){this.log({operation:"player_ready",param:String(e.time)})}logStarted(e){this.log({operation:"play",param:String(Math.round(e.position))})}logPlay(){this.log({operation:"play_toggle"})}logPause(e){this.log({operation:"pause",param:String(Math.round(e.position))})}logSeek(){this.log({operation:"seek"})}logFirstBytes(e){this.log({operation:"first_bytes",param:String(e.time)})}logFirstFrame(e){this.log({operation:"first_frame",param:String(e.time)})}logError(e){this.log({operation:"error",param:e.errorType})}logWatchCoverageRecord(e){this.log({operation:"watch_coverage_record",param:`${e.start}-${e.end}`}),this.logger.flush(!0)}logWatchCoverageLive(e){const o=e.start+this.timeSynchronisation.getOffset(),s=e.end+this.timeSynchronisation.getOffset();this.log({operation:"watch_coverage_live",param:`${o}-${s}`}),this.logger.flush(!0)}logEmptyBuffer(e){this.log({operation:"empty_buffer",param:String(e.duration)})}logDownloadSpeed(e){this.log({operation:"download_speed",param:String(e.speed)})}logAdSlotRequest(){this.log({operation:"adv",param:"slot_request"})}logAdStarted(e){this.log({operation:"adv",param:e})}logAdPaused(){this.log({operation:"adv",param:"pause"})}logAdResumed(){this.log({operation:"adv",param:"resume"})}logAdEnded(){this.log({operation:"adv",param:"ended"})}logAdSkipped(){this.log({operation:"adv",param:"skip"})}logAdClicked(){this.log({operation:"adv",param:"click"})}log(e){const o=this.createLogItem(e);this.logger.log(o)}createLogItem({operation:e,param:o}){const s=this.timeSynchronisation.now(),r={vsid:this.vsid,vid:this.statContext.movieId,quality:this.statContext.quality,dst:this.statContext.destination,ct:this.statContext.contentType,aid:this.statContext.albumId,place:this.statContext.place,cdn_host:this.statContext.cdnHostname,connection_type:this.statContext.connectionType,connection_reused:this.statContext.connectionReused===!0?b.YES:this.statContext.connectionReused===!1?b.NO:void 0,stat_type:this.statContext.autoplay===!0?y.AUTO:this.statContext.autoplay===!1?y.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode};o!==void 0&&(r.param=o);for(const i of this.fieldBlacklist)delete r[i];return{operation:e,timestamp:s,custom:r}}}exports.OneStat=J;
|