@vkontakte/videoplayer-statistics 1.0.14-beta.0 → 1.0.14

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