@vkontakte/videoplayer-statistics 1.0.11 → 1.0.12
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 +6 -0
- package/es2015.esm.js +6 -0
- 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/package.json +2 -2
- package/es5.cjs.js +0 -6
- package/es5.esm.js +0 -6
package/es2015.cjs.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vkontakte/videoplayer-statistics v1.0.12
|
|
3
|
+
* Thu, 17 Mar 2022 14:38:04 GMT
|
|
4
|
+
* https://st.mycdn.me/static/playersdk/1-0-12/doc/
|
|
5
|
+
*/
|
|
6
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var t=require('@vkontakte/videoplayer-shared/es2015.cjs.js');function e(t){return t&&'object'==typeof t&&'default'in t?t:{default:t}}var r=e(require('lodash/debounce'));function n(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{u(n.next(t))}catch(t){i(t)}}function s(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(a,s)}u((n=n.apply(t,e||[])).next())}))}var o='undefined'!=typeof globalThis?globalThis:'undefined'!=typeof window?window:'undefined'!=typeof global?global:'undefined'!=typeof self?self:{},i=function(t){return t&&t.Math==Math&&t},a=i('object'==typeof globalThis&&globalThis)||i('object'==typeof window&&window)||i('object'==typeof self&&self)||i('object'==typeof o&&o)||function(){return this}()||Function('return this')(),s=function(t){try{return!!t()}catch(t){return!0}},u=!s((function(){var t=function(){}.bind();return'function'!=typeof t||t.hasOwnProperty('prototype')})),c=u,l=Function.prototype,f=l.apply,p=l.call,h='object'==typeof Reflect&&Reflect.apply||(c?p.bind(f):function(){return p.apply(f,arguments)}),d=u,v=Function.prototype,y=v.bind,g=v.call,m=d&&y.bind(g,g),b=d?function(t){return t&&m(t)}:function(t){return t&&function(){return g.apply(t,arguments)}},w=function(t){return'function'==typeof t},O={},_=!s((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),P=u,S=Function.prototype.call,E=P?S.bind(S):function(){return S.apply(S,arguments)},T={},A={}.propertyIsEnumerable,j=Object.getOwnPropertyDescriptor,R=j&&!A.call({1:2},1);T.f=R?function(t){var e=j(this,t);return!!e&&e.enumerable}:A;var x,k,L=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},C=b,I=C({}.toString),N=C(''.slice),q=function(t){return N(I(t),8,-1)},M=b,B=s,F=q,D=a.Object,z=M(''.split),U=B((function(){return!D('z').propertyIsEnumerable(0)}))?function(t){return'String'==F(t)?z(t,''):D(t)}:D,K=a.TypeError,Q=function(t){if(null==t)throw K('Can\'t call method on '+t);return t},H=U,$=Q,G=w,Y=function(t){return'object'==typeof t?null!==t:G(t)},J={},W=J,V=a,X=w,Z=function(t){return X(t)?t:void 0},tt=function(t,e){return arguments.length<2?Z(W[t])||Z(V[t]):W[t]&&W[t][e]||V[t]&&V[t][e]},et=b({}.isPrototypeOf),rt=tt('navigator','userAgent')||'',nt=a,ot=rt,it=nt.process,at=nt.Deno,st=it&&it.versions||at&&at.version,ut=st&&st.v8;ut&&(k=(x=ut.split('.'))[0]>0&&x[0]<4?1:+(x[0]+x[1])),!k&&ot&&(!(x=ot.match(/Edge\/(\d+)/))||x[1]>=74)&&(x=ot.match(/Chrome\/(\d+)/))&&(k=+x[1]);var ct=k,lt=ct,ft=s,pt=!!Object.getOwnPropertySymbols&&!ft((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&<&<<41})),ht=pt&&!Symbol.sham&&'symbol'==typeof Symbol.iterator,dt=tt,vt=w,yt=et,gt=ht,mt=a.Object,bt=gt?function(t){return'symbol'==typeof t}:function(t){var e=dt('Symbol');return vt(e)&&yt(e.prototype,mt(t))},wt=a.String,Ot=function(t){try{return wt(t)}catch(t){return'Object'}},_t=w,Pt=Ot,St=a.TypeError,Et=function(t){if(_t(t))return t;throw St(Pt(t)+' is not a function')},Tt=Et,At=function(t,e){var r=t[e];return null==r?void 0:Tt(r)},jt=E,Rt=w,xt=Y,kt=a.TypeError,Lt={exports:{}},Ct=a,It=Object.defineProperty,Nt=function(t,e){try{It(Ct,t,{value:e,configurable:!0,writable:!0})}catch(r){Ct[t]=e}return e},qt=a['__core-js_shared__']||Nt('__core-js_shared__',{}),Mt=qt;(Lt.exports=function(t,e){return Mt[t]||(Mt[t]=void 0!==e?e:{})})('versions',[]).push({version:'3.21.1',mode:'pure',copyright:'© 2014-2022 Denis Pushkarev (zloirock.ru)',license:'https://github.com/zloirock/core-js/blob/v3.21.1/LICENSE',source:'https://github.com/zloirock/core-js'});var Bt=Q,Ft=a.Object,Dt=function(t){return Ft(Bt(t))},zt=b({}.hasOwnProperty),Ut=Object.hasOwn||function(t,e){return zt(Dt(t),e)},Kt=b,Qt=0,Ht=Math.random(),$t=Kt(1..toString),Gt=function(t){return'Symbol('+(void 0===t?'':t)+')_'+$t(++Qt+Ht,36)},Yt=a,Jt=Lt.exports,Wt=Ut,Vt=Gt,Xt=pt,Zt=ht,te=Jt('wks'),ee=Yt.Symbol,re=ee&&ee.for,ne=Zt?ee:ee&&ee.withoutSetter||Vt,oe=function(t){if(!Wt(te,t)||!Xt&&'string'!=typeof te[t]){var e='Symbol.'+t;Xt&&Wt(ee,t)?te[t]=ee[t]:te[t]=Zt&&re?re(e):ne(e)}return te[t]},ie=E,ae=Y,se=bt,ue=At,ce=function(t,e){var r,n;if('string'===e&&Rt(r=t.toString)&&!xt(n=jt(r,t)))return n;if(Rt(r=t.valueOf)&&!xt(n=jt(r,t)))return n;if('string'!==e&&Rt(r=t.toString)&&!xt(n=jt(r,t)))return n;throw kt('Can\'t convert object to primitive value')},le=oe,fe=a.TypeError,pe=le('toPrimitive'),he=function(t,e){if(!ae(t)||se(t))return t;var r,n=ue(t,pe);if(n){if(void 0===e&&(e='default'),r=ie(n,t,e),!ae(r)||se(r))return r;throw fe('Can\'t convert object to primitive value')}return void 0===e&&(e='number'),ce(t,e)},de=bt,ve=function(t){var e=he(t,'string');return de(e)?e:e+''},ye=Y,ge=a.document,me=ye(ge)&&ye(ge.createElement),be=function(t){return me?ge.createElement(t):{}},we=be,Oe=!_&&!s((function(){return 7!=Object.defineProperty(we('div'),'a',{get:function(){return 7}}).a})),_e=_,Pe=E,Se=T,Ee=L,Te=function(t){return H($(t))},Ae=ve,je=Ut,Re=Oe,xe=Object.getOwnPropertyDescriptor;O.f=_e?xe:function(t,e){if(t=Te(t),e=Ae(e),Re)try{return xe(t,e)}catch(t){}if(je(t,e))return Ee(!Pe(Se.f,t,e),t[e])};var ke=s,Le=w,Ce=/#|\.prototype\./,Ie=function(t,e){var r=qe[Ne(t)];return r==Be||r!=Me&&(Le(e)?ke(e):!!e)},Ne=Ie.normalize=function(t){return String(t).replace(Ce,'.').toLowerCase()},qe=Ie.data={},Me=Ie.NATIVE='N',Be=Ie.POLYFILL='P',Fe=Ie,De=Et,ze=u,Ue=b(b.bind),Ke=function(t,e){return De(t),void 0===e?t:ze?Ue(t,e):function(){return t.apply(e,arguments)}},Qe={},He=_&&s((function(){return 42!=Object.defineProperty((function(){}),'prototype',{value:42,writable:!1}).prototype})),$e=a,Ge=Y,Ye=$e.String,Je=$e.TypeError,We=function(t){if(Ge(t))return t;throw Je(Ye(t)+' is not an object')},Ve=_,Xe=Oe,Ze=He,tr=We,er=ve,rr=a.TypeError,nr=Object.defineProperty,or=Object.getOwnPropertyDescriptor;Qe.f=Ve?Ze?function(t,e,r){if(tr(t),e=er(e),tr(r),'function'==typeof t&&'prototype'===e&&'value'in r&&'writable'in r&&!r.writable){var n=or(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 nr(t,e,r)}:nr:function(t,e,r){if(tr(t),e=er(e),tr(r),Xe)try{return nr(t,e,r)}catch(t){}if('get'in r||'set'in r)throw rr('Accessors not supported');return'value'in r&&(t[e]=r.value),t};var ir=Qe,ar=L,sr=_?function(t,e,r){return ir.f(t,e,ar(1,r))}:function(t,e,r){return t[e]=r,t},ur=a,cr=h,lr=b,fr=w,pr=O.f,hr=Fe,dr=J,vr=Ke,yr=sr,gr=Ut,mr=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 cr(t,this,arguments)};return e.prototype=t.prototype,e},br=function(t,e){var r,n,o,i,a,s,u,c,l=t.target,f=t.global,p=t.stat,h=t.proto,d=f?ur:p?ur[l]:(ur[l]||{}).prototype,v=f?dr:dr[l]||yr(dr,l,{})[l],y=v.prototype;for(o in e)r=!hr(f?o:l+(p?'.':'#')+o,t.forced)&&d&&gr(d,o),a=v[o],r&&(s=t.noTargetGet?(c=pr(d,o))&&c.value:d[o]),i=r&&s?s:e[o],r&&typeof a==typeof i||(u=t.bind&&r?vr(i,ur):t.wrap&&r?mr(i):h&&fr(i)?lr(i):i,(t.sham||i&&i.sham||a&&a.sham)&&yr(u,'sham',!0),yr(v,o,u),h&&(gr(dr,n=l+'Prototype')||yr(dr,n,{}),yr(dr[n],o,i),t.real&&y&&!y[o]&&yr(y,o,i)))},wr=a.Promise,Or=sr,_r=function(t,e,r,n){n&&n.enumerable?t[e]=r:Or(t,e,r)},Pr=a,Sr=(Pr.String,Pr.TypeError,b);Object.setPrototypeOf||'__proto__'in{}&&function(){var t,e=!1,r={};try{(t=Sr(Object.getOwnPropertyDescriptor(Object.prototype,'__proto__').set))(r,[]),e=r instanceof Array}catch(t){}}();var Er={};Er[oe('toStringTag')]='z';var Tr='[object z]'===String(Er),Ar=a,jr=Tr,Rr=w,xr=q,kr=oe('toStringTag'),Lr=Ar.Object,Cr='Arguments'==xr(function(){return arguments}()),Ir=jr?xr: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=Lr(t),kr))?r:Cr?xr(e):'Object'==(n=xr(e))&&Rr(e.callee)?'Arguments':n},Nr=Ir,qr=Tr?{}.toString:function(){return'[object '+Nr(this)+']'},Mr=Tr,Br=Qe.f,Fr=sr,Dr=Ut,zr=qr,Ur=oe('toStringTag'),Kr=tt,Qr=Qe,Hr=_,$r=oe('species'),Gr=et,Yr=a.TypeError,Jr=w,Wr=qt,Vr=b(Function.toString);Jr(Wr.inspectSource)||(Wr.inspectSource=function(t){return Vr(t)});var Xr=Wr.inspectSource,Zr={},tn=Zr,en=oe('iterator'),rn=Array.prototype,nn=Math.ceil,on=Math.floor,an=function(t){var e=+t;return e!=e||0===e?0:(e>0?on:nn)(e)},sn=Math.min,un=function(t){return t>0?sn(an(t),9007199254740991):0},cn=Ir,ln=At,fn=Zr,pn=oe('iterator'),hn=function(t){if(null!=t)return ln(t,pn)||ln(t,'@@iterator')||fn[cn(t)]},dn=E,vn=Et,yn=We,gn=Ot,mn=hn,bn=a.TypeError,wn=E,On=We,_n=At,Pn=Ke,Sn=E,En=We,Tn=Ot,An=function(t){return void 0!==t&&(tn.Array===t||rn[en]===t)},jn=function(t){return un(t.length)},Rn=et,xn=function(t,e){var r=arguments.length<2?mn(t):e;if(vn(r))return yn(dn(r,t));throw bn(gn(t)+' is not iterable')},kn=hn,Ln=function(t,e,r){var n,o;On(t);try{if(!(n=_n(t,'return'))){if('throw'===e)throw r;return r}n=wn(n,t)}catch(t){o=!0,n=t}if('throw'===e)throw r;if(o)throw n;return On(n),r},Cn=a.TypeError,In=function(t,e){this.stopped=t,this.result=e},Nn=In.prototype,qn=oe('iterator'),Mn=!1;try{var Bn=0,Fn={next:function(){return{done:!!Bn++}},return:function(){Mn=!0}};Fn[qn]=function(){return this},Array.from(Fn,(function(){throw 2}))}catch(t){}var Dn=b,zn=s,Un=w,Kn=Ir,Qn=Xr,Hn=function(){},$n=[],Gn=tt('Reflect','construct'),Yn=/^\s*(?:class|function)\b/,Jn=Dn(Yn.exec),Wn=!Yn.exec(Hn),Vn=function(t){if(!Un(t))return!1;try{return Gn(Hn,$n,t),!0}catch(t){return!1}},Xn=function(t){if(!Un(t))return!1;switch(Kn(t)){case'AsyncFunction':case'GeneratorFunction':case'AsyncGeneratorFunction':return!1}try{return Wn||!!Jn(Yn,Qn(t))}catch(t){return!0}};Xn.sham=!0;var Zn,to,eo,ro,no=!Gn||zn((function(){var t;return Vn(Vn.call)||!Vn(Object)||!Vn((function(){t=!0}))||t}))?Xn:Vn,oo=Ot,io=a.TypeError,ao=We,so=function(t){if(no(t))return t;throw io(oo(t)+' is not a constructor')},uo=oe('species'),co=function(t,e){var r,n=ao(t).constructor;return void 0===n||null==(r=ao(n)[uo])?e:so(r)},lo=tt('document','documentElement'),fo=b([].slice),po=a.TypeError,ho=/(?:ipad|iphone|ipod).*applewebkit/i.test(rt),vo='process'==q(a.process),yo=a,go=h,mo=Ke,bo=w,wo=Ut,Oo=s,_o=lo,Po=fo,So=be,Eo=function(t,e){if(t<e)throw po('Not enough arguments');return t},To=ho,Ao=vo,jo=yo.setImmediate,Ro=yo.clearImmediate,xo=yo.process,ko=yo.Dispatch,Lo=yo.Function,Co=yo.MessageChannel,Io=yo.String,No=0,qo={};try{Zn=yo.location}catch(t){}var Mo=function(t){if(wo(qo,t)){var e=qo[t];delete qo[t],e()}},Bo=function(t){return function(){Mo(t)}},Fo=function(t){Mo(t.data)},Do=function(t){yo.postMessage(Io(t),Zn.protocol+'//'+Zn.host)};jo&&Ro||(jo=function(t){Eo(arguments.length,1);var e=bo(t)?t:Lo(t),r=Po(arguments,1);return qo[++No]=function(){go(e,void 0,r)},to(No),No},Ro=function(t){delete qo[t]},Ao?to=function(t){xo.nextTick(Bo(t))}:ko&&ko.now?to=function(t){ko.now(Bo(t))}:Co&&!To?(ro=(eo=new Co).port2,eo.port1.onmessage=Fo,to=mo(ro.postMessage,ro)):yo.addEventListener&&bo(yo.postMessage)&&!yo.importScripts&&Zn&&'file:'!==Zn.protocol&&!Oo(Do)?(to=Do,yo.addEventListener('message',Fo,!1)):to='onreadystatechange'in So('script')?function(t){_o.appendChild(So('script')).onreadystatechange=function(){_o.removeChild(this),Mo(t)}}:function(t){setTimeout(Bo(t),0)});var zo,Uo,Ko,Qo,Ho,$o,Go,Yo,Jo={set:jo,clear:Ro},Wo=a,Vo=/ipad|iphone|ipod/i.test(rt)&&void 0!==Wo.Pebble,Xo=/web0s(?!.*chrome)/i.test(rt),Zo=a,ti=Ke,ei=O.f,ri=Jo.set,ni=ho,oi=Vo,ii=Xo,ai=vo,si=Zo.MutationObserver||Zo.WebKitMutationObserver,ui=Zo.document,ci=Zo.process,li=Zo.Promise,fi=ei(Zo,'queueMicrotask'),pi=fi&&fi.value;pi||(zo=function(){var t,e;for(ai&&(t=ci.domain)&&t.exit();Uo;){e=Uo.fn,Uo=Uo.next;try{e()}catch(t){throw Uo?Qo():Ko=void 0,t}}Ko=void 0,t&&t.enter()},ni||ai||ii||!si||!ui?!oi&&li&&li.resolve?((Go=li.resolve(void 0)).constructor=li,Yo=ti(Go.then,Go),Qo=function(){Yo(zo)}):ai?Qo=function(){ci.nextTick(zo)}:(ri=ti(ri,Zo),Qo=function(){ri(zo)}):(Ho=!0,$o=ui.createTextNode(''),new si(zo).observe($o,{characterData:!0}),Qo=function(){$o.data=Ho=!Ho}));var hi=pi||function(t){var e={fn:t,next:void 0};Ko&&(Ko.next=e),Uo||(Uo=e,Qo()),Ko=e},di={},vi=Et,yi=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=vi(e),this.reject=vi(r)};di.f=function(t){return new yi(t)};var gi=We,mi=Y,bi=di,wi=function(t,e){if(gi(t),mi(e)&&e.constructor===t)return e;var r=bi.f(t);return(0,r.resolve)(e),r.promise},Oi=a,_i=function(){this.head=null,this.tail=null};_i.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 Pi,Si,Ei,Ti=_i,Ai=w,ji=Xr,Ri=a.WeakMap,xi=Ai(Ri)&&/native code/.test(ji(Ri)),ki=Lt.exports,Li=Gt,Ci=ki('keys'),Ii=xi,Ni=a,qi=b,Mi=Y,Bi=sr,Fi=Ut,Di=qt,zi=function(t){return Ci[t]||(Ci[t]=Li(t))},Ui={},Ki=Ni.TypeError,Qi=Ni.WeakMap;if(Ii||Di.state){var Hi=Di.state||(Di.state=new Qi),$i=qi(Hi.get),Gi=qi(Hi.has),Yi=qi(Hi.set);Pi=function(t,e){if(Gi(Hi,t))throw new Ki('Object already initialized');return e.facade=t,Yi(Hi,t,e),e},Si=function(t){return $i(Hi,t)||{}},Ei=function(t){return Gi(Hi,t)}}else{var Ji=zi('state');Ui[Ji]=!0,Pi=function(t,e){if(Fi(t,Ji))throw new Ki('Object already initialized');return e.facade=t,Bi(t,Ji,e),e},Si=function(t){return Fi(t,Ji)?t[Ji]:{}},Ei=function(t){return Fi(t,Ji)}}var Wi,Vi,Xi,Zi='object'==typeof window,ta=br,ea=a,ra=tt,na=E,oa=wr,ia=function(t,e,r){for(var n in e)r&&r.unsafe&&t[n]?t[n]=e[n]:_r(t,n,e[n],r);return t},aa=function(t,e,r,n){if(t){var o=r?t:t.prototype;Dr(o,Ur)||Br(o,Ur,{configurable:!0,value:e}),n&&!Mr&&Fr(o,'toString',zr)}},sa=function(t){var e=Kr(t),r=Qr.f;Hr&&e&&!e[$r]&&r(e,$r,{configurable:!0,get:function(){return this}})},ua=Et,ca=w,la=Y,fa=function(t,e){if(Gr(e,t))return t;throw Yr('Incorrect invocation')},pa=Xr,ha=function(t,e,r){var n,o,i,a,s,u,c,l=r&&r.that,f=!(!r||!r.AS_ENTRIES),p=!(!r||!r.IS_ITERATOR),h=!(!r||!r.INTERRUPTED),d=Pn(e,l),v=function(t){return n&&Ln(n,'normal',t),new In(!0,t)},y=function(t){return f?(En(t),h?d(t[0],t[1],v):d(t[0],t[1])):h?d(t,v):d(t)};if(p)n=t;else{if(!(o=kn(t)))throw Cn(Tn(t)+' is not iterable');if(An(o)){for(i=0,a=jn(t);a>i;i++)if((s=y(t[i]))&&Rn(Nn,s))return s;return new In(!1)}n=xn(t,o)}for(u=n.next;!(c=Sn(u,n)).done;){try{s=y(c.value)}catch(t){Ln(n,'throw',t)}if('object'==typeof s&&s&&Rn(Nn,s))return s}return new In(!1)},da=function(t,e){if(!e&&!Mn)return!1;var r=!1;try{var n={};n[qn]=function(){return{next:function(){return{done:r=!0}}}},t(n)}catch(t){}return r},va=co,ya=Jo.set,ga=hi,ma=wi,ba=function(t,e){var r=Oi.console;r&&r.error&&(1==arguments.length?r.error(t):r.error(t,e))},wa=di,Oa=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}},_a=Ti,Pa={set:Pi,get:Si,has:Ei,enforce:function(t){return Ei(t)?Si(t):Pi(t,{})},getterFor:function(t){return function(e){var r;if(!Mi(e)||(r=Si(e)).type!==t)throw Ki('Incompatible receiver, '+t+' required');return r}}},Sa=Fe,Ea=Zi,Ta=vo,Aa=ct,ja=oe('species'),Ra='Promise',xa=Pa.getterFor(Ra),ka=Pa.set,La=Pa.getterFor(Ra),Ca=oa&&oa.prototype,Ia=oa,Na=Ca,qa=ea.TypeError,Ma=ea.document,Ba=ea.process,Fa=wa.f,Da=Fa,za=!!(Ma&&Ma.createEvent&&ea.dispatchEvent),Ua=ca(ea.PromiseRejectionEvent),Ka=Sa(Ra,(function(){var t=pa(Ia),e=t!==String(Ia);if(!e&&66===Aa)return!0;if(!Na.finally)return!0;if(Aa>=51&&/native code/.test(t))return!1;var r=new Ia((function(t){t(1)})),n=function(t){t((function(){}),(function(){}))};return(r.constructor={})[ja]=n,!(r.then((function(){}))instanceof n)||!e&&Ea&&!Ua})),Qa=Ka||!da((function(t){Ia.all(t).catch((function(){}))})),Ha=function(t){var e;return!(!la(t)||!ca(e=t.then))&&e},$a=function(t,e){var r,n,o,i=e.value,a=1==e.state,s=a?t.ok:t.fail,u=t.resolve,c=t.reject,l=t.domain;try{s?(a||(2===e.rejection&&Va(e),e.rejection=1),!0===s?r=i:(l&&l.enter(),r=s(i),l&&(l.exit(),o=!0)),r===t.promise?c(qa('Promise-chain cycle')):(n=Ha(r))?na(n,r,u,c):u(r)):c(i)}catch(t){l&&!o&&l.exit(),c(t)}},Ga=function(t,e){t.notified||(t.notified=!0,ga((function(){for(var r,n=t.reactions;r=n.get();)$a(r,t);t.notified=!1,e&&!t.rejection&&Ja(t)})))},Ya=function(t,e,r){var n,o;za?((n=Ma.createEvent('Event')).promise=e,n.reason=r,n.initEvent(t,!1,!0),ea.dispatchEvent(n)):n={promise:e,reason:r},!Ua&&(o=ea['on'+t])?o(n):'unhandledrejection'===t&&ba('Unhandled promise rejection',r)},Ja=function(t){na(ya,ea,(function(){var e,r=t.facade,n=t.value;if(Wa(t)&&(e=Oa((function(){Ta?Ba.emit('unhandledRejection',n,r):Ya('unhandledrejection',r,n)})),t.rejection=Ta||Wa(t)?2:1,e.error))throw e.value}))},Wa=function(t){return 1!==t.rejection&&!t.parent},Va=function(t){na(ya,ea,(function(){var e=t.facade;Ta?Ba.emit('rejectionHandled',e):Ya('rejectionhandled',e,t.value)}))},Xa=function(t,e,r){return function(n){t(e,n,r)}},Za=function(t,e,r){t.done||(t.done=!0,r&&(t=r),t.value=e,t.state=2,Ga(t,!0))},ts=function(t,e,r){if(!t.done){t.done=!0,r&&(t=r);try{if(t.facade===e)throw qa('Promise can\'t be resolved itself');var n=Ha(e);n?ga((function(){var r={done:!1};try{na(n,e,Xa(ts,r,t),Xa(Za,r,t))}catch(e){Za(r,e,t)}})):(t.value=e,t.state=1,Ga(t,!1))}catch(e){Za({done:!1},e,t)}}};Ka&&(Na=(Ia=function(t){fa(this,Na),ua(t),na(Wi,this);var e=xa(this);try{t(Xa(ts,e),Xa(Za,e))}catch(t){Za(e,t)}}).prototype,(Wi=function(t){ka(this,{type:Ra,done:!1,notified:!1,parent:!1,reactions:new _a,rejection:!1,state:0,value:void 0})}).prototype=ia(Na,{then:function(t,e){var r=La(this),n=Fa(va(this,Ia));return r.parent=!0,n.ok=!ca(t)||t,n.fail=ca(e)&&e,n.domain=Ta?Ba.domain:void 0,0==r.state?r.reactions.add(n):ga((function(){$a(n,r)})),n.promise},catch:function(t){return this.then(void 0,t)}}),Vi=function(){var t=new Wi,e=xa(t);this.promise=t,this.resolve=Xa(ts,e),this.reject=Xa(Za,e)},wa.f=Fa=function(t){return t===Ia||t===Xi?new Vi(t):Da(t)}),ta({global:!0,wrap:!0,forced:Ka},{Promise:Ia}),aa(Ia,Ra,!1,!0),sa(Ra),Xi=ra(Ra),ta({target:Ra,stat:!0,forced:Ka},{reject:function(t){var e=Fa(this);return na(e.reject,void 0,t),e.promise}}),ta({target:Ra,stat:!0,forced:true},{resolve:function(t){return ma(this===Xi?Ia:this,t)}}),ta({target:Ra,stat:!0,forced:Qa},{all:function(t){var e=this,r=Fa(e),n=r.resolve,o=r.reject,i=Oa((function(){var r=ua(e.resolve),i=[],a=0,s=1;ha(t,(function(t){var u=a++,c=!1;s++,na(r,e,t).then((function(t){c||(c=!0,i[u]=t,--s||n(i))}),o)})),--s||n(i)}));return i.error&&o(i.value),r.promise},race:function(t){var e=this,r=Fa(e),n=r.reject,o=Oa((function(){var o=ua(e.resolve);ha(t,(function(t){na(o,e,t).then(r.resolve,n)}))}));return o.error&&n(o.value),r.promise}});var es=wr,rs=tt,ns=w,os=co,is=wi;br({target:'Promise',proto:!0,real:!0,forced:!!es&&s((function(){es.prototype.finally.call({then:function(){}},(function(){}))}))},{finally:function(t){var e=os(this,rs('Promise')),r=ns(t);return this.then(r?function(r){return is(e,t()).then((function(){return r}))}:t,r?function(r){return is(e,t()).then((function(){throw r}))}:t)}});var as=tt('Promise','finally');const ss=(()=>{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 us,cs,ls,fs,ps,hs,ds,vs={get:t=>function(t){const e=ss?ss.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{ss&&ss.setItem('_one-stat_'+t,JSON.stringify(e))}catch(t){}}(t,e)},remove(t){!function(t){ss&&ss.removeItem('_one-stat_'+t)}(t)}};exports.ApiEnv=void 0,(us=exports.ApiEnv||(exports.ApiEnv={})).PROD='prod',us.VK_ALIAS='vk_alias',us.VIDEOTEST='videotest',us.TEST='test',exports.Quality=void 0,(cs=exports.Quality||(exports.Quality={})).Q144P='144',cs.Q240P='240',cs.Q360P='360',cs.Q480P='480',cs.Q720P='720',cs.Q1080P='1080',cs.Q1440P='1440',cs.Q2160P='2160',cs.Q4320P='4320',cs.UNKNOWN='unknown',exports.ScreenDestination=void 0,(ls=exports.ScreenDestination||(exports.ScreenDestination={})).CHROMECAST='chromecast',ls.APPLE_TV='appletv',ls.PIP='pip',ls.HEADPHONES='externalHeadphones',ls.SCREEN='',exports.ContentType=void 0,(fs=exports.ContentType||(exports.ContentType={})).MP4='mp4',fs.DASH='dash',fs.HLS='hls',fs.WEBM='webm',function(t){t.AUTO='auto',t.MANUAL=''}(ps||(ps={})),exports.ConnectionType=void 0,(hs=exports.ConnectionType||(exports.ConnectionType={})).HTTP1='http1',hs.HTTP2='http2',hs.HTTP3='http3',function(t){t[t.YES=1]='YES',t[t.NO=0]='NO'}(ds||(ds={}));const ys={[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'};var gs;!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'}(gs||(gs={}));class ms{constructor(t){this.params=t;const e=vs.get('uuid');e?this.uuid=String(e):(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('')}(),vs.set('uuid',this.uuid))}authorize(t){return n(this,void 0,void 0,(function*(){return this.authToken=null!=t?t:yield this.refreshAuthToken(),this._authorize()}))}logBeacon(t){const e='log.externalLog',r=this.createLogParams(t),n=this.sessionKey;void 0!==n&&this.params.apiTransport.sendBeacon(e,r,n)||this.params.apiTransport.sendRequest(e,r,n)}logRequest(t){var e;return n(this,void 0,void 0,(function*(){const r='log.externalLog',n=this.createLogParams(t),o=null!==(e=this.sessionKey)&&void 0!==e?e:yield this._authorize();try{return yield this.params.apiTransport.sendRequest(r,n,o)}catch(t){switch(null==t?void 0:t.error_code){case gs.PARAM_SESSION_EXPIRED:case gs.PARAM_SESSION_KEY:case gs.PARAM_SIGNATURE:{const t=yield this._authorize();return this.params.apiTransport.sendRequest(r,n,t)}case gs.AUTH_LOGIN:{this.authToken=yield this.refreshAuthToken();const t=yield this._authorizeRequest();return this.params.apiTransport.sendRequest(r,n,t)}default:throw t}}}))}refreshAuthToken(){return n(this,void 0,void 0,(function*(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=as(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.12',platform:'WEB',items:t.map((t=>Object.assign(Object.assign({},t),{time:0,type:1})))})}}_authorize(){return n(this,void 0,void 0,(function*(){try{return yield this._authorizeRequest()}catch(t){switch(null==t?void 0:t.error_code){case gs.AUTH_LOGIN:return this.authToken=yield this.refreshAuthToken(),this._authorizeRequest()}throw t}}))}_authorizeRequest(){return n(this,void 0,void 0,(function*(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0;const t='auth.anonymLogin',e={session_data:{version:2,device_id:this.uuid,client_version:'1.0.12'.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=as(this.params.apiTransport.sendRequest(t,e).then((r=>{if(!r)throw new Error(`Empty response. Method: ${t}, params: ${JSON.stringify(e)}`);if(!r.session_key)throw new Error(`Empty 'session_key' in response. Method: ${t}, params: ${JSON.stringify(e)}, response: ${JSON.stringify(r)}`);return this.sessionKey=r.session_key,this.sessionKey})).catch((t=>{throw this.sessionKey=void 0,t})),(()=>{this.authorizePromise=void 0})),this.authorizePromise}))}}var bs={};function ws(t,e){if(!(t instanceof e))throw new TypeError('Cannot call a class as a function')}function Os(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,'value'in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function _s(t,e,r){return e&&Os(t.prototype,e),r&&Os(t,r),t}function Ps(t){return(Ps=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function Ss(t,e){return(Ss=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Es(t){if(void 0===t)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return t}function Ts(t,e){return!e||'object'!=typeof e&&'function'!=typeof e?Es(t):e}function As(t){var e=function(){if('undefined'==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if('function'==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=Ps(t);if(e){var o=Ps(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return Ts(this,r)}}function js(t,e,r){return(js='undefined'!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Ps(t)););return t}(t,e);if(n){var o=Object.getOwnPropertyDescriptor(n,e);return o.get?o.get.call(r):o.value}})(t,e,r||t)}Object.defineProperty(bs,'__esModule',{value:!0});var Rs=function(){function t(){ws(this,t),Object.defineProperty(this,'listeners',{value:{},writable:!0,configurable:!0})}return _s(t,[{key:'addEventListener',value:function(t,e,r){t in this.listeners||(this.listeners[t]=[]),this.listeners[t].push({callback:e,options:r})}},{key:'removeEventListener',value:function(t,e){if(t in this.listeners)for(var r=this.listeners[t],n=0,o=r.length;n<o;n++)if(r[n].callback===e)return void r.splice(n,1)}},{key:'dispatchEvent',value:function(t){if(t.type in this.listeners){for(var e=this.listeners[t.type].slice(),r=0,n=e.length;r<n;r++){var o=e[r];try{o.callback.call(this,t)}catch(t){Promise.resolve().then((function(){throw t}))}o.options&&o.options.once&&this.removeEventListener(t.type,o.callback)}return!t.defaultPrevented}}}]),t}(),xs=function(t){!function(t,e){if('function'!=typeof e&&null!==e)throw new TypeError('Super expression must either be null or a function');t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Ss(t,e)}(r,Rs);var e=As(r);function r(){var t;return ws(this,r),(t=e.call(this)).listeners||Rs.call(Es(t)),Object.defineProperty(Es(t),'aborted',{value:!1,writable:!0,configurable:!0}),Object.defineProperty(Es(t),'onabort',{value:null,writable:!0,configurable:!0}),t}return _s(r,[{key:'toString',value:function(){return'[object AbortSignal]'}},{key:'dispatchEvent',value:function(t){'abort'===t.type&&(this.aborted=!0,'function'==typeof this.onabort&&this.onabort.call(this,t)),js(Ps(r.prototype),'dispatchEvent',this).call(this,t)}}]),r}(),ks=function(){function t(){ws(this,t),Object.defineProperty(this,'signal',{value:new xs,writable:!0,configurable:!0})}return _s(t,[{key:'abort',value:function(){var t;try{t=new Event('abort')}catch(e){'undefined'!=typeof document?document.createEvent?(t=document.createEvent('Event')).initEvent('abort',!1,!1):(t=document.createEventObject()).type='abort':t={type:'abort',bubbles:!1,cancelable:!1}}this.signal.dispatchEvent(t)}},{key:'toString',value:function(){return'[object AbortController]'}}]),t}();'undefined'!=typeof Symbol&&Symbol.toStringTag&&(ks.prototype[Symbol.toStringTag]='AbortController',xs.prototype[Symbol.toStringTag]='AbortSignal'),bs.AbortController=ks,bs.AbortSignal=xs;var Ls=bs.abortableFetch=function(t){'function'==typeof t&&(t={fetch:t});var e=t,r=e.fetch,n=e.Request,o=void 0===n?r.Request:n,i=e.AbortController,a=e.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL,s=void 0!==a&&a;if(!function(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}({fetch:r,Request:o,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:s}))return{fetch:r,Request:u};var u=o;(u&&!u.prototype.hasOwnProperty('signal')||s)&&((u=function(t,e){var r;e&&e.signal&&(r=e.signal,delete e.signal);var n=new o(t,e);return r&&Object.defineProperty(n,'signal',{writable:!1,enumerable:!1,configurable:!0,value:r}),n}).prototype=o.prototype);var c=r;return{fetch:function(t,e){var r=u&&u.prototype.isPrototypeOf(t)?t.signal:e?e.signal:void 0;if(r){var n;try{n=new DOMException('Aborted','AbortError')}catch(t){(n=new Error('Aborted')).name='AbortError'}if(r.aborted)return Promise.reject(n);var o=new Promise((function(t,e){r.addEventListener('abort',(function(){return e(n)}),{once:!0})}));return e&&e.signal&&delete e.signal,Promise.race([o,c(t,e)])}return c(t,e)},Request:u}};class Cs{constructor(t){this.params=t,this.apiKey=t.apiKey,this.apiBaseUrl=t.apiBaseUrl,'/'!==this.apiBaseUrl[this.apiBaseUrl.length-1]&&(this.apiBaseUrl+='/')}sendBeacon(t,e,r){if(!window.Blob||!window.navigator.sendBeacon)return!1;const n=this._prepareQueryParams({method:t,queryParams:e,sessionKey:r}),o=new window.Blob([n.toString()],{type:'application/x-www-form-urlencoded'});return window.navigator.sendBeacon(`${this.apiBaseUrl}fb.do`,o)}sendRequest(t,e,r){return n(this,void 0,void 0,(function*(){const n=Date.now(),o=o=>{throw this.params.error$.next({id:'OneStat:ApiTransport:sendRequest',message:'Unhandled request error',thrown:o,data:{method:t,params:e,sessionKey:r,time:Date.now()-n}}),o};return Ls(fetch).fetch(`${this.apiBaseUrl}fb.do`,{method:'post',headers:{'Content-type':'application/x-www-form-urlencoded'},body:this._prepareQueryParams({method:t,queryParams:e,sessionKey:r})}).then((t=>Number(t.headers.get('content-length'))>0?t.json().then((t=>Object.prototype.hasOwnProperty.call(t,'error_msg')?Promise.reject(t):t),o):void 0),o)}))}_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 Is{constructor(t){this.requestQueue=[],this.isPaused=!1,this.debouncedFlush=r.default((()=>this.flush()),3e3,{maxWait:15e3}),this.api=t.api}log(t){this.requestQueue.push(t),this.isPaused||this.debouncedFlush()}flush(t=!1){0!==this.requestQueue.length&&(t?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[],this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}}exports.OneStat=class{constructor(e,r){this.statContext=e;const n=new t.Subject;this.experimental={error$:n};const o=new Cs({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:ys[r.apiEnv],error$:n});this.api=new ms({apiTransport:o,refreshAuthToken:r.refreshAuthToken}),this.logger=new Is({api:this.api}),window.addEventListener('beforeunload',(()=>this.logger.flush(!0)))}updateContext(t){this.statContext=Object.assign(Object.assign({},this.statContext),t)}authorize(t){return this.api.authorize(t)}pause(){this.logger.pause()}resume(){this.logger.resume()}logStarted(){this.log({operation:'play'})}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){this.log({operation:'watch_coverage_live',param:`${t.start}-${t.end}`}),this.logger.flush(!0)}logEmptyBuffer(t){this.log({operation:'empty_buffer',param:String(t.duration)})}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.crateLogItem(t);this.logger.log(e)}crateLogItem({operation:t,param:e}){const r=Date.now(),n={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?ds.YES:!1===this.statContext.connectionReused?ds.NO:void 0,stat_type:!0===this.statContext.autoplay?ps.AUTO:!1===this.statContext.autoplay?ps.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId};return void 0!==e&&(n.param=e),{operation:t,timestamp:r,custom:n}}};
|
package/es2015.esm.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vkontakte/videoplayer-statistics v1.0.12
|
|
3
|
+
* Thu, 17 Mar 2022 14:38:04 GMT
|
|
4
|
+
* https://st.mycdn.me/static/playersdk/1-0-12/doc/
|
|
5
|
+
*/
|
|
6
|
+
import{Subject as t}from'@vkontakte/videoplayer-shared/es2015.esm.js';import e from'lodash/debounce';function r(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{u(n.next(t))}catch(t){i(t)}}function s(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(a,s)}u((n=n.apply(t,e||[])).next())}))}var n='undefined'!=typeof globalThis?globalThis:'undefined'!=typeof window?window:'undefined'!=typeof global?global:'undefined'!=typeof self?self:{},o=function(t){return t&&t.Math==Math&&t},i=o('object'==typeof globalThis&&globalThis)||o('object'==typeof window&&window)||o('object'==typeof self&&self)||o('object'==typeof n&&n)||function(){return this}()||Function('return this')(),a=function(t){try{return!!t()}catch(t){return!0}},s=!a((function(){var t=function(){}.bind();return'function'!=typeof t||t.hasOwnProperty('prototype')})),u=s,c=Function.prototype,l=c.apply,f=c.call,h='object'==typeof Reflect&&Reflect.apply||(u?f.bind(l):function(){return f.apply(l,arguments)}),p=s,d=Function.prototype,v=d.bind,y=d.call,g=p&&v.bind(y,y),m=p?function(t){return t&&g(t)}:function(t){return t&&function(){return y.apply(t,arguments)}},b=function(t){return'function'==typeof t},w={},O=!a((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),_=s,P=Function.prototype.call,S=_?P.bind(P):function(){return P.apply(P,arguments)},E={},T={}.propertyIsEnumerable,A=Object.getOwnPropertyDescriptor,j=A&&!T.call({1:2},1);E.f=j?function(t){var e=A(this,t);return!!e&&e.enumerable}:T;var R,k,L=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},I=m,x=I({}.toString),C=I(''.slice),N=function(t){return C(x(t),8,-1)},q=m,M=a,B=N,F=i.Object,D=q(''.split),z=M((function(){return!F('z').propertyIsEnumerable(0)}))?function(t){return'String'==B(t)?D(t,''):F(t)}:F,U=i.TypeError,K=function(t){if(null==t)throw U('Can\'t call method on '+t);return t},Q=z,H=K,$=b,G=function(t){return'object'==typeof t?null!==t:$(t)},Y={},J=Y,W=i,V=b,X=function(t){return V(t)?t:void 0},Z=function(t,e){return arguments.length<2?X(J[t])||X(W[t]):J[t]&&J[t][e]||W[t]&&W[t][e]},tt=m({}.isPrototypeOf),et=Z('navigator','userAgent')||'',rt=i,nt=et,ot=rt.process,it=rt.Deno,at=ot&&ot.versions||it&&it.version,st=at&&at.v8;st&&(k=(R=st.split('.'))[0]>0&&R[0]<4?1:+(R[0]+R[1])),!k&&nt&&(!(R=nt.match(/Edge\/(\d+)/))||R[1]>=74)&&(R=nt.match(/Chrome\/(\d+)/))&&(k=+R[1]);var ut=k,ct=ut,lt=a,ft=!!Object.getOwnPropertySymbols&&!lt((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&ct&&ct<41})),ht=ft&&!Symbol.sham&&'symbol'==typeof Symbol.iterator,pt=Z,dt=b,vt=tt,yt=ht,gt=i.Object,mt=yt?function(t){return'symbol'==typeof t}:function(t){var e=pt('Symbol');return dt(e)&&vt(e.prototype,gt(t))},bt=i.String,wt=function(t){try{return bt(t)}catch(t){return'Object'}},Ot=b,_t=wt,Pt=i.TypeError,St=function(t){if(Ot(t))return t;throw Pt(_t(t)+' is not a function')},Et=St,Tt=function(t,e){var r=t[e];return null==r?void 0:Et(r)},At=S,jt=b,Rt=G,kt=i.TypeError,Lt={exports:{}},It=i,xt=Object.defineProperty,Ct=function(t,e){try{xt(It,t,{value:e,configurable:!0,writable:!0})}catch(r){It[t]=e}return e},Nt=i['__core-js_shared__']||Ct('__core-js_shared__',{}),qt=Nt;(Lt.exports=function(t,e){return qt[t]||(qt[t]=void 0!==e?e:{})})('versions',[]).push({version:'3.21.1',mode:'pure',copyright:'© 2014-2022 Denis Pushkarev (zloirock.ru)',license:'https://github.com/zloirock/core-js/blob/v3.21.1/LICENSE',source:'https://github.com/zloirock/core-js'});var Mt=K,Bt=i.Object,Ft=function(t){return Bt(Mt(t))},Dt=m({}.hasOwnProperty),zt=Object.hasOwn||function(t,e){return Dt(Ft(t),e)},Ut=m,Kt=0,Qt=Math.random(),Ht=Ut(1..toString),$t=function(t){return'Symbol('+(void 0===t?'':t)+')_'+Ht(++Kt+Qt,36)},Gt=i,Yt=Lt.exports,Jt=zt,Wt=$t,Vt=ft,Xt=ht,Zt=Yt('wks'),te=Gt.Symbol,ee=te&&te.for,re=Xt?te:te&&te.withoutSetter||Wt,ne=function(t){if(!Jt(Zt,t)||!Vt&&'string'!=typeof Zt[t]){var e='Symbol.'+t;Vt&&Jt(te,t)?Zt[t]=te[t]:Zt[t]=Xt&&ee?ee(e):re(e)}return Zt[t]},oe=S,ie=G,ae=mt,se=Tt,ue=function(t,e){var r,n;if('string'===e&&jt(r=t.toString)&&!Rt(n=At(r,t)))return n;if(jt(r=t.valueOf)&&!Rt(n=At(r,t)))return n;if('string'!==e&&jt(r=t.toString)&&!Rt(n=At(r,t)))return n;throw kt('Can\'t convert object to primitive value')},ce=ne,le=i.TypeError,fe=ce('toPrimitive'),he=function(t,e){if(!ie(t)||ae(t))return t;var r,n=se(t,fe);if(n){if(void 0===e&&(e='default'),r=oe(n,t,e),!ie(r)||ae(r))return r;throw le('Can\'t convert object to primitive value')}return void 0===e&&(e='number'),ue(t,e)},pe=mt,de=function(t){var e=he(t,'string');return pe(e)?e:e+''},ve=G,ye=i.document,ge=ve(ye)&&ve(ye.createElement),me=function(t){return ge?ye.createElement(t):{}},be=me,we=!O&&!a((function(){return 7!=Object.defineProperty(be('div'),'a',{get:function(){return 7}}).a})),Oe=O,_e=S,Pe=E,Se=L,Ee=function(t){return Q(H(t))},Te=de,Ae=zt,je=we,Re=Object.getOwnPropertyDescriptor;w.f=Oe?Re:function(t,e){if(t=Ee(t),e=Te(e),je)try{return Re(t,e)}catch(t){}if(Ae(t,e))return Se(!_e(Pe.f,t,e),t[e])};var ke=a,Le=b,Ie=/#|\.prototype\./,xe=function(t,e){var r=Ne[Ce(t)];return r==Me||r!=qe&&(Le(e)?ke(e):!!e)},Ce=xe.normalize=function(t){return String(t).replace(Ie,'.').toLowerCase()},Ne=xe.data={},qe=xe.NATIVE='N',Me=xe.POLYFILL='P',Be=xe,Fe=St,De=s,ze=m(m.bind),Ue=function(t,e){return Fe(t),void 0===e?t:De?ze(t,e):function(){return t.apply(e,arguments)}},Ke={},Qe=O&&a((function(){return 42!=Object.defineProperty((function(){}),'prototype',{value:42,writable:!1}).prototype})),He=i,$e=G,Ge=He.String,Ye=He.TypeError,Je=function(t){if($e(t))return t;throw Ye(Ge(t)+' is not an object')},We=O,Ve=we,Xe=Qe,Ze=Je,tr=de,er=i.TypeError,rr=Object.defineProperty,nr=Object.getOwnPropertyDescriptor;Ke.f=We?Xe?function(t,e,r){if(Ze(t),e=tr(e),Ze(r),'function'==typeof t&&'prototype'===e&&'value'in r&&'writable'in r&&!r.writable){var n=nr(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 rr(t,e,r)}:rr:function(t,e,r){if(Ze(t),e=tr(e),Ze(r),Ve)try{return rr(t,e,r)}catch(t){}if('get'in r||'set'in r)throw er('Accessors not supported');return'value'in r&&(t[e]=r.value),t};var or=Ke,ir=L,ar=O?function(t,e,r){return or.f(t,e,ir(1,r))}:function(t,e,r){return t[e]=r,t},sr=i,ur=h,cr=m,lr=b,fr=w.f,hr=Be,pr=Y,dr=Ue,vr=ar,yr=zt,gr=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 ur(t,this,arguments)};return e.prototype=t.prototype,e},mr=function(t,e){var r,n,o,i,a,s,u,c,l=t.target,f=t.global,h=t.stat,p=t.proto,d=f?sr:h?sr[l]:(sr[l]||{}).prototype,v=f?pr:pr[l]||vr(pr,l,{})[l],y=v.prototype;for(o in e)r=!hr(f?o:l+(h?'.':'#')+o,t.forced)&&d&&yr(d,o),a=v[o],r&&(s=t.noTargetGet?(c=fr(d,o))&&c.value:d[o]),i=r&&s?s:e[o],r&&typeof a==typeof i||(u=t.bind&&r?dr(i,sr):t.wrap&&r?gr(i):p&&lr(i)?cr(i):i,(t.sham||i&&i.sham||a&&a.sham)&&vr(u,'sham',!0),vr(v,o,u),p&&(yr(pr,n=l+'Prototype')||vr(pr,n,{}),vr(pr[n],o,i),t.real&&y&&!y[o]&&vr(y,o,i)))},br=i.Promise,wr=ar,Or=function(t,e,r,n){n&&n.enumerable?t[e]=r:wr(t,e,r)},_r=i,Pr=(_r.String,_r.TypeError,m);Object.setPrototypeOf||'__proto__'in{}&&function(){var t,e=!1,r={};try{(t=Pr(Object.getOwnPropertyDescriptor(Object.prototype,'__proto__').set))(r,[]),e=r instanceof Array}catch(t){}}();var Sr={};Sr[ne('toStringTag')]='z';var Er='[object z]'===String(Sr),Tr=i,Ar=Er,jr=b,Rr=N,kr=ne('toStringTag'),Lr=Tr.Object,Ir='Arguments'==Rr(function(){return arguments}()),xr=Ar?Rr: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=Lr(t),kr))?r:Ir?Rr(e):'Object'==(n=Rr(e))&&jr(e.callee)?'Arguments':n},Cr=xr,Nr=Er?{}.toString:function(){return'[object '+Cr(this)+']'},qr=Er,Mr=Ke.f,Br=ar,Fr=zt,Dr=Nr,zr=ne('toStringTag'),Ur=Z,Kr=Ke,Qr=O,Hr=ne('species'),$r=tt,Gr=i.TypeError,Yr=b,Jr=Nt,Wr=m(Function.toString);Yr(Jr.inspectSource)||(Jr.inspectSource=function(t){return Wr(t)});var Vr=Jr.inspectSource,Xr={},Zr=Xr,tn=ne('iterator'),en=Array.prototype,rn=Math.ceil,nn=Math.floor,on=function(t){var e=+t;return e!=e||0===e?0:(e>0?nn:rn)(e)},an=Math.min,sn=function(t){return t>0?an(on(t),9007199254740991):0},un=xr,cn=Tt,ln=Xr,fn=ne('iterator'),hn=function(t){if(null!=t)return cn(t,fn)||cn(t,'@@iterator')||ln[un(t)]},pn=S,dn=St,vn=Je,yn=wt,gn=hn,mn=i.TypeError,bn=S,wn=Je,On=Tt,_n=Ue,Pn=S,Sn=Je,En=wt,Tn=function(t){return void 0!==t&&(Zr.Array===t||en[tn]===t)},An=function(t){return sn(t.length)},jn=tt,Rn=function(t,e){var r=arguments.length<2?gn(t):e;if(dn(r))return vn(pn(r,t));throw mn(yn(t)+' is not iterable')},kn=hn,Ln=function(t,e,r){var n,o;wn(t);try{if(!(n=On(t,'return'))){if('throw'===e)throw r;return r}n=bn(n,t)}catch(t){o=!0,n=t}if('throw'===e)throw r;if(o)throw n;return wn(n),r},In=i.TypeError,xn=function(t,e){this.stopped=t,this.result=e},Cn=xn.prototype,Nn=ne('iterator'),qn=!1;try{var Mn=0,Bn={next:function(){return{done:!!Mn++}},return:function(){qn=!0}};Bn[Nn]=function(){return this},Array.from(Bn,(function(){throw 2}))}catch(t){}var Fn=m,Dn=a,zn=b,Un=xr,Kn=Vr,Qn=function(){},Hn=[],$n=Z('Reflect','construct'),Gn=/^\s*(?:class|function)\b/,Yn=Fn(Gn.exec),Jn=!Gn.exec(Qn),Wn=function(t){if(!zn(t))return!1;try{return $n(Qn,Hn,t),!0}catch(t){return!1}},Vn=function(t){if(!zn(t))return!1;switch(Un(t)){case'AsyncFunction':case'GeneratorFunction':case'AsyncGeneratorFunction':return!1}try{return Jn||!!Yn(Gn,Kn(t))}catch(t){return!0}};Vn.sham=!0;var Xn,Zn,to,eo,ro=!$n||Dn((function(){var t;return Wn(Wn.call)||!Wn(Object)||!Wn((function(){t=!0}))||t}))?Vn:Wn,no=wt,oo=i.TypeError,io=Je,ao=function(t){if(ro(t))return t;throw oo(no(t)+' is not a constructor')},so=ne('species'),uo=function(t,e){var r,n=io(t).constructor;return void 0===n||null==(r=io(n)[so])?e:ao(r)},co=Z('document','documentElement'),lo=m([].slice),fo=i.TypeError,ho=/(?:ipad|iphone|ipod).*applewebkit/i.test(et),po='process'==N(i.process),vo=i,yo=h,go=Ue,mo=b,bo=zt,wo=a,Oo=co,_o=lo,Po=me,So=function(t,e){if(t<e)throw fo('Not enough arguments');return t},Eo=ho,To=po,Ao=vo.setImmediate,jo=vo.clearImmediate,Ro=vo.process,ko=vo.Dispatch,Lo=vo.Function,Io=vo.MessageChannel,xo=vo.String,Co=0,No={};try{Xn=vo.location}catch(t){}var qo=function(t){if(bo(No,t)){var e=No[t];delete No[t],e()}},Mo=function(t){return function(){qo(t)}},Bo=function(t){qo(t.data)},Fo=function(t){vo.postMessage(xo(t),Xn.protocol+'//'+Xn.host)};Ao&&jo||(Ao=function(t){So(arguments.length,1);var e=mo(t)?t:Lo(t),r=_o(arguments,1);return No[++Co]=function(){yo(e,void 0,r)},Zn(Co),Co},jo=function(t){delete No[t]},To?Zn=function(t){Ro.nextTick(Mo(t))}:ko&&ko.now?Zn=function(t){ko.now(Mo(t))}:Io&&!Eo?(eo=(to=new Io).port2,to.port1.onmessage=Bo,Zn=go(eo.postMessage,eo)):vo.addEventListener&&mo(vo.postMessage)&&!vo.importScripts&&Xn&&'file:'!==Xn.protocol&&!wo(Fo)?(Zn=Fo,vo.addEventListener('message',Bo,!1)):Zn='onreadystatechange'in Po('script')?function(t){Oo.appendChild(Po('script')).onreadystatechange=function(){Oo.removeChild(this),qo(t)}}:function(t){setTimeout(Mo(t),0)});var Do,zo,Uo,Ko,Qo,Ho,$o,Go,Yo={set:Ao,clear:jo},Jo=i,Wo=/ipad|iphone|ipod/i.test(et)&&void 0!==Jo.Pebble,Vo=/web0s(?!.*chrome)/i.test(et),Xo=i,Zo=Ue,ti=w.f,ei=Yo.set,ri=ho,ni=Wo,oi=Vo,ii=po,ai=Xo.MutationObserver||Xo.WebKitMutationObserver,si=Xo.document,ui=Xo.process,ci=Xo.Promise,li=ti(Xo,'queueMicrotask'),fi=li&&li.value;fi||(Do=function(){var t,e;for(ii&&(t=ui.domain)&&t.exit();zo;){e=zo.fn,zo=zo.next;try{e()}catch(t){throw zo?Ko():Uo=void 0,t}}Uo=void 0,t&&t.enter()},ri||ii||oi||!ai||!si?!ni&&ci&&ci.resolve?(($o=ci.resolve(void 0)).constructor=ci,Go=Zo($o.then,$o),Ko=function(){Go(Do)}):ii?Ko=function(){ui.nextTick(Do)}:(ei=Zo(ei,Xo),Ko=function(){ei(Do)}):(Qo=!0,Ho=si.createTextNode(''),new ai(Do).observe(Ho,{characterData:!0}),Ko=function(){Ho.data=Qo=!Qo}));var hi=fi||function(t){var e={fn:t,next:void 0};Uo&&(Uo.next=e),zo||(zo=e,Ko()),Uo=e},pi={},di=St,vi=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=di(e),this.reject=di(r)};pi.f=function(t){return new vi(t)};var yi=Je,gi=G,mi=pi,bi=function(t,e){if(yi(t),gi(e)&&e.constructor===t)return e;var r=mi.f(t);return(0,r.resolve)(e),r.promise},wi=i,Oi=function(){this.head=null,this.tail=null};Oi.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 _i,Pi,Si,Ei=Oi,Ti=b,Ai=Vr,ji=i.WeakMap,Ri=Ti(ji)&&/native code/.test(Ai(ji)),ki=Lt.exports,Li=$t,Ii=ki('keys'),xi=Ri,Ci=i,Ni=m,qi=G,Mi=ar,Bi=zt,Fi=Nt,Di=function(t){return Ii[t]||(Ii[t]=Li(t))},zi={},Ui=Ci.TypeError,Ki=Ci.WeakMap;if(xi||Fi.state){var Qi=Fi.state||(Fi.state=new Ki),Hi=Ni(Qi.get),$i=Ni(Qi.has),Gi=Ni(Qi.set);_i=function(t,e){if($i(Qi,t))throw new Ui('Object already initialized');return e.facade=t,Gi(Qi,t,e),e},Pi=function(t){return Hi(Qi,t)||{}},Si=function(t){return $i(Qi,t)}}else{var Yi=Di('state');zi[Yi]=!0,_i=function(t,e){if(Bi(t,Yi))throw new Ui('Object already initialized');return e.facade=t,Mi(t,Yi,e),e},Pi=function(t){return Bi(t,Yi)?t[Yi]:{}},Si=function(t){return Bi(t,Yi)}}var Ji,Wi,Vi,Xi='object'==typeof window,Zi=mr,ta=i,ea=Z,ra=S,na=br,oa=function(t,e,r){for(var n in e)r&&r.unsafe&&t[n]?t[n]=e[n]:Or(t,n,e[n],r);return t},ia=function(t,e,r,n){if(t){var o=r?t:t.prototype;Fr(o,zr)||Mr(o,zr,{configurable:!0,value:e}),n&&!qr&&Br(o,'toString',Dr)}},aa=function(t){var e=Ur(t),r=Kr.f;Qr&&e&&!e[Hr]&&r(e,Hr,{configurable:!0,get:function(){return this}})},sa=St,ua=b,ca=G,la=function(t,e){if($r(e,t))return t;throw Gr('Incorrect invocation')},fa=Vr,ha=function(t,e,r){var n,o,i,a,s,u,c,l=r&&r.that,f=!(!r||!r.AS_ENTRIES),h=!(!r||!r.IS_ITERATOR),p=!(!r||!r.INTERRUPTED),d=_n(e,l),v=function(t){return n&&Ln(n,'normal',t),new xn(!0,t)},y=function(t){return f?(Sn(t),p?d(t[0],t[1],v):d(t[0],t[1])):p?d(t,v):d(t)};if(h)n=t;else{if(!(o=kn(t)))throw In(En(t)+' is not iterable');if(Tn(o)){for(i=0,a=An(t);a>i;i++)if((s=y(t[i]))&&jn(Cn,s))return s;return new xn(!1)}n=Rn(t,o)}for(u=n.next;!(c=Pn(u,n)).done;){try{s=y(c.value)}catch(t){Ln(n,'throw',t)}if('object'==typeof s&&s&&jn(Cn,s))return s}return new xn(!1)},pa=function(t,e){if(!e&&!qn)return!1;var r=!1;try{var n={};n[Nn]=function(){return{next:function(){return{done:r=!0}}}},t(n)}catch(t){}return r},da=uo,va=Yo.set,ya=hi,ga=bi,ma=function(t,e){var r=wi.console;r&&r.error&&(1==arguments.length?r.error(t):r.error(t,e))},ba=pi,wa=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}},Oa=Ei,_a={set:_i,get:Pi,has:Si,enforce:function(t){return Si(t)?Pi(t):_i(t,{})},getterFor:function(t){return function(e){var r;if(!qi(e)||(r=Pi(e)).type!==t)throw Ui('Incompatible receiver, '+t+' required');return r}}},Pa=Be,Sa=Xi,Ea=po,Ta=ut,Aa=ne('species'),ja='Promise',Ra=_a.getterFor(ja),ka=_a.set,La=_a.getterFor(ja),Ia=na&&na.prototype,xa=na,Ca=Ia,Na=ta.TypeError,qa=ta.document,Ma=ta.process,Ba=ba.f,Fa=Ba,Da=!!(qa&&qa.createEvent&&ta.dispatchEvent),za=ua(ta.PromiseRejectionEvent),Ua=Pa(ja,(function(){var t=fa(xa),e=t!==String(xa);if(!e&&66===Ta)return!0;if(!Ca.finally)return!0;if(Ta>=51&&/native code/.test(t))return!1;var r=new xa((function(t){t(1)})),n=function(t){t((function(){}),(function(){}))};return(r.constructor={})[Aa]=n,!(r.then((function(){}))instanceof n)||!e&&Sa&&!za})),Ka=Ua||!pa((function(t){xa.all(t).catch((function(){}))})),Qa=function(t){var e;return!(!ca(t)||!ua(e=t.then))&&e},Ha=function(t,e){var r,n,o,i=e.value,a=1==e.state,s=a?t.ok:t.fail,u=t.resolve,c=t.reject,l=t.domain;try{s?(a||(2===e.rejection&&Wa(e),e.rejection=1),!0===s?r=i:(l&&l.enter(),r=s(i),l&&(l.exit(),o=!0)),r===t.promise?c(Na('Promise-chain cycle')):(n=Qa(r))?ra(n,r,u,c):u(r)):c(i)}catch(t){l&&!o&&l.exit(),c(t)}},$a=function(t,e){t.notified||(t.notified=!0,ya((function(){for(var r,n=t.reactions;r=n.get();)Ha(r,t);t.notified=!1,e&&!t.rejection&&Ya(t)})))},Ga=function(t,e,r){var n,o;Da?((n=qa.createEvent('Event')).promise=e,n.reason=r,n.initEvent(t,!1,!0),ta.dispatchEvent(n)):n={promise:e,reason:r},!za&&(o=ta['on'+t])?o(n):'unhandledrejection'===t&&ma('Unhandled promise rejection',r)},Ya=function(t){ra(va,ta,(function(){var e,r=t.facade,n=t.value;if(Ja(t)&&(e=wa((function(){Ea?Ma.emit('unhandledRejection',n,r):Ga('unhandledrejection',r,n)})),t.rejection=Ea||Ja(t)?2:1,e.error))throw e.value}))},Ja=function(t){return 1!==t.rejection&&!t.parent},Wa=function(t){ra(va,ta,(function(){var e=t.facade;Ea?Ma.emit('rejectionHandled',e):Ga('rejectionhandled',e,t.value)}))},Va=function(t,e,r){return function(n){t(e,n,r)}},Xa=function(t,e,r){t.done||(t.done=!0,r&&(t=r),t.value=e,t.state=2,$a(t,!0))},Za=function(t,e,r){if(!t.done){t.done=!0,r&&(t=r);try{if(t.facade===e)throw Na('Promise can\'t be resolved itself');var n=Qa(e);n?ya((function(){var r={done:!1};try{ra(n,e,Va(Za,r,t),Va(Xa,r,t))}catch(e){Xa(r,e,t)}})):(t.value=e,t.state=1,$a(t,!1))}catch(e){Xa({done:!1},e,t)}}};Ua&&(Ca=(xa=function(t){la(this,Ca),sa(t),ra(Ji,this);var e=Ra(this);try{t(Va(Za,e),Va(Xa,e))}catch(t){Xa(e,t)}}).prototype,(Ji=function(t){ka(this,{type:ja,done:!1,notified:!1,parent:!1,reactions:new Oa,rejection:!1,state:0,value:void 0})}).prototype=oa(Ca,{then:function(t,e){var r=La(this),n=Ba(da(this,xa));return r.parent=!0,n.ok=!ua(t)||t,n.fail=ua(e)&&e,n.domain=Ea?Ma.domain:void 0,0==r.state?r.reactions.add(n):ya((function(){Ha(n,r)})),n.promise},catch:function(t){return this.then(void 0,t)}}),Wi=function(){var t=new Ji,e=Ra(t);this.promise=t,this.resolve=Va(Za,e),this.reject=Va(Xa,e)},ba.f=Ba=function(t){return t===xa||t===Vi?new Wi(t):Fa(t)}),Zi({global:!0,wrap:!0,forced:Ua},{Promise:xa}),ia(xa,ja,!1,!0),aa(ja),Vi=ea(ja),Zi({target:ja,stat:!0,forced:Ua},{reject:function(t){var e=Ba(this);return ra(e.reject,void 0,t),e.promise}}),Zi({target:ja,stat:!0,forced:true},{resolve:function(t){return ga(this===Vi?xa:this,t)}}),Zi({target:ja,stat:!0,forced:Ka},{all:function(t){var e=this,r=Ba(e),n=r.resolve,o=r.reject,i=wa((function(){var r=sa(e.resolve),i=[],a=0,s=1;ha(t,(function(t){var u=a++,c=!1;s++,ra(r,e,t).then((function(t){c||(c=!0,i[u]=t,--s||n(i))}),o)})),--s||n(i)}));return i.error&&o(i.value),r.promise},race:function(t){var e=this,r=Ba(e),n=r.reject,o=wa((function(){var o=sa(e.resolve);ha(t,(function(t){ra(o,e,t).then(r.resolve,n)}))}));return o.error&&n(o.value),r.promise}});var ts=br,es=Z,rs=b,ns=uo,os=bi;mr({target:'Promise',proto:!0,real:!0,forced:!!ts&&a((function(){ts.prototype.finally.call({then:function(){}},(function(){}))}))},{finally:function(t){var e=ns(this,es('Promise')),r=rs(t);return this.then(r?function(r){return os(e,t()).then((function(){return r}))}:t,r?function(r){return os(e,t()).then((function(){throw r}))}:t)}});var is=Z('Promise','finally');const as=(()=>{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 ss,us,cs,ls,fs,hs,ps,ds={get:t=>function(t){const e=as?as.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{as&&as.setItem('_one-stat_'+t,JSON.stringify(e))}catch(t){}}(t,e)},remove(t){!function(t){as&&as.removeItem('_one-stat_'+t)}(t)}};!function(t){t.PROD='prod',t.VK_ALIAS='vk_alias',t.VIDEOTEST='videotest',t.TEST='test'}(ss||(ss={})),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'}(us||(us={})),function(t){t.CHROMECAST='chromecast',t.APPLE_TV='appletv',t.PIP='pip',t.HEADPHONES='externalHeadphones',t.SCREEN=''}(cs||(cs={})),function(t){t.MP4='mp4',t.DASH='dash',t.HLS='hls',t.WEBM='webm'}(ls||(ls={})),function(t){t.AUTO='auto',t.MANUAL=''}(fs||(fs={})),function(t){t.HTTP1='http1',t.HTTP2='http2',t.HTTP3='http3'}(hs||(hs={})),function(t){t[t.YES=1]='YES',t[t.NO=0]='NO'}(ps||(ps={}));const vs={[ss.PROD]:'https://api.ok.ru',[ss.VK_ALIAS]:'https://api.mycdn.me',[ss.VIDEOTEST]:'https://videotestapi.ok.ru/api',[ss.TEST]:'https://apitest.ok.ru'};var ys;!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'}(ys||(ys={}));class gs{constructor(t){this.params=t;const e=ds.get('uuid');e?this.uuid=String(e):(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('')}(),ds.set('uuid',this.uuid))}authorize(t){return r(this,void 0,void 0,(function*(){return this.authToken=null!=t?t:yield this.refreshAuthToken(),this._authorize()}))}logBeacon(t){const e='log.externalLog',r=this.createLogParams(t),n=this.sessionKey;void 0!==n&&this.params.apiTransport.sendBeacon(e,r,n)||this.params.apiTransport.sendRequest(e,r,n)}logRequest(t){var e;return r(this,void 0,void 0,(function*(){const r='log.externalLog',n=this.createLogParams(t),o=null!==(e=this.sessionKey)&&void 0!==e?e:yield this._authorize();try{return yield this.params.apiTransport.sendRequest(r,n,o)}catch(t){switch(null==t?void 0:t.error_code){case ys.PARAM_SESSION_EXPIRED:case ys.PARAM_SESSION_KEY:case ys.PARAM_SIGNATURE:{const t=yield this._authorize();return this.params.apiTransport.sendRequest(r,n,t)}case ys.AUTH_LOGIN:{this.authToken=yield this.refreshAuthToken();const t=yield this._authorizeRequest();return this.params.apiTransport.sendRequest(r,n,t)}default:throw t}}}))}refreshAuthToken(){return r(this,void 0,void 0,(function*(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=is(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.12',platform:'WEB',items:t.map((t=>Object.assign(Object.assign({},t),{time:0,type:1})))})}}_authorize(){return r(this,void 0,void 0,(function*(){try{return yield this._authorizeRequest()}catch(t){switch(null==t?void 0:t.error_code){case ys.AUTH_LOGIN:return this.authToken=yield this.refreshAuthToken(),this._authorizeRequest()}throw t}}))}_authorizeRequest(){return r(this,void 0,void 0,(function*(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0;const t='auth.anonymLogin',e={session_data:{version:2,device_id:this.uuid,client_version:'1.0.12'.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=is(this.params.apiTransport.sendRequest(t,e).then((r=>{if(!r)throw new Error(`Empty response. Method: ${t}, params: ${JSON.stringify(e)}`);if(!r.session_key)throw new Error(`Empty 'session_key' in response. Method: ${t}, params: ${JSON.stringify(e)}, response: ${JSON.stringify(r)}`);return this.sessionKey=r.session_key,this.sessionKey})).catch((t=>{throw this.sessionKey=void 0,t})),(()=>{this.authorizePromise=void 0})),this.authorizePromise}))}}var ms={};function bs(t,e){if(!(t instanceof e))throw new TypeError('Cannot call a class as a function')}function ws(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,'value'in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function Os(t,e,r){return e&&ws(t.prototype,e),r&&ws(t,r),t}function _s(t){return(_s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function Ps(t,e){return(Ps=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Ss(t){if(void 0===t)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return t}function Es(t,e){return!e||'object'!=typeof e&&'function'!=typeof e?Ss(t):e}function Ts(t){var e=function(){if('undefined'==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if('function'==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=_s(t);if(e){var o=_s(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return Es(this,r)}}function As(t,e,r){return(As='undefined'!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=_s(t)););return t}(t,e);if(n){var o=Object.getOwnPropertyDescriptor(n,e);return o.get?o.get.call(r):o.value}})(t,e,r||t)}Object.defineProperty(ms,'__esModule',{value:!0});var js=function(){function t(){bs(this,t),Object.defineProperty(this,'listeners',{value:{},writable:!0,configurable:!0})}return Os(t,[{key:'addEventListener',value:function(t,e,r){t in this.listeners||(this.listeners[t]=[]),this.listeners[t].push({callback:e,options:r})}},{key:'removeEventListener',value:function(t,e){if(t in this.listeners)for(var r=this.listeners[t],n=0,o=r.length;n<o;n++)if(r[n].callback===e)return void r.splice(n,1)}},{key:'dispatchEvent',value:function(t){if(t.type in this.listeners){for(var e=this.listeners[t.type].slice(),r=0,n=e.length;r<n;r++){var o=e[r];try{o.callback.call(this,t)}catch(t){Promise.resolve().then((function(){throw t}))}o.options&&o.options.once&&this.removeEventListener(t.type,o.callback)}return!t.defaultPrevented}}}]),t}(),Rs=function(t){!function(t,e){if('function'!=typeof e&&null!==e)throw new TypeError('Super expression must either be null or a function');t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Ps(t,e)}(r,js);var e=Ts(r);function r(){var t;return bs(this,r),(t=e.call(this)).listeners||js.call(Ss(t)),Object.defineProperty(Ss(t),'aborted',{value:!1,writable:!0,configurable:!0}),Object.defineProperty(Ss(t),'onabort',{value:null,writable:!0,configurable:!0}),t}return Os(r,[{key:'toString',value:function(){return'[object AbortSignal]'}},{key:'dispatchEvent',value:function(t){'abort'===t.type&&(this.aborted=!0,'function'==typeof this.onabort&&this.onabort.call(this,t)),As(_s(r.prototype),'dispatchEvent',this).call(this,t)}}]),r}(),ks=function(){function t(){bs(this,t),Object.defineProperty(this,'signal',{value:new Rs,writable:!0,configurable:!0})}return Os(t,[{key:'abort',value:function(){var t;try{t=new Event('abort')}catch(e){'undefined'!=typeof document?document.createEvent?(t=document.createEvent('Event')).initEvent('abort',!1,!1):(t=document.createEventObject()).type='abort':t={type:'abort',bubbles:!1,cancelable:!1}}this.signal.dispatchEvent(t)}},{key:'toString',value:function(){return'[object AbortController]'}}]),t}();'undefined'!=typeof Symbol&&Symbol.toStringTag&&(ks.prototype[Symbol.toStringTag]='AbortController',Rs.prototype[Symbol.toStringTag]='AbortSignal'),ms.AbortController=ks,ms.AbortSignal=Rs;var Ls=ms.abortableFetch=function(t){'function'==typeof t&&(t={fetch:t});var e=t,r=e.fetch,n=e.Request,o=void 0===n?r.Request:n,i=e.AbortController,a=e.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL,s=void 0!==a&&a;if(!function(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}({fetch:r,Request:o,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:s}))return{fetch:r,Request:u};var u=o;(u&&!u.prototype.hasOwnProperty('signal')||s)&&((u=function(t,e){var r;e&&e.signal&&(r=e.signal,delete e.signal);var n=new o(t,e);return r&&Object.defineProperty(n,'signal',{writable:!1,enumerable:!1,configurable:!0,value:r}),n}).prototype=o.prototype);var c=r;return{fetch:function(t,e){var r=u&&u.prototype.isPrototypeOf(t)?t.signal:e?e.signal:void 0;if(r){var n;try{n=new DOMException('Aborted','AbortError')}catch(t){(n=new Error('Aborted')).name='AbortError'}if(r.aborted)return Promise.reject(n);var o=new Promise((function(t,e){r.addEventListener('abort',(function(){return e(n)}),{once:!0})}));return e&&e.signal&&delete e.signal,Promise.race([o,c(t,e)])}return c(t,e)},Request:u}};class Is{constructor(t){this.params=t,this.apiKey=t.apiKey,this.apiBaseUrl=t.apiBaseUrl,'/'!==this.apiBaseUrl[this.apiBaseUrl.length-1]&&(this.apiBaseUrl+='/')}sendBeacon(t,e,r){if(!window.Blob||!window.navigator.sendBeacon)return!1;const n=this._prepareQueryParams({method:t,queryParams:e,sessionKey:r}),o=new window.Blob([n.toString()],{type:'application/x-www-form-urlencoded'});return window.navigator.sendBeacon(`${this.apiBaseUrl}fb.do`,o)}sendRequest(t,e,n){return r(this,void 0,void 0,(function*(){const r=Date.now(),o=o=>{throw this.params.error$.next({id:'OneStat:ApiTransport:sendRequest',message:'Unhandled request error',thrown:o,data:{method:t,params:e,sessionKey:n,time:Date.now()-r}}),o};return Ls(fetch).fetch(`${this.apiBaseUrl}fb.do`,{method:'post',headers:{'Content-type':'application/x-www-form-urlencoded'},body:this._prepareQueryParams({method:t,queryParams:e,sessionKey:n})}).then((t=>Number(t.headers.get('content-length'))>0?t.json().then((t=>Object.prototype.hasOwnProperty.call(t,'error_msg')?Promise.reject(t):t),o):void 0),o)}))}_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 xs{constructor(t){this.requestQueue=[],this.isPaused=!1,this.debouncedFlush=e((()=>this.flush()),3e3,{maxWait:15e3}),this.api=t.api}log(t){this.requestQueue.push(t),this.isPaused||this.debouncedFlush()}flush(t=!1){0!==this.requestQueue.length&&(t?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[],this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}}class Cs{constructor(e,r){this.statContext=e;const n=new t;this.experimental={error$:n};const o=new Is({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:vs[r.apiEnv],error$:n});this.api=new gs({apiTransport:o,refreshAuthToken:r.refreshAuthToken}),this.logger=new xs({api:this.api}),window.addEventListener('beforeunload',(()=>this.logger.flush(!0)))}updateContext(t){this.statContext=Object.assign(Object.assign({},this.statContext),t)}authorize(t){return this.api.authorize(t)}pause(){this.logger.pause()}resume(){this.logger.resume()}logStarted(){this.log({operation:'play'})}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){this.log({operation:'watch_coverage_live',param:`${t.start}-${t.end}`}),this.logger.flush(!0)}logEmptyBuffer(t){this.log({operation:'empty_buffer',param:String(t.duration)})}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.crateLogItem(t);this.logger.log(e)}crateLogItem({operation:t,param:e}){const r=Date.now(),n={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?ps.YES:!1===this.statContext.connectionReused?ps.NO:void 0,stat_type:!0===this.statContext.autoplay?fs.AUTO:!1===this.statContext.autoplay?fs.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId};return void 0!==e&&(n.param=e),{operation:t,timestamp:r,custom:n}}}export{ss as ApiEnv,hs as ConnectionType,ls as ContentType,Cs as OneStat,us as Quality,cs as ScreenDestination};
|
package/es2018.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-statistics v1.0.
|
|
3
|
-
* Thu, 17 Mar 2022
|
|
4
|
-
* https://st.mycdn.me/static/playersdk/1-0-
|
|
2
|
+
* @vkontakte/videoplayer-statistics v1.0.12
|
|
3
|
+
* Thu, 17 Mar 2022 14:38:04 GMT
|
|
4
|
+
* https://st.mycdn.me/static/playersdk/1-0-12/doc/
|
|
5
5
|
*/
|
|
6
|
-
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var t=require('@vkontakte/videoplayer-shared/es2018.cjs.js');function e(t){return t&&'object'==typeof t&&'default'in t?t:{default:t}}var r=e(require('lodash/debounce'));const o=(()=>{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 n,s,i,a,u,l,c,p={get:t=>function(t){const e=o?o.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{o&&o.setItem('_one-stat_'+t,JSON.stringify(e))}catch(t){}}(t,e)},remove(t){!function(t){o&&o.removeItem('_one-stat_'+t)}(t)}};exports.ApiEnv=void 0,(n=exports.ApiEnv||(exports.ApiEnv={})).PROD='prod',n.VK_ALIAS='vk_alias',n.VIDEOTEST='videotest',n.TEST='test',exports.Quality=void 0,(s=exports.Quality||(exports.Quality={})).Q144P='144',s.Q240P='240',s.Q360P='360',s.Q480P='480',s.Q720P='720',s.Q1080P='1080',s.Q1440P='1440',s.Q2160P='2160',s.Q4320P='4320',s.UNKNOWN='unknown',exports.ScreenDestination=void 0,(i=exports.ScreenDestination||(exports.ScreenDestination={})).CHROMECAST='chromecast',i.APPLE_TV='appletv',i.PIP='pip',i.HEADPHONES='externalHeadphones',i.SCREEN='',exports.ContentType=void 0,(a=exports.ContentType||(exports.ContentType={})).MP4='mp4',a.DASH='dash',a.HLS='hls',a.WEBM='webm',function(t){t.AUTO='auto',t.MANUAL=''}(u||(u={})),exports.ConnectionType=void 0,(l=exports.ConnectionType||(exports.ConnectionType={})).HTTP1='http1',l.HTTP2='http2',l.HTTP3='http3',function(t){t[t.YES=1]='YES',t[t.NO=0]='NO'}(c||(c={}));const h={[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'};var d;!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'}(d||(d={}));class f{constructor(t){this.params=t;const e=p.get('uuid');e?this.uuid=String(e):(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('')}(),p.set('uuid',this.uuid))}async authorize(t){return this.authToken=null!=t?t:await this.refreshAuthToken(),this._authorize()}logBeacon(t){const e='log.externalLog',r=this.createLogParams(t),o=this.sessionKey;void 0!==o&&this.params.apiTransport.sendBeacon(e,r,o)||this.params.apiTransport.sendRequest(e,r,o)}async logRequest(t){var e;const r='log.externalLog',o=this.createLogParams(t),n=null!==(e=this.sessionKey)&&void 0!==e?e:await this._authorize();try{return await this.params.apiTransport.sendRequest(r,o,n)}catch(t){switch(null==t?void 0:t.error_code){case d.PARAM_SESSION_EXPIRED:case d.PARAM_SESSION_KEY:case d.PARAM_SIGNATURE:{const t=await this._authorize();return this.params.apiTransport.sendRequest(r,o,t)}case d.AUTH_LOGIN:{this.authToken=await this.refreshAuthToken();const t=await this._authorizeRequest();return this.params.apiTransport.sendRequest(r,o,t)}default:throw t}}}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.11',platform:'WEB',items:t.map((t=>({...t,time:0,type:1})))})}}async _authorize(){try{return await this._authorizeRequest()}catch(t){switch(null==t?void 0:t.error_code){case d.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this._authorizeRequest()}throw t}}async _authorizeRequest(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0;const t='auth.anonymLogin',e={session_data:{version:2,device_id:this.uuid,client_version:'1.0.11'.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(t,e).then((r=>{if(!r)throw new Error(`Empty response. Method: ${t}, params: ${JSON.stringify(e)}`);if(!r.session_key)throw new Error(`Empty 'session_key' in response. Method: ${t}, params: ${JSON.stringify(e)}, response: ${JSON.stringify(r)}`);return this.sessionKey=r.session_key,this.sessionKey})).catch((t=>{throw this.sessionKey=void 0,t})).finally((()=>{this.authorizePromise=void 0})),this.authorizePromise}}var y={};function g(t,e){if(!(t instanceof e))throw new TypeError('Cannot call a class as a function')}function v(t,e){for(var r=0;r<e.length;r++){var o=e[r];o.enumerable=o.enumerable||!1,o.configurable=!0,'value'in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function m(t,e,r){return e&&v(t.prototype,e),r&&v(t,r),t}function _(t){return(_=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function b(t,e){return(b=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function A(t){if(void 0===t)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return t}function P(t,e){return!e||'object'!=typeof e&&'function'!=typeof e?A(t):e}function O(t){var e=function(){if('undefined'==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if('function'==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,o=_(t);if(e){var n=_(this).constructor;r=Reflect.construct(o,arguments,n)}else r=o.apply(this,arguments);return P(this,r)}}function S(t,e,r){return(S='undefined'!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var o=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=_(t)););return t}(t,e);if(o){var n=Object.getOwnPropertyDescriptor(o,e);return n.get?n.get.call(r):n.value}})(t,e,r||t)}Object.defineProperty(y,'__esModule',{value:!0});var E=function(){function t(){g(this,t),Object.defineProperty(this,'listeners',{value:{},writable:!0,configurable:!0})}return m(t,[{key:'addEventListener',value:function(t,e,r){t in this.listeners||(this.listeners[t]=[]),this.listeners[t].push({callback:e,options:r})}},{key:'removeEventListener',value:function(t,e){if(t in this.listeners)for(var r=this.listeners[t],o=0,n=r.length;o<n;o++)if(r[o].callback===e)return void r.splice(o,1)}},{key:'dispatchEvent',value:function(t){if(t.type in this.listeners){for(var e=this.listeners[t.type].slice(),r=0,o=e.length;r<o;r++){var n=e[r];try{n.callback.call(this,t)}catch(t){Promise.resolve().then((function(){throw t}))}n.options&&n.options.once&&this.removeEventListener(t.type,n.callback)}return!t.defaultPrevented}}}]),t}(),w=function(t){!function(t,e){if('function'!=typeof e&&null!==e)throw new TypeError('Super expression must either be null or a function');t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&b(t,e)}(r,E);var e=O(r);function r(){var t;return g(this,r),(t=e.call(this)).listeners||E.call(A(t)),Object.defineProperty(A(t),'aborted',{value:!1,writable:!0,configurable:!0}),Object.defineProperty(A(t),'onabort',{value:null,writable:!0,configurable:!0}),t}return m(r,[{key:'toString',value:function(){return'[object AbortSignal]'}},{key:'dispatchEvent',value:function(t){'abort'===t.type&&(this.aborted=!0,'function'==typeof this.onabort&&this.onabort.call(this,t)),S(_(r.prototype),'dispatchEvent',this).call(this,t)}}]),r}(),T=function(){function t(){g(this,t),Object.defineProperty(this,'signal',{value:new w,writable:!0,configurable:!0})}return m(t,[{key:'abort',value:function(){var t;try{t=new Event('abort')}catch(e){'undefined'!=typeof document?document.createEvent?(t=document.createEvent('Event')).initEvent('abort',!1,!1):(t=document.createEventObject()).type='abort':t={type:'abort',bubbles:!1,cancelable:!1}}this.signal.dispatchEvent(t)}},{key:'toString',value:function(){return'[object AbortController]'}}]),t}();'undefined'!=typeof Symbol&&Symbol.toStringTag&&(T.prototype[Symbol.toStringTag]='AbortController',w.prototype[Symbol.toStringTag]='AbortSignal'),y.AbortController=T,y.AbortSignal=w;var R=y.abortableFetch=function(t){'function'==typeof t&&(t={fetch:t});var e,r=t,o=r.fetch,n=r.Request,s=void 0===n?o.Request:n,i=r.AbortController,a=r.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL,u=void 0!==a&&a;if(!((e={fetch:o,Request:s,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:u}).__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log('__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill'),1):'function'==typeof e.Request&&!e.Request.prototype.hasOwnProperty('signal')||!e.AbortController))return{fetch:o,Request:l};var l=s;(l&&!l.prototype.hasOwnProperty('signal')||u)&&((l=function(t,e){var r;e&&e.signal&&(r=e.signal,delete e.signal);var o=new s(t,e);return r&&Object.defineProperty(o,'signal',{writable:!1,enumerable:!1,configurable:!0,value:r}),o}).prototype=s.prototype);var c=o;return{fetch:function(t,e){var r=l&&l.prototype.isPrototypeOf(t)?t.signal:e?e.signal:void 0;if(r){var o;try{o=new DOMException('Aborted','AbortError')}catch(t){(o=new Error('Aborted')).name='AbortError'}if(r.aborted)return Promise.reject(o);var n=new Promise((function(t,e){r.addEventListener('abort',(function(){return e(o)}),{once:!0})}));return e&&e.signal&&delete e.signal,Promise.race([n,c(t,e)])}return c(t,e)},Request:l}};class k{constructor(t){this.params=t,this.apiKey=t.apiKey,this.apiBaseUrl=t.apiBaseUrl,'/'!==this.apiBaseUrl[this.apiBaseUrl.length-1]&&(this.apiBaseUrl+='/')}sendBeacon(t,e,r){if(!window.Blob||!window.navigator.sendBeacon)return!1;const o=this._prepareQueryParams({method:t,queryParams:e,sessionKey:r}),n=new window.Blob([o.toString()],{type:'application/x-www-form-urlencoded'});return window.navigator.sendBeacon(`${this.apiBaseUrl}fb.do`,n)}async sendRequest(t,e,r){const o=Date.now(),n=n=>{throw this.params.error$.next({id:'OneStat:ApiTransport:sendRequest',message:'Unhandled request error',thrown:n,data:{method:t,params:e,sessionKey:r,time:Date.now()-o}}),n};return R(fetch).fetch(`${this.apiBaseUrl}fb.do`,{method:'post',headers:{'Content-type':'application/x-www-form-urlencoded'},body:this._prepareQueryParams({method:t,queryParams:e,sessionKey:r})}).then((t=>Number(t.headers.get('content-length'))>0?t.json().then((t=>Object.prototype.hasOwnProperty.call(t,'error_msg')?Promise.reject(t):t),n):void 0),n)}_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 L{constructor(t){this.requestQueue=[],this.isPaused=!1,this.debouncedFlush=r.default((()=>this.flush()),3e3,{maxWait:15e3}),this.api=t.api}log(t){this.requestQueue.push(t),this.isPaused||this.debouncedFlush()}flush(t=!1){0!==this.requestQueue.length&&(t?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[],this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}}exports.OneStat=class{constructor(e,r){this.statContext=e;const o=new t.Subject;this.experimental={error$:o};const n=new k({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:h[r.apiEnv],error$:o});this.api=new f({apiTransport:n,refreshAuthToken:r.refreshAuthToken}),this.logger=new L({api:this.api}),window.addEventListener('beforeunload',(()=>this.logger.flush(!0)))}updateContext(t){this.statContext={...this.statContext,...t}}authorize(t){return this.api.authorize(t)}pause(){this.logger.pause()}resume(){this.logger.resume()}logStarted(){this.log({operation:'play'})}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){this.log({operation:'watch_coverage_live',param:`${t.start}-${t.end}`})}logEmptyBuffer(t){this.log({operation:'empty_buffer',param:String(t.duration)})}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.crateLogItem(t);this.logger.log(e)}crateLogItem({operation:t,param:e}){const r=Date.now(),o={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?c.YES:!1===this.statContext.connectionReused?c.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};return void 0!==e&&(o.param=e),{operation:t,timestamp:r,custom:o}}};
|
|
6
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var t=require('@vkontakte/videoplayer-shared/es2018.cjs.js');function e(t){return t&&'object'==typeof t&&'default'in t?t:{default:t}}var r=e(require('lodash/debounce'));const o=(()=>{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 n,s,i,a,u,l,c,p={get:t=>function(t){const e=o?o.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{o&&o.setItem('_one-stat_'+t,JSON.stringify(e))}catch(t){}}(t,e)},remove(t){!function(t){o&&o.removeItem('_one-stat_'+t)}(t)}};exports.ApiEnv=void 0,(n=exports.ApiEnv||(exports.ApiEnv={})).PROD='prod',n.VK_ALIAS='vk_alias',n.VIDEOTEST='videotest',n.TEST='test',exports.Quality=void 0,(s=exports.Quality||(exports.Quality={})).Q144P='144',s.Q240P='240',s.Q360P='360',s.Q480P='480',s.Q720P='720',s.Q1080P='1080',s.Q1440P='1440',s.Q2160P='2160',s.Q4320P='4320',s.UNKNOWN='unknown',exports.ScreenDestination=void 0,(i=exports.ScreenDestination||(exports.ScreenDestination={})).CHROMECAST='chromecast',i.APPLE_TV='appletv',i.PIP='pip',i.HEADPHONES='externalHeadphones',i.SCREEN='',exports.ContentType=void 0,(a=exports.ContentType||(exports.ContentType={})).MP4='mp4',a.DASH='dash',a.HLS='hls',a.WEBM='webm',function(t){t.AUTO='auto',t.MANUAL=''}(u||(u={})),exports.ConnectionType=void 0,(l=exports.ConnectionType||(exports.ConnectionType={})).HTTP1='http1',l.HTTP2='http2',l.HTTP3='http3',function(t){t[t.YES=1]='YES',t[t.NO=0]='NO'}(c||(c={}));const h={[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'};var d;!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'}(d||(d={}));class f{constructor(t){this.params=t;const e=p.get('uuid');e?this.uuid=String(e):(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('')}(),p.set('uuid',this.uuid))}async authorize(t){return this.authToken=null!=t?t:await this.refreshAuthToken(),this._authorize()}logBeacon(t){const e='log.externalLog',r=this.createLogParams(t),o=this.sessionKey;void 0!==o&&this.params.apiTransport.sendBeacon(e,r,o)||this.params.apiTransport.sendRequest(e,r,o)}async logRequest(t){var e;const r='log.externalLog',o=this.createLogParams(t),n=null!==(e=this.sessionKey)&&void 0!==e?e:await this._authorize();try{return await this.params.apiTransport.sendRequest(r,o,n)}catch(t){switch(null==t?void 0:t.error_code){case d.PARAM_SESSION_EXPIRED:case d.PARAM_SESSION_KEY:case d.PARAM_SIGNATURE:{const t=await this._authorize();return this.params.apiTransport.sendRequest(r,o,t)}case d.AUTH_LOGIN:{this.authToken=await this.refreshAuthToken();const t=await this._authorizeRequest();return this.params.apiTransport.sendRequest(r,o,t)}default:throw t}}}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.12',platform:'WEB',items:t.map((t=>({...t,time:0,type:1})))})}}async _authorize(){try{return await this._authorizeRequest()}catch(t){switch(null==t?void 0:t.error_code){case d.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this._authorizeRequest()}throw t}}async _authorizeRequest(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0;const t='auth.anonymLogin',e={session_data:{version:2,device_id:this.uuid,client_version:'1.0.12'.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(t,e).then((r=>{if(!r)throw new Error(`Empty response. Method: ${t}, params: ${JSON.stringify(e)}`);if(!r.session_key)throw new Error(`Empty 'session_key' in response. Method: ${t}, params: ${JSON.stringify(e)}, response: ${JSON.stringify(r)}`);return this.sessionKey=r.session_key,this.sessionKey})).catch((t=>{throw this.sessionKey=void 0,t})).finally((()=>{this.authorizePromise=void 0})),this.authorizePromise}}var y={};function g(t,e){if(!(t instanceof e))throw new TypeError('Cannot call a class as a function')}function v(t,e){for(var r=0;r<e.length;r++){var o=e[r];o.enumerable=o.enumerable||!1,o.configurable=!0,'value'in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function m(t,e,r){return e&&v(t.prototype,e),r&&v(t,r),t}function _(t){return(_=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function b(t,e){return(b=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function A(t){if(void 0===t)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return t}function P(t,e){return!e||'object'!=typeof e&&'function'!=typeof e?A(t):e}function O(t){var e=function(){if('undefined'==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if('function'==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,o=_(t);if(e){var n=_(this).constructor;r=Reflect.construct(o,arguments,n)}else r=o.apply(this,arguments);return P(this,r)}}function S(t,e,r){return(S='undefined'!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var o=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=_(t)););return t}(t,e);if(o){var n=Object.getOwnPropertyDescriptor(o,e);return n.get?n.get.call(r):n.value}})(t,e,r||t)}Object.defineProperty(y,'__esModule',{value:!0});var E=function(){function t(){g(this,t),Object.defineProperty(this,'listeners',{value:{},writable:!0,configurable:!0})}return m(t,[{key:'addEventListener',value:function(t,e,r){t in this.listeners||(this.listeners[t]=[]),this.listeners[t].push({callback:e,options:r})}},{key:'removeEventListener',value:function(t,e){if(t in this.listeners)for(var r=this.listeners[t],o=0,n=r.length;o<n;o++)if(r[o].callback===e)return void r.splice(o,1)}},{key:'dispatchEvent',value:function(t){if(t.type in this.listeners){for(var e=this.listeners[t.type].slice(),r=0,o=e.length;r<o;r++){var n=e[r];try{n.callback.call(this,t)}catch(t){Promise.resolve().then((function(){throw t}))}n.options&&n.options.once&&this.removeEventListener(t.type,n.callback)}return!t.defaultPrevented}}}]),t}(),w=function(t){!function(t,e){if('function'!=typeof e&&null!==e)throw new TypeError('Super expression must either be null or a function');t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&b(t,e)}(r,E);var e=O(r);function r(){var t;return g(this,r),(t=e.call(this)).listeners||E.call(A(t)),Object.defineProperty(A(t),'aborted',{value:!1,writable:!0,configurable:!0}),Object.defineProperty(A(t),'onabort',{value:null,writable:!0,configurable:!0}),t}return m(r,[{key:'toString',value:function(){return'[object AbortSignal]'}},{key:'dispatchEvent',value:function(t){'abort'===t.type&&(this.aborted=!0,'function'==typeof this.onabort&&this.onabort.call(this,t)),S(_(r.prototype),'dispatchEvent',this).call(this,t)}}]),r}(),T=function(){function t(){g(this,t),Object.defineProperty(this,'signal',{value:new w,writable:!0,configurable:!0})}return m(t,[{key:'abort',value:function(){var t;try{t=new Event('abort')}catch(e){'undefined'!=typeof document?document.createEvent?(t=document.createEvent('Event')).initEvent('abort',!1,!1):(t=document.createEventObject()).type='abort':t={type:'abort',bubbles:!1,cancelable:!1}}this.signal.dispatchEvent(t)}},{key:'toString',value:function(){return'[object AbortController]'}}]),t}();'undefined'!=typeof Symbol&&Symbol.toStringTag&&(T.prototype[Symbol.toStringTag]='AbortController',w.prototype[Symbol.toStringTag]='AbortSignal'),y.AbortController=T,y.AbortSignal=w;var R=y.abortableFetch=function(t){'function'==typeof t&&(t={fetch:t});var e,r=t,o=r.fetch,n=r.Request,s=void 0===n?o.Request:n,i=r.AbortController,a=r.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL,u=void 0!==a&&a;if(!((e={fetch:o,Request:s,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:u}).__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log('__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill'),1):'function'==typeof e.Request&&!e.Request.prototype.hasOwnProperty('signal')||!e.AbortController))return{fetch:o,Request:l};var l=s;(l&&!l.prototype.hasOwnProperty('signal')||u)&&((l=function(t,e){var r;e&&e.signal&&(r=e.signal,delete e.signal);var o=new s(t,e);return r&&Object.defineProperty(o,'signal',{writable:!1,enumerable:!1,configurable:!0,value:r}),o}).prototype=s.prototype);var c=o;return{fetch:function(t,e){var r=l&&l.prototype.isPrototypeOf(t)?t.signal:e?e.signal:void 0;if(r){var o;try{o=new DOMException('Aborted','AbortError')}catch(t){(o=new Error('Aborted')).name='AbortError'}if(r.aborted)return Promise.reject(o);var n=new Promise((function(t,e){r.addEventListener('abort',(function(){return e(o)}),{once:!0})}));return e&&e.signal&&delete e.signal,Promise.race([n,c(t,e)])}return c(t,e)},Request:l}};class k{constructor(t){this.params=t,this.apiKey=t.apiKey,this.apiBaseUrl=t.apiBaseUrl,'/'!==this.apiBaseUrl[this.apiBaseUrl.length-1]&&(this.apiBaseUrl+='/')}sendBeacon(t,e,r){if(!window.Blob||!window.navigator.sendBeacon)return!1;const o=this._prepareQueryParams({method:t,queryParams:e,sessionKey:r}),n=new window.Blob([o.toString()],{type:'application/x-www-form-urlencoded'});return window.navigator.sendBeacon(`${this.apiBaseUrl}fb.do`,n)}async sendRequest(t,e,r){const o=Date.now(),n=n=>{throw this.params.error$.next({id:'OneStat:ApiTransport:sendRequest',message:'Unhandled request error',thrown:n,data:{method:t,params:e,sessionKey:r,time:Date.now()-o}}),n};return R(fetch).fetch(`${this.apiBaseUrl}fb.do`,{method:'post',headers:{'Content-type':'application/x-www-form-urlencoded'},body:this._prepareQueryParams({method:t,queryParams:e,sessionKey:r})}).then((t=>Number(t.headers.get('content-length'))>0?t.json().then((t=>Object.prototype.hasOwnProperty.call(t,'error_msg')?Promise.reject(t):t),n):void 0),n)}_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 L{constructor(t){this.requestQueue=[],this.isPaused=!1,this.debouncedFlush=r.default((()=>this.flush()),3e3,{maxWait:15e3}),this.api=t.api}log(t){this.requestQueue.push(t),this.isPaused||this.debouncedFlush()}flush(t=!1){0!==this.requestQueue.length&&(t?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[],this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}}exports.OneStat=class{constructor(e,r){this.statContext=e;const o=new t.Subject;this.experimental={error$:o};const n=new k({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:h[r.apiEnv],error$:o});this.api=new f({apiTransport:n,refreshAuthToken:r.refreshAuthToken}),this.logger=new L({api:this.api}),window.addEventListener('beforeunload',(()=>this.logger.flush(!0)))}updateContext(t){this.statContext={...this.statContext,...t}}authorize(t){return this.api.authorize(t)}pause(){this.logger.pause()}resume(){this.logger.resume()}logStarted(){this.log({operation:'play'})}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){this.log({operation:'watch_coverage_live',param:`${t.start}-${t.end}`}),this.logger.flush(!0)}logEmptyBuffer(t){this.log({operation:'empty_buffer',param:String(t.duration)})}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.crateLogItem(t);this.logger.log(e)}crateLogItem({operation:t,param:e}){const r=Date.now(),o={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?c.YES:!1===this.statContext.connectionReused?c.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};return void 0!==e&&(o.param=e),{operation:t,timestamp:r,custom:o}}};
|
package/es2018.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-statistics v1.0.
|
|
3
|
-
* Thu, 17 Mar 2022
|
|
4
|
-
* https://st.mycdn.me/static/playersdk/1-0-
|
|
2
|
+
* @vkontakte/videoplayer-statistics v1.0.12
|
|
3
|
+
* Thu, 17 Mar 2022 14:38:04 GMT
|
|
4
|
+
* https://st.mycdn.me/static/playersdk/1-0-12/doc/
|
|
5
5
|
*/
|
|
6
|
-
import{Subject as t}from'@vkontakte/videoplayer-shared/es2018.esm.js';import e from'lodash/debounce';const r=(()=>{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 o,n,s,i,a,u,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)}};!function(t){t.PROD='prod',t.VK_ALIAS='vk_alias',t.VIDEOTEST='videotest',t.TEST='test'}(o||(o={})),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'}(n||(n={})),function(t){t.CHROMECAST='chromecast',t.APPLE_TV='appletv',t.PIP='pip',t.HEADPHONES='externalHeadphones',t.SCREEN=''}(s||(s={})),function(t){t.MP4='mp4',t.DASH='dash',t.HLS='hls',t.WEBM='webm'}(i||(i={})),function(t){t.AUTO='auto',t.MANUAL=''}(a||(a={})),function(t){t.HTTP1='http1',t.HTTP2='http2',t.HTTP3='http3'}(u||(u={})),function(t){t[t.YES=1]='YES',t[t.NO=0]='NO'}(l||(l={}));const h={[o.PROD]:'https://api.ok.ru',[o.VK_ALIAS]:'https://api.mycdn.me',[o.VIDEOTEST]:'https://videotestapi.ok.ru/api',[o.TEST]:'https://apitest.ok.ru'};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 d{constructor(t){this.params=t;const e=c.get('uuid');e?this.uuid=String(e):(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('')}(),c.set('uuid',this.uuid))}async authorize(t){return this.authToken=null!=t?t:await this.refreshAuthToken(),this._authorize()}logBeacon(t){const e='log.externalLog',r=this.createLogParams(t),o=this.sessionKey;void 0!==o&&this.params.apiTransport.sendBeacon(e,r,o)||this.params.apiTransport.sendRequest(e,r,o)}async logRequest(t){var e;const r='log.externalLog',o=this.createLogParams(t),n=null!==(e=this.sessionKey)&&void 0!==e?e:await this._authorize();try{return await this.params.apiTransport.sendRequest(r,o,n)}catch(t){switch(null==t?void 0:t.error_code){case p.PARAM_SESSION_EXPIRED:case p.PARAM_SESSION_KEY:case p.PARAM_SIGNATURE:{const t=await this._authorize();return this.params.apiTransport.sendRequest(r,o,t)}case p.AUTH_LOGIN:{this.authToken=await this.refreshAuthToken();const t=await this._authorizeRequest();return this.params.apiTransport.sendRequest(r,o,t)}default:throw t}}}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.11',platform:'WEB',items:t.map((t=>({...t,time:0,type:1})))})}}async _authorize(){try{return await this._authorizeRequest()}catch(t){switch(null==t?void 0:t.error_code){case p.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this._authorizeRequest()}throw t}}async _authorizeRequest(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0;const t='auth.anonymLogin',e={session_data:{version:2,device_id:this.uuid,client_version:'1.0.11'.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(t,e).then((r=>{if(!r)throw new Error(`Empty response. Method: ${t}, params: ${JSON.stringify(e)}`);if(!r.session_key)throw new Error(`Empty 'session_key' in response. Method: ${t}, params: ${JSON.stringify(e)}, response: ${JSON.stringify(r)}`);return this.sessionKey=r.session_key,this.sessionKey})).catch((t=>{throw this.sessionKey=void 0,t})).finally((()=>{this.authorizePromise=void 0})),this.authorizePromise}}var f={};function y(t,e){if(!(t instanceof e))throw new TypeError('Cannot call a class as a function')}function g(t,e){for(var r=0;r<e.length;r++){var o=e[r];o.enumerable=o.enumerable||!1,o.configurable=!0,'value'in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function m(t,e,r){return e&&g(t.prototype,e),r&&g(t,r),t}function v(t){return(v=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function _(t,e){return(_=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function b(t){if(void 0===t)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return t}function P(t,e){return!e||'object'!=typeof e&&'function'!=typeof e?b(t):e}function A(t){var e=function(){if('undefined'==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if('function'==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,o=v(t);if(e){var n=v(this).constructor;r=Reflect.construct(o,arguments,n)}else r=o.apply(this,arguments);return P(this,r)}}function O(t,e,r){return(O='undefined'!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var o=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=v(t)););return t}(t,e);if(o){var n=Object.getOwnPropertyDescriptor(o,e);return n.get?n.get.call(r):n.value}})(t,e,r||t)}Object.defineProperty(f,'__esModule',{value:!0});var w=function(){function t(){y(this,t),Object.defineProperty(this,'listeners',{value:{},writable:!0,configurable:!0})}return m(t,[{key:'addEventListener',value:function(t,e,r){t in this.listeners||(this.listeners[t]=[]),this.listeners[t].push({callback:e,options:r})}},{key:'removeEventListener',value:function(t,e){if(t in this.listeners)for(var r=this.listeners[t],o=0,n=r.length;o<n;o++)if(r[o].callback===e)return void r.splice(o,1)}},{key:'dispatchEvent',value:function(t){if(t.type in this.listeners){for(var e=this.listeners[t.type].slice(),r=0,o=e.length;r<o;r++){var n=e[r];try{n.callback.call(this,t)}catch(t){Promise.resolve().then((function(){throw t}))}n.options&&n.options.once&&this.removeEventListener(t.type,n.callback)}return!t.defaultPrevented}}}]),t}(),S=function(t){!function(t,e){if('function'!=typeof e&&null!==e)throw new TypeError('Super expression must either be null or a function');t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&_(t,e)}(r,w);var e=A(r);function r(){var t;return y(this,r),(t=e.call(this)).listeners||w.call(b(t)),Object.defineProperty(b(t),'aborted',{value:!1,writable:!0,configurable:!0}),Object.defineProperty(b(t),'onabort',{value:null,writable:!0,configurable:!0}),t}return m(r,[{key:'toString',value:function(){return'[object AbortSignal]'}},{key:'dispatchEvent',value:function(t){'abort'===t.type&&(this.aborted=!0,'function'==typeof this.onabort&&this.onabort.call(this,t)),O(v(r.prototype),'dispatchEvent',this).call(this,t)}}]),r}(),E=function(){function t(){y(this,t),Object.defineProperty(this,'signal',{value:new S,writable:!0,configurable:!0})}return m(t,[{key:'abort',value:function(){var t;try{t=new Event('abort')}catch(e){'undefined'!=typeof document?document.createEvent?(t=document.createEvent('Event')).initEvent('abort',!1,!1):(t=document.createEventObject()).type='abort':t={type:'abort',bubbles:!1,cancelable:!1}}this.signal.dispatchEvent(t)}},{key:'toString',value:function(){return'[object AbortController]'}}]),t}();'undefined'!=typeof Symbol&&Symbol.toStringTag&&(E.prototype[Symbol.toStringTag]='AbortController',S.prototype[Symbol.toStringTag]='AbortSignal'),f.AbortController=E,f.AbortSignal=S;var R=f.abortableFetch=function(t){'function'==typeof t&&(t={fetch:t});var e,r=t,o=r.fetch,n=r.Request,s=void 0===n?o.Request:n,i=r.AbortController,a=r.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL,u=void 0!==a&&a;if(!((e={fetch:o,Request:s,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:u}).__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log('__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill'),1):'function'==typeof e.Request&&!e.Request.prototype.hasOwnProperty('signal')||!e.AbortController))return{fetch:o,Request:l};var l=s;(l&&!l.prototype.hasOwnProperty('signal')||u)&&((l=function(t,e){var r;e&&e.signal&&(r=e.signal,delete e.signal);var o=new s(t,e);return r&&Object.defineProperty(o,'signal',{writable:!1,enumerable:!1,configurable:!0,value:r}),o}).prototype=s.prototype);var c=o;return{fetch:function(t,e){var r=l&&l.prototype.isPrototypeOf(t)?t.signal:e?e.signal:void 0;if(r){var o;try{o=new DOMException('Aborted','AbortError')}catch(t){(o=new Error('Aborted')).name='AbortError'}if(r.aborted)return Promise.reject(o);var n=new Promise((function(t,e){r.addEventListener('abort',(function(){return e(o)}),{once:!0})}));return e&&e.signal&&delete e.signal,Promise.race([n,c(t,e)])}return c(t,e)},Request:l}};class T{constructor(t){this.params=t,this.apiKey=t.apiKey,this.apiBaseUrl=t.apiBaseUrl,'/'!==this.apiBaseUrl[this.apiBaseUrl.length-1]&&(this.apiBaseUrl+='/')}sendBeacon(t,e,r){if(!window.Blob||!window.navigator.sendBeacon)return!1;const o=this._prepareQueryParams({method:t,queryParams:e,sessionKey:r}),n=new window.Blob([o.toString()],{type:'application/x-www-form-urlencoded'});return window.navigator.sendBeacon(`${this.apiBaseUrl}fb.do`,n)}async sendRequest(t,e,r){const o=Date.now(),n=n=>{throw this.params.error$.next({id:'OneStat:ApiTransport:sendRequest',message:'Unhandled request error',thrown:n,data:{method:t,params:e,sessionKey:r,time:Date.now()-o}}),n};return R(fetch).fetch(`${this.apiBaseUrl}fb.do`,{method:'post',headers:{'Content-type':'application/x-www-form-urlencoded'},body:this._prepareQueryParams({method:t,queryParams:e,sessionKey:r})}).then((t=>Number(t.headers.get('content-length'))>0?t.json().then((t=>Object.prototype.hasOwnProperty.call(t,'error_msg')?Promise.reject(t):t),n):void 0),n)}_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 k{constructor(t){this.requestQueue=[],this.isPaused=!1,this.debouncedFlush=e((()=>this.flush()),3e3,{maxWait:15e3}),this.api=t.api}log(t){this.requestQueue.push(t),this.isPaused||this.debouncedFlush()}flush(t=!1){0!==this.requestQueue.length&&(t?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[],this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}}class L{constructor(e,r){this.statContext=e;const o=new t;this.experimental={error$:o};const n=new T({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:h[r.apiEnv],error$:o});this.api=new d({apiTransport:n,refreshAuthToken:r.refreshAuthToken}),this.logger=new k({api:this.api}),window.addEventListener('beforeunload',(()=>this.logger.flush(!0)))}updateContext(t){this.statContext={...this.statContext,...t}}authorize(t){return this.api.authorize(t)}pause(){this.logger.pause()}resume(){this.logger.resume()}logStarted(){this.log({operation:'play'})}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){this.log({operation:'watch_coverage_live',param:`${t.start}-${t.end}`})}logEmptyBuffer(t){this.log({operation:'empty_buffer',param:String(t.duration)})}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.crateLogItem(t);this.logger.log(e)}crateLogItem({operation:t,param:e}){const r=Date.now(),o={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?a.AUTO:!1===this.statContext.autoplay?a.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId};return void 0!==e&&(o.param=e),{operation:t,timestamp:r,custom:o}}}export{o as ApiEnv,u as ConnectionType,i as ContentType,L as OneStat,n as Quality,s as ScreenDestination};
|
|
6
|
+
import{Subject as t}from'@vkontakte/videoplayer-shared/es2018.esm.js';import e from'lodash/debounce';const r=(()=>{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 o,n,s,i,a,u,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)}};!function(t){t.PROD='prod',t.VK_ALIAS='vk_alias',t.VIDEOTEST='videotest',t.TEST='test'}(o||(o={})),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'}(n||(n={})),function(t){t.CHROMECAST='chromecast',t.APPLE_TV='appletv',t.PIP='pip',t.HEADPHONES='externalHeadphones',t.SCREEN=''}(s||(s={})),function(t){t.MP4='mp4',t.DASH='dash',t.HLS='hls',t.WEBM='webm'}(i||(i={})),function(t){t.AUTO='auto',t.MANUAL=''}(a||(a={})),function(t){t.HTTP1='http1',t.HTTP2='http2',t.HTTP3='http3'}(u||(u={})),function(t){t[t.YES=1]='YES',t[t.NO=0]='NO'}(l||(l={}));const h={[o.PROD]:'https://api.ok.ru',[o.VK_ALIAS]:'https://api.mycdn.me',[o.VIDEOTEST]:'https://videotestapi.ok.ru/api',[o.TEST]:'https://apitest.ok.ru'};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 d{constructor(t){this.params=t;const e=c.get('uuid');e?this.uuid=String(e):(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('')}(),c.set('uuid',this.uuid))}async authorize(t){return this.authToken=null!=t?t:await this.refreshAuthToken(),this._authorize()}logBeacon(t){const e='log.externalLog',r=this.createLogParams(t),o=this.sessionKey;void 0!==o&&this.params.apiTransport.sendBeacon(e,r,o)||this.params.apiTransport.sendRequest(e,r,o)}async logRequest(t){var e;const r='log.externalLog',o=this.createLogParams(t),n=null!==(e=this.sessionKey)&&void 0!==e?e:await this._authorize();try{return await this.params.apiTransport.sendRequest(r,o,n)}catch(t){switch(null==t?void 0:t.error_code){case p.PARAM_SESSION_EXPIRED:case p.PARAM_SESSION_KEY:case p.PARAM_SIGNATURE:{const t=await this._authorize();return this.params.apiTransport.sendRequest(r,o,t)}case p.AUTH_LOGIN:{this.authToken=await this.refreshAuthToken();const t=await this._authorizeRequest();return this.params.apiTransport.sendRequest(r,o,t)}default:throw t}}}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.12',platform:'WEB',items:t.map((t=>({...t,time:0,type:1})))})}}async _authorize(){try{return await this._authorizeRequest()}catch(t){switch(null==t?void 0:t.error_code){case p.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this._authorizeRequest()}throw t}}async _authorizeRequest(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0;const t='auth.anonymLogin',e={session_data:{version:2,device_id:this.uuid,client_version:'1.0.12'.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(t,e).then((r=>{if(!r)throw new Error(`Empty response. Method: ${t}, params: ${JSON.stringify(e)}`);if(!r.session_key)throw new Error(`Empty 'session_key' in response. Method: ${t}, params: ${JSON.stringify(e)}, response: ${JSON.stringify(r)}`);return this.sessionKey=r.session_key,this.sessionKey})).catch((t=>{throw this.sessionKey=void 0,t})).finally((()=>{this.authorizePromise=void 0})),this.authorizePromise}}var f={};function y(t,e){if(!(t instanceof e))throw new TypeError('Cannot call a class as a function')}function g(t,e){for(var r=0;r<e.length;r++){var o=e[r];o.enumerable=o.enumerable||!1,o.configurable=!0,'value'in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function m(t,e,r){return e&&g(t.prototype,e),r&&g(t,r),t}function v(t){return(v=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function _(t,e){return(_=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function b(t){if(void 0===t)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return t}function P(t,e){return!e||'object'!=typeof e&&'function'!=typeof e?b(t):e}function A(t){var e=function(){if('undefined'==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if('function'==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,o=v(t);if(e){var n=v(this).constructor;r=Reflect.construct(o,arguments,n)}else r=o.apply(this,arguments);return P(this,r)}}function O(t,e,r){return(O='undefined'!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var o=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=v(t)););return t}(t,e);if(o){var n=Object.getOwnPropertyDescriptor(o,e);return n.get?n.get.call(r):n.value}})(t,e,r||t)}Object.defineProperty(f,'__esModule',{value:!0});var w=function(){function t(){y(this,t),Object.defineProperty(this,'listeners',{value:{},writable:!0,configurable:!0})}return m(t,[{key:'addEventListener',value:function(t,e,r){t in this.listeners||(this.listeners[t]=[]),this.listeners[t].push({callback:e,options:r})}},{key:'removeEventListener',value:function(t,e){if(t in this.listeners)for(var r=this.listeners[t],o=0,n=r.length;o<n;o++)if(r[o].callback===e)return void r.splice(o,1)}},{key:'dispatchEvent',value:function(t){if(t.type in this.listeners){for(var e=this.listeners[t.type].slice(),r=0,o=e.length;r<o;r++){var n=e[r];try{n.callback.call(this,t)}catch(t){Promise.resolve().then((function(){throw t}))}n.options&&n.options.once&&this.removeEventListener(t.type,n.callback)}return!t.defaultPrevented}}}]),t}(),S=function(t){!function(t,e){if('function'!=typeof e&&null!==e)throw new TypeError('Super expression must either be null or a function');t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&_(t,e)}(r,w);var e=A(r);function r(){var t;return y(this,r),(t=e.call(this)).listeners||w.call(b(t)),Object.defineProperty(b(t),'aborted',{value:!1,writable:!0,configurable:!0}),Object.defineProperty(b(t),'onabort',{value:null,writable:!0,configurable:!0}),t}return m(r,[{key:'toString',value:function(){return'[object AbortSignal]'}},{key:'dispatchEvent',value:function(t){'abort'===t.type&&(this.aborted=!0,'function'==typeof this.onabort&&this.onabort.call(this,t)),O(v(r.prototype),'dispatchEvent',this).call(this,t)}}]),r}(),E=function(){function t(){y(this,t),Object.defineProperty(this,'signal',{value:new S,writable:!0,configurable:!0})}return m(t,[{key:'abort',value:function(){var t;try{t=new Event('abort')}catch(e){'undefined'!=typeof document?document.createEvent?(t=document.createEvent('Event')).initEvent('abort',!1,!1):(t=document.createEventObject()).type='abort':t={type:'abort',bubbles:!1,cancelable:!1}}this.signal.dispatchEvent(t)}},{key:'toString',value:function(){return'[object AbortController]'}}]),t}();'undefined'!=typeof Symbol&&Symbol.toStringTag&&(E.prototype[Symbol.toStringTag]='AbortController',S.prototype[Symbol.toStringTag]='AbortSignal'),f.AbortController=E,f.AbortSignal=S;var R=f.abortableFetch=function(t){'function'==typeof t&&(t={fetch:t});var e,r=t,o=r.fetch,n=r.Request,s=void 0===n?o.Request:n,i=r.AbortController,a=r.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL,u=void 0!==a&&a;if(!((e={fetch:o,Request:s,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:u}).__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log('__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill'),1):'function'==typeof e.Request&&!e.Request.prototype.hasOwnProperty('signal')||!e.AbortController))return{fetch:o,Request:l};var l=s;(l&&!l.prototype.hasOwnProperty('signal')||u)&&((l=function(t,e){var r;e&&e.signal&&(r=e.signal,delete e.signal);var o=new s(t,e);return r&&Object.defineProperty(o,'signal',{writable:!1,enumerable:!1,configurable:!0,value:r}),o}).prototype=s.prototype);var c=o;return{fetch:function(t,e){var r=l&&l.prototype.isPrototypeOf(t)?t.signal:e?e.signal:void 0;if(r){var o;try{o=new DOMException('Aborted','AbortError')}catch(t){(o=new Error('Aborted')).name='AbortError'}if(r.aborted)return Promise.reject(o);var n=new Promise((function(t,e){r.addEventListener('abort',(function(){return e(o)}),{once:!0})}));return e&&e.signal&&delete e.signal,Promise.race([n,c(t,e)])}return c(t,e)},Request:l}};class T{constructor(t){this.params=t,this.apiKey=t.apiKey,this.apiBaseUrl=t.apiBaseUrl,'/'!==this.apiBaseUrl[this.apiBaseUrl.length-1]&&(this.apiBaseUrl+='/')}sendBeacon(t,e,r){if(!window.Blob||!window.navigator.sendBeacon)return!1;const o=this._prepareQueryParams({method:t,queryParams:e,sessionKey:r}),n=new window.Blob([o.toString()],{type:'application/x-www-form-urlencoded'});return window.navigator.sendBeacon(`${this.apiBaseUrl}fb.do`,n)}async sendRequest(t,e,r){const o=Date.now(),n=n=>{throw this.params.error$.next({id:'OneStat:ApiTransport:sendRequest',message:'Unhandled request error',thrown:n,data:{method:t,params:e,sessionKey:r,time:Date.now()-o}}),n};return R(fetch).fetch(`${this.apiBaseUrl}fb.do`,{method:'post',headers:{'Content-type':'application/x-www-form-urlencoded'},body:this._prepareQueryParams({method:t,queryParams:e,sessionKey:r})}).then((t=>Number(t.headers.get('content-length'))>0?t.json().then((t=>Object.prototype.hasOwnProperty.call(t,'error_msg')?Promise.reject(t):t),n):void 0),n)}_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 k{constructor(t){this.requestQueue=[],this.isPaused=!1,this.debouncedFlush=e((()=>this.flush()),3e3,{maxWait:15e3}),this.api=t.api}log(t){this.requestQueue.push(t),this.isPaused||this.debouncedFlush()}flush(t=!1){0!==this.requestQueue.length&&(t?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[],this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}}class L{constructor(e,r){this.statContext=e;const o=new t;this.experimental={error$:o};const n=new T({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:h[r.apiEnv],error$:o});this.api=new d({apiTransport:n,refreshAuthToken:r.refreshAuthToken}),this.logger=new k({api:this.api}),window.addEventListener('beforeunload',(()=>this.logger.flush(!0)))}updateContext(t){this.statContext={...this.statContext,...t}}authorize(t){return this.api.authorize(t)}pause(){this.logger.pause()}resume(){this.logger.resume()}logStarted(){this.log({operation:'play'})}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){this.log({operation:'watch_coverage_live',param:`${t.start}-${t.end}`}),this.logger.flush(!0)}logEmptyBuffer(t){this.log({operation:'empty_buffer',param:String(t.duration)})}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.crateLogItem(t);this.logger.log(e)}crateLogItem({operation:t,param:e}){const r=Date.now(),o={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?a.AUTO:!1===this.statContext.autoplay?a.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId};return void 0!==e&&(o.param=e),{operation:t,timestamp:r,custom:o}}}export{o as ApiEnv,u as ConnectionType,i as ContentType,L as OneStat,n as Quality,s as ScreenDestination};
|
package/esnext.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-statistics v1.0.
|
|
3
|
-
* Thu, 17 Mar 2022
|
|
4
|
-
* https://st.mycdn.me/static/playersdk/1-0-
|
|
2
|
+
* @vkontakte/videoplayer-statistics v1.0.12
|
|
3
|
+
* Thu, 17 Mar 2022 14:38:04 GMT
|
|
4
|
+
* https://st.mycdn.me/static/playersdk/1-0-12/doc/
|
|
5
5
|
*/
|
|
6
|
-
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var t=require('@vkontakte/videoplayer-shared/esnext.cjs.js');function e(t){return t&&'object'==typeof t&&'default'in t?t:{default:t}}var r=e(require('lodash/debounce'));const o=(()=>{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 n,s,i,a,u,l,p,c={get:t=>function(t){const e=o?o.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{o&&o.setItem('_one-stat_'+t,JSON.stringify(e))}catch(t){}}(t,e)},remove(t){!function(t){o&&o.removeItem('_one-stat_'+t)}(t)}};exports.ApiEnv=void 0,(n=exports.ApiEnv||(exports.ApiEnv={})).PROD='prod',n.VK_ALIAS='vk_alias',n.VIDEOTEST='videotest',n.TEST='test',exports.Quality=void 0,(s=exports.Quality||(exports.Quality={})).Q144P='144',s.Q240P='240',s.Q360P='360',s.Q480P='480',s.Q720P='720',s.Q1080P='1080',s.Q1440P='1440',s.Q2160P='2160',s.Q4320P='4320',s.UNKNOWN='unknown',exports.ScreenDestination=void 0,(i=exports.ScreenDestination||(exports.ScreenDestination={})).CHROMECAST='chromecast',i.APPLE_TV='appletv',i.PIP='pip',i.HEADPHONES='externalHeadphones',i.SCREEN='',exports.ContentType=void 0,(a=exports.ContentType||(exports.ContentType={})).MP4='mp4',a.DASH='dash',a.HLS='hls',a.WEBM='webm',function(t){t.AUTO='auto',t.MANUAL=''}(u||(u={})),exports.ConnectionType=void 0,(l=exports.ConnectionType||(exports.ConnectionType={})).HTTP1='http1',l.HTTP2='http2',l.HTTP3='http3',function(t){t[t.YES=1]='YES',t[t.NO=0]='NO'}(p||(p={}));const h={[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'};var d;!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'}(d||(d={}));class f{params;uuid;authToken;sessionKey;authorizePromise;refreshAuthTokenPromise;constructor(t){this.params=t;const e=c.get('uuid');e?this.uuid=String(e):(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('')}(),c.set('uuid',this.uuid))}async authorize(t){return this.authToken=t??await this.refreshAuthToken(),this._authorize()}logBeacon(t){const e='log.externalLog',r=this.createLogParams(t),o=this.sessionKey;void 0!==o&&this.params.apiTransport.sendBeacon(e,r,o)||this.params.apiTransport.sendRequest(e,r,o)}async logRequest(t){const e='log.externalLog',r=this.createLogParams(t),o=this.sessionKey??await this._authorize();try{return await this.params.apiTransport.sendRequest(e,r,o)}catch(t){switch(t?.error_code){case d.PARAM_SESSION_EXPIRED:case d.PARAM_SESSION_KEY:case d.PARAM_SIGNATURE:{const t=await this._authorize();return this.params.apiTransport.sendRequest(e,r,t)}case d.AUTH_LOGIN:{this.authToken=await this.refreshAuthToken();const t=await this._authorizeRequest();return this.params.apiTransport.sendRequest(e,r,t)}default:throw t}}}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.11',platform:'WEB',items:t.map((t=>({...t,time:0,type:1})))})}}async _authorize(){try{return await this._authorizeRequest()}catch(t){switch(t?.error_code){case d.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this._authorizeRequest()}throw t}}async _authorizeRequest(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0;const t='auth.anonymLogin',e={session_data:{version:2,device_id:this.uuid,client_version:'1.0.11'.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(t,e).then((r=>{if(!r)throw new Error(`Empty response. Method: ${t}, params: ${JSON.stringify(e)}`);if(!r.session_key)throw new Error(`Empty 'session_key' in response. Method: ${t}, params: ${JSON.stringify(e)}, response: ${JSON.stringify(r)}`);return this.sessionKey=r.session_key,this.sessionKey})).catch((t=>{throw this.sessionKey=void 0,t})).finally((()=>{this.authorizePromise=void 0})),this.authorizePromise}}var y={};function g(t,e){if(!(t instanceof e))throw new TypeError('Cannot call a class as a function')}function m(t,e){for(var r=0;r<e.length;r++){var o=e[r];o.enumerable=o.enumerable||!1,o.configurable=!0,'value'in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function v(t,e,r){return e&&m(t.prototype,e),r&&m(t,r),t}function _(t){return(_=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function b(t,e){return(b=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function A(t){if(void 0===t)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return t}function P(t,e){return!e||'object'!=typeof e&&'function'!=typeof e?A(t):e}function O(t){var e=function(){if('undefined'==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if('function'==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,o=_(t);if(e){var n=_(this).constructor;r=Reflect.construct(o,arguments,n)}else r=o.apply(this,arguments);return P(this,r)}}function S(t,e,r){return(S='undefined'!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var o=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=_(t)););return t}(t,e);if(o){var n=Object.getOwnPropertyDescriptor(o,e);return n.get?n.get.call(r):n.value}})(t,e,r||t)}Object.defineProperty(y,'__esModule',{value:!0});var E=function(){function t(){g(this,t),Object.defineProperty(this,'listeners',{value:{},writable:!0,configurable:!0})}return v(t,[{key:'addEventListener',value:function(t,e,r){t in this.listeners||(this.listeners[t]=[]),this.listeners[t].push({callback:e,options:r})}},{key:'removeEventListener',value:function(t,e){if(t in this.listeners)for(var r=this.listeners[t],o=0,n=r.length;o<n;o++)if(r[o].callback===e)return void r.splice(o,1)}},{key:'dispatchEvent',value:function(t){if(t.type in this.listeners){for(var e=this.listeners[t.type].slice(),r=0,o=e.length;r<o;r++){var n=e[r];try{n.callback.call(this,t)}catch(t){Promise.resolve().then((function(){throw t}))}n.options&&n.options.once&&this.removeEventListener(t.type,n.callback)}return!t.defaultPrevented}}}]),t}(),w=function(t){!function(t,e){if('function'!=typeof e&&null!==e)throw new TypeError('Super expression must either be null or a function');t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&b(t,e)}(r,E);var e=O(r);function r(){var t;return g(this,r),(t=e.call(this)).listeners||E.call(A(t)),Object.defineProperty(A(t),'aborted',{value:!1,writable:!0,configurable:!0}),Object.defineProperty(A(t),'onabort',{value:null,writable:!0,configurable:!0}),t}return v(r,[{key:'toString',value:function(){return'[object AbortSignal]'}},{key:'dispatchEvent',value:function(t){'abort'===t.type&&(this.aborted=!0,'function'==typeof this.onabort&&this.onabort.call(this,t)),S(_(r.prototype),'dispatchEvent',this).call(this,t)}}]),r}(),T=function(){function t(){g(this,t),Object.defineProperty(this,'signal',{value:new w,writable:!0,configurable:!0})}return v(t,[{key:'abort',value:function(){var t;try{t=new Event('abort')}catch(e){'undefined'!=typeof document?document.createEvent?(t=document.createEvent('Event')).initEvent('abort',!1,!1):(t=document.createEventObject()).type='abort':t={type:'abort',bubbles:!1,cancelable:!1}}this.signal.dispatchEvent(t)}},{key:'toString',value:function(){return'[object AbortController]'}}]),t}();'undefined'!=typeof Symbol&&Symbol.toStringTag&&(T.prototype[Symbol.toStringTag]='AbortController',w.prototype[Symbol.toStringTag]='AbortSignal'),y.AbortController=T,y.AbortSignal=w;var R=y.abortableFetch=function(t){'function'==typeof t&&(t={fetch:t});var e,r=t,o=r.fetch,n=r.Request,s=void 0===n?o.Request:n,i=r.AbortController,a=r.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL,u=void 0!==a&&a;if(!((e={fetch:o,Request:s,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:u}).__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log('__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill'),1):'function'==typeof e.Request&&!e.Request.prototype.hasOwnProperty('signal')||!e.AbortController))return{fetch:o,Request:l};var l=s;(l&&!l.prototype.hasOwnProperty('signal')||u)&&((l=function(t,e){var r;e&&e.signal&&(r=e.signal,delete e.signal);var o=new s(t,e);return r&&Object.defineProperty(o,'signal',{writable:!1,enumerable:!1,configurable:!0,value:r}),o}).prototype=s.prototype);var p=o;return{fetch:function(t,e){var r=l&&l.prototype.isPrototypeOf(t)?t.signal:e?e.signal:void 0;if(r){var o;try{o=new DOMException('Aborted','AbortError')}catch(t){(o=new Error('Aborted')).name='AbortError'}if(r.aborted)return Promise.reject(o);var n=new Promise((function(t,e){r.addEventListener('abort',(function(){return e(o)}),{once:!0})}));return e&&e.signal&&delete e.signal,Promise.race([n,p(t,e)])}return p(t,e)},Request:l}};class k{apiKey;apiBaseUrl;params;constructor(t){this.params=t,this.apiKey=t.apiKey,this.apiBaseUrl=t.apiBaseUrl,'/'!==this.apiBaseUrl[this.apiBaseUrl.length-1]&&(this.apiBaseUrl+='/')}sendBeacon(t,e,r){if(!window.Blob||!window.navigator.sendBeacon)return!1;const o=this._prepareQueryParams({method:t,queryParams:e,sessionKey:r}),n=new window.Blob([o.toString()],{type:'application/x-www-form-urlencoded'});return window.navigator.sendBeacon(`${this.apiBaseUrl}fb.do`,n)}async sendRequest(t,e,r){const o=Date.now(),n=n=>{throw this.params.error$.next({id:'OneStat:ApiTransport:sendRequest',message:'Unhandled request error',thrown:n,data:{method:t,params:e,sessionKey:r,time:Date.now()-o}}),n};return R(fetch).fetch(`${this.apiBaseUrl}fb.do`,{method:'post',headers:{'Content-type':'application/x-www-form-urlencoded'},body:this._prepareQueryParams({method:t,queryParams:e,sessionKey:r})}).then((t=>Number(t.headers.get('content-length'))>0?t.json().then((t=>Object.prototype.hasOwnProperty.call(t,'error_msg')?Promise.reject(t):t),n):void 0),n)}_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 x{api;requestQueue=[];isPaused=!1;debouncedFlush=r.default((()=>this.flush()),3e3,{maxWait:15e3});constructor(t){this.api=t.api}log(t){this.requestQueue.push(t),this.isPaused||this.debouncedFlush()}flush(t=!1){0!==this.requestQueue.length&&(t?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[],this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}}exports.OneStat=class{api;logger;experimental;statContext;constructor(e,r){this.statContext=e;const o=new t.Subject;this.experimental={error$:o};const n=new k({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:h[r.apiEnv],error$:o});this.api=new f({apiTransport:n,refreshAuthToken:r.refreshAuthToken}),this.logger=new x({api:this.api}),window.addEventListener('beforeunload',(()=>this.logger.flush(!0)))}updateContext(t){this.statContext={...this.statContext,...t}}authorize(t){return this.api.authorize(t)}pause(){this.logger.pause()}resume(){this.logger.resume()}logStarted(){this.log({operation:'play'})}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){this.log({operation:'watch_coverage_live',param:`${t.start}-${t.end}`})}logEmptyBuffer(t){this.log({operation:'empty_buffer',param:String(t.duration)})}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.crateLogItem(t);this.logger.log(e)}crateLogItem({operation:t,param:e}){const r=Date.now(),o={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?p.YES:!1===this.statContext.connectionReused?p.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};return void 0!==e&&(o.param=e),{operation:t,timestamp:r,custom:o}}};
|
|
6
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var t=require('@vkontakte/videoplayer-shared/esnext.cjs.js');function e(t){return t&&'object'==typeof t&&'default'in t?t:{default:t}}var r=e(require('lodash/debounce'));const o=(()=>{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 n,s,i,a,u,l,p,c={get:t=>function(t){const e=o?o.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{o&&o.setItem('_one-stat_'+t,JSON.stringify(e))}catch(t){}}(t,e)},remove(t){!function(t){o&&o.removeItem('_one-stat_'+t)}(t)}};exports.ApiEnv=void 0,(n=exports.ApiEnv||(exports.ApiEnv={})).PROD='prod',n.VK_ALIAS='vk_alias',n.VIDEOTEST='videotest',n.TEST='test',exports.Quality=void 0,(s=exports.Quality||(exports.Quality={})).Q144P='144',s.Q240P='240',s.Q360P='360',s.Q480P='480',s.Q720P='720',s.Q1080P='1080',s.Q1440P='1440',s.Q2160P='2160',s.Q4320P='4320',s.UNKNOWN='unknown',exports.ScreenDestination=void 0,(i=exports.ScreenDestination||(exports.ScreenDestination={})).CHROMECAST='chromecast',i.APPLE_TV='appletv',i.PIP='pip',i.HEADPHONES='externalHeadphones',i.SCREEN='',exports.ContentType=void 0,(a=exports.ContentType||(exports.ContentType={})).MP4='mp4',a.DASH='dash',a.HLS='hls',a.WEBM='webm',function(t){t.AUTO='auto',t.MANUAL=''}(u||(u={})),exports.ConnectionType=void 0,(l=exports.ConnectionType||(exports.ConnectionType={})).HTTP1='http1',l.HTTP2='http2',l.HTTP3='http3',function(t){t[t.YES=1]='YES',t[t.NO=0]='NO'}(p||(p={}));const h={[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'};var d;!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'}(d||(d={}));class f{params;uuid;authToken;sessionKey;authorizePromise;refreshAuthTokenPromise;constructor(t){this.params=t;const e=c.get('uuid');e?this.uuid=String(e):(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('')}(),c.set('uuid',this.uuid))}async authorize(t){return this.authToken=t??await this.refreshAuthToken(),this._authorize()}logBeacon(t){const e='log.externalLog',r=this.createLogParams(t),o=this.sessionKey;void 0!==o&&this.params.apiTransport.sendBeacon(e,r,o)||this.params.apiTransport.sendRequest(e,r,o)}async logRequest(t){const e='log.externalLog',r=this.createLogParams(t),o=this.sessionKey??await this._authorize();try{return await this.params.apiTransport.sendRequest(e,r,o)}catch(t){switch(t?.error_code){case d.PARAM_SESSION_EXPIRED:case d.PARAM_SESSION_KEY:case d.PARAM_SIGNATURE:{const t=await this._authorize();return this.params.apiTransport.sendRequest(e,r,t)}case d.AUTH_LOGIN:{this.authToken=await this.refreshAuthToken();const t=await this._authorizeRequest();return this.params.apiTransport.sendRequest(e,r,t)}default:throw t}}}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.12',platform:'WEB',items:t.map((t=>({...t,time:0,type:1})))})}}async _authorize(){try{return await this._authorizeRequest()}catch(t){switch(t?.error_code){case d.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this._authorizeRequest()}throw t}}async _authorizeRequest(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0;const t='auth.anonymLogin',e={session_data:{version:2,device_id:this.uuid,client_version:'1.0.12'.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(t,e).then((r=>{if(!r)throw new Error(`Empty response. Method: ${t}, params: ${JSON.stringify(e)}`);if(!r.session_key)throw new Error(`Empty 'session_key' in response. Method: ${t}, params: ${JSON.stringify(e)}, response: ${JSON.stringify(r)}`);return this.sessionKey=r.session_key,this.sessionKey})).catch((t=>{throw this.sessionKey=void 0,t})).finally((()=>{this.authorizePromise=void 0})),this.authorizePromise}}var y={};function g(t,e){if(!(t instanceof e))throw new TypeError('Cannot call a class as a function')}function m(t,e){for(var r=0;r<e.length;r++){var o=e[r];o.enumerable=o.enumerable||!1,o.configurable=!0,'value'in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function v(t,e,r){return e&&m(t.prototype,e),r&&m(t,r),t}function _(t){return(_=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function b(t,e){return(b=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function A(t){if(void 0===t)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return t}function P(t,e){return!e||'object'!=typeof e&&'function'!=typeof e?A(t):e}function O(t){var e=function(){if('undefined'==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if('function'==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,o=_(t);if(e){var n=_(this).constructor;r=Reflect.construct(o,arguments,n)}else r=o.apply(this,arguments);return P(this,r)}}function S(t,e,r){return(S='undefined'!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var o=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=_(t)););return t}(t,e);if(o){var n=Object.getOwnPropertyDescriptor(o,e);return n.get?n.get.call(r):n.value}})(t,e,r||t)}Object.defineProperty(y,'__esModule',{value:!0});var E=function(){function t(){g(this,t),Object.defineProperty(this,'listeners',{value:{},writable:!0,configurable:!0})}return v(t,[{key:'addEventListener',value:function(t,e,r){t in this.listeners||(this.listeners[t]=[]),this.listeners[t].push({callback:e,options:r})}},{key:'removeEventListener',value:function(t,e){if(t in this.listeners)for(var r=this.listeners[t],o=0,n=r.length;o<n;o++)if(r[o].callback===e)return void r.splice(o,1)}},{key:'dispatchEvent',value:function(t){if(t.type in this.listeners){for(var e=this.listeners[t.type].slice(),r=0,o=e.length;r<o;r++){var n=e[r];try{n.callback.call(this,t)}catch(t){Promise.resolve().then((function(){throw t}))}n.options&&n.options.once&&this.removeEventListener(t.type,n.callback)}return!t.defaultPrevented}}}]),t}(),w=function(t){!function(t,e){if('function'!=typeof e&&null!==e)throw new TypeError('Super expression must either be null or a function');t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&b(t,e)}(r,E);var e=O(r);function r(){var t;return g(this,r),(t=e.call(this)).listeners||E.call(A(t)),Object.defineProperty(A(t),'aborted',{value:!1,writable:!0,configurable:!0}),Object.defineProperty(A(t),'onabort',{value:null,writable:!0,configurable:!0}),t}return v(r,[{key:'toString',value:function(){return'[object AbortSignal]'}},{key:'dispatchEvent',value:function(t){'abort'===t.type&&(this.aborted=!0,'function'==typeof this.onabort&&this.onabort.call(this,t)),S(_(r.prototype),'dispatchEvent',this).call(this,t)}}]),r}(),T=function(){function t(){g(this,t),Object.defineProperty(this,'signal',{value:new w,writable:!0,configurable:!0})}return v(t,[{key:'abort',value:function(){var t;try{t=new Event('abort')}catch(e){'undefined'!=typeof document?document.createEvent?(t=document.createEvent('Event')).initEvent('abort',!1,!1):(t=document.createEventObject()).type='abort':t={type:'abort',bubbles:!1,cancelable:!1}}this.signal.dispatchEvent(t)}},{key:'toString',value:function(){return'[object AbortController]'}}]),t}();'undefined'!=typeof Symbol&&Symbol.toStringTag&&(T.prototype[Symbol.toStringTag]='AbortController',w.prototype[Symbol.toStringTag]='AbortSignal'),y.AbortController=T,y.AbortSignal=w;var R=y.abortableFetch=function(t){'function'==typeof t&&(t={fetch:t});var e,r=t,o=r.fetch,n=r.Request,s=void 0===n?o.Request:n,i=r.AbortController,a=r.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL,u=void 0!==a&&a;if(!((e={fetch:o,Request:s,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:u}).__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log('__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill'),1):'function'==typeof e.Request&&!e.Request.prototype.hasOwnProperty('signal')||!e.AbortController))return{fetch:o,Request:l};var l=s;(l&&!l.prototype.hasOwnProperty('signal')||u)&&((l=function(t,e){var r;e&&e.signal&&(r=e.signal,delete e.signal);var o=new s(t,e);return r&&Object.defineProperty(o,'signal',{writable:!1,enumerable:!1,configurable:!0,value:r}),o}).prototype=s.prototype);var p=o;return{fetch:function(t,e){var r=l&&l.prototype.isPrototypeOf(t)?t.signal:e?e.signal:void 0;if(r){var o;try{o=new DOMException('Aborted','AbortError')}catch(t){(o=new Error('Aborted')).name='AbortError'}if(r.aborted)return Promise.reject(o);var n=new Promise((function(t,e){r.addEventListener('abort',(function(){return e(o)}),{once:!0})}));return e&&e.signal&&delete e.signal,Promise.race([n,p(t,e)])}return p(t,e)},Request:l}};class k{apiKey;apiBaseUrl;params;constructor(t){this.params=t,this.apiKey=t.apiKey,this.apiBaseUrl=t.apiBaseUrl,'/'!==this.apiBaseUrl[this.apiBaseUrl.length-1]&&(this.apiBaseUrl+='/')}sendBeacon(t,e,r){if(!window.Blob||!window.navigator.sendBeacon)return!1;const o=this._prepareQueryParams({method:t,queryParams:e,sessionKey:r}),n=new window.Blob([o.toString()],{type:'application/x-www-form-urlencoded'});return window.navigator.sendBeacon(`${this.apiBaseUrl}fb.do`,n)}async sendRequest(t,e,r){const o=Date.now(),n=n=>{throw this.params.error$.next({id:'OneStat:ApiTransport:sendRequest',message:'Unhandled request error',thrown:n,data:{method:t,params:e,sessionKey:r,time:Date.now()-o}}),n};return R(fetch).fetch(`${this.apiBaseUrl}fb.do`,{method:'post',headers:{'Content-type':'application/x-www-form-urlencoded'},body:this._prepareQueryParams({method:t,queryParams:e,sessionKey:r})}).then((t=>Number(t.headers.get('content-length'))>0?t.json().then((t=>Object.prototype.hasOwnProperty.call(t,'error_msg')?Promise.reject(t):t),n):void 0),n)}_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 x{api;requestQueue=[];isPaused=!1;debouncedFlush=r.default((()=>this.flush()),3e3,{maxWait:15e3});constructor(t){this.api=t.api}log(t){this.requestQueue.push(t),this.isPaused||this.debouncedFlush()}flush(t=!1){0!==this.requestQueue.length&&(t?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[],this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}}exports.OneStat=class{api;logger;experimental;statContext;constructor(e,r){this.statContext=e;const o=new t.Subject;this.experimental={error$:o};const n=new k({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:h[r.apiEnv],error$:o});this.api=new f({apiTransport:n,refreshAuthToken:r.refreshAuthToken}),this.logger=new x({api:this.api}),window.addEventListener('beforeunload',(()=>this.logger.flush(!0)))}updateContext(t){this.statContext={...this.statContext,...t}}authorize(t){return this.api.authorize(t)}pause(){this.logger.pause()}resume(){this.logger.resume()}logStarted(){this.log({operation:'play'})}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){this.log({operation:'watch_coverage_live',param:`${t.start}-${t.end}`}),this.logger.flush(!0)}logEmptyBuffer(t){this.log({operation:'empty_buffer',param:String(t.duration)})}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.crateLogItem(t);this.logger.log(e)}crateLogItem({operation:t,param:e}){const r=Date.now(),o={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?p.YES:!1===this.statContext.connectionReused?p.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};return void 0!==e&&(o.param=e),{operation:t,timestamp:r,custom:o}}};
|
package/esnext.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-statistics v1.0.
|
|
3
|
-
* Thu, 17 Mar 2022
|
|
4
|
-
* https://st.mycdn.me/static/playersdk/1-0-
|
|
2
|
+
* @vkontakte/videoplayer-statistics v1.0.12
|
|
3
|
+
* Thu, 17 Mar 2022 14:38:04 GMT
|
|
4
|
+
* https://st.mycdn.me/static/playersdk/1-0-12/doc/
|
|
5
5
|
*/
|
|
6
|
-
import{Subject as t}from'@vkontakte/videoplayer-shared/esnext.esm.js';import e from'lodash/debounce';const r=(()=>{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 o,n,s,i,a,u,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)}};!function(t){t.PROD='prod',t.VK_ALIAS='vk_alias',t.VIDEOTEST='videotest',t.TEST='test'}(o||(o={})),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'}(n||(n={})),function(t){t.CHROMECAST='chromecast',t.APPLE_TV='appletv',t.PIP='pip',t.HEADPHONES='externalHeadphones',t.SCREEN=''}(s||(s={})),function(t){t.MP4='mp4',t.DASH='dash',t.HLS='hls',t.WEBM='webm'}(i||(i={})),function(t){t.AUTO='auto',t.MANUAL=''}(a||(a={})),function(t){t.HTTP1='http1',t.HTTP2='http2',t.HTTP3='http3'}(u||(u={})),function(t){t[t.YES=1]='YES',t[t.NO=0]='NO'}(l||(l={}));const h={[o.PROD]:'https://api.ok.ru',[o.VK_ALIAS]:'https://api.mycdn.me',[o.VIDEOTEST]:'https://videotestapi.ok.ru/api',[o.TEST]:'https://apitest.ok.ru'};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 d{params;uuid;authToken;sessionKey;authorizePromise;refreshAuthTokenPromise;constructor(t){this.params=t;const e=c.get('uuid');e?this.uuid=String(e):(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('')}(),c.set('uuid',this.uuid))}async authorize(t){return this.authToken=t??await this.refreshAuthToken(),this._authorize()}logBeacon(t){const e='log.externalLog',r=this.createLogParams(t),o=this.sessionKey;void 0!==o&&this.params.apiTransport.sendBeacon(e,r,o)||this.params.apiTransport.sendRequest(e,r,o)}async logRequest(t){const e='log.externalLog',r=this.createLogParams(t),o=this.sessionKey??await this._authorize();try{return await this.params.apiTransport.sendRequest(e,r,o)}catch(t){switch(t?.error_code){case p.PARAM_SESSION_EXPIRED:case p.PARAM_SESSION_KEY:case p.PARAM_SIGNATURE:{const t=await this._authorize();return this.params.apiTransport.sendRequest(e,r,t)}case p.AUTH_LOGIN:{this.authToken=await this.refreshAuthToken();const t=await this._authorizeRequest();return this.params.apiTransport.sendRequest(e,r,t)}default:throw t}}}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.11',platform:'WEB',items:t.map((t=>({...t,time:0,type:1})))})}}async _authorize(){try{return await this._authorizeRequest()}catch(t){switch(t?.error_code){case p.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this._authorizeRequest()}throw t}}async _authorizeRequest(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0;const t='auth.anonymLogin',e={session_data:{version:2,device_id:this.uuid,client_version:'1.0.11'.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(t,e).then((r=>{if(!r)throw new Error(`Empty response. Method: ${t}, params: ${JSON.stringify(e)}`);if(!r.session_key)throw new Error(`Empty 'session_key' in response. Method: ${t}, params: ${JSON.stringify(e)}, response: ${JSON.stringify(r)}`);return this.sessionKey=r.session_key,this.sessionKey})).catch((t=>{throw this.sessionKey=void 0,t})).finally((()=>{this.authorizePromise=void 0})),this.authorizePromise}}var f={};function y(t,e){if(!(t instanceof e))throw new TypeError('Cannot call a class as a function')}function g(t,e){for(var r=0;r<e.length;r++){var o=e[r];o.enumerable=o.enumerable||!1,o.configurable=!0,'value'in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function m(t,e,r){return e&&g(t.prototype,e),r&&g(t,r),t}function v(t){return(v=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function _(t,e){return(_=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function b(t){if(void 0===t)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return t}function P(t,e){return!e||'object'!=typeof e&&'function'!=typeof e?b(t):e}function A(t){var e=function(){if('undefined'==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if('function'==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,o=v(t);if(e){var n=v(this).constructor;r=Reflect.construct(o,arguments,n)}else r=o.apply(this,arguments);return P(this,r)}}function O(t,e,r){return(O='undefined'!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var o=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=v(t)););return t}(t,e);if(o){var n=Object.getOwnPropertyDescriptor(o,e);return n.get?n.get.call(r):n.value}})(t,e,r||t)}Object.defineProperty(f,'__esModule',{value:!0});var w=function(){function t(){y(this,t),Object.defineProperty(this,'listeners',{value:{},writable:!0,configurable:!0})}return m(t,[{key:'addEventListener',value:function(t,e,r){t in this.listeners||(this.listeners[t]=[]),this.listeners[t].push({callback:e,options:r})}},{key:'removeEventListener',value:function(t,e){if(t in this.listeners)for(var r=this.listeners[t],o=0,n=r.length;o<n;o++)if(r[o].callback===e)return void r.splice(o,1)}},{key:'dispatchEvent',value:function(t){if(t.type in this.listeners){for(var e=this.listeners[t.type].slice(),r=0,o=e.length;r<o;r++){var n=e[r];try{n.callback.call(this,t)}catch(t){Promise.resolve().then((function(){throw t}))}n.options&&n.options.once&&this.removeEventListener(t.type,n.callback)}return!t.defaultPrevented}}}]),t}(),S=function(t){!function(t,e){if('function'!=typeof e&&null!==e)throw new TypeError('Super expression must either be null or a function');t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&_(t,e)}(r,w);var e=A(r);function r(){var t;return y(this,r),(t=e.call(this)).listeners||w.call(b(t)),Object.defineProperty(b(t),'aborted',{value:!1,writable:!0,configurable:!0}),Object.defineProperty(b(t),'onabort',{value:null,writable:!0,configurable:!0}),t}return m(r,[{key:'toString',value:function(){return'[object AbortSignal]'}},{key:'dispatchEvent',value:function(t){'abort'===t.type&&(this.aborted=!0,'function'==typeof this.onabort&&this.onabort.call(this,t)),O(v(r.prototype),'dispatchEvent',this).call(this,t)}}]),r}(),E=function(){function t(){y(this,t),Object.defineProperty(this,'signal',{value:new S,writable:!0,configurable:!0})}return m(t,[{key:'abort',value:function(){var t;try{t=new Event('abort')}catch(e){'undefined'!=typeof document?document.createEvent?(t=document.createEvent('Event')).initEvent('abort',!1,!1):(t=document.createEventObject()).type='abort':t={type:'abort',bubbles:!1,cancelable:!1}}this.signal.dispatchEvent(t)}},{key:'toString',value:function(){return'[object AbortController]'}}]),t}();'undefined'!=typeof Symbol&&Symbol.toStringTag&&(E.prototype[Symbol.toStringTag]='AbortController',S.prototype[Symbol.toStringTag]='AbortSignal'),f.AbortController=E,f.AbortSignal=S;var T=f.abortableFetch=function(t){'function'==typeof t&&(t={fetch:t});var e,r=t,o=r.fetch,n=r.Request,s=void 0===n?o.Request:n,i=r.AbortController,a=r.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL,u=void 0!==a&&a;if(!((e={fetch:o,Request:s,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:u}).__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log('__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill'),1):'function'==typeof e.Request&&!e.Request.prototype.hasOwnProperty('signal')||!e.AbortController))return{fetch:o,Request:l};var l=s;(l&&!l.prototype.hasOwnProperty('signal')||u)&&((l=function(t,e){var r;e&&e.signal&&(r=e.signal,delete e.signal);var o=new s(t,e);return r&&Object.defineProperty(o,'signal',{writable:!1,enumerable:!1,configurable:!0,value:r}),o}).prototype=s.prototype);var c=o;return{fetch:function(t,e){var r=l&&l.prototype.isPrototypeOf(t)?t.signal:e?e.signal:void 0;if(r){var o;try{o=new DOMException('Aborted','AbortError')}catch(t){(o=new Error('Aborted')).name='AbortError'}if(r.aborted)return Promise.reject(o);var n=new Promise((function(t,e){r.addEventListener('abort',(function(){return e(o)}),{once:!0})}));return e&&e.signal&&delete e.signal,Promise.race([n,c(t,e)])}return c(t,e)},Request:l}};class R{apiKey;apiBaseUrl;params;constructor(t){this.params=t,this.apiKey=t.apiKey,this.apiBaseUrl=t.apiBaseUrl,'/'!==this.apiBaseUrl[this.apiBaseUrl.length-1]&&(this.apiBaseUrl+='/')}sendBeacon(t,e,r){if(!window.Blob||!window.navigator.sendBeacon)return!1;const o=this._prepareQueryParams({method:t,queryParams:e,sessionKey:r}),n=new window.Blob([o.toString()],{type:'application/x-www-form-urlencoded'});return window.navigator.sendBeacon(`${this.apiBaseUrl}fb.do`,n)}async sendRequest(t,e,r){const o=Date.now(),n=n=>{throw this.params.error$.next({id:'OneStat:ApiTransport:sendRequest',message:'Unhandled request error',thrown:n,data:{method:t,params:e,sessionKey:r,time:Date.now()-o}}),n};return T(fetch).fetch(`${this.apiBaseUrl}fb.do`,{method:'post',headers:{'Content-type':'application/x-www-form-urlencoded'},body:this._prepareQueryParams({method:t,queryParams:e,sessionKey:r})}).then((t=>Number(t.headers.get('content-length'))>0?t.json().then((t=>Object.prototype.hasOwnProperty.call(t,'error_msg')?Promise.reject(t):t),n):void 0),n)}_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 k{api;requestQueue=[];isPaused=!1;debouncedFlush=e((()=>this.flush()),3e3,{maxWait:15e3});constructor(t){this.api=t.api}log(t){this.requestQueue.push(t),this.isPaused||this.debouncedFlush()}flush(t=!1){0!==this.requestQueue.length&&(t?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[],this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}}class L{api;logger;experimental;statContext;constructor(e,r){this.statContext=e;const o=new t;this.experimental={error$:o};const n=new R({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:h[r.apiEnv],error$:o});this.api=new d({apiTransport:n,refreshAuthToken:r.refreshAuthToken}),this.logger=new k({api:this.api}),window.addEventListener('beforeunload',(()=>this.logger.flush(!0)))}updateContext(t){this.statContext={...this.statContext,...t}}authorize(t){return this.api.authorize(t)}pause(){this.logger.pause()}resume(){this.logger.resume()}logStarted(){this.log({operation:'play'})}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){this.log({operation:'watch_coverage_live',param:`${t.start}-${t.end}`})}logEmptyBuffer(t){this.log({operation:'empty_buffer',param:String(t.duration)})}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.crateLogItem(t);this.logger.log(e)}crateLogItem({operation:t,param:e}){const r=Date.now(),o={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?a.AUTO:!1===this.statContext.autoplay?a.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId};return void 0!==e&&(o.param=e),{operation:t,timestamp:r,custom:o}}}export{o as ApiEnv,u as ConnectionType,i as ContentType,L as OneStat,n as Quality,s as ScreenDestination};
|
|
6
|
+
import{Subject as t}from'@vkontakte/videoplayer-shared/esnext.esm.js';import e from'lodash/debounce';const r=(()=>{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 o,n,s,i,a,u,l,h={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)}};!function(t){t.PROD='prod',t.VK_ALIAS='vk_alias',t.VIDEOTEST='videotest',t.TEST='test'}(o||(o={})),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'}(n||(n={})),function(t){t.CHROMECAST='chromecast',t.APPLE_TV='appletv',t.PIP='pip',t.HEADPHONES='externalHeadphones',t.SCREEN=''}(s||(s={})),function(t){t.MP4='mp4',t.DASH='dash',t.HLS='hls',t.WEBM='webm'}(i||(i={})),function(t){t.AUTO='auto',t.MANUAL=''}(a||(a={})),function(t){t.HTTP1='http1',t.HTTP2='http2',t.HTTP3='http3'}(u||(u={})),function(t){t[t.YES=1]='YES',t[t.NO=0]='NO'}(l||(l={}));const c={[o.PROD]:'https://api.ok.ru',[o.VK_ALIAS]:'https://api.mycdn.me',[o.VIDEOTEST]:'https://videotestapi.ok.ru/api',[o.TEST]:'https://apitest.ok.ru'};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 d{params;uuid;authToken;sessionKey;authorizePromise;refreshAuthTokenPromise;constructor(t){this.params=t;const e=h.get('uuid');e?this.uuid=String(e):(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('')}(),h.set('uuid',this.uuid))}async authorize(t){return this.authToken=t??await this.refreshAuthToken(),this._authorize()}logBeacon(t){const e='log.externalLog',r=this.createLogParams(t),o=this.sessionKey;void 0!==o&&this.params.apiTransport.sendBeacon(e,r,o)||this.params.apiTransport.sendRequest(e,r,o)}async logRequest(t){const e='log.externalLog',r=this.createLogParams(t),o=this.sessionKey??await this._authorize();try{return await this.params.apiTransport.sendRequest(e,r,o)}catch(t){switch(t?.error_code){case p.PARAM_SESSION_EXPIRED:case p.PARAM_SESSION_KEY:case p.PARAM_SIGNATURE:{const t=await this._authorize();return this.params.apiTransport.sendRequest(e,r,t)}case p.AUTH_LOGIN:{this.authToken=await this.refreshAuthToken();const t=await this._authorizeRequest();return this.params.apiTransport.sendRequest(e,r,t)}default:throw t}}}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.12',platform:'WEB',items:t.map((t=>({...t,time:0,type:1})))})}}async _authorize(){try{return await this._authorizeRequest()}catch(t){switch(t?.error_code){case p.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this._authorizeRequest()}throw t}}async _authorizeRequest(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0;const t='auth.anonymLogin',e={session_data:{version:2,device_id:this.uuid,client_version:'1.0.12'.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(t,e).then((r=>{if(!r)throw new Error(`Empty response. Method: ${t}, params: ${JSON.stringify(e)}`);if(!r.session_key)throw new Error(`Empty 'session_key' in response. Method: ${t}, params: ${JSON.stringify(e)}, response: ${JSON.stringify(r)}`);return this.sessionKey=r.session_key,this.sessionKey})).catch((t=>{throw this.sessionKey=void 0,t})).finally((()=>{this.authorizePromise=void 0})),this.authorizePromise}}var f={};function y(t,e){if(!(t instanceof e))throw new TypeError('Cannot call a class as a function')}function g(t,e){for(var r=0;r<e.length;r++){var o=e[r];o.enumerable=o.enumerable||!1,o.configurable=!0,'value'in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function m(t,e,r){return e&&g(t.prototype,e),r&&g(t,r),t}function v(t){return(v=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function _(t,e){return(_=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function b(t){if(void 0===t)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return t}function P(t,e){return!e||'object'!=typeof e&&'function'!=typeof e?b(t):e}function A(t){var e=function(){if('undefined'==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if('function'==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,o=v(t);if(e){var n=v(this).constructor;r=Reflect.construct(o,arguments,n)}else r=o.apply(this,arguments);return P(this,r)}}function O(t,e,r){return(O='undefined'!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var o=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=v(t)););return t}(t,e);if(o){var n=Object.getOwnPropertyDescriptor(o,e);return n.get?n.get.call(r):n.value}})(t,e,r||t)}Object.defineProperty(f,'__esModule',{value:!0});var w=function(){function t(){y(this,t),Object.defineProperty(this,'listeners',{value:{},writable:!0,configurable:!0})}return m(t,[{key:'addEventListener',value:function(t,e,r){t in this.listeners||(this.listeners[t]=[]),this.listeners[t].push({callback:e,options:r})}},{key:'removeEventListener',value:function(t,e){if(t in this.listeners)for(var r=this.listeners[t],o=0,n=r.length;o<n;o++)if(r[o].callback===e)return void r.splice(o,1)}},{key:'dispatchEvent',value:function(t){if(t.type in this.listeners){for(var e=this.listeners[t.type].slice(),r=0,o=e.length;r<o;r++){var n=e[r];try{n.callback.call(this,t)}catch(t){Promise.resolve().then((function(){throw t}))}n.options&&n.options.once&&this.removeEventListener(t.type,n.callback)}return!t.defaultPrevented}}}]),t}(),S=function(t){!function(t,e){if('function'!=typeof e&&null!==e)throw new TypeError('Super expression must either be null or a function');t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&_(t,e)}(r,w);var e=A(r);function r(){var t;return y(this,r),(t=e.call(this)).listeners||w.call(b(t)),Object.defineProperty(b(t),'aborted',{value:!1,writable:!0,configurable:!0}),Object.defineProperty(b(t),'onabort',{value:null,writable:!0,configurable:!0}),t}return m(r,[{key:'toString',value:function(){return'[object AbortSignal]'}},{key:'dispatchEvent',value:function(t){'abort'===t.type&&(this.aborted=!0,'function'==typeof this.onabort&&this.onabort.call(this,t)),O(v(r.prototype),'dispatchEvent',this).call(this,t)}}]),r}(),E=function(){function t(){y(this,t),Object.defineProperty(this,'signal',{value:new S,writable:!0,configurable:!0})}return m(t,[{key:'abort',value:function(){var t;try{t=new Event('abort')}catch(e){'undefined'!=typeof document?document.createEvent?(t=document.createEvent('Event')).initEvent('abort',!1,!1):(t=document.createEventObject()).type='abort':t={type:'abort',bubbles:!1,cancelable:!1}}this.signal.dispatchEvent(t)}},{key:'toString',value:function(){return'[object AbortController]'}}]),t}();'undefined'!=typeof Symbol&&Symbol.toStringTag&&(E.prototype[Symbol.toStringTag]='AbortController',S.prototype[Symbol.toStringTag]='AbortSignal'),f.AbortController=E,f.AbortSignal=S;var T=f.abortableFetch=function(t){'function'==typeof t&&(t={fetch:t});var e,r=t,o=r.fetch,n=r.Request,s=void 0===n?o.Request:n,i=r.AbortController,a=r.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL,u=void 0!==a&&a;if(!((e={fetch:o,Request:s,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:u}).__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log('__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill'),1):'function'==typeof e.Request&&!e.Request.prototype.hasOwnProperty('signal')||!e.AbortController))return{fetch:o,Request:l};var l=s;(l&&!l.prototype.hasOwnProperty('signal')||u)&&((l=function(t,e){var r;e&&e.signal&&(r=e.signal,delete e.signal);var o=new s(t,e);return r&&Object.defineProperty(o,'signal',{writable:!1,enumerable:!1,configurable:!0,value:r}),o}).prototype=s.prototype);var h=o;return{fetch:function(t,e){var r=l&&l.prototype.isPrototypeOf(t)?t.signal:e?e.signal:void 0;if(r){var o;try{o=new DOMException('Aborted','AbortError')}catch(t){(o=new Error('Aborted')).name='AbortError'}if(r.aborted)return Promise.reject(o);var n=new Promise((function(t,e){r.addEventListener('abort',(function(){return e(o)}),{once:!0})}));return e&&e.signal&&delete e.signal,Promise.race([n,h(t,e)])}return h(t,e)},Request:l}};class R{apiKey;apiBaseUrl;params;constructor(t){this.params=t,this.apiKey=t.apiKey,this.apiBaseUrl=t.apiBaseUrl,'/'!==this.apiBaseUrl[this.apiBaseUrl.length-1]&&(this.apiBaseUrl+='/')}sendBeacon(t,e,r){if(!window.Blob||!window.navigator.sendBeacon)return!1;const o=this._prepareQueryParams({method:t,queryParams:e,sessionKey:r}),n=new window.Blob([o.toString()],{type:'application/x-www-form-urlencoded'});return window.navigator.sendBeacon(`${this.apiBaseUrl}fb.do`,n)}async sendRequest(t,e,r){const o=Date.now(),n=n=>{throw this.params.error$.next({id:'OneStat:ApiTransport:sendRequest',message:'Unhandled request error',thrown:n,data:{method:t,params:e,sessionKey:r,time:Date.now()-o}}),n};return T(fetch).fetch(`${this.apiBaseUrl}fb.do`,{method:'post',headers:{'Content-type':'application/x-www-form-urlencoded'},body:this._prepareQueryParams({method:t,queryParams:e,sessionKey:r})}).then((t=>Number(t.headers.get('content-length'))>0?t.json().then((t=>Object.prototype.hasOwnProperty.call(t,'error_msg')?Promise.reject(t):t),n):void 0),n)}_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 k{api;requestQueue=[];isPaused=!1;debouncedFlush=e((()=>this.flush()),3e3,{maxWait:15e3});constructor(t){this.api=t.api}log(t){this.requestQueue.push(t),this.isPaused||this.debouncedFlush()}flush(t=!1){0!==this.requestQueue.length&&(t?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[],this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}}class L{api;logger;experimental;statContext;constructor(e,r){this.statContext=e;const o=new t;this.experimental={error$:o};const n=new R({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:c[r.apiEnv],error$:o});this.api=new d({apiTransport:n,refreshAuthToken:r.refreshAuthToken}),this.logger=new k({api:this.api}),window.addEventListener('beforeunload',(()=>this.logger.flush(!0)))}updateContext(t){this.statContext={...this.statContext,...t}}authorize(t){return this.api.authorize(t)}pause(){this.logger.pause()}resume(){this.logger.resume()}logStarted(){this.log({operation:'play'})}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){this.log({operation:'watch_coverage_live',param:`${t.start}-${t.end}`}),this.logger.flush(!0)}logEmptyBuffer(t){this.log({operation:'empty_buffer',param:String(t.duration)})}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.crateLogItem(t);this.logger.log(e)}crateLogItem({operation:t,param:e}){const r=Date.now(),o={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?a.AUTO:!1===this.statContext.autoplay?a.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId};return void 0!==e&&(o.param=e),{operation:t,timestamp:r,custom:o}}}export{o as ApiEnv,u as ConnectionType,i as ContentType,L as OneStat,n as Quality,s as ScreenDestination};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vkontakte/videoplayer-statistics",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"author": "vk.com",
|
|
5
5
|
"description": "Statistics library for vk.com videoplayer",
|
|
6
6
|
"homepage": "https://vk.com",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"**/*.d.ts"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@vkontakte/videoplayer-shared": "1.0.
|
|
17
|
+
"@vkontakte/videoplayer-shared": "1.0.9",
|
|
18
18
|
"lodash": "4.17.21"
|
|
19
19
|
}
|
|
20
20
|
}
|
package/es5.cjs.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @vkontakte/videoplayer-statistics v1.0.11
|
|
3
|
-
* Thu, 17 Mar 2022 09:49:34 GMT
|
|
4
|
-
* https://st.mycdn.me/static/playersdk/1-0-11/doc/
|
|
5
|
-
*/
|
|
6
|
-
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var t=require('@vkontakte/videoplayer-shared/es5.cjs.js');function e(t){return t&&'object'==typeof t&&'default'in t?t:{default:t}}var n=e(require('lodash/debounce')),r=function(){return(r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function o(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))}function i(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},'function'==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError('Generator is already executing.');for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var a='undefined'!=typeof globalThis?globalThis:'undefined'!=typeof window?window:'undefined'!=typeof global?global:'undefined'!=typeof self?self:{},u=function(t){return t&&t.Math==Math&&t},s=u('object'==typeof globalThis&&globalThis)||u('object'==typeof window&&window)||u('object'==typeof self&&self)||u('object'==typeof a&&a)||function(){return this}()||Function('return this')(),c=function(t){try{return!!t()}catch(t){return!0}},f=!c((function(){var t=function(){}.bind();return'function'!=typeof t||t.hasOwnProperty('prototype')})),p=f,l=Function.prototype,h=l.apply,d=l.call,v='object'==typeof Reflect&&Reflect.apply||(p?d.bind(h):function(){return d.apply(h,arguments)}),y=f,b=Function.prototype,g=b.bind,m=b.call,w=y&&g.bind(m,m),O=y?function(t){return t&&w(t)}:function(t){return t&&function(){return m.apply(t,arguments)}},S=function(t){return'function'==typeof t},_={},P=!c((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),E=f,T=Function.prototype.call,A=E?T.bind(T):function(){return T.apply(T,arguments)},j={},R={}.propertyIsEnumerable,x=Object.getOwnPropertyDescriptor,k=x&&!R.call({1:2},1);j.f=k?function(t){var e=x(this,t);return!!e&&e.enumerable}:R;var L,C,I=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},N=O,q=N({}.toString),M=N(''.slice),B=function(t){return M(q(t),8,-1)},F=O,D=c,U=B,z=s.Object,K=F(''.split),Q=D((function(){return!z('z').propertyIsEnumerable(0)}))?function(t){return'String'==U(t)?K(t,''):z(t)}:z,H=s.TypeError,G=function(t){if(null==t)throw H('Can\'t call method on '+t);return t},Y=Q,J=G,W=S,V=function(t){return'object'==typeof t?null!==t:W(t)},X={},$=X,Z=s,tt=S,et=function(t){return tt(t)?t:void 0},nt=function(t,e){return arguments.length<2?et($[t])||et(Z[t]):$[t]&&$[t][e]||Z[t]&&Z[t][e]},rt=O({}.isPrototypeOf),ot=nt('navigator','userAgent')||'',it=s,at=ot,ut=it.process,st=it.Deno,ct=ut&&ut.versions||st&&st.version,ft=ct&&ct.v8;ft&&(C=(L=ft.split('.'))[0]>0&&L[0]<4?1:+(L[0]+L[1])),!C&&at&&(!(L=at.match(/Edge\/(\d+)/))||L[1]>=74)&&(L=at.match(/Chrome\/(\d+)/))&&(C=+L[1]);var pt=C,lt=pt,ht=c,dt=!!Object.getOwnPropertySymbols&&!ht((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&<&<<41})),vt=dt&&!Symbol.sham&&'symbol'==typeof Symbol.iterator,yt=nt,bt=S,gt=rt,mt=vt,wt=s.Object,Ot=mt?function(t){return'symbol'==typeof t}:function(t){var e=yt('Symbol');return bt(e)&>(e.prototype,wt(t))},St=s.String,_t=function(t){try{return St(t)}catch(t){return'Object'}},Pt=S,Et=_t,Tt=s.TypeError,At=function(t){if(Pt(t))return t;throw Tt(Et(t)+' is not a function')},jt=At,Rt=function(t,e){var n=t[e];return null==n?void 0:jt(n)},xt=A,kt=S,Lt=V,Ct=s.TypeError,It={exports:{}},Nt=s,qt=Object.defineProperty,Mt=function(t,e){try{qt(Nt,t,{value:e,configurable:!0,writable:!0})}catch(n){Nt[t]=e}return e},Bt=s['__core-js_shared__']||Mt('__core-js_shared__',{}),Ft=Bt;(It.exports=function(t,e){return Ft[t]||(Ft[t]=void 0!==e?e:{})})('versions',[]).push({version:'3.21.1',mode:'pure',copyright:'© 2014-2022 Denis Pushkarev (zloirock.ru)',license:'https://github.com/zloirock/core-js/blob/v3.21.1/LICENSE',source:'https://github.com/zloirock/core-js'});var Dt=G,Ut=s.Object,zt=function(t){return Ut(Dt(t))},Kt=O({}.hasOwnProperty),Qt=Object.hasOwn||function(t,e){return Kt(zt(t),e)},Ht=O,Gt=0,Yt=Math.random(),Jt=Ht(1..toString),Wt=function(t){return'Symbol('+(void 0===t?'':t)+')_'+Jt(++Gt+Yt,36)},Vt=s,Xt=It.exports,$t=Qt,Zt=Wt,te=dt,ee=vt,ne=Xt('wks'),re=Vt.Symbol,oe=re&&re.for,ie=ee?re:re&&re.withoutSetter||Zt,ae=function(t){if(!$t(ne,t)||!te&&'string'!=typeof ne[t]){var e='Symbol.'+t;te&&$t(re,t)?ne[t]=re[t]:ne[t]=ee&&oe?oe(e):ie(e)}return ne[t]},ue=A,se=V,ce=Ot,fe=Rt,pe=function(t,e){var n,r;if('string'===e&&kt(n=t.toString)&&!Lt(r=xt(n,t)))return r;if(kt(n=t.valueOf)&&!Lt(r=xt(n,t)))return r;if('string'!==e&&kt(n=t.toString)&&!Lt(r=xt(n,t)))return r;throw Ct('Can\'t convert object to primitive value')},le=ae,he=s.TypeError,de=le('toPrimitive'),ve=function(t,e){if(!se(t)||ce(t))return t;var n,r=fe(t,de);if(r){if(void 0===e&&(e='default'),n=ue(r,t,e),!se(n)||ce(n))return n;throw he('Can\'t convert object to primitive value')}return void 0===e&&(e='number'),pe(t,e)},ye=Ot,be=function(t){var e=ve(t,'string');return ye(e)?e:e+''},ge=V,me=s.document,we=ge(me)&&ge(me.createElement),Oe=function(t){return we?me.createElement(t):{}},Se=Oe,_e=!P&&!c((function(){return 7!=Object.defineProperty(Se('div'),'a',{get:function(){return 7}}).a})),Pe=P,Ee=A,Te=j,Ae=I,je=function(t){return Y(J(t))},Re=be,xe=Qt,ke=_e,Le=Object.getOwnPropertyDescriptor;_.f=Pe?Le:function(t,e){if(t=je(t),e=Re(e),ke)try{return Le(t,e)}catch(t){}if(xe(t,e))return Ae(!Ee(Te.f,t,e),t[e])};var Ce=c,Ie=S,Ne=/#|\.prototype\./,qe=function(t,e){var n=Be[Me(t)];return n==De||n!=Fe&&(Ie(e)?Ce(e):!!e)},Me=qe.normalize=function(t){return String(t).replace(Ne,'.').toLowerCase()},Be=qe.data={},Fe=qe.NATIVE='N',De=qe.POLYFILL='P',Ue=qe,ze=At,Ke=f,Qe=O(O.bind),He=function(t,e){return ze(t),void 0===e?t:Ke?Qe(t,e):function(){return t.apply(e,arguments)}},Ge={},Ye=P&&c((function(){return 42!=Object.defineProperty((function(){}),'prototype',{value:42,writable:!1}).prototype})),Je=s,We=V,Ve=Je.String,Xe=Je.TypeError,$e=function(t){if(We(t))return t;throw Xe(Ve(t)+' is not an object')},Ze=P,tn=_e,en=Ye,nn=$e,rn=be,on=s.TypeError,an=Object.defineProperty,un=Object.getOwnPropertyDescriptor;Ge.f=Ze?en?function(t,e,n){if(nn(t),e=rn(e),nn(n),'function'==typeof t&&'prototype'===e&&'value'in n&&'writable'in n&&!n.writable){var r=un(t,e);r&&r.writable&&(t[e]=n.value,n={configurable:'configurable'in n?n.configurable:r.configurable,enumerable:'enumerable'in n?n.enumerable:r.enumerable,writable:!1})}return an(t,e,n)}:an:function(t,e,n){if(nn(t),e=rn(e),nn(n),tn)try{return an(t,e,n)}catch(t){}if('get'in n||'set'in n)throw on('Accessors not supported');return'value'in n&&(t[e]=n.value),t};var sn=Ge,cn=I,fn=P?function(t,e,n){return sn.f(t,e,cn(1,n))}:function(t,e,n){return t[e]=n,t},pn=s,ln=v,hn=O,dn=S,vn=_.f,yn=Ue,bn=X,gn=He,mn=fn,wn=Qt,On=function(t){var e=function(n,r,o){if(this instanceof e){switch(arguments.length){case 0:return new t;case 1:return new t(n);case 2:return new t(n,r)}return new t(n,r,o)}return ln(t,this,arguments)};return e.prototype=t.prototype,e},Sn=function(t,e){var n,r,o,i,a,u,s,c,f=t.target,p=t.global,l=t.stat,h=t.proto,d=p?pn:l?pn[f]:(pn[f]||{}).prototype,v=p?bn:bn[f]||mn(bn,f,{})[f],y=v.prototype;for(o in e)n=!yn(p?o:f+(l?'.':'#')+o,t.forced)&&d&&wn(d,o),a=v[o],n&&(u=t.noTargetGet?(c=vn(d,o))&&c.value:d[o]),i=n&&u?u:e[o],n&&typeof a==typeof i||(s=t.bind&&n?gn(i,pn):t.wrap&&n?On(i):h&&dn(i)?hn(i):i,(t.sham||i&&i.sham||a&&a.sham)&&mn(s,'sham',!0),mn(v,o,s),h&&(wn(bn,r=f+'Prototype')||mn(bn,r,{}),mn(bn[r],o,i),t.real&&y&&!y[o]&&mn(y,o,i)))},_n=s.Promise,Pn=fn,En=function(t,e,n,r){r&&r.enumerable?t[e]=n:Pn(t,e,n)},Tn=s,An=(Tn.String,Tn.TypeError,O);Object.setPrototypeOf||'__proto__'in{}&&function(){var t,e=!1,n={};try{(t=An(Object.getOwnPropertyDescriptor(Object.prototype,'__proto__').set))(n,[]),e=n instanceof Array}catch(t){}}();var jn={};jn[ae('toStringTag')]='z';var Rn='[object z]'===String(jn),xn=s,kn=Rn,Ln=S,Cn=B,In=ae('toStringTag'),Nn=xn.Object,qn='Arguments'==Cn(function(){return arguments}()),Mn=kn?Cn:function(t){var e,n,r;return void 0===t?'Undefined':null===t?'Null':'string'==typeof(n=function(t,e){try{return t[e]}catch(t){}}(e=Nn(t),In))?n:qn?Cn(e):'Object'==(r=Cn(e))&&Ln(e.callee)?'Arguments':r},Bn=Mn,Fn=Rn?{}.toString:function(){return'[object '+Bn(this)+']'},Dn=Rn,Un=Ge.f,zn=fn,Kn=Qt,Qn=Fn,Hn=ae('toStringTag'),Gn=nt,Yn=Ge,Jn=P,Wn=ae('species'),Vn=rt,Xn=s.TypeError,$n=S,Zn=Bt,tr=O(Function.toString);$n(Zn.inspectSource)||(Zn.inspectSource=function(t){return tr(t)});var er=Zn.inspectSource,nr={},rr=nr,or=ae('iterator'),ir=Array.prototype,ar=Math.ceil,ur=Math.floor,sr=function(t){var e=+t;return e!=e||0===e?0:(e>0?ur:ar)(e)},cr=Math.min,fr=function(t){return t>0?cr(sr(t),9007199254740991):0},pr=Mn,lr=Rt,hr=nr,dr=ae('iterator'),vr=function(t){if(null!=t)return lr(t,dr)||lr(t,'@@iterator')||hr[pr(t)]},yr=A,br=At,gr=$e,mr=_t,wr=vr,Or=s.TypeError,Sr=A,_r=$e,Pr=Rt,Er=He,Tr=A,Ar=$e,jr=_t,Rr=function(t){return void 0!==t&&(rr.Array===t||ir[or]===t)},xr=function(t){return fr(t.length)},kr=rt,Lr=function(t,e){var n=arguments.length<2?wr(t):e;if(br(n))return gr(yr(n,t));throw Or(mr(t)+' is not iterable')},Cr=vr,Ir=function(t,e,n){var r,o;_r(t);try{if(!(r=Pr(t,'return'))){if('throw'===e)throw n;return n}r=Sr(r,t)}catch(t){o=!0,r=t}if('throw'===e)throw n;if(o)throw r;return _r(r),n},Nr=s.TypeError,qr=function(t,e){this.stopped=t,this.result=e},Mr=qr.prototype,Br=ae('iterator'),Fr=!1;try{var Dr=0,Ur={next:function(){return{done:!!Dr++}},return:function(){Fr=!0}};Ur[Br]=function(){return this},Array.from(Ur,(function(){throw 2}))}catch(t){}var zr=O,Kr=c,Qr=S,Hr=Mn,Gr=er,Yr=function(){},Jr=[],Wr=nt('Reflect','construct'),Vr=/^\s*(?:class|function)\b/,Xr=zr(Vr.exec),$r=!Vr.exec(Yr),Zr=function(t){if(!Qr(t))return!1;try{return Wr(Yr,Jr,t),!0}catch(t){return!1}},to=function(t){if(!Qr(t))return!1;switch(Hr(t)){case'AsyncFunction':case'GeneratorFunction':case'AsyncGeneratorFunction':return!1}try{return $r||!!Xr(Vr,Gr(t))}catch(t){return!0}};to.sham=!0;var eo,no,ro,oo,io=!Wr||Kr((function(){var t;return Zr(Zr.call)||!Zr(Object)||!Zr((function(){t=!0}))||t}))?to:Zr,ao=_t,uo=s.TypeError,so=$e,co=function(t){if(io(t))return t;throw uo(ao(t)+' is not a constructor')},fo=ae('species'),po=function(t,e){var n,r=so(t).constructor;return void 0===r||null==(n=so(r)[fo])?e:co(n)},lo=nt('document','documentElement'),ho=O([].slice),vo=s.TypeError,yo=/(?:ipad|iphone|ipod).*applewebkit/i.test(ot),bo='process'==B(s.process),go=s,mo=v,wo=He,Oo=S,So=Qt,_o=c,Po=lo,Eo=ho,To=Oe,Ao=function(t,e){if(t<e)throw vo('Not enough arguments');return t},jo=yo,Ro=bo,xo=go.setImmediate,ko=go.clearImmediate,Lo=go.process,Co=go.Dispatch,Io=go.Function,No=go.MessageChannel,qo=go.String,Mo=0,Bo={};try{eo=go.location}catch(t){}var Fo=function(t){if(So(Bo,t)){var e=Bo[t];delete Bo[t],e()}},Do=function(t){return function(){Fo(t)}},Uo=function(t){Fo(t.data)},zo=function(t){go.postMessage(qo(t),eo.protocol+'//'+eo.host)};xo&&ko||(xo=function(t){Ao(arguments.length,1);var e=Oo(t)?t:Io(t),n=Eo(arguments,1);return Bo[++Mo]=function(){mo(e,void 0,n)},no(Mo),Mo},ko=function(t){delete Bo[t]},Ro?no=function(t){Lo.nextTick(Do(t))}:Co&&Co.now?no=function(t){Co.now(Do(t))}:No&&!jo?(oo=(ro=new No).port2,ro.port1.onmessage=Uo,no=wo(oo.postMessage,oo)):go.addEventListener&&Oo(go.postMessage)&&!go.importScripts&&eo&&'file:'!==eo.protocol&&!_o(zo)?(no=zo,go.addEventListener('message',Uo,!1)):no='onreadystatechange'in To('script')?function(t){Po.appendChild(To('script')).onreadystatechange=function(){Po.removeChild(this),Fo(t)}}:function(t){setTimeout(Do(t),0)});var Ko,Qo,Ho,Go,Yo,Jo,Wo,Vo,Xo={set:xo,clear:ko},$o=s,Zo=/ipad|iphone|ipod/i.test(ot)&&void 0!==$o.Pebble,ti=/web0s(?!.*chrome)/i.test(ot),ei=s,ni=He,ri=_.f,oi=Xo.set,ii=yo,ai=Zo,ui=ti,si=bo,ci=ei.MutationObserver||ei.WebKitMutationObserver,fi=ei.document,pi=ei.process,li=ei.Promise,hi=ri(ei,'queueMicrotask'),di=hi&&hi.value;di||(Ko=function(){var t,e;for(si&&(t=pi.domain)&&t.exit();Qo;){e=Qo.fn,Qo=Qo.next;try{e()}catch(t){throw Qo?Go():Ho=void 0,t}}Ho=void 0,t&&t.enter()},ii||si||ui||!ci||!fi?!ai&&li&&li.resolve?((Wo=li.resolve(void 0)).constructor=li,Vo=ni(Wo.then,Wo),Go=function(){Vo(Ko)}):si?Go=function(){pi.nextTick(Ko)}:(oi=ni(oi,ei),Go=function(){oi(Ko)}):(Yo=!0,Jo=fi.createTextNode(''),new ci(Ko).observe(Jo,{characterData:!0}),Go=function(){Jo.data=Yo=!Yo}));var vi=di||function(t){var e={fn:t,next:void 0};Ho&&(Ho.next=e),Qo||(Qo=e,Go()),Ho=e},yi={},bi=At,gi=function(t){var e,n;this.promise=new t((function(t,r){if(void 0!==e||void 0!==n)throw TypeError('Bad Promise constructor');e=t,n=r})),this.resolve=bi(e),this.reject=bi(n)};yi.f=function(t){return new gi(t)};var mi=$e,wi=V,Oi=yi,Si=function(t,e){if(mi(t),wi(e)&&e.constructor===t)return e;var n=Oi.f(t);return(0,n.resolve)(e),n.promise},_i=s,Pi=function(){this.head=null,this.tail=null};Pi.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 Ei,Ti,Ai,ji=Pi,Ri=S,xi=er,ki=s.WeakMap,Li=Ri(ki)&&/native code/.test(xi(ki)),Ci=It.exports,Ii=Wt,Ni=Ci('keys'),qi=Li,Mi=s,Bi=O,Fi=V,Di=fn,Ui=Qt,zi=Bt,Ki=function(t){return Ni[t]||(Ni[t]=Ii(t))},Qi={},Hi=Mi.TypeError,Gi=Mi.WeakMap;if(qi||zi.state){var Yi=zi.state||(zi.state=new Gi),Ji=Bi(Yi.get),Wi=Bi(Yi.has),Vi=Bi(Yi.set);Ei=function(t,e){if(Wi(Yi,t))throw new Hi('Object already initialized');return e.facade=t,Vi(Yi,t,e),e},Ti=function(t){return Ji(Yi,t)||{}},Ai=function(t){return Wi(Yi,t)}}else{var Xi=Ki('state');Qi[Xi]=!0,Ei=function(t,e){if(Ui(t,Xi))throw new Hi('Object already initialized');return e.facade=t,Di(t,Xi,e),e},Ti=function(t){return Ui(t,Xi)?t[Xi]:{}},Ai=function(t){return Ui(t,Xi)}}var $i,Zi,ta,ea='object'==typeof window,na=Sn,ra=s,oa=nt,ia=A,aa=_n,ua=function(t,e,n){for(var r in e)n&&n.unsafe&&t[r]?t[r]=e[r]:En(t,r,e[r],n);return t},sa=function(t,e,n,r){if(t){var o=n?t:t.prototype;Kn(o,Hn)||Un(o,Hn,{configurable:!0,value:e}),r&&!Dn&&zn(o,'toString',Qn)}},ca=function(t){var e=Gn(t),n=Yn.f;Jn&&e&&!e[Wn]&&n(e,Wn,{configurable:!0,get:function(){return this}})},fa=At,pa=S,la=V,ha=function(t,e){if(Vn(e,t))return t;throw Xn('Incorrect invocation')},da=er,va=function(t,e,n){var r,o,i,a,u,s,c,f=n&&n.that,p=!(!n||!n.AS_ENTRIES),l=!(!n||!n.IS_ITERATOR),h=!(!n||!n.INTERRUPTED),d=Er(e,f),v=function(t){return r&&Ir(r,'normal',t),new qr(!0,t)},y=function(t){return p?(Ar(t),h?d(t[0],t[1],v):d(t[0],t[1])):h?d(t,v):d(t)};if(l)r=t;else{if(!(o=Cr(t)))throw Nr(jr(t)+' is not iterable');if(Rr(o)){for(i=0,a=xr(t);a>i;i++)if((u=y(t[i]))&&kr(Mr,u))return u;return new qr(!1)}r=Lr(t,o)}for(s=r.next;!(c=Tr(s,r)).done;){try{u=y(c.value)}catch(t){Ir(r,'throw',t)}if('object'==typeof u&&u&&kr(Mr,u))return u}return new qr(!1)},ya=function(t,e){if(!e&&!Fr)return!1;var n=!1;try{var r={};r[Br]=function(){return{next:function(){return{done:n=!0}}}},t(r)}catch(t){}return n},ba=po,ga=Xo.set,ma=vi,wa=Si,Oa=function(t,e){var n=_i.console;n&&n.error&&(1==arguments.length?n.error(t):n.error(t,e))},Sa=yi,_a=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}},Pa=ji,Ea={set:Ei,get:Ti,has:Ai,enforce:function(t){return Ai(t)?Ti(t):Ei(t,{})},getterFor:function(t){return function(e){var n;if(!Fi(e)||(n=Ti(e)).type!==t)throw Hi('Incompatible receiver, '+t+' required');return n}}},Ta=Ue,Aa=ea,ja=bo,Ra=pt,xa=ae('species'),ka='Promise',La=Ea.getterFor(ka),Ca=Ea.set,Ia=Ea.getterFor(ka),Na=aa&&aa.prototype,qa=aa,Ma=Na,Ba=ra.TypeError,Fa=ra.document,Da=ra.process,Ua=Sa.f,za=Ua,Ka=!!(Fa&&Fa.createEvent&&ra.dispatchEvent),Qa=pa(ra.PromiseRejectionEvent),Ha=Ta(ka,(function(){var t=da(qa),e=t!==String(qa);if(!e&&66===Ra)return!0;if(!Ma.finally)return!0;if(Ra>=51&&/native code/.test(t))return!1;var n=new qa((function(t){t(1)})),r=function(t){t((function(){}),(function(){}))};return(n.constructor={})[xa]=r,!(n.then((function(){}))instanceof r)||!e&&Aa&&!Qa})),Ga=Ha||!ya((function(t){qa.all(t).catch((function(){}))})),Ya=function(t){var e;return!(!la(t)||!pa(e=t.then))&&e},Ja=function(t,e){var n,r,o,i=e.value,a=1==e.state,u=a?t.ok:t.fail,s=t.resolve,c=t.reject,f=t.domain;try{u?(a||(2===e.rejection&&Za(e),e.rejection=1),!0===u?n=i:(f&&f.enter(),n=u(i),f&&(f.exit(),o=!0)),n===t.promise?c(Ba('Promise-chain cycle')):(r=Ya(n))?ia(r,n,s,c):s(n)):c(i)}catch(t){f&&!o&&f.exit(),c(t)}},Wa=function(t,e){t.notified||(t.notified=!0,ma((function(){for(var n,r=t.reactions;n=r.get();)Ja(n,t);t.notified=!1,e&&!t.rejection&&Xa(t)})))},Va=function(t,e,n){var r,o;Ka?((r=Fa.createEvent('Event')).promise=e,r.reason=n,r.initEvent(t,!1,!0),ra.dispatchEvent(r)):r={promise:e,reason:n},!Qa&&(o=ra['on'+t])?o(r):'unhandledrejection'===t&&Oa('Unhandled promise rejection',n)},Xa=function(t){ia(ga,ra,(function(){var e,n=t.facade,r=t.value;if($a(t)&&(e=_a((function(){ja?Da.emit('unhandledRejection',r,n):Va('unhandledrejection',n,r)})),t.rejection=ja||$a(t)?2:1,e.error))throw e.value}))},$a=function(t){return 1!==t.rejection&&!t.parent},Za=function(t){ia(ga,ra,(function(){var e=t.facade;ja?Da.emit('rejectionHandled',e):Va('rejectionhandled',e,t.value)}))},tu=function(t,e,n){return function(r){t(e,r,n)}},eu=function(t,e,n){t.done||(t.done=!0,n&&(t=n),t.value=e,t.state=2,Wa(t,!0))},nu=function(t,e,n){if(!t.done){t.done=!0,n&&(t=n);try{if(t.facade===e)throw Ba('Promise can\'t be resolved itself');var r=Ya(e);r?ma((function(){var n={done:!1};try{ia(r,e,tu(nu,n,t),tu(eu,n,t))}catch(e){eu(n,e,t)}})):(t.value=e,t.state=1,Wa(t,!1))}catch(e){eu({done:!1},e,t)}}};Ha&&(Ma=(qa=function(t){ha(this,Ma),fa(t),ia($i,this);var e=La(this);try{t(tu(nu,e),tu(eu,e))}catch(t){eu(e,t)}}).prototype,($i=function(t){Ca(this,{type:ka,done:!1,notified:!1,parent:!1,reactions:new Pa,rejection:!1,state:0,value:void 0})}).prototype=ua(Ma,{then:function(t,e){var n=Ia(this),r=Ua(ba(this,qa));return n.parent=!0,r.ok=!pa(t)||t,r.fail=pa(e)&&e,r.domain=ja?Da.domain:void 0,0==n.state?n.reactions.add(r):ma((function(){Ja(r,n)})),r.promise},catch:function(t){return this.then(void 0,t)}}),Zi=function(){var t=new $i,e=La(t);this.promise=t,this.resolve=tu(nu,e),this.reject=tu(eu,e)},Sa.f=Ua=function(t){return t===qa||t===ta?new Zi(t):za(t)}),na({global:!0,wrap:!0,forced:Ha},{Promise:qa}),sa(qa,ka,!1,!0),ca(ka),ta=oa(ka),na({target:ka,stat:!0,forced:Ha},{reject:function(t){var e=Ua(this);return ia(e.reject,void 0,t),e.promise}}),na({target:ka,stat:!0,forced:true},{resolve:function(t){return wa(this===ta?qa:this,t)}}),na({target:ka,stat:!0,forced:Ga},{all:function(t){var e=this,n=Ua(e),r=n.resolve,o=n.reject,i=_a((function(){var n=fa(e.resolve),i=[],a=0,u=1;va(t,(function(t){var s=a++,c=!1;u++,ia(n,e,t).then((function(t){c||(c=!0,i[s]=t,--u||r(i))}),o)})),--u||r(i)}));return i.error&&o(i.value),n.promise},race:function(t){var e=this,n=Ua(e),r=n.reject,o=_a((function(){var o=fa(e.resolve);va(t,(function(t){ia(o,e,t).then(n.resolve,r)}))}));return o.error&&r(o.value),n.promise}});var ru=_n,ou=nt,iu=S,au=po,uu=Si;Sn({target:'Promise',proto:!0,real:!0,forced:!!ru&&c((function(){ru.prototype.finally.call({then:function(){}},(function(){}))}))},{finally:function(t){var e=au(this,ou('Promise')),n=iu(t);return this.then(n?function(n){return uu(e,t()).then((function(){return n}))}:t,n?function(n){return uu(e,t()).then((function(){throw n}))}:t)}});var su=nt('Promise','finally'),cu=function(){try{var t=Date.now().toString(),e=window.localStorage;e.setItem(t,t);var n=e.getItem(t)===t;return e.removeItem(t),n?e:null}catch(t){return null}}();var fu,pu,lu,hu,du,vu,yu,bu,gu=function(t){return function(t){var e=cu?cu.getItem('_one-stat_'+t):null;if(null===e)return null;try{return JSON.parse(e)}catch(t){return null}}(t)||null},mu=function(t,e){!function(t,e){try{cu&&cu.setItem('_one-stat_'+t,JSON.stringify(e))}catch(t){}}(t,e)};exports.ApiEnv=void 0,(fu=exports.ApiEnv||(exports.ApiEnv={})).PROD='prod',fu.VK_ALIAS='vk_alias',fu.VIDEOTEST='videotest',fu.TEST='test',exports.Quality=void 0,(pu=exports.Quality||(exports.Quality={})).Q144P='144',pu.Q240P='240',pu.Q360P='360',pu.Q480P='480',pu.Q720P='720',pu.Q1080P='1080',pu.Q1440P='1440',pu.Q2160P='2160',pu.Q4320P='4320',pu.UNKNOWN='unknown',exports.ScreenDestination=void 0,(lu=exports.ScreenDestination||(exports.ScreenDestination={})).CHROMECAST='chromecast',lu.APPLE_TV='appletv',lu.PIP='pip',lu.HEADPHONES='externalHeadphones',lu.SCREEN='',exports.ContentType=void 0,(hu=exports.ContentType||(exports.ContentType={})).MP4='mp4',hu.DASH='dash',hu.HLS='hls',hu.WEBM='webm',function(t){t.AUTO='auto',t.MANUAL=''}(du||(du={})),exports.ConnectionType=void 0,(vu=exports.ConnectionType||(exports.ConnectionType={})).HTTP1='http1',vu.HTTP2='http2',vu.HTTP3='http3',function(t){t[t.YES=1]='YES',t[t.NO=0]='NO'}(yu||(yu={}));var wu,Ou=((bu={})[exports.ApiEnv.PROD]='https://api.ok.ru',bu[exports.ApiEnv.VK_ALIAS]='https://api.mycdn.me',bu[exports.ApiEnv.VIDEOTEST]='https://videotestapi.ok.ru/api',bu[exports.ApiEnv.TEST]='https://apitest.ok.ru',bu);!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'}(wu||(wu={}));var Su=function(){function t(t){this.params=t;var e=gu('uuid');e?this.uuid=String(e):(this.uuid=function(){var t,e,n='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''),r=new Array(36),o=0;for(e=0;e<36;e++)8===e||13===e||18===e||23===e?r[e]='-':14===e?r[e]='4':(o<=2&&(o=33554432+16777216*Math.random()|0),t=15&o,o>>=4,r[e]=n[19===e?3&t|8:t]);return r.join('')}(),mu('uuid',this.uuid))}return t.prototype.authorize=function(t){return o(this,void 0,void 0,(function(){var e,n;return i(this,(function(r){switch(r.label){case 0:return e=this,null==t?[3,1]:(n=t,[3,3]);case 1:return[4,this.refreshAuthToken()];case 2:n=r.sent(),r.label=3;case 3:return e.authToken=n,[2,this._authorize()]}}))}))},t.prototype.logBeacon=function(t){var e='log.externalLog',n=this.createLogParams(t),r=this.sessionKey;void 0!==r&&this.params.apiTransport.sendBeacon(e,n,r)||this.params.apiTransport.sendRequest(e,n,r)},t.prototype.logRequest=function(t){var e;return o(this,void 0,void 0,(function(){var n,r,o,a,u,s,c;return i(this,(function(i){switch(i.label){case 0:return n='log.externalLog',r=this.createLogParams(t),null===(e=this.sessionKey)||void 0===e?[3,1]:(a=e,[3,3]);case 1:return[4,this._authorize()];case 2:a=i.sent(),i.label=3;case 3:o=a,i.label=4;case 4:return i.trys.push([4,6,,14]),[4,this.params.apiTransport.sendRequest(n,r,o)];case 5:return[2,i.sent()];case 6:switch(u=i.sent(),null==u?void 0:u.error_code){case wu.PARAM_SESSION_EXPIRED:case wu.PARAM_SESSION_KEY:case wu.PARAM_SIGNATURE:return[3,7];case wu.AUTH_LOGIN:return[3,9]}return[3,12];case 7:return[4,this._authorize()];case 8:return c=i.sent(),[2,this.params.apiTransport.sendRequest(n,r,c)];case 9:return s=this,[4,this.refreshAuthToken()];case 10:return s.authToken=i.sent(),[4,this._authorizeRequest()];case 11:return c=i.sent(),[2,this.params.apiTransport.sendRequest(n,r,c)];case 12:throw u;case 13:return[3,14];case 14:return[2]}}))}))},t.prototype.refreshAuthToken=function(){return o(this,void 0,void 0,(function(){var t=this;return i(this,(function(e){return this.params.refreshAuthToken?(this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=su(this.params.refreshAuthToken(),(function(){t.refreshAuthTokenPromise=void 0}))),[2,this.refreshAuthTokenPromise]):[2,void 0]}))}))},t.prototype.createLogParams=function(t){return{collector:'ok.mobile.apps.video',data:JSON.stringify({application:''.concat('@vkontakte/videoplayer-statistics',':').concat('1.0.11'),platform:'WEB',items:t.map((function(t){return r(r({},t),{time:0,type:1})}))})}},t.prototype._authorize=function(){return o(this,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,6]),[4,this._authorizeRequest()];case 1:return[2,n.sent()];case 2:switch(t=n.sent(),null==t?void 0:t.error_code){case wu.AUTH_LOGIN:return[3,3]}return[3,5];case 3:return e=this,[4,this.refreshAuthToken()];case 4:return e.authToken=n.sent(),[2,this._authorizeRequest()];case 5:throw t;case 6:return[2]}}))}))},t.prototype._authorizeRequest=function(){return o(this,void 0,void 0,(function(){var t,e,n=this;return i(this,(function(r){return this.authorizePromise||(this.sessionKey=void 0,t='auth.anonymLogin',e={session_data:{version:2,device_id:this.uuid,client_version:'1.0.11'.split('-')[0],client_type:'SDK_JS'}},void 0!==this.authToken&&(e.session_data.auth_token=this.authToken,e.session_data.version=3),this.authorizePromise=su(this.params.apiTransport.sendRequest(t,e).then((function(r){if(!r)throw new Error('Empty response. Method: '.concat(t,', params: ').concat(JSON.stringify(e)));if(!r.session_key)throw new Error('Empty \'session_key\' in response. Method: '.concat(t,', params: ').concat(JSON.stringify(e),', response: ').concat(JSON.stringify(r)));return n.sessionKey=r.session_key,n.sessionKey})).catch((function(t){throw n.sessionKey=void 0,t})),(function(){n.authorizePromise=void 0}))),[2,this.authorizePromise]}))}))},t}(),_u={};function Pu(t,e){if(!(t instanceof e))throw new TypeError('Cannot call a class as a function')}function Eu(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,'value'in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function Tu(t,e,n){return e&&Eu(t.prototype,e),n&&Eu(t,n),t}function Au(t){return(Au=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function ju(t,e){return(ju=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Ru(t){if(void 0===t)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return t}function xu(t,e){return!e||'object'!=typeof e&&'function'!=typeof e?Ru(t):e}function ku(t){var e=function(){if('undefined'==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if('function'==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=Au(t);if(e){var o=Au(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return xu(this,n)}}function Lu(t,e,n){return(Lu='undefined'!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var r=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Au(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(n):o.value}})(t,e,n||t)}Object.defineProperty(_u,'__esModule',{value:!0});var Cu=function(){function t(){Pu(this,t),Object.defineProperty(this,'listeners',{value:{},writable:!0,configurable:!0})}return Tu(t,[{key:'addEventListener',value:function(t,e,n){t in this.listeners||(this.listeners[t]=[]),this.listeners[t].push({callback:e,options:n})}},{key:'removeEventListener',value:function(t,e){if(t in this.listeners)for(var n=this.listeners[t],r=0,o=n.length;r<o;r++)if(n[r].callback===e)return void n.splice(r,1)}},{key:'dispatchEvent',value:function(t){if(t.type in this.listeners){for(var e=this.listeners[t.type].slice(),n=0,r=e.length;n<r;n++){var o=e[n];try{o.callback.call(this,t)}catch(t){Promise.resolve().then((function(){throw t}))}o.options&&o.options.once&&this.removeEventListener(t.type,o.callback)}return!t.defaultPrevented}}}]),t}(),Iu=function(t){!function(t,e){if('function'!=typeof e&&null!==e)throw new TypeError('Super expression must either be null or a function');t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&ju(t,e)}(n,Cu);var e=ku(n);function n(){var t;return Pu(this,n),(t=e.call(this)).listeners||Cu.call(Ru(t)),Object.defineProperty(Ru(t),'aborted',{value:!1,writable:!0,configurable:!0}),Object.defineProperty(Ru(t),'onabort',{value:null,writable:!0,configurable:!0}),t}return Tu(n,[{key:'toString',value:function(){return'[object AbortSignal]'}},{key:'dispatchEvent',value:function(t){'abort'===t.type&&(this.aborted=!0,'function'==typeof this.onabort&&this.onabort.call(this,t)),Lu(Au(n.prototype),'dispatchEvent',this).call(this,t)}}]),n}(),Nu=function(){function t(){Pu(this,t),Object.defineProperty(this,'signal',{value:new Iu,writable:!0,configurable:!0})}return Tu(t,[{key:'abort',value:function(){var t;try{t=new Event('abort')}catch(e){'undefined'!=typeof document?document.createEvent?(t=document.createEvent('Event')).initEvent('abort',!1,!1):(t=document.createEventObject()).type='abort':t={type:'abort',bubbles:!1,cancelable:!1}}this.signal.dispatchEvent(t)}},{key:'toString',value:function(){return'[object AbortController]'}}]),t}();'undefined'!=typeof Symbol&&Symbol.toStringTag&&(Nu.prototype[Symbol.toStringTag]='AbortController',Iu.prototype[Symbol.toStringTag]='AbortSignal'),_u.AbortController=Nu,_u.AbortSignal=Iu;var qu=_u.abortableFetch=function(t){'function'==typeof t&&(t={fetch:t});var e=t,n=e.fetch,r=e.Request,o=void 0===r?n.Request:r,i=e.AbortController,a=e.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL,u=void 0!==a&&a;if(!function(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}({fetch:n,Request:o,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:u}))return{fetch:n,Request:s};var s=o;(s&&!s.prototype.hasOwnProperty('signal')||u)&&((s=function(t,e){var n;e&&e.signal&&(n=e.signal,delete e.signal);var r=new o(t,e);return n&&Object.defineProperty(r,'signal',{writable:!1,enumerable:!1,configurable:!0,value:n}),r}).prototype=o.prototype);var c=n;return{fetch:function(t,e){var n=s&&s.prototype.isPrototypeOf(t)?t.signal:e?e.signal:void 0;if(n){var r;try{r=new DOMException('Aborted','AbortError')}catch(t){(r=new Error('Aborted')).name='AbortError'}if(n.aborted)return Promise.reject(r);var o=new Promise((function(t,e){n.addEventListener('abort',(function(){return e(r)}),{once:!0})}));return e&&e.signal&&delete e.signal,Promise.race([o,c(t,e)])}return c(t,e)},Request:s}},Mu=function(){function t(t){this.params=t,this.apiKey=t.apiKey,this.apiBaseUrl=t.apiBaseUrl,'/'!==this.apiBaseUrl[this.apiBaseUrl.length-1]&&(this.apiBaseUrl+='/')}return t.prototype.sendBeacon=function(t,e,n){if(!window.Blob||!window.navigator.sendBeacon)return!1;var r=this._prepareQueryParams({method:t,queryParams:e,sessionKey:n}),o=new window.Blob([r.toString()],{type:'application/x-www-form-urlencoded'});return window.navigator.sendBeacon(''.concat(this.apiBaseUrl,'fb.do'),o)},t.prototype.sendRequest=function(t,e,n){return o(this,void 0,void 0,(function(){var r,o,a=this;return i(this,(function(i){return r=Date.now(),o=function(o){throw a.params.error$.next({id:'OneStat:ApiTransport:sendRequest',message:'Unhandled request error',thrown:o,data:{method:t,params:e,sessionKey:n,time:Date.now()-r}}),o},[2,qu(fetch).fetch(''.concat(this.apiBaseUrl,'fb.do'),{method:'post',headers:{'Content-type':'application/x-www-form-urlencoded'},body:this._prepareQueryParams({method:t,queryParams:e,sessionKey:n})}).then((function(t){return Number(t.headers.get('content-length'))>0?t.json().then((function(t){return Object.prototype.hasOwnProperty.call(t,'error_msg')?Promise.reject(t):t}),o):void 0}),o)]}))}))},t.prototype._prepareQueryParams=function(t){var 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((function(t){var n=function(t,e){var n='function'==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}(t,2),r=n[0],o=n[1];return e.append(r,'string'==typeof o?o:JSON.stringify(o))})),e},t}(),Bu=function(){function t(t){var e=this;this.requestQueue=[],this.isPaused=!1,this.debouncedFlush=n.default((function(){return e.flush()}),3e3,{maxWait:15e3}),this.api=t.api}return t.prototype.log=function(t){this.requestQueue.push(t),this.isPaused||this.debouncedFlush()},t.prototype.flush=function(t){void 0===t&&(t=!1),0!==this.requestQueue.length&&(t?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[],this.debouncedFlush.cancel())},t.prototype.pause=function(){this.isPaused=!0,this.debouncedFlush.cancel()},t.prototype.resume=function(){this.isPaused=!1,this.debouncedFlush()},t}(),Fu=function(){function e(e,n){var r=this;this.statContext=e;var o=new t.Subject;this.experimental={error$:o};var i=new Mu({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:Ou[n.apiEnv],error$:o});this.api=new Su({apiTransport:i,refreshAuthToken:n.refreshAuthToken}),this.logger=new Bu({api:this.api}),window.addEventListener('beforeunload',(function(){return r.logger.flush(!0)}))}return e.prototype.updateContext=function(t){this.statContext=r(r({},this.statContext),t)},e.prototype.authorize=function(t){return this.api.authorize(t)},e.prototype.pause=function(){this.logger.pause()},e.prototype.resume=function(){this.logger.resume()},e.prototype.logStarted=function(){this.log({operation:'play'})},e.prototype.logPlay=function(){this.log({operation:'play_toggle'})},e.prototype.logPause=function(t){this.log({operation:'pause',param:String(Math.round(t.position))})},e.prototype.logSeek=function(){this.log({operation:'seek'})},e.prototype.logFirstBytes=function(t){this.log({operation:'first_bytes',param:String(t.time)})},e.prototype.logFirstFrame=function(t){this.log({operation:'first_frame',param:String(t.time)})},e.prototype.logError=function(t){this.log({operation:'error',param:t.errorType})},e.prototype.logWatchCoverageRecord=function(t){this.log({operation:'watch_coverage_record',param:''.concat(t.start,'-').concat(t.end)}),this.logger.flush(!0)},e.prototype.logWatchCoverageLive=function(t){this.log({operation:'watch_coverage_live',param:''.concat(t.start,'-').concat(t.end)})},e.prototype.logEmptyBuffer=function(t){this.log({operation:'empty_buffer',param:String(t.duration)})},e.prototype.logAdSlotRequest=function(){this.log({operation:'adv',param:'slot_request'})},e.prototype.logAdStarted=function(t){this.log({operation:'adv',param:t})},e.prototype.logAdPaused=function(){this.log({operation:'adv',param:'pause'})},e.prototype.logAdResumed=function(){this.log({operation:'adv',param:'resume'})},e.prototype.logAdEnded=function(){this.log({operation:'adv',param:'ended'})},e.prototype.logAdSkipped=function(){this.log({operation:'adv',param:'skip'})},e.prototype.logAdClicked=function(){this.log({operation:'adv',param:'click'})},e.prototype.log=function(t){var e=this.crateLogItem(t);this.logger.log(e)},e.prototype.crateLogItem=function(t){var e=t.operation,n=t.param,r=Date.now(),o={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?yu.YES:!1===this.statContext.connectionReused?yu.NO:void 0,stat_type:!0===this.statContext.autoplay?du.AUTO:!1===this.statContext.autoplay?du.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId};return void 0!==n&&(o.param=n),{operation:e,timestamp:r,custom:o}},e}();exports.OneStat=Fu;
|
package/es5.esm.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @vkontakte/videoplayer-statistics v1.0.11
|
|
3
|
-
* Thu, 17 Mar 2022 09:49:34 GMT
|
|
4
|
-
* https://st.mycdn.me/static/playersdk/1-0-11/doc/
|
|
5
|
-
*/
|
|
6
|
-
import{Subject as t}from'@vkontakte/videoplayer-shared/es5.esm.js';import e from'lodash/debounce';var n=function(){return(n=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function r(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function u(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}c((r=r.apply(t,e||[])).next())}))}function o(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},'function'==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError('Generator is already executing.');for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var i='undefined'!=typeof globalThis?globalThis:'undefined'!=typeof window?window:'undefined'!=typeof global?global:'undefined'!=typeof self?self:{},a=function(t){return t&&t.Math==Math&&t},u=a('object'==typeof globalThis&&globalThis)||a('object'==typeof window&&window)||a('object'==typeof self&&self)||a('object'==typeof i&&i)||function(){return this}()||Function('return this')(),c=function(t){try{return!!t()}catch(t){return!0}},s=!c((function(){var t=function(){}.bind();return'function'!=typeof t||t.hasOwnProperty('prototype')})),f=s,l=Function.prototype,p=l.apply,h=l.call,d='object'==typeof Reflect&&Reflect.apply||(f?h.bind(p):function(){return h.apply(p,arguments)}),v=s,y=Function.prototype,g=y.bind,m=y.call,b=v&&g.bind(m,m),w=v?function(t){return t&&b(t)}:function(t){return t&&function(){return m.apply(t,arguments)}},O=function(t){return'function'==typeof t},P={},_=!c((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),S=s,E=Function.prototype.call,T=S?E.bind(E):function(){return E.apply(E,arguments)},A={},j={}.propertyIsEnumerable,R=Object.getOwnPropertyDescriptor,k=R&&!j.call({1:2},1);A.f=k?function(t){var e=R(this,t);return!!e&&e.enumerable}:j;var L,x,I=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},C=w,N=C({}.toString),q=C(''.slice),M=function(t){return q(N(t),8,-1)},B=w,F=c,D=M,U=u.Object,z=B(''.split),K=F((function(){return!U('z').propertyIsEnumerable(0)}))?function(t){return'String'==D(t)?z(t,''):U(t)}:U,Q=u.TypeError,H=function(t){if(null==t)throw Q('Can\'t call method on '+t);return t},G=K,Y=H,J=O,W=function(t){return'object'==typeof t?null!==t:J(t)},V={},X=V,$=u,Z=O,tt=function(t){return Z(t)?t:void 0},et=function(t,e){return arguments.length<2?tt(X[t])||tt($[t]):X[t]&&X[t][e]||$[t]&&$[t][e]},nt=w({}.isPrototypeOf),rt=et('navigator','userAgent')||'',ot=u,it=rt,at=ot.process,ut=ot.Deno,ct=at&&at.versions||ut&&ut.version,st=ct&&ct.v8;st&&(x=(L=st.split('.'))[0]>0&&L[0]<4?1:+(L[0]+L[1])),!x&&it&&(!(L=it.match(/Edge\/(\d+)/))||L[1]>=74)&&(L=it.match(/Chrome\/(\d+)/))&&(x=+L[1]);var ft=x,lt=ft,pt=c,ht=!!Object.getOwnPropertySymbols&&!pt((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&<&<<41})),dt=ht&&!Symbol.sham&&'symbol'==typeof Symbol.iterator,vt=et,yt=O,gt=nt,mt=dt,bt=u.Object,wt=mt?function(t){return'symbol'==typeof t}:function(t){var e=vt('Symbol');return yt(e)&>(e.prototype,bt(t))},Ot=u.String,Pt=function(t){try{return Ot(t)}catch(t){return'Object'}},_t=O,St=Pt,Et=u.TypeError,Tt=function(t){if(_t(t))return t;throw Et(St(t)+' is not a function')},At=Tt,jt=function(t,e){var n=t[e];return null==n?void 0:At(n)},Rt=T,kt=O,Lt=W,xt=u.TypeError,It={exports:{}},Ct=u,Nt=Object.defineProperty,qt=function(t,e){try{Nt(Ct,t,{value:e,configurable:!0,writable:!0})}catch(n){Ct[t]=e}return e},Mt=u['__core-js_shared__']||qt('__core-js_shared__',{}),Bt=Mt;(It.exports=function(t,e){return Bt[t]||(Bt[t]=void 0!==e?e:{})})('versions',[]).push({version:'3.21.1',mode:'pure',copyright:'© 2014-2022 Denis Pushkarev (zloirock.ru)',license:'https://github.com/zloirock/core-js/blob/v3.21.1/LICENSE',source:'https://github.com/zloirock/core-js'});var Ft=H,Dt=u.Object,Ut=function(t){return Dt(Ft(t))},zt=w({}.hasOwnProperty),Kt=Object.hasOwn||function(t,e){return zt(Ut(t),e)},Qt=w,Ht=0,Gt=Math.random(),Yt=Qt(1..toString),Jt=function(t){return'Symbol('+(void 0===t?'':t)+')_'+Yt(++Ht+Gt,36)},Wt=u,Vt=It.exports,Xt=Kt,$t=Jt,Zt=ht,te=dt,ee=Vt('wks'),ne=Wt.Symbol,re=ne&&ne.for,oe=te?ne:ne&&ne.withoutSetter||$t,ie=function(t){if(!Xt(ee,t)||!Zt&&'string'!=typeof ee[t]){var e='Symbol.'+t;Zt&&Xt(ne,t)?ee[t]=ne[t]:ee[t]=te&&re?re(e):oe(e)}return ee[t]},ae=T,ue=W,ce=wt,se=jt,fe=function(t,e){var n,r;if('string'===e&&kt(n=t.toString)&&!Lt(r=Rt(n,t)))return r;if(kt(n=t.valueOf)&&!Lt(r=Rt(n,t)))return r;if('string'!==e&&kt(n=t.toString)&&!Lt(r=Rt(n,t)))return r;throw xt('Can\'t convert object to primitive value')},le=ie,pe=u.TypeError,he=le('toPrimitive'),de=function(t,e){if(!ue(t)||ce(t))return t;var n,r=se(t,he);if(r){if(void 0===e&&(e='default'),n=ae(r,t,e),!ue(n)||ce(n))return n;throw pe('Can\'t convert object to primitive value')}return void 0===e&&(e='number'),fe(t,e)},ve=wt,ye=function(t){var e=de(t,'string');return ve(e)?e:e+''},ge=W,me=u.document,be=ge(me)&&ge(me.createElement),we=function(t){return be?me.createElement(t):{}},Oe=we,Pe=!_&&!c((function(){return 7!=Object.defineProperty(Oe('div'),'a',{get:function(){return 7}}).a})),_e=_,Se=T,Ee=A,Te=I,Ae=function(t){return G(Y(t))},je=ye,Re=Kt,ke=Pe,Le=Object.getOwnPropertyDescriptor;P.f=_e?Le:function(t,e){if(t=Ae(t),e=je(e),ke)try{return Le(t,e)}catch(t){}if(Re(t,e))return Te(!Se(Ee.f,t,e),t[e])};var xe=c,Ie=O,Ce=/#|\.prototype\./,Ne=function(t,e){var n=Me[qe(t)];return n==Fe||n!=Be&&(Ie(e)?xe(e):!!e)},qe=Ne.normalize=function(t){return String(t).replace(Ce,'.').toLowerCase()},Me=Ne.data={},Be=Ne.NATIVE='N',Fe=Ne.POLYFILL='P',De=Ne,Ue=Tt,ze=s,Ke=w(w.bind),Qe=function(t,e){return Ue(t),void 0===e?t:ze?Ke(t,e):function(){return t.apply(e,arguments)}},He={},Ge=_&&c((function(){return 42!=Object.defineProperty((function(){}),'prototype',{value:42,writable:!1}).prototype})),Ye=u,Je=W,We=Ye.String,Ve=Ye.TypeError,Xe=function(t){if(Je(t))return t;throw Ve(We(t)+' is not an object')},$e=_,Ze=Pe,tn=Ge,en=Xe,nn=ye,rn=u.TypeError,on=Object.defineProperty,an=Object.getOwnPropertyDescriptor;He.f=$e?tn?function(t,e,n){if(en(t),e=nn(e),en(n),'function'==typeof t&&'prototype'===e&&'value'in n&&'writable'in n&&!n.writable){var r=an(t,e);r&&r.writable&&(t[e]=n.value,n={configurable:'configurable'in n?n.configurable:r.configurable,enumerable:'enumerable'in n?n.enumerable:r.enumerable,writable:!1})}return on(t,e,n)}:on:function(t,e,n){if(en(t),e=nn(e),en(n),Ze)try{return on(t,e,n)}catch(t){}if('get'in n||'set'in n)throw rn('Accessors not supported');return'value'in n&&(t[e]=n.value),t};var un=He,cn=I,sn=_?function(t,e,n){return un.f(t,e,cn(1,n))}:function(t,e,n){return t[e]=n,t},fn=u,ln=d,pn=w,hn=O,dn=P.f,vn=De,yn=V,gn=Qe,mn=sn,bn=Kt,wn=function(t){var e=function(n,r,o){if(this instanceof e){switch(arguments.length){case 0:return new t;case 1:return new t(n);case 2:return new t(n,r)}return new t(n,r,o)}return ln(t,this,arguments)};return e.prototype=t.prototype,e},On=function(t,e){var n,r,o,i,a,u,c,s,f=t.target,l=t.global,p=t.stat,h=t.proto,d=l?fn:p?fn[f]:(fn[f]||{}).prototype,v=l?yn:yn[f]||mn(yn,f,{})[f],y=v.prototype;for(o in e)n=!vn(l?o:f+(p?'.':'#')+o,t.forced)&&d&&bn(d,o),a=v[o],n&&(u=t.noTargetGet?(s=dn(d,o))&&s.value:d[o]),i=n&&u?u:e[o],n&&typeof a==typeof i||(c=t.bind&&n?gn(i,fn):t.wrap&&n?wn(i):h&&hn(i)?pn(i):i,(t.sham||i&&i.sham||a&&a.sham)&&mn(c,'sham',!0),mn(v,o,c),h&&(bn(yn,r=f+'Prototype')||mn(yn,r,{}),mn(yn[r],o,i),t.real&&y&&!y[o]&&mn(y,o,i)))},Pn=u.Promise,_n=sn,Sn=function(t,e,n,r){r&&r.enumerable?t[e]=n:_n(t,e,n)},En=u,Tn=(En.String,En.TypeError,w);Object.setPrototypeOf||'__proto__'in{}&&function(){var t,e=!1,n={};try{(t=Tn(Object.getOwnPropertyDescriptor(Object.prototype,'__proto__').set))(n,[]),e=n instanceof Array}catch(t){}}();var An={};An[ie('toStringTag')]='z';var jn='[object z]'===String(An),Rn=u,kn=jn,Ln=O,xn=M,In=ie('toStringTag'),Cn=Rn.Object,Nn='Arguments'==xn(function(){return arguments}()),qn=kn?xn:function(t){var e,n,r;return void 0===t?'Undefined':null===t?'Null':'string'==typeof(n=function(t,e){try{return t[e]}catch(t){}}(e=Cn(t),In))?n:Nn?xn(e):'Object'==(r=xn(e))&&Ln(e.callee)?'Arguments':r},Mn=qn,Bn=jn?{}.toString:function(){return'[object '+Mn(this)+']'},Fn=jn,Dn=He.f,Un=sn,zn=Kt,Kn=Bn,Qn=ie('toStringTag'),Hn=et,Gn=He,Yn=_,Jn=ie('species'),Wn=nt,Vn=u.TypeError,Xn=O,$n=Mt,Zn=w(Function.toString);Xn($n.inspectSource)||($n.inspectSource=function(t){return Zn(t)});var tr=$n.inspectSource,er={},nr=er,rr=ie('iterator'),or=Array.prototype,ir=Math.ceil,ar=Math.floor,ur=function(t){var e=+t;return e!=e||0===e?0:(e>0?ar:ir)(e)},cr=Math.min,sr=function(t){return t>0?cr(ur(t),9007199254740991):0},fr=qn,lr=jt,pr=er,hr=ie('iterator'),dr=function(t){if(null!=t)return lr(t,hr)||lr(t,'@@iterator')||pr[fr(t)]},vr=T,yr=Tt,gr=Xe,mr=Pt,br=dr,wr=u.TypeError,Or=T,Pr=Xe,_r=jt,Sr=Qe,Er=T,Tr=Xe,Ar=Pt,jr=function(t){return void 0!==t&&(nr.Array===t||or[rr]===t)},Rr=function(t){return sr(t.length)},kr=nt,Lr=function(t,e){var n=arguments.length<2?br(t):e;if(yr(n))return gr(vr(n,t));throw wr(mr(t)+' is not iterable')},xr=dr,Ir=function(t,e,n){var r,o;Pr(t);try{if(!(r=_r(t,'return'))){if('throw'===e)throw n;return n}r=Or(r,t)}catch(t){o=!0,r=t}if('throw'===e)throw n;if(o)throw r;return Pr(r),n},Cr=u.TypeError,Nr=function(t,e){this.stopped=t,this.result=e},qr=Nr.prototype,Mr=ie('iterator'),Br=!1;try{var Fr=0,Dr={next:function(){return{done:!!Fr++}},return:function(){Br=!0}};Dr[Mr]=function(){return this},Array.from(Dr,(function(){throw 2}))}catch(t){}var Ur=w,zr=c,Kr=O,Qr=qn,Hr=tr,Gr=function(){},Yr=[],Jr=et('Reflect','construct'),Wr=/^\s*(?:class|function)\b/,Vr=Ur(Wr.exec),Xr=!Wr.exec(Gr),$r=function(t){if(!Kr(t))return!1;try{return Jr(Gr,Yr,t),!0}catch(t){return!1}},Zr=function(t){if(!Kr(t))return!1;switch(Qr(t)){case'AsyncFunction':case'GeneratorFunction':case'AsyncGeneratorFunction':return!1}try{return Xr||!!Vr(Wr,Hr(t))}catch(t){return!0}};Zr.sham=!0;var to,eo,no,ro,oo=!Jr||zr((function(){var t;return $r($r.call)||!$r(Object)||!$r((function(){t=!0}))||t}))?Zr:$r,io=Pt,ao=u.TypeError,uo=Xe,co=function(t){if(oo(t))return t;throw ao(io(t)+' is not a constructor')},so=ie('species'),fo=function(t,e){var n,r=uo(t).constructor;return void 0===r||null==(n=uo(r)[so])?e:co(n)},lo=et('document','documentElement'),po=w([].slice),ho=u.TypeError,vo=/(?:ipad|iphone|ipod).*applewebkit/i.test(rt),yo='process'==M(u.process),go=u,mo=d,bo=Qe,wo=O,Oo=Kt,Po=c,_o=lo,So=po,Eo=we,To=function(t,e){if(t<e)throw ho('Not enough arguments');return t},Ao=vo,jo=yo,Ro=go.setImmediate,ko=go.clearImmediate,Lo=go.process,xo=go.Dispatch,Io=go.Function,Co=go.MessageChannel,No=go.String,qo=0,Mo={};try{to=go.location}catch(t){}var Bo=function(t){if(Oo(Mo,t)){var e=Mo[t];delete Mo[t],e()}},Fo=function(t){return function(){Bo(t)}},Do=function(t){Bo(t.data)},Uo=function(t){go.postMessage(No(t),to.protocol+'//'+to.host)};Ro&&ko||(Ro=function(t){To(arguments.length,1);var e=wo(t)?t:Io(t),n=So(arguments,1);return Mo[++qo]=function(){mo(e,void 0,n)},eo(qo),qo},ko=function(t){delete Mo[t]},jo?eo=function(t){Lo.nextTick(Fo(t))}:xo&&xo.now?eo=function(t){xo.now(Fo(t))}:Co&&!Ao?(ro=(no=new Co).port2,no.port1.onmessage=Do,eo=bo(ro.postMessage,ro)):go.addEventListener&&wo(go.postMessage)&&!go.importScripts&&to&&'file:'!==to.protocol&&!Po(Uo)?(eo=Uo,go.addEventListener('message',Do,!1)):eo='onreadystatechange'in Eo('script')?function(t){_o.appendChild(Eo('script')).onreadystatechange=function(){_o.removeChild(this),Bo(t)}}:function(t){setTimeout(Fo(t),0)});var zo,Ko,Qo,Ho,Go,Yo,Jo,Wo,Vo={set:Ro,clear:ko},Xo=u,$o=/ipad|iphone|ipod/i.test(rt)&&void 0!==Xo.Pebble,Zo=/web0s(?!.*chrome)/i.test(rt),ti=u,ei=Qe,ni=P.f,ri=Vo.set,oi=vo,ii=$o,ai=Zo,ui=yo,ci=ti.MutationObserver||ti.WebKitMutationObserver,si=ti.document,fi=ti.process,li=ti.Promise,pi=ni(ti,'queueMicrotask'),hi=pi&&pi.value;hi||(zo=function(){var t,e;for(ui&&(t=fi.domain)&&t.exit();Ko;){e=Ko.fn,Ko=Ko.next;try{e()}catch(t){throw Ko?Ho():Qo=void 0,t}}Qo=void 0,t&&t.enter()},oi||ui||ai||!ci||!si?!ii&&li&&li.resolve?((Jo=li.resolve(void 0)).constructor=li,Wo=ei(Jo.then,Jo),Ho=function(){Wo(zo)}):ui?Ho=function(){fi.nextTick(zo)}:(ri=ei(ri,ti),Ho=function(){ri(zo)}):(Go=!0,Yo=si.createTextNode(''),new ci(zo).observe(Yo,{characterData:!0}),Ho=function(){Yo.data=Go=!Go}));var di=hi||function(t){var e={fn:t,next:void 0};Qo&&(Qo.next=e),Ko||(Ko=e,Ho()),Qo=e},vi={},yi=Tt,gi=function(t){var e,n;this.promise=new t((function(t,r){if(void 0!==e||void 0!==n)throw TypeError('Bad Promise constructor');e=t,n=r})),this.resolve=yi(e),this.reject=yi(n)};vi.f=function(t){return new gi(t)};var mi=Xe,bi=W,wi=vi,Oi=function(t,e){if(mi(t),bi(e)&&e.constructor===t)return e;var n=wi.f(t);return(0,n.resolve)(e),n.promise},Pi=u,_i=function(){this.head=null,this.tail=null};_i.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 Si,Ei,Ti,Ai=_i,ji=O,Ri=tr,ki=u.WeakMap,Li=ji(ki)&&/native code/.test(Ri(ki)),xi=It.exports,Ii=Jt,Ci=xi('keys'),Ni=Li,qi=u,Mi=w,Bi=W,Fi=sn,Di=Kt,Ui=Mt,zi=function(t){return Ci[t]||(Ci[t]=Ii(t))},Ki={},Qi=qi.TypeError,Hi=qi.WeakMap;if(Ni||Ui.state){var Gi=Ui.state||(Ui.state=new Hi),Yi=Mi(Gi.get),Ji=Mi(Gi.has),Wi=Mi(Gi.set);Si=function(t,e){if(Ji(Gi,t))throw new Qi('Object already initialized');return e.facade=t,Wi(Gi,t,e),e},Ei=function(t){return Yi(Gi,t)||{}},Ti=function(t){return Ji(Gi,t)}}else{var Vi=zi('state');Ki[Vi]=!0,Si=function(t,e){if(Di(t,Vi))throw new Qi('Object already initialized');return e.facade=t,Fi(t,Vi,e),e},Ei=function(t){return Di(t,Vi)?t[Vi]:{}},Ti=function(t){return Di(t,Vi)}}var Xi,$i,Zi,ta='object'==typeof window,ea=On,na=u,ra=et,oa=T,ia=Pn,aa=function(t,e,n){for(var r in e)n&&n.unsafe&&t[r]?t[r]=e[r]:Sn(t,r,e[r],n);return t},ua=function(t,e,n,r){if(t){var o=n?t:t.prototype;zn(o,Qn)||Dn(o,Qn,{configurable:!0,value:e}),r&&!Fn&&Un(o,'toString',Kn)}},ca=function(t){var e=Hn(t),n=Gn.f;Yn&&e&&!e[Jn]&&n(e,Jn,{configurable:!0,get:function(){return this}})},sa=Tt,fa=O,la=W,pa=function(t,e){if(Wn(e,t))return t;throw Vn('Incorrect invocation')},ha=tr,da=function(t,e,n){var r,o,i,a,u,c,s,f=n&&n.that,l=!(!n||!n.AS_ENTRIES),p=!(!n||!n.IS_ITERATOR),h=!(!n||!n.INTERRUPTED),d=Sr(e,f),v=function(t){return r&&Ir(r,'normal',t),new Nr(!0,t)},y=function(t){return l?(Tr(t),h?d(t[0],t[1],v):d(t[0],t[1])):h?d(t,v):d(t)};if(p)r=t;else{if(!(o=xr(t)))throw Cr(Ar(t)+' is not iterable');if(jr(o)){for(i=0,a=Rr(t);a>i;i++)if((u=y(t[i]))&&kr(qr,u))return u;return new Nr(!1)}r=Lr(t,o)}for(c=r.next;!(s=Er(c,r)).done;){try{u=y(s.value)}catch(t){Ir(r,'throw',t)}if('object'==typeof u&&u&&kr(qr,u))return u}return new Nr(!1)},va=function(t,e){if(!e&&!Br)return!1;var n=!1;try{var r={};r[Mr]=function(){return{next:function(){return{done:n=!0}}}},t(r)}catch(t){}return n},ya=fo,ga=Vo.set,ma=di,ba=Oi,wa=function(t,e){var n=Pi.console;n&&n.error&&(1==arguments.length?n.error(t):n.error(t,e))},Oa=vi,Pa=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}},_a=Ai,Sa={set:Si,get:Ei,has:Ti,enforce:function(t){return Ti(t)?Ei(t):Si(t,{})},getterFor:function(t){return function(e){var n;if(!Bi(e)||(n=Ei(e)).type!==t)throw Qi('Incompatible receiver, '+t+' required');return n}}},Ea=De,Ta=ta,Aa=yo,ja=ft,Ra=ie('species'),ka='Promise',La=Sa.getterFor(ka),xa=Sa.set,Ia=Sa.getterFor(ka),Ca=ia&&ia.prototype,Na=ia,qa=Ca,Ma=na.TypeError,Ba=na.document,Fa=na.process,Da=Oa.f,Ua=Da,za=!!(Ba&&Ba.createEvent&&na.dispatchEvent),Ka=fa(na.PromiseRejectionEvent),Qa=Ea(ka,(function(){var t=ha(Na),e=t!==String(Na);if(!e&&66===ja)return!0;if(!qa.finally)return!0;if(ja>=51&&/native code/.test(t))return!1;var n=new Na((function(t){t(1)})),r=function(t){t((function(){}),(function(){}))};return(n.constructor={})[Ra]=r,!(n.then((function(){}))instanceof r)||!e&&Ta&&!Ka})),Ha=Qa||!va((function(t){Na.all(t).catch((function(){}))})),Ga=function(t){var e;return!(!la(t)||!fa(e=t.then))&&e},Ya=function(t,e){var n,r,o,i=e.value,a=1==e.state,u=a?t.ok:t.fail,c=t.resolve,s=t.reject,f=t.domain;try{u?(a||(2===e.rejection&&$a(e),e.rejection=1),!0===u?n=i:(f&&f.enter(),n=u(i),f&&(f.exit(),o=!0)),n===t.promise?s(Ma('Promise-chain cycle')):(r=Ga(n))?oa(r,n,c,s):c(n)):s(i)}catch(t){f&&!o&&f.exit(),s(t)}},Ja=function(t,e){t.notified||(t.notified=!0,ma((function(){for(var n,r=t.reactions;n=r.get();)Ya(n,t);t.notified=!1,e&&!t.rejection&&Va(t)})))},Wa=function(t,e,n){var r,o;za?((r=Ba.createEvent('Event')).promise=e,r.reason=n,r.initEvent(t,!1,!0),na.dispatchEvent(r)):r={promise:e,reason:n},!Ka&&(o=na['on'+t])?o(r):'unhandledrejection'===t&&wa('Unhandled promise rejection',n)},Va=function(t){oa(ga,na,(function(){var e,n=t.facade,r=t.value;if(Xa(t)&&(e=Pa((function(){Aa?Fa.emit('unhandledRejection',r,n):Wa('unhandledrejection',n,r)})),t.rejection=Aa||Xa(t)?2:1,e.error))throw e.value}))},Xa=function(t){return 1!==t.rejection&&!t.parent},$a=function(t){oa(ga,na,(function(){var e=t.facade;Aa?Fa.emit('rejectionHandled',e):Wa('rejectionhandled',e,t.value)}))},Za=function(t,e,n){return function(r){t(e,r,n)}},tu=function(t,e,n){t.done||(t.done=!0,n&&(t=n),t.value=e,t.state=2,Ja(t,!0))},eu=function(t,e,n){if(!t.done){t.done=!0,n&&(t=n);try{if(t.facade===e)throw Ma('Promise can\'t be resolved itself');var r=Ga(e);r?ma((function(){var n={done:!1};try{oa(r,e,Za(eu,n,t),Za(tu,n,t))}catch(e){tu(n,e,t)}})):(t.value=e,t.state=1,Ja(t,!1))}catch(e){tu({done:!1},e,t)}}};Qa&&(qa=(Na=function(t){pa(this,qa),sa(t),oa(Xi,this);var e=La(this);try{t(Za(eu,e),Za(tu,e))}catch(t){tu(e,t)}}).prototype,(Xi=function(t){xa(this,{type:ka,done:!1,notified:!1,parent:!1,reactions:new _a,rejection:!1,state:0,value:void 0})}).prototype=aa(qa,{then:function(t,e){var n=Ia(this),r=Da(ya(this,Na));return n.parent=!0,r.ok=!fa(t)||t,r.fail=fa(e)&&e,r.domain=Aa?Fa.domain:void 0,0==n.state?n.reactions.add(r):ma((function(){Ya(r,n)})),r.promise},catch:function(t){return this.then(void 0,t)}}),$i=function(){var t=new Xi,e=La(t);this.promise=t,this.resolve=Za(eu,e),this.reject=Za(tu,e)},Oa.f=Da=function(t){return t===Na||t===Zi?new $i(t):Ua(t)}),ea({global:!0,wrap:!0,forced:Qa},{Promise:Na}),ua(Na,ka,!1,!0),ca(ka),Zi=ra(ka),ea({target:ka,stat:!0,forced:Qa},{reject:function(t){var e=Da(this);return oa(e.reject,void 0,t),e.promise}}),ea({target:ka,stat:!0,forced:true},{resolve:function(t){return ba(this===Zi?Na:this,t)}}),ea({target:ka,stat:!0,forced:Ha},{all:function(t){var e=this,n=Da(e),r=n.resolve,o=n.reject,i=Pa((function(){var n=sa(e.resolve),i=[],a=0,u=1;da(t,(function(t){var c=a++,s=!1;u++,oa(n,e,t).then((function(t){s||(s=!0,i[c]=t,--u||r(i))}),o)})),--u||r(i)}));return i.error&&o(i.value),n.promise},race:function(t){var e=this,n=Da(e),r=n.reject,o=Pa((function(){var o=sa(e.resolve);da(t,(function(t){oa(o,e,t).then(n.resolve,r)}))}));return o.error&&r(o.value),n.promise}});var nu=Pn,ru=et,ou=O,iu=fo,au=Oi;On({target:'Promise',proto:!0,real:!0,forced:!!nu&&c((function(){nu.prototype.finally.call({then:function(){}},(function(){}))}))},{finally:function(t){var e=iu(this,ru('Promise')),n=ou(t);return this.then(n?function(n){return au(e,t()).then((function(){return n}))}:t,n?function(n){return au(e,t()).then((function(){throw n}))}:t)}});var uu=et('Promise','finally'),cu=function(){try{var t=Date.now().toString(),e=window.localStorage;e.setItem(t,t);var n=e.getItem(t)===t;return e.removeItem(t),n?e:null}catch(t){return null}}();var su,fu,lu,pu,hu,du,vu,yu,gu=function(t){return function(t){var e=cu?cu.getItem('_one-stat_'+t):null;if(null===e)return null;try{return JSON.parse(e)}catch(t){return null}}(t)||null},mu=function(t,e){!function(t,e){try{cu&&cu.setItem('_one-stat_'+t,JSON.stringify(e))}catch(t){}}(t,e)};!function(t){t.PROD='prod',t.VK_ALIAS='vk_alias',t.VIDEOTEST='videotest',t.TEST='test'}(su||(su={})),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'}(fu||(fu={})),function(t){t.CHROMECAST='chromecast',t.APPLE_TV='appletv',t.PIP='pip',t.HEADPHONES='externalHeadphones',t.SCREEN=''}(lu||(lu={})),function(t){t.MP4='mp4',t.DASH='dash',t.HLS='hls',t.WEBM='webm'}(pu||(pu={})),function(t){t.AUTO='auto',t.MANUAL=''}(hu||(hu={})),function(t){t.HTTP1='http1',t.HTTP2='http2',t.HTTP3='http3'}(du||(du={})),function(t){t[t.YES=1]='YES',t[t.NO=0]='NO'}(vu||(vu={}));var bu,wu=((yu={})[su.PROD]='https://api.ok.ru',yu[su.VK_ALIAS]='https://api.mycdn.me',yu[su.VIDEOTEST]='https://videotestapi.ok.ru/api',yu[su.TEST]='https://apitest.ok.ru',yu);!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'}(bu||(bu={}));var Ou=function(){function t(t){this.params=t;var e=gu('uuid');e?this.uuid=String(e):(this.uuid=function(){var t,e,n='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''),r=new Array(36),o=0;for(e=0;e<36;e++)8===e||13===e||18===e||23===e?r[e]='-':14===e?r[e]='4':(o<=2&&(o=33554432+16777216*Math.random()|0),t=15&o,o>>=4,r[e]=n[19===e?3&t|8:t]);return r.join('')}(),mu('uuid',this.uuid))}return t.prototype.authorize=function(t){return r(this,void 0,void 0,(function(){var e,n;return o(this,(function(r){switch(r.label){case 0:return e=this,null==t?[3,1]:(n=t,[3,3]);case 1:return[4,this.refreshAuthToken()];case 2:n=r.sent(),r.label=3;case 3:return e.authToken=n,[2,this._authorize()]}}))}))},t.prototype.logBeacon=function(t){var e='log.externalLog',n=this.createLogParams(t),r=this.sessionKey;void 0!==r&&this.params.apiTransport.sendBeacon(e,n,r)||this.params.apiTransport.sendRequest(e,n,r)},t.prototype.logRequest=function(t){var e;return r(this,void 0,void 0,(function(){var n,r,i,a,u,c,s;return o(this,(function(o){switch(o.label){case 0:return n='log.externalLog',r=this.createLogParams(t),null===(e=this.sessionKey)||void 0===e?[3,1]:(a=e,[3,3]);case 1:return[4,this._authorize()];case 2:a=o.sent(),o.label=3;case 3:i=a,o.label=4;case 4:return o.trys.push([4,6,,14]),[4,this.params.apiTransport.sendRequest(n,r,i)];case 5:return[2,o.sent()];case 6:switch(u=o.sent(),null==u?void 0:u.error_code){case bu.PARAM_SESSION_EXPIRED:case bu.PARAM_SESSION_KEY:case bu.PARAM_SIGNATURE:return[3,7];case bu.AUTH_LOGIN:return[3,9]}return[3,12];case 7:return[4,this._authorize()];case 8:return s=o.sent(),[2,this.params.apiTransport.sendRequest(n,r,s)];case 9:return c=this,[4,this.refreshAuthToken()];case 10:return c.authToken=o.sent(),[4,this._authorizeRequest()];case 11:return s=o.sent(),[2,this.params.apiTransport.sendRequest(n,r,s)];case 12:throw u;case 13:return[3,14];case 14:return[2]}}))}))},t.prototype.refreshAuthToken=function(){return r(this,void 0,void 0,(function(){var t=this;return o(this,(function(e){return this.params.refreshAuthToken?(this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=uu(this.params.refreshAuthToken(),(function(){t.refreshAuthTokenPromise=void 0}))),[2,this.refreshAuthTokenPromise]):[2,void 0]}))}))},t.prototype.createLogParams=function(t){return{collector:'ok.mobile.apps.video',data:JSON.stringify({application:''.concat('@vkontakte/videoplayer-statistics',':').concat('1.0.11'),platform:'WEB',items:t.map((function(t){return n(n({},t),{time:0,type:1})}))})}},t.prototype._authorize=function(){return r(this,void 0,void 0,(function(){var t,e;return o(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,6]),[4,this._authorizeRequest()];case 1:return[2,n.sent()];case 2:switch(t=n.sent(),null==t?void 0:t.error_code){case bu.AUTH_LOGIN:return[3,3]}return[3,5];case 3:return e=this,[4,this.refreshAuthToken()];case 4:return e.authToken=n.sent(),[2,this._authorizeRequest()];case 5:throw t;case 6:return[2]}}))}))},t.prototype._authorizeRequest=function(){return r(this,void 0,void 0,(function(){var t,e,n=this;return o(this,(function(r){return this.authorizePromise||(this.sessionKey=void 0,t='auth.anonymLogin',e={session_data:{version:2,device_id:this.uuid,client_version:'1.0.11'.split('-')[0],client_type:'SDK_JS'}},void 0!==this.authToken&&(e.session_data.auth_token=this.authToken,e.session_data.version=3),this.authorizePromise=uu(this.params.apiTransport.sendRequest(t,e).then((function(r){if(!r)throw new Error('Empty response. Method: '.concat(t,', params: ').concat(JSON.stringify(e)));if(!r.session_key)throw new Error('Empty \'session_key\' in response. Method: '.concat(t,', params: ').concat(JSON.stringify(e),', response: ').concat(JSON.stringify(r)));return n.sessionKey=r.session_key,n.sessionKey})).catch((function(t){throw n.sessionKey=void 0,t})),(function(){n.authorizePromise=void 0}))),[2,this.authorizePromise]}))}))},t}(),Pu={};function _u(t,e){if(!(t instanceof e))throw new TypeError('Cannot call a class as a function')}function Su(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,'value'in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function Eu(t,e,n){return e&&Su(t.prototype,e),n&&Su(t,n),t}function Tu(t){return(Tu=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function Au(t,e){return(Au=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function ju(t){if(void 0===t)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return t}function Ru(t,e){return!e||'object'!=typeof e&&'function'!=typeof e?ju(t):e}function ku(t){var e=function(){if('undefined'==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if('function'==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=Tu(t);if(e){var o=Tu(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return Ru(this,n)}}function Lu(t,e,n){return(Lu='undefined'!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var r=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Tu(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(n):o.value}})(t,e,n||t)}Object.defineProperty(Pu,'__esModule',{value:!0});var xu=function(){function t(){_u(this,t),Object.defineProperty(this,'listeners',{value:{},writable:!0,configurable:!0})}return Eu(t,[{key:'addEventListener',value:function(t,e,n){t in this.listeners||(this.listeners[t]=[]),this.listeners[t].push({callback:e,options:n})}},{key:'removeEventListener',value:function(t,e){if(t in this.listeners)for(var n=this.listeners[t],r=0,o=n.length;r<o;r++)if(n[r].callback===e)return void n.splice(r,1)}},{key:'dispatchEvent',value:function(t){if(t.type in this.listeners){for(var e=this.listeners[t.type].slice(),n=0,r=e.length;n<r;n++){var o=e[n];try{o.callback.call(this,t)}catch(t){Promise.resolve().then((function(){throw t}))}o.options&&o.options.once&&this.removeEventListener(t.type,o.callback)}return!t.defaultPrevented}}}]),t}(),Iu=function(t){!function(t,e){if('function'!=typeof e&&null!==e)throw new TypeError('Super expression must either be null or a function');t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Au(t,e)}(n,xu);var e=ku(n);function n(){var t;return _u(this,n),(t=e.call(this)).listeners||xu.call(ju(t)),Object.defineProperty(ju(t),'aborted',{value:!1,writable:!0,configurable:!0}),Object.defineProperty(ju(t),'onabort',{value:null,writable:!0,configurable:!0}),t}return Eu(n,[{key:'toString',value:function(){return'[object AbortSignal]'}},{key:'dispatchEvent',value:function(t){'abort'===t.type&&(this.aborted=!0,'function'==typeof this.onabort&&this.onabort.call(this,t)),Lu(Tu(n.prototype),'dispatchEvent',this).call(this,t)}}]),n}(),Cu=function(){function t(){_u(this,t),Object.defineProperty(this,'signal',{value:new Iu,writable:!0,configurable:!0})}return Eu(t,[{key:'abort',value:function(){var t;try{t=new Event('abort')}catch(e){'undefined'!=typeof document?document.createEvent?(t=document.createEvent('Event')).initEvent('abort',!1,!1):(t=document.createEventObject()).type='abort':t={type:'abort',bubbles:!1,cancelable:!1}}this.signal.dispatchEvent(t)}},{key:'toString',value:function(){return'[object AbortController]'}}]),t}();'undefined'!=typeof Symbol&&Symbol.toStringTag&&(Cu.prototype[Symbol.toStringTag]='AbortController',Iu.prototype[Symbol.toStringTag]='AbortSignal'),Pu.AbortController=Cu,Pu.AbortSignal=Iu;var Nu=Pu.abortableFetch=function(t){'function'==typeof t&&(t={fetch:t});var e=t,n=e.fetch,r=e.Request,o=void 0===r?n.Request:r,i=e.AbortController,a=e.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL,u=void 0!==a&&a;if(!function(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}({fetch:n,Request:o,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:u}))return{fetch:n,Request:c};var c=o;(c&&!c.prototype.hasOwnProperty('signal')||u)&&((c=function(t,e){var n;e&&e.signal&&(n=e.signal,delete e.signal);var r=new o(t,e);return n&&Object.defineProperty(r,'signal',{writable:!1,enumerable:!1,configurable:!0,value:n}),r}).prototype=o.prototype);var s=n;return{fetch:function(t,e){var n=c&&c.prototype.isPrototypeOf(t)?t.signal:e?e.signal:void 0;if(n){var r;try{r=new DOMException('Aborted','AbortError')}catch(t){(r=new Error('Aborted')).name='AbortError'}if(n.aborted)return Promise.reject(r);var o=new Promise((function(t,e){n.addEventListener('abort',(function(){return e(r)}),{once:!0})}));return e&&e.signal&&delete e.signal,Promise.race([o,s(t,e)])}return s(t,e)},Request:c}},qu=function(){function t(t){this.params=t,this.apiKey=t.apiKey,this.apiBaseUrl=t.apiBaseUrl,'/'!==this.apiBaseUrl[this.apiBaseUrl.length-1]&&(this.apiBaseUrl+='/')}return t.prototype.sendBeacon=function(t,e,n){if(!window.Blob||!window.navigator.sendBeacon)return!1;var r=this._prepareQueryParams({method:t,queryParams:e,sessionKey:n}),o=new window.Blob([r.toString()],{type:'application/x-www-form-urlencoded'});return window.navigator.sendBeacon(''.concat(this.apiBaseUrl,'fb.do'),o)},t.prototype.sendRequest=function(t,e,n){return r(this,void 0,void 0,(function(){var r,i,a=this;return o(this,(function(o){return r=Date.now(),i=function(o){throw a.params.error$.next({id:'OneStat:ApiTransport:sendRequest',message:'Unhandled request error',thrown:o,data:{method:t,params:e,sessionKey:n,time:Date.now()-r}}),o},[2,Nu(fetch).fetch(''.concat(this.apiBaseUrl,'fb.do'),{method:'post',headers:{'Content-type':'application/x-www-form-urlencoded'},body:this._prepareQueryParams({method:t,queryParams:e,sessionKey:n})}).then((function(t){return Number(t.headers.get('content-length'))>0?t.json().then((function(t){return Object.prototype.hasOwnProperty.call(t,'error_msg')?Promise.reject(t):t}),i):void 0}),i)]}))}))},t.prototype._prepareQueryParams=function(t){var 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((function(t){var n=function(t,e){var n='function'==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}(t,2),r=n[0],o=n[1];return e.append(r,'string'==typeof o?o:JSON.stringify(o))})),e},t}(),Mu=function(){function t(t){var n=this;this.requestQueue=[],this.isPaused=!1,this.debouncedFlush=e((function(){return n.flush()}),3e3,{maxWait:15e3}),this.api=t.api}return t.prototype.log=function(t){this.requestQueue.push(t),this.isPaused||this.debouncedFlush()},t.prototype.flush=function(t){void 0===t&&(t=!1),0!==this.requestQueue.length&&(t?this.api.logBeacon(this.requestQueue):this.api.logRequest(this.requestQueue),this.requestQueue=[],this.debouncedFlush.cancel())},t.prototype.pause=function(){this.isPaused=!0,this.debouncedFlush.cancel()},t.prototype.resume=function(){this.isPaused=!1,this.debouncedFlush()},t}(),Bu=function(){function e(e,n){var r=this;this.statContext=e;var o=new t;this.experimental={error$:o};var i=new qu({apiKey:'CIOPGQJGDIHBABABA',apiBaseUrl:wu[n.apiEnv],error$:o});this.api=new Ou({apiTransport:i,refreshAuthToken:n.refreshAuthToken}),this.logger=new Mu({api:this.api}),window.addEventListener('beforeunload',(function(){return r.logger.flush(!0)}))}return e.prototype.updateContext=function(t){this.statContext=n(n({},this.statContext),t)},e.prototype.authorize=function(t){return this.api.authorize(t)},e.prototype.pause=function(){this.logger.pause()},e.prototype.resume=function(){this.logger.resume()},e.prototype.logStarted=function(){this.log({operation:'play'})},e.prototype.logPlay=function(){this.log({operation:'play_toggle'})},e.prototype.logPause=function(t){this.log({operation:'pause',param:String(Math.round(t.position))})},e.prototype.logSeek=function(){this.log({operation:'seek'})},e.prototype.logFirstBytes=function(t){this.log({operation:'first_bytes',param:String(t.time)})},e.prototype.logFirstFrame=function(t){this.log({operation:'first_frame',param:String(t.time)})},e.prototype.logError=function(t){this.log({operation:'error',param:t.errorType})},e.prototype.logWatchCoverageRecord=function(t){this.log({operation:'watch_coverage_record',param:''.concat(t.start,'-').concat(t.end)}),this.logger.flush(!0)},e.prototype.logWatchCoverageLive=function(t){this.log({operation:'watch_coverage_live',param:''.concat(t.start,'-').concat(t.end)})},e.prototype.logEmptyBuffer=function(t){this.log({operation:'empty_buffer',param:String(t.duration)})},e.prototype.logAdSlotRequest=function(){this.log({operation:'adv',param:'slot_request'})},e.prototype.logAdStarted=function(t){this.log({operation:'adv',param:t})},e.prototype.logAdPaused=function(){this.log({operation:'adv',param:'pause'})},e.prototype.logAdResumed=function(){this.log({operation:'adv',param:'resume'})},e.prototype.logAdEnded=function(){this.log({operation:'adv',param:'ended'})},e.prototype.logAdSkipped=function(){this.log({operation:'adv',param:'skip'})},e.prototype.logAdClicked=function(){this.log({operation:'adv',param:'click'})},e.prototype.log=function(t){var e=this.crateLogItem(t);this.logger.log(e)},e.prototype.crateLogItem=function(t){var e=t.operation,n=t.param,r=Date.now(),o={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?vu.YES:!1===this.statContext.connectionReused?vu.NO:void 0,stat_type:!0===this.statContext.autoplay?hu.AUTO:!1===this.statContext.autoplay?hu.MANUAL:void 0,vk_playlist_id:this.statContext.vkPlaylistId,vk_app_id:this.statContext.vkAppId};return void 0!==n&&(o.param=n),{operation:e,timestamp:r,custom:o}},e}();export{su as ApiEnv,du as ConnectionType,pu as ContentType,Bu as OneStat,fu as Quality,lu as ScreenDestination};
|