@vkontakte/videoplayer-statistics 1.0.45 → 1.0.46-dev.df8758f1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es2015.cjs.js +4 -4
- package/es2015.esm.js +4 -4
- package/es2018.cjs.js +4 -4
- package/es2018.esm.js +4 -4
- package/esnext.cjs.js +4 -4
- package/esnext.esm.js +4 -4
- package/evergreen.esm.js +4 -4
- package/index.d.ts +1 -0
- package/package.json +3 -3
package/es2018.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-statistics v1.0.
|
|
3
|
-
*
|
|
4
|
-
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-
|
|
2
|
+
* @vkontakte/videoplayer-statistics v1.0.46-dev.df8758f1.0
|
|
3
|
+
* Wed, 13 Mar 2024 12:50:02 GMT
|
|
4
|
+
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-46/doc/
|
|
5
5
|
*/
|
|
6
|
-
import{fillWithDefault as Mn,ValueSubject as me,getExponentialDelay as Bn,ErrorCategory as T,now as S,debounceFn as Dt,safeStorage as F,assertNever as Br,Observable as Un,Subscription as $e,merge as ve,fromEvent as ut,filterChanged as Gn,map as Kn,filter as kt,Subject as pe,isNullable as Se,Logger as Vn,isNonNullable as V,detectEmbed as Wn,once as Hn,combine as jt,observableFrom as qn,assertNonNullable as zn}from"@vkontakte/videoplayer-shared/es2018.esm.js";import{Surface as Z,VideoQuality as A,HttpConnectionType as Ce,VideoFormat as m,PlaybackState as Ft}from"@vkontakte/videoplayer-core/es2018.esm.js";var De=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Ur(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var oe=function(e){return e&&e.Math==Math&&e},w=oe(typeof globalThis=="object"&&globalThis)||oe(typeof window=="object"&&window)||oe(typeof self=="object"&&self)||oe(typeof De=="object"&&De)||function(){return this}()||De||Function("return this")(),x=function(e){try{return!!e()}catch(t){return!0}},Yn=x,Pe=!Yn(function(){var e=function(){}.bind();return typeof e!="function"||e.hasOwnProperty("prototype")}),Qn=Pe,Gr=Function.prototype,Mt=Gr.apply,Bt=Gr.call,Xn=typeof Reflect=="object"&&Reflect.apply||(Qn?Bt.bind(Mt):function(){return Bt.apply(Mt,arguments)}),Kr=Pe,Vr=Function.prototype,ct=Vr.call,Jn=Kr&&Vr.bind.bind(ct,ct),C=Kr?Jn:function(e){return function(){return ct.apply(e,arguments)}},Wr=C,Zn=Wr({}.toString),ea=Wr("".slice),Ae=function(e){return ea(Zn(e),8,-1)},ta=Ae,ra=C,Hr=function(e){if(ta(e)==="Function")return ra(e)},ft=typeof document=="object"&&document.all,na=typeof ft=="undefined"&&ft!==void 0,qr={all:ft,IS_HTMLDDA:na},zr=qr,aa=zr.all,_=zr.IS_HTMLDDA?function(e){return typeof e=="function"||e===aa}:function(e){return typeof e=="function"},Yr={},oa=x,U=!oa(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),ia=Pe,ie=Function.prototype.call,D=ia?ie.bind(ie):function(){return ie.apply(ie,arguments)},Qr={},Xr={}.propertyIsEnumerable,Jr=Object.getOwnPropertyDescriptor,sa=Jr&&!Xr.call({1:2},1);Qr.f=sa?function(t){var r=Jr(this,t);return!!r&&r.enumerable}:Xr;var Ie=function(e,t){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:t}},la=C,ua=x,ca=Ae,ke=Object,fa=la("".split),da=ua(function(){return!ke("z").propertyIsEnumerable(0)})?function(e){return ca(e)=="String"?fa(e,""):ke(e)}:ke,Re=function(e){return e==null},ha=Re,va=TypeError,mt=function(e){if(ha(e))throw va("Can't call method on "+e);return e},pa=da,ga=mt,re=function(e){return pa(ga(e))},Ut=_,Zr=qr,ba=Zr.all,G=Zr.IS_HTMLDDA?function(e){return typeof e=="object"?e!==null:Ut(e)||e===ba}:function(e){return typeof e=="object"?e!==null:Ut(e)},$t={},je=$t,Fe=w,ya=_,Gt=function(e){return ya(e)?e:void 0},St=function(e,t){return arguments.length<2?Gt(je[e])||Gt(Fe[e]):je[e]&&je[e][t]||Fe[e]&&Fe[e][t]},ma=C,Et=ma({}.isPrototypeOf),$a=typeof navigator!="undefined"&&String(navigator.userAgent)||"",en=w,Me=$a,Kt=en.process,Vt=en.Deno,Wt=Kt&&Kt.versions||Vt&&Vt.version,Ht=Wt&&Wt.v8,O,Ee;Ht&&(O=Ht.split("."),Ee=O[0]>0&&O[0]<4?1:+(O[0]+O[1]));!Ee&&Me&&(O=Me.match(/Edge\/(\d+)/),(!O||O[1]>=74)&&(O=Me.match(/Chrome\/(\d+)/),O&&(Ee=+O[1])));var Sa=Ee,qt=Sa,Ea=x,_a=w,Ta=_a.String,tn=!!Object.getOwnPropertySymbols&&!Ea(function(){var e=Symbol();return!Ta(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&qt&&qt<41}),Oa=tn,rn=Oa&&!Symbol.sham&&typeof Symbol.iterator=="symbol",wa=St,Pa=_,Aa=Et,Ia=rn,Ra=Object,nn=Ia?function(e){return typeof e=="symbol"}:function(e){var t=wa("Symbol");return Pa(t)&&Aa(t.prototype,Ra(e))},La=String,_t=function(e){try{return La(e)}catch(t){return"Object"}},Na=_,xa=_t,Ca=TypeError,Tt=function(e){if(Na(e))return e;throw Ca(xa(e)+" is not a function")},Da=Tt,ka=Re,Le=function(e,t){var r=e[t];return ka(r)?void 0:Da(r)},Be=D,Ue=_,Ge=G,ja=TypeError,Fa=function(e,t){var r,n;if(t==="string"&&Ue(r=e.toString)&&!Ge(n=Be(r,e))||Ue(r=e.valueOf)&&!Ge(n=Be(r,e))||t!=="string"&&Ue(r=e.toString)&&!Ge(n=Be(r,e)))return n;throw ja("Can't convert object to primitive value")},an={exports:{}},zt=w,Ma=Object.defineProperty,Ba=function(e,t){try{Ma(zt,e,{value:t,configurable:!0,writable:!0})}catch(r){zt[e]=t}return t},Ua=w,Ga=Ba,Yt="__core-js_shared__",Ka=Ua[Yt]||Ga(Yt,{}),on=Ka,Qt=on;(an.exports=function(e,t){return Qt[e]||(Qt[e]=t!==void 0?t:{})})("versions",[]).push({version:"3.31.0",mode:"pure",copyright:"\xA9 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.31.0/LICENSE",source:"https://github.com/zloirock/core-js"});var sn=an.exports,Va=mt,Wa=Object,Ot=function(e){return Wa(Va(e))},Ha=C,qa=Ot,za=Ha({}.hasOwnProperty),k=Object.hasOwn||function(t,r){return za(qa(t),r)},Ya=C,Qa=0,Xa=Math.random(),Ja=Ya(1 .toString),ln=function(e){return"Symbol("+(e===void 0?"":e)+")_"+Ja(++Qa+Xa,36)},Za=w,eo=sn,Xt=k,to=ln,ro=tn,no=rn,Y=Za.Symbol,Ke=eo("wks"),ao=no?Y.for||Y:Y&&Y.withoutSetter||to,P=function(e){return Xt(Ke,e)||(Ke[e]=ro&&Xt(Y,e)?Y[e]:ao("Symbol."+e)),Ke[e]},oo=D,Jt=G,Zt=nn,io=Le,so=Fa,lo=P,uo=TypeError,co=lo("toPrimitive"),fo=function(e,t){if(!Jt(e)||Zt(e))return e;var r=io(e,co),n;if(r){if(t===void 0&&(t="default"),n=oo(r,e,t),!Jt(n)||Zt(n))return n;throw uo("Can't convert object to primitive value")}return t===void 0&&(t="number"),so(e,t)},ho=fo,vo=nn,wt=function(e){var t=ho(e,"string");return vo(t)?t:t+""},po=w,er=G,dt=po.document,go=er(dt)&&er(dt.createElement),un=function(e){return go?dt.createElement(e):{}},bo=U,yo=x,mo=un,cn=!bo&&!yo(function(){return Object.defineProperty(mo("div"),"a",{get:function(){return 7}}).a!=7}),$o=U,So=D,Eo=Qr,_o=Ie,To=re,Oo=wt,wo=k,Po=cn,tr=Object.getOwnPropertyDescriptor;Yr.f=$o?tr:function(t,r){if(t=To(t),r=Oo(r),Po)try{return tr(t,r)}catch(n){}if(wo(t,r))return _o(!So(Eo.f,t,r),t[r])};var Ao=x,Io=_,Ro=/#|\.prototype\./,ne=function(e,t){var r=No[Lo(e)];return r==Co?!0:r==xo?!1:Io(t)?Ao(t):!!t},Lo=ne.normalize=function(e){return String(e).replace(Ro,".").toLowerCase()},No=ne.data={},xo=ne.NATIVE="N",Co=ne.POLYFILL="P",Do=ne,rr=Hr,ko=Tt,jo=Pe,Fo=rr(rr.bind),fn=function(e,t){return ko(e),t===void 0?e:jo?Fo(e,t):function(){return e.apply(t,arguments)}},X={},Mo=U,Bo=x,dn=Mo&&Bo(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),Uo=G,Go=String,Ko=TypeError,K=function(e){if(Uo(e))return e;throw Ko(Go(e)+" is not an object")},Vo=U,Wo=cn,Ho=dn,se=K,nr=wt,qo=TypeError,Ve=Object.defineProperty,zo=Object.getOwnPropertyDescriptor,We="enumerable",He="configurable",qe="writable";X.f=Vo?Ho?function(t,r,n){if(se(t),r=nr(r),se(n),typeof t=="function"&&r==="prototype"&&"value"in n&&qe in n&&!n[qe]){var a=zo(t,r);a&&a[qe]&&(t[r]=n.value,n={configurable:He in n?n[He]:a[He],enumerable:We in n?n[We]:a[We],writable:!1})}return Ve(t,r,n)}:Ve:function(t,r,n){if(se(t),r=nr(r),se(n),Wo)try{return Ve(t,r,n)}catch(a){}if("get"in n||"set"in n)throw qo("Accessors not supported");return"value"in n&&(t[r]=n.value),t};var Yo=U,Qo=X,Xo=Ie,ae=Yo?function(e,t,r){return Qo.f(e,t,Xo(1,r))}:function(e,t,r){return e[t]=r,e},le=w,Jo=Xn,Zo=Hr,ei=_,ti=Yr.f,ri=Do,W=$t,ni=fn,H=ae,ar=k,ai=function(e){var t=function(r,n,a){if(this instanceof t){switch(arguments.length){case 0:return new e;case 1:return new e(r);case 2:return new e(r,n)}return new e(r,n,a)}return Jo(e,this,arguments)};return t.prototype=e.prototype,t},Pt=function(e,t){var r=e.target,n=e.global,a=e.stat,i=e.proto,s=n?le:a?le[r]:(le[r]||{}).prototype,f=n?W:W[r]||H(W,r,{})[r],d=f.prototype,u,o,l,c,h,v,p,b,g;for(c in t)u=ri(n?c:r+(a?".":"#")+c,e.forced),o=!u&&s&&ar(s,c),v=f[c],o&&(e.dontCallGetSet?(g=ti(s,c),p=g&&g.value):p=s[c]),h=o&&p?p:t[c],!(o&&typeof v==typeof h)&&(e.bind&&o?b=ni(h,le):e.wrap&&o?b=ai(h):i&&ei(h)?b=Zo(h):b=h,(e.sham||h&&h.sham||v&&v.sham)&&H(b,"sham",!0),H(f,c,b),i&&(l=r+"Prototype",ar(W,l)||H(W,l,{}),H(W[l],c,h),e.real&&d&&(u||!d[c])&&H(d,c,h)))},oi=G,ii=Ae,si=P,li=si("match"),ui=function(e){var t;return oi(e)&&((t=e[li])!==void 0?!!t:ii(e)=="RegExp")},ci=P,fi=ci("toStringTag"),hn={};hn[fi]="z";var At=String(hn)==="[object z]",di=At,hi=_,ge=Ae,vi=P,pi=vi("toStringTag"),gi=Object,bi=ge(function(){return arguments}())=="Arguments",yi=function(e,t){try{return e[t]}catch(r){}},Ne=di?ge:function(e){var t,r,n;return e===void 0?"Undefined":e===null?"Null":typeof(r=yi(t=gi(e),pi))=="string"?r:bi?ge(t):(n=ge(t))=="Object"&&hi(t.callee)?"Arguments":n},mi=Ne,$i=String,Si=function(e){if(mi(e)==="Symbol")throw TypeError("Cannot convert a Symbol value to a string");return $i(e)},Ei=K,_i=function(){var e=Ei(this),t="";return e.hasIndices&&(t+="d"),e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.unicodeSets&&(t+="v"),e.sticky&&(t+="y"),t},Ti=D,Oi=k,wi=Et,Pi=_i,or=RegExp.prototype,Ai=function(e){var t=e.flags;return t===void 0&&!("flags"in or)&&!Oi(e,"flags")&&wi(or,e)?Ti(Pi,e):t},It=C,Ii=Ot,Ri=Math.floor,ze=It("".charAt),Li=It("".replace),Ye=It("".slice),Ni=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,xi=/\$([$&'`]|\d{1,2})/g,Ci=function(e,t,r,n,a,i){var s=r+e.length,f=n.length,d=xi;return a!==void 0&&(a=Ii(a),d=Ni),Li(i,d,function(u,o){var l;switch(ze(o,0)){case"$":return"$";case"&":return e;case"`":return Ye(t,0,r);case"'":return Ye(t,s);case"<":l=a[Ye(o,1,-1)];break;default:var c=+o;if(c===0)return u;if(c>f){var h=Ri(c/10);return h===0?u:h<=f?n[h-1]===void 0?ze(o,1):n[h-1]+ze(o,1):u}l=n[c-1]}return l===void 0?"":l})},Di=Pt,ki=D,Rt=C,ir=mt,ji=_,Fi=Re,Mi=ui,q=Si,Bi=Le,Ui=Ai,Gi=Ci,Ki=P,Vi=Ki("replace"),Wi=TypeError,vn=Rt("".indexOf),Hi=Rt("".replace),sr=Rt("".slice),qi=Math.max,lr=function(e,t,r){return r>e.length?-1:t===""?r:vn(e,t,r)};Di({target:"String",proto:!0},{replaceAll:function(t,r){var n=ir(this),a,i,s,f,d,u,o,l,c,h=0,v=0,p="";if(!Fi(t)){if(a=Mi(t),a&&(i=q(ir(Ui(t))),!~vn(i,"g")))throw Wi("`.replaceAll` does not allow non-global regexes");if(s=Bi(t,Vi),s)return ki(s,t,n,r);if(a)return Hi(q(n),t,r)}for(f=q(n),d=q(t),u=ji(r),u||(r=q(r)),o=d.length,l=qi(1,o),h=lr(f,d,0);h!==-1;)c=u?q(r(d,h,f)):Gi(d,f,h,[],void 0,r),p+=sr(f,v,h)+c,v=h+o,h=lr(f,d,h+l);return v<f.length&&(p+=sr(f,v)),p}});var zi=St,Yi=zi,Qi=Yi,Xi=Qi("String","replaceAll"),Ji=Xi,Zi=Ji,es=Zi,ts=es,rs=Ur(ts),R;(function(e){e.PROD="prod",e.VK_ALIAS="vk_alias",e.VIDEOTEST="videotest",e.TEST="test",e.AUTO="auto"})(R||(R={}));var E;(function(e){e.Q144P="mobile",e.Q240P="lowest",e.Q360P="low",e.Q480P="medium",e.Q720P="high",e.Q1080P="fullhd",e.Q1440P="quadhd",e.Q2160P="ultrahd",e.UNKNOWN="unknown"})(E||(E={}));var $;(function(e){e.MP4="mp4",e.DASH="dash",e.DASH_SEP="dash_sep",e.ONDEMAND_DASH="ondemand_dash",e.HLS="hls",e.ONDEMAND_HLS="ondemand_hls",e.WEBM="webm",e.AV1="av1",e.ONDEMAND_DASH_LIVE="ondemand_dash_live",e.ONDEMAND_HLS_LIVE="ondemand_hls_live",e.WEBRTC="webrtc",e.UNKNOWN="unknown",e.RTMP="rtmp"})($||($={}));var _e;(function(e){e.AUTO="auto",e.MANUAL=""})(_e||(_e={}));var ee;(function(e){e.HTTP1="http1",e.HTTP2="http2",e.HTTP3="http3"})(ee||(ee={}));var L;(function(e){e[e.YES=1]="YES",e[e.NO=0]="NO"})(L||(L={}));var Q;(function(e){e.EXCELLENT="excellent",e.GOOD="good",e.POOR="poor"})(Q||(Q={}));var B;(function(e){e.PIP="pip",e.FULLSCREEN="fullscreen",e.EXTERNAL="external",e.PREFETCH="prefetch",e.AIRPLAY="airplay",e.CHROMECAST="chromecast",e.INVISIBLE="invisible"})(B||(B={}));var Te;(function(e){e.SLIDER="slider",e.DOUBLE_TAP="double_tap",e.TIME_CODE="time_code",e.EPISODE="episode",e.REWIND="rewind",e.LIVE="live",e.UNKNOWN="unknown"})(Te||(Te={}));var ur;(function(e){e.GRAPH_SHOW="iGraphShow",e.GRAPH_HIDE="iGraphHide",e.NEXT_AREA="iNextChapterArea",e.NEXT_BUTTON="iNextChapterBtn",e.WATCH_AGAIN="iWatchAgainBtn"})(ur||(ur={}));const ns={action_play:"ap",first_bytes:"fb",player_ready:"pr",first_frame:"ff",seek:"sk",watch_coverage_record:"wr",watch_coverage_live:"wl",empty_buffer:"eb",action_stop:"as",close_at_empty_buffer:"cb",content_error:"er",player_interface_click:"pc",next_movie:"nm",track_switch:"ts"},as={vsid:"si",vid:"vi",place:"pl",quality:"qt",cdn_host:"ch",stat_type:"st",param:"pm",vk_app_id:"va",track_code:"tc",connection_type:"cnt",connection_reused:"cr",cached_data:"cd",live:"lv",muted:"mu",mode:"mo",subtitles:"sb",failover:"fo",download_speed:"ds",manual_quality:"mq",ref_domain:"rd",direct_url:"du"},os={unknown:"un",mobile:"m",lowest:"ls",low:"l",medium:"md",high:"h",fullhd:"f",quadhd:"q",ultrahd:"u"},is={pip:"pi",fullscreen:"fs",external:"ex",prefetch:"pr",airplay:"ap",chromecast:"cc",invisible:"iv"},ss={apiEnv:R.VK_ALIAS,requestRetryCount:1,firstFlushTime:5e3,flushDebounceTime:1e4,flushMaxWait:6e4,storageExpiration:36*60*60*1e3,watchCoverageInterval:15e3,disabledOperations:[],disabledCustomFields:[],shorten:!0,maxLoops:100,embedUrlParams:[],useBeacon:!0,synchronizeTime:!0,debugLog:!1,backoff:{start:1e3,factor:1.5,max:5*60*1e3,random:.1}},ls=e=>Mn(e,ss);function us(){const e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),t=new Array(36);let r=0,n,a;for(a=0;a<36;a++)a===8||a===13||a===18||a===23?t[a]="-":a===14?t[a]="4":(r<=2&&(r=33554432+Math.random()*16777216|0),n=r&15,r=r>>4,t[a]=e[a===19?n&3|8:n]);return t.join("")}var J={},cs=w,fs=_,cr=cs.WeakMap,ds=fs(cr)&&/native code/.test(String(cr)),hs=sn,vs=ln,fr=hs("keys"),Lt=function(e){return fr[e]||(fr[e]=vs(e))},Nt={},ps=ds,pn=w,gs=G,bs=ae,Qe=k,Xe=on,ys=Lt,ms=Nt,dr="Object already initialized",ht=pn.TypeError,$s=pn.WeakMap,Oe,te,we,Ss=function(e){return we(e)?te(e):Oe(e,{})},Es=function(e){return function(t){var r;if(!gs(t)||(r=te(t)).type!==e)throw ht("Incompatible receiver, "+e+" required");return r}};if(ps||Xe.state){var I=Xe.state||(Xe.state=new $s);I.get=I.get,I.has=I.has,I.set=I.set,Oe=function(e,t){if(I.has(e))throw ht(dr);return t.facade=e,I.set(e,t),t},te=function(e){return I.get(e)||{}},we=function(e){return I.has(e)}}else{var z=ys("state");ms[z]=!0,Oe=function(e,t){if(Qe(e,z))throw ht(dr);return t.facade=e,bs(e,z,t),t},te=function(e){return Qe(e,z)?e[z]:{}},we=function(e){return Qe(e,z)}}var _s={set:Oe,get:te,has:we,enforce:Ss,getterFor:Es},vt=U,Ts=k,gn=Function.prototype,Os=vt&&Object.getOwnPropertyDescriptor,xt=Ts(gn,"name"),ws=xt&&function(){}.name==="something",Ps=xt&&(!vt||vt&&Os(gn,"name").configurable),As={EXISTS:xt,PROPER:ws,CONFIGURABLE:Ps},bn={},Is=Math.ceil,Rs=Math.floor,Ls=Math.trunc||function(t){var r=+t;return(r>0?Rs:Is)(r)},Ns=Ls,yn=function(e){var t=+e;return t!==t||t===0?0:Ns(t)},xs=yn,Cs=Math.max,Ds=Math.min,ks=function(e,t){var r=xs(e);return r<0?Cs(r+t,0):Ds(r,t)},js=yn,Fs=Math.min,Ms=function(e){return e>0?Fs(js(e),9007199254740991):0},Bs=Ms,mn=function(e){return Bs(e.length)},Us=re,Gs=ks,Ks=mn,hr=function(e){return function(t,r,n){var a=Us(t),i=Ks(a),s=Gs(n,i),f;if(e&&r!=r){for(;i>s;)if(f=a[s++],f!=f)return!0}else for(;i>s;s++)if((e||s in a)&&a[s]===r)return e||s||0;return!e&&-1}},Vs={includes:hr(!0),indexOf:hr(!1)},Ws=C,Je=k,Hs=re,qs=Vs.indexOf,zs=Nt,vr=Ws([].push),Ys=function(e,t){var r=Hs(e),n=0,a=[],i;for(i in r)!Je(zs,i)&&Je(r,i)&&vr(a,i);for(;t.length>n;)Je(r,i=t[n++])&&(~qs(a,i)||vr(a,i));return a},$n=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Qs=Ys,Xs=$n,Js=Object.keys||function(t){return Qs(t,Xs)},Zs=U,el=dn,tl=X,rl=K,nl=re,al=Js;bn.f=Zs&&!el?Object.defineProperties:function(t,r){rl(t);for(var n=nl(r),a=al(r),i=a.length,s=0,f;i>s;)tl.f(t,f=a[s++],n[f]);return t};var ol=St,il=ol("document","documentElement"),sl=K,ll=bn,pr=$n,ul=Nt,cl=il,fl=un,dl=Lt,gr=">",br="<",pt="prototype",gt="script",Sn=dl("IE_PROTO"),Ze=function(){},En=function(e){return br+gt+gr+e+br+"/"+gt+gr},yr=function(e){e.write(En("")),e.close();var t=e.parentWindow.Object;return e=null,t},hl=function(){var e=fl("iframe"),t="java"+gt+":",r;return e.style.display="none",cl.appendChild(e),e.src=String(t),r=e.contentWindow.document,r.open(),r.write(En("document.F=Object")),r.close(),r.F},ue,be=function(){try{ue=new ActiveXObject("htmlfile")}catch(t){}be=typeof document!="undefined"?document.domain&&ue?yr(ue):hl():yr(ue);for(var e=pr.length;e--;)delete be[pt][pr[e]];return be()};ul[Sn]=!0;var _n=Object.create||function(t,r){var n;return t!==null?(Ze[pt]=sl(t),n=new Ze,Ze[pt]=null,n[Sn]=t):n=be(),r===void 0?n:ll.f(n,r)},vl=x,pl=!vl(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}),gl=k,bl=_,yl=Ot,ml=Lt,$l=pl,mr=ml("IE_PROTO"),bt=Object,Sl=bt.prototype,Tn=$l?bt.getPrototypeOf:function(e){var t=yl(e);if(gl(t,mr))return t[mr];var r=t.constructor;return bl(r)&&t instanceof r?r.prototype:t instanceof bt?Sl:null},El=ae,On=function(e,t,r,n){return n&&n.enumerable?e[t]=r:El(e,t,r),e},_l=x,Tl=_,Ol=G,wl=_n,$r=Tn,Pl=On,Al=P,yt=Al("iterator"),wn=!1,N,et,tt;[].keys&&(tt=[].keys(),"next"in tt?(et=$r($r(tt)),et!==Object.prototype&&(N=et)):wn=!0);var Il=!Ol(N)||_l(function(){var e={};return N[yt].call(e)!==e});Il?N={}:N=wl(N);Tl(N[yt])||Pl(N,yt,function(){return this});var Pn={IteratorPrototype:N,BUGGY_SAFARI_ITERATORS:wn},Rl=At,Ll=Ne,Nl=Rl?{}.toString:function(){return"[object "+Ll(this)+"]"},xl=At,Cl=X.f,Dl=ae,kl=k,jl=Nl,Fl=P,Sr=Fl("toStringTag"),An=function(e,t,r,n){if(e){var a=r?e:e.prototype;kl(a,Sr)||Cl(a,Sr,{configurable:!0,value:t}),n&&!xl&&Dl(a,"toString",jl)}},Ml=Pn.IteratorPrototype,Bl=_n,Ul=Ie,Gl=An,Kl=J,Vl=function(){return this},Wl=function(e,t,r,n){var a=t+" Iterator";return e.prototype=Bl(Ml,{next:Ul(+!n,r)}),Gl(e,a,!1,!0),Kl[a]=Vl,e},Hl=Pt,ql=D,In=As,zl=Wl,Yl=Tn,Ql=An,Er=On,Xl=P,_r=J,Rn=Pn,Jl=In.PROPER;In.CONFIGURABLE;Rn.IteratorPrototype;var ce=Rn.BUGGY_SAFARI_ITERATORS,rt=Xl("iterator"),Tr="keys",fe="values",Or="entries",Zl=function(){return this},eu=function(e,t,r,n,a,i,s){zl(r,t,n);var f=function(g){if(g===a&&c)return c;if(!ce&&g in o)return o[g];switch(g){case Tr:return function(){return new r(this,g)};case fe:return function(){return new r(this,g)};case Or:return function(){return new r(this,g)}}return function(){return new r(this)}},d=t+" Iterator",u=!1,o=e.prototype,l=o[rt]||o["@@iterator"]||a&&o[a],c=!ce&&l||f(a),h=t=="Array"&&o.entries||l,v,p,b;if(h&&(v=Yl(h.call(new e)),v!==Object.prototype&&v.next&&(Ql(v,d,!0,!0),_r[d]=Zl)),Jl&&a==fe&&l&&l.name!==fe&&(u=!0,c=function(){return ql(l,this)}),a)if(p={values:f(fe),keys:i?c:f(Tr),entries:f(Or)},s)for(b in p)(ce||u||!(b in o))&&Er(o,b,p[b]);else Hl({target:t,proto:!0,forced:ce||u},p);return s&&o[rt]!==c&&Er(o,rt,c,{name:a}),_r[t]=c,p},tu=function(e,t){return{value:e,done:t}},ru=re,wr=J,Ln=_s;X.f;var nu=eu,de=tu,Nn="Array Iterator",au=Ln.set,ou=Ln.getterFor(Nn);nu(Array,"Array",function(e,t){au(this,{type:Nn,target:ru(e),index:0,kind:t})},function(){var e=ou(this),t=e.target,r=e.kind,n=e.index++;return!t||n>=t.length?(e.target=void 0,de(void 0,!0)):r=="keys"?de(n,!1):r=="values"?de(t[n],!1):de([n,t[n]],!1)},"values");wr.Arguments=wr.Array;var iu=P,su=J,lu=iu("iterator"),uu=Array.prototype,cu=function(e){return e!==void 0&&(su.Array===e||uu[lu]===e)},fu=Ne,Pr=Le,du=Re,hu=J,vu=P,pu=vu("iterator"),xn=function(e){if(!du(e))return Pr(e,pu)||Pr(e,"@@iterator")||hu[fu(e)]},gu=D,bu=Tt,yu=K,mu=_t,$u=xn,Su=TypeError,Eu=function(e,t){var r=arguments.length<2?$u(e):t;if(bu(r))return yu(gu(r,e));throw Su(mu(e)+" is not iterable")},_u=D,Ar=K,Tu=Le,Ou=function(e,t,r){var n,a;Ar(e);try{if(n=Tu(e,"return"),!n){if(t==="throw")throw r;return r}n=_u(n,e)}catch(i){a=!0,n=i}if(t==="throw")throw r;if(a)throw n;return Ar(n),r},wu=fn,Pu=D,Au=K,Iu=_t,Ru=cu,Lu=mn,Ir=Et,Nu=Eu,xu=xn,Rr=Ou,Cu=TypeError,ye=function(e,t){this.stopped=e,this.result=t},Lr=ye.prototype,Du=function(e,t,r){var n=r&&r.that,a=!!(r&&r.AS_ENTRIES),i=!!(r&&r.IS_RECORD),s=!!(r&&r.IS_ITERATOR),f=!!(r&&r.INTERRUPTED),d=wu(t,n),u,o,l,c,h,v,p,b=function(y){return u&&Rr(u,"normal",y),new ye(!0,y)},g=function(y){return a?(Au(y),f?d(y[0],y[1],b):d(y[0],y[1])):f?d(y,b):d(y)};if(i)u=e.iterator;else if(s)u=e;else{if(o=xu(e),!o)throw Cu(Iu(e)+" is not iterable");if(Ru(o)){for(l=0,c=Lu(e);c>l;l++)if(h=g(e[l]),h&&Ir(Lr,h))return h;return new ye(!1)}u=Nu(e,o)}for(v=i?e.next:u.next;!(p=Pu(v,u)).done;){try{h=g(p.value)}catch(y){Rr(u,"throw",y)}if(typeof h=="object"&&h&&Ir(Lr,h))return h}return new ye(!1)},ku=wt,ju=X,Fu=Ie,Mu=function(e,t,r){var n=ku(t);n in e?ju.f(e,n,Fu(0,r)):e[n]=r},Bu=Pt,Uu=Du,Gu=Mu;Bu({target:"Object",stat:!0},{fromEntries:function(t){var r={};return Uu(t,function(n,a){Gu(r,n,a)},{AS_ENTRIES:!0}),r}});var Ku=$t,Vu=Ku.Object.fromEntries,Wu={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},Hu=Wu,qu=w,zu=Ne,Yu=ae,Nr=J,Qu=P,xr=Qu("toStringTag");for(var nt in Hu){var Cr=qu[nt],at=Cr&&Cr.prototype;at&&zu(at)!==xr&&Yu(at,xr,nt),Nr[nt]=Nr.Array}var Xu=Vu,Ju=Xu,Zu=Ju,ec=Zu,tc=Ur(ec);const rc=e=>{var t;const{operation:r,custom:n}=e,a=tc(Object.entries(n).map(([i,s])=>{var f,d,u;const o=(f=as[i])!==null&&f!==void 0?f:i;let l=s;return s&&(i==="mode"?l=(d=is[s])!==null&&d!==void 0?d:s:i==="quality"&&(l=(u=os[s])!==null&&u!==void 0?u:s)),[o,l]}));return{...e,operation:(t=ns[r])!==null&&t!==void 0?t:r,custom:a}},Dr="1.0.45",nc="CIOPGQJGDIHBABABA",kr={[R.PROD]:"https://api.ok.ru",[R.VK_ALIAS]:"https://api.mycdn.me",[R.VIDEOTEST]:"https://videotestapi.ok.ru/api",[R.TEST]:"https://apitest.ok.ru",[R.AUTO]:""};var M;(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"})(M||(M={}));class ac{constructor(t){this.consequentAuthErrors=0,this.authorized$=new me(!1),this.params=t}async authorize(t){return this.authToken=t!=null?t:await this.refreshAuthToken(),this._authorizeWithBackoff()}logBeacon(t){const r="log.externalLog",n=this.createLogParams(t),a=this.sessionKey;if(!a)return;this.params.apiTransport.sendBeacon(r,n,a)||this.logRequest(t)}async logRequest(t){var r;const n="log.externalLog",a=this.createLogParams(t),i=(r=this.sessionKey)!==null&&r!==void 0?r:await this._authorizeWithBackoff();if(!i)return;const s=async(f,d=this.params.config.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(n,a,i)}catch(u){if(!u||!("error_code"in u)){this.params.error$.next({id:"logRequestUnknown",category:T.NETWORK,message:`Unknown ${n} error`,thrown:u});return}const o=u==null?void 0:u.error_code;switch(o){case M.PARAM_SESSION_EXPIRED:case M.PARAM_SESSION_KEY:case M.PARAM_SIGNATURE:return this.authorized$.next(!1),this.sessionKey=await this._authorizeWithBackoff(),d>0?s(f,d-1):void 0;case M.AUTH_LOGIN:return this.authorized$.next(!1),this.authToken=await this.refreshAuthToken(),this.sessionKey=await this._authorizeWithBackoff(),d>0?s(f,d-1):void 0;default:{this.params.error$.next({id:`LogRequest#${o}`,category:T.EXTERNAL_API,message:`${n} error`,data:u});return}}}};return s(t)}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}async refreshAuthToken(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=this.params.refreshAuthToken().finally(()=>{this.refreshAuthTokenPromise=void 0})),this.refreshAuthTokenPromise}createLogParams(t){return{collector:"ok.mobile.apps.video",data:JSON.stringify({application:`@vkontakte/videoplayer-statistics:${Dr}`,platform:this.params.mobile?"M_WEB":"WEB",items:this.params.config.shorten?t.map(rc):t})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();const t=Bn(this.consequentAuthErrors,this.params.config.backoff);return new Promise(r=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout(()=>{this._authorize().then(r).catch(n=>this.params.error$.next({id:"AuthorizeBackoff",category:T.NETWORK,message:"Otherwise unhandled error in authorization",thrown:n})).finally(()=>this.backoffTimeoutId=0)},t))})}async _authorize(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);const t="auth.anonymLogin",r={session_data:{version:2,device_id:this.params.uuid,client_version:Dr.split("-")[0],client_type:"SDK_JS"}};return this.authToken!==void 0&&(r.session_data.auth_token=this.authToken,r.session_data.version=3),this.authorizePromise=this.params.apiTransport.sendRequest(t,r).then(n=>{var a;return(!n||!n.session_key)&&this.params.error$.next({id:"AuthorizeFailed",category:T.EXTERNAL_API,message:"No session key",data:n}),this.sessionKey=(a=n==null?void 0:n.session_key)!==null&&a!==void 0?a:void 0,this.sessionKey}).catch(async n=>{this.sessionKey=void 0;const a=n==null?void 0:n.error_code;switch(a){case M.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this._authorizeWithBackoff()}a?this.params.error$.next({id:`Authorize#${a}`,category:T.EXTERNAL_API,message:"authorize error",data:n}):this.params.error$.next({id:"AuthorizeUnknown",category:T.NETWORK,message:"authorize error",thrown:n})}).finally(()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(this.sessionKey!==void 0)}),this.authorizePromise}}class jr{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(t,r,n){t in this.listeners||(this.listeners[t]=[]),this.listeners[t].push({callback:r,options:n})}removeEventListener(t,r){if(!(t in this.listeners))return;const n=this.listeners[t];for(let a=0,i=n.length;a<i;a++)if(n[a].callback===r){n.splice(a,1);return}}dispatchEvent(t){if(!(t.type in this.listeners))return;const n=this.listeners[t.type].slice();for(let a=0,i=n.length;a<i;a++){const s=n[a];try{s.callback.call(this,t)}catch(f){Promise.resolve().then(()=>{throw f})}s.options&&s.options.once&&this.removeEventListener(t.type,s.callback)}return!t.defaultPrevented}}class Cn extends jr{constructor(){super(),this.listeners||jr.call(this),Object.defineProperty(this,"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,"reason",{value:void 0,writable:!0,configurable:!0})}toString(){return"[object AbortSignal]"}dispatchEvent(t){t.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,t)),super.dispatchEvent(t)}}class oc{constructor(){Object.defineProperty(this,"signal",{value:new Cn,writable:!0,configurable:!0})}abort(t){let r;try{r=new Event("abort")}catch(a){typeof document!="undefined"?document.createEvent?(r=document.createEvent("Event"),r.initEvent("abort",!1,!1)):(r=document.createEventObject(),r.type="abort"):r={type:"abort",bubbles:!1,cancelable:!1}}let n=t;if(n===void 0)if(typeof document=="undefined")n=new Error("This operation was aborted"),n.name="AbortError";else try{n=new DOMException("signal is aborted without reason")}catch(a){n=new Error("This operation was aborted"),n.name="AbortError"}this.signal.reason=n,this.signal.dispatchEvent(r)}toString(){return"[object AbortController]"}}typeof Symbol!="undefined"&&Symbol.toStringTag&&(oc.prototype[Symbol.toStringTag]="AbortController",Cn.prototype[Symbol.toStringTag]="AbortSignal");function Dn(e){return e.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):typeof e.Request=="function"&&!e.Request.prototype.hasOwnProperty("signal")||!e.AbortController}function ic(e){typeof e=="function"&&(e={fetch:e});const{fetch:t,Request:r=t.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:a=!1}=e;if(!Dn({fetch:t,Request:r,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:a}))return{fetch:t,Request:i};let i=r;(i&&!i.prototype.hasOwnProperty("signal")||a)&&(i=function(u,o){let l;o&&o.signal&&(l=o.signal,delete o.signal);const c=new r(u,o);return l&&Object.defineProperty(c,"signal",{writable:!1,enumerable:!1,configurable:!0,value:l}),c},i.prototype=r.prototype);const s=t;return{fetch:(d,u)=>{const o=i&&i.prototype.isPrototypeOf(d)?d.signal:u?u.signal:void 0;if(o){let l;try{l=new DOMException("Aborted","AbortError")}catch(h){l=new Error("Aborted"),l.name="AbortError"}if(o.aborted)return Promise.reject(l);const c=new Promise((h,v)=>{o.addEventListener("abort",()=>v(l),{once:!0})});return u&&u.signal&&delete u.signal,Promise.race([c,s(d,u)])}return s(d,u)},Request:i}}const Ct=Dn({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),kn=Ct?ic({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,Fr=Ct?kn.fetch:window.fetch;Ct?kn.Request:window.Request;class sc{constructor(t){this.params=t,this.apiKey=t.apiKey,this.apiEnv=t.config.apiEnv,this.apiBaseUrl=kr[this.apiEnv],this.timeSynchronisation=t.timeSynchronisation,this.isApiBaseUrlFetched=!1}async resolveApiBaseUrl(){var t;if(this.apiEnv!==R.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const r=atob("aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ="),a=await(await Fr(r,{method:"GET",mode:"cors",cache:"no-cache"})).json(),i=(t=a==null?void 0:a.Answer[0])===null||t===void 0?void 0:t.data;if(!i)throw new Error("Wrong DNS response");return i}catch(r){return this.params.error$.next({id:"OneStat:ApiTransport:resolveApiBaseUrl",category:T.NETWORK,message:"Unhandled resolve api base url error",thrown:r}),kr[R.VK_ALIAS]}finally{this.isApiBaseUrlFetched=!0}}sendBeacon(t,r,n){if(!window.Blob||!window.navigator.sendBeacon)return!1;const a=this._prepareQueryParams({method:t,queryParams:r,sessionKey:n}),i=new window.Blob([a.toString()],{type:"application/x-www-form-urlencoded"});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,i)}catch(s){this.params.error$.next({id:"OneStat:ApiTransport:sendBeacon",category:T.NETWORK,message:"Unhandled beacon error",thrown:s,data:{method:t,params:r}})}return!1}async sendRequest(t,r,n){const a=S(),i=s=>{if(s instanceof TypeError&&["Failed to fetch","NetworkError when attempting to fetch resource."].includes(s.message)){this.params.error$.next({id:"Network",category:T.NETWORK,message:"Request failed",thrown:s});return}this.params.error$.next({id:"OneStat:ApiTransport:sendRequest",category:T.NETWORK,message:"Unhandled request error",thrown:s,data:{method:t,params:r,sessionKey:n,time:S()-a}})};return this.apiBaseUrl=await this.resolveApiBaseUrl(),Fr(`${this.apiBaseUrl}/fb.do`,{method:"post",headers:{"Content-type":"application/x-www-form-urlencoded"},body:this._prepareQueryParams({method:t,queryParams:r,sessionKey:n})}).then(s=>{var f,d;const u=Number(s.headers.get("content-length"))===0,o=new Date((f=s.headers.get("date"))!==null&&f!==void 0?f:"").getTime(),l=S()-a;if(isFinite(o)&&((d=this.timeSynchronisation)===null||d===void 0||d.addServerTime(o,l)),!u)return s.json().then(c=>Object.prototype.hasOwnProperty.call(c,"error_msg")?Promise.reject(c):c,i)},i)}_prepareQueryParams(t){const r=new URLSearchParams({format:"JSON",method:t.method,application_key:this.apiKey});return t.sessionKey!==void 0&&r.append("session_key",t.sessionKey),Object.entries(t.queryParams).forEach(([n,a])=>r.append(n,typeof a=="string"?a:JSON.stringify(a))),r}}const he="onestat_events",ot=e=>t=>t.timestamp+e>=S();class lc{constructor(t){this.unsaltedStorage=[],this.isPaused=!1,this.isUrgent=n=>{const{operation:a}=n;return["action_play","watch_coverage_record","watch_coverage_live"].includes(a)},this.params=t,this.api=t.api,this.error$=t.error$,this.userSalt=t.userSalt,this.loggerDebugLog=t.debugLogger.createComponentLog("stat logger"),this.firstFlush=Dt(()=>this.safeFlush(),this.params.config.firstFlushTime,{maxWait:this.params.config.firstFlushTime});const r=F.isPersistent()?this.params.config.flushMaxWait:0;this.debouncedFlush=Dt(()=>this.safeFlush(),this.params.config.flushDebounceTime,{maxWait:r}),this.subscription=this.api.authorized$.subscribe(n=>{n&&this.debouncedFlush()}),this.housekeepStorage()}safeFlush(){var t;try{this.flush()}catch(r){this.error$.next({id:"LoggerError",category:T.WTF,message:(t=String(r))!==null&&t!==void 0?t:"Unknown logger error",thrown:r})}}readFromStorage(){const t=F.get(he);try{return t?JSON.parse(t):{}}catch(r){}return{}}addToStorage(t){var r;if(!this.userSalt){this.unsaltedStorage.push(t);return}const n=this.readFromStorage(),i=((r=n[this.userSalt])!==null&&r!==void 0?r:[]).filter(ot(this.params.config.storageExpiration));F.set(he,JSON.stringify({...n,[this.userSalt]:[...i,t]}))}getFromStorage(){var t;return this.userSalt?((t=this.readFromStorage()[this.userSalt])!==null&&t!==void 0?t:[]).filter(ot(this.params.config.storageExpiration)):this.unsaltedStorage}markStorageSent(){if(!this.userSalt){this.unsaltedStorage=[];return}const t=this.readFromStorage();delete t[this.userSalt],F.set(he,JSON.stringify(t))}housekeepStorage(){const t=this.readFromStorage();for(const[r,n]of Object.entries(t)){const a=n.filter(ot(this.params.config.storageExpiration));a.length?t[r]=a:delete t[r],this.loggerDebugLog({message:`${n.length} retrieved from storage, ${a.length} of them actual`})}F.set(he,JSON.stringify(t))}log(t){this.addToStorage(t),!this.isPaused&&(this.isUrgent(t)?this.flush():this.lastVsid!==t.custom.vsid?this.firstFlush():this.debouncedFlush(),this.lastVsid=t.custom.vsid)}flush(t=!1){const r=this.getFromStorage();r.length!==0&&(this.api.authorized$.getValue()?(t&&this.params.config.useBeacon?(this.loggerDebugLog({message:`Flushing ${r.length} events through beacon`}),this.api.logBeacon(r)):(this.loggerDebugLog({message:`Flushing ${r.length} events`}),this.api.logRequest(r)),this.markStorageSent()):this.api.authorize(),this.firstFlush.cancel(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe(),this.firstFlush.cancel(),this.debouncedFlush.cancel()}}const uc=e=>e&&{[A.INVARIANT]:E.UNKNOWN,[A.Q_144P]:E.Q144P,[A.Q_240P]:E.Q240P,[A.Q_360P]:E.Q360P,[A.Q_480P]:E.Q480P,[A.Q_720P]:E.Q720P,[A.Q_1080P]:E.Q1080P,[A.Q_1440P]:E.Q1440P,[A.Q_2160P]:E.Q2160P,[A.Q_4320P]:E.UNKNOWN}[e],Mr=e=>e&&{[Ce.HTTP1]:ee.HTTP1,[Ce.HTTP2]:ee.HTTP2,[Ce.QUIC]:ee.HTTP3}[e],cc=e=>{if(e!==void 0)switch(e){case m.MPEG:return $.MP4;case m.DASH:case m.DASH_LIVE:return $.DASH;case m.DASH_SEP:return $.DASH_SEP;case m.DASH_ONDEMAND:return $.ONDEMAND_DASH;case m.DASH_WEBM:case m.DASH_LIVE_WEBM:return $.WEBM;case m.DASH_WEBM_AV1:return $.AV1;case m.DASH_LIVE_CMAF:return $.ONDEMAND_DASH_LIVE;case m.HLS:case m.HLS_LIVE:return $.HLS;case m.HLS_ONDEMAND:return $.ONDEMAND_HLS;case m.HLS_LIVE_CMAF:return $.ONDEMAND_HLS_LIVE;case m.WEB_RTC_LIVE:return $.WEBRTC;default:return Br(e)}},it=e=>{if(e!==void 0)switch(e){case Z.NONE:case Z.INLINE:return;case Z.FULLSCREEN:return B.FULLSCREEN;case Z.SECOND_SCREEN:return B.CHROMECAST;case Z.PIP:return B.PIP;default:return Br(e)}},fc=e=>{switch(e){case"slow-2g":return Q.POOR;case"2g":return Q.POOR;case"3g":return Q.GOOD;case"4g":return Q.EXCELLENT}};class dc{constructor(t){this.offset=void 0,this.offset=t}getOffset(){var t;return(t=this.offset)!==null&&t!==void 0?t:0}setOffset(t){this.offset=t}now(){var t;return Date.now()+((t=this.offset)!==null&&t!==void 0?t:0)}date(t=new Date){var r;return t.setTime(t.getTime()+((r=this.offset)!==null&&r!==void 0?r:0)),t}addServerTime(t,r){const n=Date.now(),a=t-n-r/2;if(Math.abs(a)<1e3){this.offset=0;return}this.offset===void 0?this.offset=Math.round(a):this.offset=Math.round(.2*a+(1-.2)*this.offset)}}const hc=()=>Math.floor(Math.random()*2**32).toString(36).padStart(8,"0"),vc=(e,t)=>new Un(r=>{const n=new $e,a=ve(ut(window,"beforeunload"),e.events.willDestruct$),i=new me(void 0);let s;n.add(e.info.isLive$.pipe(Gn()).subscribe(j=>{s&&(s.unsubscribe(),i.next(void 0)),j?s=e.info.liveTime$.pipe(Kn(xe=>xe&&xe/1e3)).subscribe(i):s=e.info.position$.subscribe(i),n.add(s)}));const{playing$:f,paused$:d}=e.events,u=e.events.willSeek$.pipe(kt(()=>e.info.playbackState$.getValue()===Ft.PLAYING)),o=e.events.seeked$.pipe(kt(()=>e.info.playbackState$.getValue()===Ft.PLAYING));let l=!1;const c=new pe;n.add(u.subscribe(()=>{l||c.next(),l=!0})),n.add(o.subscribe(()=>l=!1));const h=new pe,v=new pe,p=ve(f,o,h),b=ve(d,c,a,e.events.looped$,v);let g;const y=()=>g=i.getValue(),jn=()=>{const j=i.getValue();Se(g)||g===j||Se(j)||(r.next({from:g,to:j}),g=void 0)},Fn=()=>{v.next(),h.next()};if(n.add(p.subscribe(y)),n.add(b.subscribe(jn)),t.forceInterval&&isFinite(t.forceInterval)){let j=0;n.add(p.subscribe(()=>j=window.setTimeout(Fn,t.forceInterval))),n.add(b.subscribe(()=>window.clearTimeout(j)))}return n}),pc="_one-stat_",st=`${pc}uuid`,lt=()=>{const e=new $e;return{subscription:e,subscribe:(t,r)=>{t&&e.add(t.subscribe(r))}}};class yc{constructor(t,r){var n,a;this.subscription=new $e,this.debugLogger=new Vn,this.oneStatDebugLog=this.debugLogger.createComponentLog("onestat"),this.loopCounter=0,this.disabled=!1,this.vsid$=new me(void 0),this.seekAction$=new me(Te.UNKNOWN),this.statContext=t,this.config=ls((n=r.config)!==null&&n!==void 0?n:{}),V(r.apiEnv)&&(this.config.apiEnv=r.apiEnv),this.config.synchronizeTime&&(this.timeSynchronisation=new dc);const i=new pe;this.experimental={error$:i};const s=F.get(st);s?s.startsWith('"')&&s.endsWith('"')?(this.uuid=rs(s,'"',""),F.set(st,this.uuid)):this.uuid=s:(this.uuid=us(),F.set(st,this.uuid)),this.resetViewSession();const f=new sc({apiKey:nc,config:this.config,error$:i,timeSynchronisation:this.timeSynchronisation});this.api=new ac({config:this.config,apiTransport:f,refreshAuthToken:r.refreshAuthToken,mobile:(a=this.statContext.mobile)!==null&&a!==void 0?a:!1,uuid:this.uuid,error$:i}),this.logger=new lc({config:this.config,debugLogger:this.debugLogger,api:this.api,error$:i,userSalt:r.userSalt});const{isEmbed:d,host:u}=Wn();this.isEmbed=d,this.embedParent=u,this.subscribe()}updateContext(t){this.statContext={...this.statContext,...t}}attachTo(t){const r=new $e,n=(o,l)=>r.add(o.subscribe(l));n(t.events.willStart$,()=>{const o=t.info.position$.getValue();this.logActionPlay({position:o}),this.statContext.projectId&&this.logActionPlayWithProjectId({position:o})}),n(t.events.looped$,()=>{this.resetViewSession(),++this.loopCounter>this.config.maxLoops&&(this.disabled=!0),this.logActionPlay({position:t.info.position$.getValue()})}),n(t.events.seeked$,()=>{this.logSeek({action:this.seekAction$.getValue(),time:t.info.position$.getValue()}),this.seekAction$.next(Te.UNKNOWN)}),n(t.events.paused$,()=>{this.logPause({position:t.info.position$.getValue()})}),n(t.events.willResume$,()=>{this.logPlay()}),n(t.events.started$,()=>{this.statContext.clip&&this.logWatchCoverageRecord({start:0,end:0})}),n(vc(t,{forceInterval:this.config.watchCoverageInterval}),o=>{const l=t.info.isLive$.getValue(),c={start:parseFloat(o.from.toFixed(3)),end:parseFloat(o.to.toFixed(3))};l?this.logWatchCoverageLive(c):this.logWatchCoverageRecord(c)});let a;n(t.info.isStalled$,o=>{o?a=S():(V(a)&&this.logEmptyBuffer({duration:S()-a}),a=void 0)});let i=!1;r.add(t.events.fatalError$.pipe(Hn()).subscribe(()=>i=!0)),n(t.events.willStop$,()=>{if(t.info.isStalled$.getValue()){const l=V(a)?S()-a:void 0;this.logCloseAtEmptyBuffer({duration:l!=null?l:0}),a=void 0}else i||this.logActionStop()}),n(t.events.managedError$,({id:o})=>{this.logError({fatal:!1,errorType:o})}),n(t.events.fatalError$,({id:o})=>{this.logError({fatal:!0,errorType:o})});let s,f,d=!1;n(t.events.firstBytes$,o=>{s=S(),this.logFirstBytes({time:o})}),n(t.events.willStart$,()=>f=S()),n(t.info.currentBuffer$,o=>{!d&&o&&o.end-o.start>0&&V(s)&&(this.logPlayerReady({duration:S()-s}),d=!0)}),n(t.events.firstFrame$,()=>{V(s)&&!d&&(this.logPlayerReady({duration:S()-s}),d=!0),V(f)&&this.logFirstFrame({time:S()-f})}),n(t.info.atLiveEdge$,o=>this.updateContext({liveEdge:o})),n(jt({muted:t.info.muted$,volume:t.info.volume$}),({muted:o,volume:l})=>this.updateContext({audible:!o&&l>0})),n(t.info.currentQuality$,o=>this.updateContext({quality:uc(o)})),n(t.info.isAutoQualityEnabled$,o=>this.updateContext({autoQuality:o})),n(t.info.currentFormat$,o=>this.updateContext({contentType:cc(o)})),n(t.info.currentPlaybackRate$,o=>this.updateContext({rate:o})),n(t.info.is3DVideo$,o=>this.updateContext({is3d:o}));let u;return n(t.info.hostname$,o=>{this.updateContext({cdnHostname:o,failover:u!==void 0&&u!==o}),u=o}),n(t.info.throughputEstimation$,o=>this.updateContext({downloadSpeed:o})),n(t.info.httpConnectionType$,o=>{this.statContext.firstConnectionType||this.updateContext({firstConnectionType:Mr(o)}),this.updateContext({connectionType:Mr(o)})}),n(t.info.httpConnectionReused$,o=>{Se(this.statContext.firstConnectionReused)&&this.updateContext({firstConnectionReused:o}),this.updateContext({connectionReused:o})}),n(t.info.surface$,o=>this.updateContext({mode:it(o)})),n(jt({current:t.info.currentTextTrack$,available:t.info.availableTextTracks$}),({current:o,available:l})=>{const c=l.find(({id:v})=>v===o),h=c&&(c.isAuto?`${c.language}_auto`:c.language);this.updateContext({subtitles:h})}),this.player=t,this.uiEvents&&this.attachToUi(this.uiEvents),this.resubscribeBeforeunload(),this.subscription.add(r),r}attachToUi(t){this.uiEvents=t;const{subscription:r,subscribe:n}=lt();return this.player&&(n(t.actionRewind$,()=>{this.player&&(this.resetViewSession(),this.logActionPlay({position:this.player.info.position$.getValue()}))}),n(t.actionSeek$,this.seekAction$),n(t.inPiP$,a=>{var i;const s=a?B.PIP:it((i=this.player)===null||i===void 0?void 0:i.info.surface$.getValue());this.updateContext({mode:s})}),n(t.inFullscreen$,a=>{var i;const s=a?B.FULLSCREEN:it((i=this.player)===null||i===void 0?void 0:i.info.surface$.getValue());this.updateContext({mode:s})}),n(t.actionSetSubtitle$,a=>this.updateContext({subtitles:a})),n(t.nextMovie$,a=>this.logNextMovie(a)),this.resubscribeBeforeunload(),this.subscription.add(r)),r}attachToAds(t){const{subscription:r,subscribe:n}=lt();return n(t.slotRequested$,()=>this.logAdSlotRequest()),n(t.started$,a=>this.logAdStarted(a)),n(t.paused$,()=>this.logAdPaused()),n(t.resumed$,()=>this.logAdResumed()),n(t.ended$,()=>this.logAdEnded()),n(t.skipped$,()=>this.logAdSkipped()),n(t.clicked$,()=>this.logAdClicked()),this.resubscribeBeforeunload(),this.subscription.add(r),r}attachToInteractive(t){const{subscription:r,subscribe:n}=lt();return n(t.click$,a=>this.logInterfaceClick(a)),n(t.nextMovie$,a=>this.logNextMovie(a)),this.resubscribeBeforeunload(),this.subscription.add(r),r}authorize(t){return this.api.authorize(t)}pause(){this.logger.pause(),this.oneStatDebugLog({message:"paused"})}resume(){this.logger.resume(),this.oneStatDebugLog({message:"resumed"})}destroy(){this.logger.flush(),this.subscription.unsubscribe(),this.api.destroy(),this.logger.destroy()}resetViewSession(){this.oneStatDebugLog({message:"VSID reset"}),this.vsid$.next(hc())}getDeviceId(){return this.uuid}setFieldBlacklist(){}logInited(){}logReady(t){this.log({operation:"player_ready",param:String(t.time)})}logStarted(...t){this.logActionPlay(...t)}logPlay(){this.log({operation:"play_toggle"})}logPause(t){this.log({operation:"pause",param:String(Math.round(t.position))})}logSeek(t){this.log({operation:"seek",param:t.action,time:t.time})}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:"content_error",param:`${t.fatal?"fatal":"recoverable"}_${t.errorType}`})}logWatchCoverageRecord(t){this.log({operation:"watch_coverage_record",param:`${t.start}-${t.end}`})}logWatchCoverageLive(t){var r,n;const a=(n=(r=this.timeSynchronisation)===null||r===void 0?void 0:r.getOffset())!==null&&n!==void 0?n:0,i=t.start+a,s=t.end+a;this.log({operation:"watch_coverage_live",param:`${i}-${s}`})}logEmptyBuffer(t){this.log({operation:"empty_buffer",param:String(t.duration)})}logDownloadSpeed(){}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"})}logInterfaceClick(t){this.log({operation:"player_interface_click",param:t})}logNextMovie(t){this.log({operation:"next_movie",param:String(t)})}subscribe(){this.resubscribeBeforeunload();const t=window.navigator.connection;t&&"onchange"in t&&"effectiveType"in t&&this.subscription.add(ve(ut(t,"change"),qn(["init"])).subscribe(()=>this.updateContext({network:fc(t.effectiveType)}))),this.config.debugLog&&this.debugLogger.log$.subscribe(r=>{console.debug("%c stat ","background:#fa6470;",`component: ${r.component}.`,r.message)})}resubscribeBeforeunload(){var t;(t=this.beforeunloadSubscription)===null||t===void 0||t.unsubscribe(),this.beforeunloadSubscription=ut(window,"beforeunload").subscribe(()=>this.logger.flush(!0)),this.subscription.add(this.beforeunloadSubscription)}logPlayerReady(t){this.log({operation:"player_ready",param:String(Math.round(t.duration))})}logActionPlay(t){this.log({operation:"action_play",param:String(Math.round(t.position))})}logActionPlayWithProjectId(t){this.statContext.projectId&&this.log({operation:"action_play",param:String(Math.round(t.position))},{vid:this.statContext.projectId})}logCloseAtEmptyBuffer(t){this.log({operation:"close_at_empty_buffer",param:String(Math.round(t.duration))})}logActionStop(){this.log({operation:"action_stop"})}log(t,r={}){if(this.disabled){this.oneStatDebugLog({message:`operation ${t.operation} but statistics is disabled`});return}if(this.config.disabledOperations.includes(t.operation)){this.oneStatDebugLog({message:`operation ${t.operation} but it is disabled`});return}this.oneStatDebugLog({message:`operation ${t.operation} ${t.param}`});const n=this.createLogItem(t,r);this.logger.log(n)}createLogItem({operation:t,param:r,time:n},a={}){var i,s;const f=(s=(i=this.timeSynchronisation)===null||i===void 0?void 0:i.now())!==null&&s!==void 0?s:S(),d=this.vsid$.getValue();zn(d);const u=t==="empty_buffer"||t==="close_at_empty_buffer"?this.statContext.connectionType:this.statContext.firstConnectionType,o=this.statContext.firstConnectionReused;let l,c;if(this.isEmbed){l=this.embedParent;const v=[...new URLSearchParams(location.search).entries()].filter(([p,b])=>this.config.embedUrlParams.includes(p));c=new URLSearchParams(v).toString()}else this.statContext.place==="direct"&&(document.referrer&&(l=new URL(document.referrer).hostname),c=location.href.substring(0,1024));const h={vsid:d,vid:this.statContext.movieId,ct:this.statContext.contentType,place:this.isEmbed?"embed":this.statContext.place,quality:this.statContext.quality,cdn_host:this.statContext.cdnHostname,stat_type:this.statContext.autoplay===!0?_e.AUTO:this.statContext.autoplay===!1?_e.MANUAL:void 0,param:r,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode,connection_type:u,connection_reused:o===!0?L.YES:o===!1?L.NO:void 0,cached_data:this.statContext.cached===!0?L.YES:this.statContext.cached===!1?L.NO:void 0,live:this.statContext.liveEdge?L.YES:void 0,muted:this.statContext.audible===!1?L.YES:void 0,mode:this.statContext.mode,subtitles:this.statContext.subtitles,download_speed:this.statContext.downloadSpeed,manual_quality:this.statContext.autoQuality?void 0:L.YES,ref_domain:l,direct_url:c,rate:this.statContext.rate===1||Se(this.statContext.rate)?void 0:this.statContext.rate.toFixed(2),view_360:this.statContext.is3d?1:void 0,aid:this.statContext.albumId,vk_playlist_id:this.statContext.vkPlaylistId,...a};for(const v of this.config.disabledCustomFields)delete h[v];return{operation:t,type:1,time:n,network:this.statContext.network,timestamp:f,custom:h}}}export{R as ApiEnv,ee as ConnectionType,$ as ContentType,ur as InteractiveInterfaceClick,yc as OneStat,E as Quality,Te as SeekAction,Dr as VERSION};
|
|
6
|
+
import{fillWithDefault as Mn,ValueSubject as me,getExponentialDelay as Bn,ErrorCategory as T,now as S,debounceFn as Dt,safeStorage as F,assertNever as Br,Observable as Un,Subscription as $e,merge as ve,fromEvent as ut,filterChanged as Gn,map as Kn,filter as kt,Subject as pe,isNullable as Se,Logger as Vn,isNonNullable as V,detectEmbed as Wn,once as Hn,combine as jt,observableFrom as qn,assertNonNullable as zn}from"@vkontakte/videoplayer-shared/es2018.esm.js";import{Surface as Z,VideoQuality as A,HttpConnectionType as Ce,VideoFormat as m,PlaybackState as Ft}from"@vkontakte/videoplayer-core/es2018.esm.js";var De=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Ur(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var oe=function(e){return e&&e.Math==Math&&e},w=oe(typeof globalThis=="object"&&globalThis)||oe(typeof window=="object"&&window)||oe(typeof self=="object"&&self)||oe(typeof De=="object"&&De)||function(){return this}()||De||Function("return this")(),N=function(e){try{return!!e()}catch(t){return!0}},Yn=N,Pe=!Yn(function(){var e=function(){}.bind();return typeof e!="function"||e.hasOwnProperty("prototype")}),Qn=Pe,Gr=Function.prototype,Mt=Gr.apply,Bt=Gr.call,Xn=typeof Reflect=="object"&&Reflect.apply||(Qn?Bt.bind(Mt):function(){return Bt.apply(Mt,arguments)}),Kr=Pe,Vr=Function.prototype,ct=Vr.call,Jn=Kr&&Vr.bind.bind(ct,ct),C=Kr?Jn:function(e){return function(){return ct.apply(e,arguments)}},Wr=C,Zn=Wr({}.toString),ea=Wr("".slice),Ae=function(e){return ea(Zn(e),8,-1)},ta=Ae,ra=C,Hr=function(e){if(ta(e)==="Function")return ra(e)},ft=typeof document=="object"&&document.all,na=typeof ft=="undefined"&&ft!==void 0,qr={all:ft,IS_HTMLDDA:na},zr=qr,aa=zr.all,_=zr.IS_HTMLDDA?function(e){return typeof e=="function"||e===aa}:function(e){return typeof e=="function"},Yr={},oa=N,U=!oa(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),ia=Pe,ie=Function.prototype.call,D=ia?ie.bind(ie):function(){return ie.apply(ie,arguments)},Qr={},Xr={}.propertyIsEnumerable,Jr=Object.getOwnPropertyDescriptor,sa=Jr&&!Xr.call({1:2},1);Qr.f=sa?function(t){var r=Jr(this,t);return!!r&&r.enumerable}:Xr;var Ie=function(e,t){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:t}},la=C,ua=N,ca=Ae,ke=Object,fa=la("".split),da=ua(function(){return!ke("z").propertyIsEnumerable(0)})?function(e){return ca(e)=="String"?fa(e,""):ke(e)}:ke,Re=function(e){return e==null},ha=Re,va=TypeError,mt=function(e){if(ha(e))throw va("Can't call method on "+e);return e},pa=da,ga=mt,re=function(e){return pa(ga(e))},Ut=_,Zr=qr,ba=Zr.all,G=Zr.IS_HTMLDDA?function(e){return typeof e=="object"?e!==null:Ut(e)||e===ba}:function(e){return typeof e=="object"?e!==null:Ut(e)},$t={},je=$t,Fe=w,ya=_,Gt=function(e){return ya(e)?e:void 0},St=function(e,t){return arguments.length<2?Gt(je[e])||Gt(Fe[e]):je[e]&&je[e][t]||Fe[e]&&Fe[e][t]},ma=C,Et=ma({}.isPrototypeOf),$a=typeof navigator!="undefined"&&String(navigator.userAgent)||"",en=w,Me=$a,Kt=en.process,Vt=en.Deno,Wt=Kt&&Kt.versions||Vt&&Vt.version,Ht=Wt&&Wt.v8,O,Ee;Ht&&(O=Ht.split("."),Ee=O[0]>0&&O[0]<4?1:+(O[0]+O[1]));!Ee&&Me&&(O=Me.match(/Edge\/(\d+)/),(!O||O[1]>=74)&&(O=Me.match(/Chrome\/(\d+)/),O&&(Ee=+O[1])));var Sa=Ee,qt=Sa,Ea=N,_a=w,Ta=_a.String,tn=!!Object.getOwnPropertySymbols&&!Ea(function(){var e=Symbol();return!Ta(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&qt&&qt<41}),Oa=tn,rn=Oa&&!Symbol.sham&&typeof Symbol.iterator=="symbol",wa=St,Pa=_,Aa=Et,Ia=rn,Ra=Object,nn=Ia?function(e){return typeof e=="symbol"}:function(e){var t=wa("Symbol");return Pa(t)&&Aa(t.prototype,Ra(e))},La=String,_t=function(e){try{return La(e)}catch(t){return"Object"}},xa=_,Na=_t,Ca=TypeError,Tt=function(e){if(xa(e))return e;throw Ca(Na(e)+" is not a function")},Da=Tt,ka=Re,Le=function(e,t){var r=e[t];return ka(r)?void 0:Da(r)},Be=D,Ue=_,Ge=G,ja=TypeError,Fa=function(e,t){var r,n;if(t==="string"&&Ue(r=e.toString)&&!Ge(n=Be(r,e))||Ue(r=e.valueOf)&&!Ge(n=Be(r,e))||t!=="string"&&Ue(r=e.toString)&&!Ge(n=Be(r,e)))return n;throw ja("Can't convert object to primitive value")},an={exports:{}},zt=w,Ma=Object.defineProperty,Ba=function(e,t){try{Ma(zt,e,{value:t,configurable:!0,writable:!0})}catch(r){zt[e]=t}return t},Ua=w,Ga=Ba,Yt="__core-js_shared__",Ka=Ua[Yt]||Ga(Yt,{}),on=Ka,Qt=on;(an.exports=function(e,t){return Qt[e]||(Qt[e]=t!==void 0?t:{})})("versions",[]).push({version:"3.31.0",mode:"pure",copyright:"\xA9 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.31.0/LICENSE",source:"https://github.com/zloirock/core-js"});var sn=an.exports,Va=mt,Wa=Object,Ot=function(e){return Wa(Va(e))},Ha=C,qa=Ot,za=Ha({}.hasOwnProperty),k=Object.hasOwn||function(t,r){return za(qa(t),r)},Ya=C,Qa=0,Xa=Math.random(),Ja=Ya(1 .toString),ln=function(e){return"Symbol("+(e===void 0?"":e)+")_"+Ja(++Qa+Xa,36)},Za=w,eo=sn,Xt=k,to=ln,ro=tn,no=rn,Y=Za.Symbol,Ke=eo("wks"),ao=no?Y.for||Y:Y&&Y.withoutSetter||to,P=function(e){return Xt(Ke,e)||(Ke[e]=ro&&Xt(Y,e)?Y[e]:ao("Symbol."+e)),Ke[e]},oo=D,Jt=G,Zt=nn,io=Le,so=Fa,lo=P,uo=TypeError,co=lo("toPrimitive"),fo=function(e,t){if(!Jt(e)||Zt(e))return e;var r=io(e,co),n;if(r){if(t===void 0&&(t="default"),n=oo(r,e,t),!Jt(n)||Zt(n))return n;throw uo("Can't convert object to primitive value")}return t===void 0&&(t="number"),so(e,t)},ho=fo,vo=nn,wt=function(e){var t=ho(e,"string");return vo(t)?t:t+""},po=w,er=G,dt=po.document,go=er(dt)&&er(dt.createElement),un=function(e){return go?dt.createElement(e):{}},bo=U,yo=N,mo=un,cn=!bo&&!yo(function(){return Object.defineProperty(mo("div"),"a",{get:function(){return 7}}).a!=7}),$o=U,So=D,Eo=Qr,_o=Ie,To=re,Oo=wt,wo=k,Po=cn,tr=Object.getOwnPropertyDescriptor;Yr.f=$o?tr:function(t,r){if(t=To(t),r=Oo(r),Po)try{return tr(t,r)}catch(n){}if(wo(t,r))return _o(!So(Eo.f,t,r),t[r])};var Ao=N,Io=_,Ro=/#|\.prototype\./,ne=function(e,t){var r=xo[Lo(e)];return r==Co?!0:r==No?!1:Io(t)?Ao(t):!!t},Lo=ne.normalize=function(e){return String(e).replace(Ro,".").toLowerCase()},xo=ne.data={},No=ne.NATIVE="N",Co=ne.POLYFILL="P",Do=ne,rr=Hr,ko=Tt,jo=Pe,Fo=rr(rr.bind),fn=function(e,t){return ko(e),t===void 0?e:jo?Fo(e,t):function(){return e.apply(t,arguments)}},X={},Mo=U,Bo=N,dn=Mo&&Bo(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),Uo=G,Go=String,Ko=TypeError,K=function(e){if(Uo(e))return e;throw Ko(Go(e)+" is not an object")},Vo=U,Wo=cn,Ho=dn,se=K,nr=wt,qo=TypeError,Ve=Object.defineProperty,zo=Object.getOwnPropertyDescriptor,We="enumerable",He="configurable",qe="writable";X.f=Vo?Ho?function(t,r,n){if(se(t),r=nr(r),se(n),typeof t=="function"&&r==="prototype"&&"value"in n&&qe in n&&!n[qe]){var a=zo(t,r);a&&a[qe]&&(t[r]=n.value,n={configurable:He in n?n[He]:a[He],enumerable:We in n?n[We]:a[We],writable:!1})}return Ve(t,r,n)}:Ve:function(t,r,n){if(se(t),r=nr(r),se(n),Wo)try{return Ve(t,r,n)}catch(a){}if("get"in n||"set"in n)throw qo("Accessors not supported");return"value"in n&&(t[r]=n.value),t};var Yo=U,Qo=X,Xo=Ie,ae=Yo?function(e,t,r){return Qo.f(e,t,Xo(1,r))}:function(e,t,r){return e[t]=r,e},le=w,Jo=Xn,Zo=Hr,ei=_,ti=Yr.f,ri=Do,W=$t,ni=fn,H=ae,ar=k,ai=function(e){var t=function(r,n,a){if(this instanceof t){switch(arguments.length){case 0:return new e;case 1:return new e(r);case 2:return new e(r,n)}return new e(r,n,a)}return Jo(e,this,arguments)};return t.prototype=e.prototype,t},Pt=function(e,t){var r=e.target,n=e.global,a=e.stat,i=e.proto,s=n?le:a?le[r]:(le[r]||{}).prototype,f=n?W:W[r]||H(W,r,{})[r],d=f.prototype,u,o,l,c,h,v,p,b,g;for(c in t)u=ri(n?c:r+(a?".":"#")+c,e.forced),o=!u&&s&&ar(s,c),v=f[c],o&&(e.dontCallGetSet?(g=ti(s,c),p=g&&g.value):p=s[c]),h=o&&p?p:t[c],!(o&&typeof v==typeof h)&&(e.bind&&o?b=ni(h,le):e.wrap&&o?b=ai(h):i&&ei(h)?b=Zo(h):b=h,(e.sham||h&&h.sham||v&&v.sham)&&H(b,"sham",!0),H(f,c,b),i&&(l=r+"Prototype",ar(W,l)||H(W,l,{}),H(W[l],c,h),e.real&&d&&(u||!d[c])&&H(d,c,h)))},oi=G,ii=Ae,si=P,li=si("match"),ui=function(e){var t;return oi(e)&&((t=e[li])!==void 0?!!t:ii(e)=="RegExp")},ci=P,fi=ci("toStringTag"),hn={};hn[fi]="z";var At=String(hn)==="[object z]",di=At,hi=_,ge=Ae,vi=P,pi=vi("toStringTag"),gi=Object,bi=ge(function(){return arguments}())=="Arguments",yi=function(e,t){try{return e[t]}catch(r){}},xe=di?ge:function(e){var t,r,n;return e===void 0?"Undefined":e===null?"Null":typeof(r=yi(t=gi(e),pi))=="string"?r:bi?ge(t):(n=ge(t))=="Object"&&hi(t.callee)?"Arguments":n},mi=xe,$i=String,Si=function(e){if(mi(e)==="Symbol")throw TypeError("Cannot convert a Symbol value to a string");return $i(e)},Ei=K,_i=function(){var e=Ei(this),t="";return e.hasIndices&&(t+="d"),e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.unicodeSets&&(t+="v"),e.sticky&&(t+="y"),t},Ti=D,Oi=k,wi=Et,Pi=_i,or=RegExp.prototype,Ai=function(e){var t=e.flags;return t===void 0&&!("flags"in or)&&!Oi(e,"flags")&&wi(or,e)?Ti(Pi,e):t},It=C,Ii=Ot,Ri=Math.floor,ze=It("".charAt),Li=It("".replace),Ye=It("".slice),xi=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,Ni=/\$([$&'`]|\d{1,2})/g,Ci=function(e,t,r,n,a,i){var s=r+e.length,f=n.length,d=Ni;return a!==void 0&&(a=Ii(a),d=xi),Li(i,d,function(u,o){var l;switch(ze(o,0)){case"$":return"$";case"&":return e;case"`":return Ye(t,0,r);case"'":return Ye(t,s);case"<":l=a[Ye(o,1,-1)];break;default:var c=+o;if(c===0)return u;if(c>f){var h=Ri(c/10);return h===0?u:h<=f?n[h-1]===void 0?ze(o,1):n[h-1]+ze(o,1):u}l=n[c-1]}return l===void 0?"":l})},Di=Pt,ki=D,Rt=C,ir=mt,ji=_,Fi=Re,Mi=ui,q=Si,Bi=Le,Ui=Ai,Gi=Ci,Ki=P,Vi=Ki("replace"),Wi=TypeError,vn=Rt("".indexOf),Hi=Rt("".replace),sr=Rt("".slice),qi=Math.max,lr=function(e,t,r){return r>e.length?-1:t===""?r:vn(e,t,r)};Di({target:"String",proto:!0},{replaceAll:function(t,r){var n=ir(this),a,i,s,f,d,u,o,l,c,h=0,v=0,p="";if(!Fi(t)){if(a=Mi(t),a&&(i=q(ir(Ui(t))),!~vn(i,"g")))throw Wi("`.replaceAll` does not allow non-global regexes");if(s=Bi(t,Vi),s)return ki(s,t,n,r);if(a)return Hi(q(n),t,r)}for(f=q(n),d=q(t),u=ji(r),u||(r=q(r)),o=d.length,l=qi(1,o),h=lr(f,d,0);h!==-1;)c=u?q(r(d,h,f)):Gi(d,f,h,[],void 0,r),p+=sr(f,v,h)+c,v=h+o,h=lr(f,d,h+l);return v<f.length&&(p+=sr(f,v)),p}});var zi=St,Yi=zi,Qi=Yi,Xi=Qi("String","replaceAll"),Ji=Xi,Zi=Ji,es=Zi,ts=es,rs=Ur(ts),R;(function(e){e.PROD="prod",e.VK_ALIAS="vk_alias",e.VIDEOTEST="videotest",e.TEST="test",e.AUTO="auto"})(R||(R={}));var E;(function(e){e.Q144P="mobile",e.Q240P="lowest",e.Q360P="low",e.Q480P="medium",e.Q720P="high",e.Q1080P="fullhd",e.Q1440P="quadhd",e.Q2160P="ultrahd",e.UNKNOWN="unknown"})(E||(E={}));var $;(function(e){e.MP4="mp4",e.DASH="dash",e.DASH_SEP="dash_sep",e.ONDEMAND_DASH="ondemand_dash",e.HLS="hls",e.ONDEMAND_HLS="ondemand_hls",e.WEBM="webm",e.AV1="av1",e.ONDEMAND_DASH_LIVE="ondemand_dash_live",e.ONDEMAND_HLS_LIVE="ondemand_hls_live",e.WEBRTC="webrtc",e.UNKNOWN="unknown",e.RTMP="rtmp"})($||($={}));var _e;(function(e){e.AUTO="auto",e.MANUAL=""})(_e||(_e={}));var ee;(function(e){e.HTTP1="http1",e.HTTP2="http2",e.HTTP3="http3"})(ee||(ee={}));var L;(function(e){e[e.YES=1]="YES",e[e.NO=0]="NO"})(L||(L={}));var Q;(function(e){e.EXCELLENT="excellent",e.GOOD="good",e.POOR="poor"})(Q||(Q={}));var B;(function(e){e.PIP="pip",e.FULLSCREEN="fullscreen",e.EXTERNAL="external",e.PREFETCH="prefetch",e.AIRPLAY="airplay",e.CHROMECAST="chromecast",e.INVISIBLE="invisible"})(B||(B={}));var Te;(function(e){e.SLIDER="slider",e.DOUBLE_TAP="double_tap",e.TIME_CODE="time_code",e.EPISODE="episode",e.REWIND="rewind",e.LIVE="live",e.UNKNOWN="unknown"})(Te||(Te={}));var ur;(function(e){e.GRAPH_SHOW="iGraphShow",e.GRAPH_HIDE="iGraphHide",e.NEXT_AREA="iNextChapterArea",e.NEXT_BUTTON="iNextChapterBtn",e.WATCH_AGAIN="iWatchAgainBtn"})(ur||(ur={}));const ns={action_play:"ap",first_bytes:"fb",player_ready:"pr",first_frame:"ff",seek:"sk",watch_coverage_record:"wr",watch_coverage_live:"wl",empty_buffer:"eb",action_stop:"as",close_at_empty_buffer:"cb",content_error:"er",player_interface_click:"pc",next_movie:"nm",track_switch:"ts"},as={vsid:"si",vid:"vi",place:"pl",quality:"qt",cdn_host:"ch",stat_type:"st",param:"pm",vk_app_id:"va",track_code:"tc",connection_type:"cnt",connection_reused:"cr",cached_data:"cd",live:"lv",muted:"mu",mode:"mo",subtitles:"sb",failover:"fo",download_speed:"ds",manual_quality:"mq",ref_domain:"rd",direct_url:"du"},os={unknown:"un",mobile:"m",lowest:"ls",low:"l",medium:"md",high:"h",fullhd:"f",quadhd:"q",ultrahd:"u"},is={pip:"pi",fullscreen:"fs",external:"ex",prefetch:"pr",airplay:"ap",chromecast:"cc",invisible:"iv"},ss={apiEnv:R.VK_ALIAS,requestRetryCount:1,firstFlushTime:5e3,flushDebounceTime:1e4,flushMaxWait:6e4,storageExpiration:36*60*60*1e3,watchCoverageInterval:15e3,disabledOperations:[],disabledCustomFields:[],shorten:!0,maxLoops:100,embedUrlParams:[],useBeacon:!0,synchronizeTime:!0,debugLog:!1,backoff:{start:1e3,factor:1.5,max:5*60*1e3,random:.1}},ls=e=>Mn(e,ss);function us(){const e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),t=new Array(36);let r=0,n,a;for(a=0;a<36;a++)a===8||a===13||a===18||a===23?t[a]="-":a===14?t[a]="4":(r<=2&&(r=33554432+Math.random()*16777216|0),n=r&15,r=r>>4,t[a]=e[a===19?n&3|8:n]);return t.join("")}var J={},cs=w,fs=_,cr=cs.WeakMap,ds=fs(cr)&&/native code/.test(String(cr)),hs=sn,vs=ln,fr=hs("keys"),Lt=function(e){return fr[e]||(fr[e]=vs(e))},xt={},ps=ds,pn=w,gs=G,bs=ae,Qe=k,Xe=on,ys=Lt,ms=xt,dr="Object already initialized",ht=pn.TypeError,$s=pn.WeakMap,Oe,te,we,Ss=function(e){return we(e)?te(e):Oe(e,{})},Es=function(e){return function(t){var r;if(!gs(t)||(r=te(t)).type!==e)throw ht("Incompatible receiver, "+e+" required");return r}};if(ps||Xe.state){var I=Xe.state||(Xe.state=new $s);I.get=I.get,I.has=I.has,I.set=I.set,Oe=function(e,t){if(I.has(e))throw ht(dr);return t.facade=e,I.set(e,t),t},te=function(e){return I.get(e)||{}},we=function(e){return I.has(e)}}else{var z=ys("state");ms[z]=!0,Oe=function(e,t){if(Qe(e,z))throw ht(dr);return t.facade=e,bs(e,z,t),t},te=function(e){return Qe(e,z)?e[z]:{}},we=function(e){return Qe(e,z)}}var _s={set:Oe,get:te,has:we,enforce:Ss,getterFor:Es},vt=U,Ts=k,gn=Function.prototype,Os=vt&&Object.getOwnPropertyDescriptor,Nt=Ts(gn,"name"),ws=Nt&&function(){}.name==="something",Ps=Nt&&(!vt||vt&&Os(gn,"name").configurable),As={EXISTS:Nt,PROPER:ws,CONFIGURABLE:Ps},bn={},Is=Math.ceil,Rs=Math.floor,Ls=Math.trunc||function(t){var r=+t;return(r>0?Rs:Is)(r)},xs=Ls,yn=function(e){var t=+e;return t!==t||t===0?0:xs(t)},Ns=yn,Cs=Math.max,Ds=Math.min,ks=function(e,t){var r=Ns(e);return r<0?Cs(r+t,0):Ds(r,t)},js=yn,Fs=Math.min,Ms=function(e){return e>0?Fs(js(e),9007199254740991):0},Bs=Ms,mn=function(e){return Bs(e.length)},Us=re,Gs=ks,Ks=mn,hr=function(e){return function(t,r,n){var a=Us(t),i=Ks(a),s=Gs(n,i),f;if(e&&r!=r){for(;i>s;)if(f=a[s++],f!=f)return!0}else for(;i>s;s++)if((e||s in a)&&a[s]===r)return e||s||0;return!e&&-1}},Vs={includes:hr(!0),indexOf:hr(!1)},Ws=C,Je=k,Hs=re,qs=Vs.indexOf,zs=xt,vr=Ws([].push),Ys=function(e,t){var r=Hs(e),n=0,a=[],i;for(i in r)!Je(zs,i)&&Je(r,i)&&vr(a,i);for(;t.length>n;)Je(r,i=t[n++])&&(~qs(a,i)||vr(a,i));return a},$n=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Qs=Ys,Xs=$n,Js=Object.keys||function(t){return Qs(t,Xs)},Zs=U,el=dn,tl=X,rl=K,nl=re,al=Js;bn.f=Zs&&!el?Object.defineProperties:function(t,r){rl(t);for(var n=nl(r),a=al(r),i=a.length,s=0,f;i>s;)tl.f(t,f=a[s++],n[f]);return t};var ol=St,il=ol("document","documentElement"),sl=K,ll=bn,pr=$n,ul=xt,cl=il,fl=un,dl=Lt,gr=">",br="<",pt="prototype",gt="script",Sn=dl("IE_PROTO"),Ze=function(){},En=function(e){return br+gt+gr+e+br+"/"+gt+gr},yr=function(e){e.write(En("")),e.close();var t=e.parentWindow.Object;return e=null,t},hl=function(){var e=fl("iframe"),t="java"+gt+":",r;return e.style.display="none",cl.appendChild(e),e.src=String(t),r=e.contentWindow.document,r.open(),r.write(En("document.F=Object")),r.close(),r.F},ue,be=function(){try{ue=new ActiveXObject("htmlfile")}catch(t){}be=typeof document!="undefined"?document.domain&&ue?yr(ue):hl():yr(ue);for(var e=pr.length;e--;)delete be[pt][pr[e]];return be()};ul[Sn]=!0;var _n=Object.create||function(t,r){var n;return t!==null?(Ze[pt]=sl(t),n=new Ze,Ze[pt]=null,n[Sn]=t):n=be(),r===void 0?n:ll.f(n,r)},vl=N,pl=!vl(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}),gl=k,bl=_,yl=Ot,ml=Lt,$l=pl,mr=ml("IE_PROTO"),bt=Object,Sl=bt.prototype,Tn=$l?bt.getPrototypeOf:function(e){var t=yl(e);if(gl(t,mr))return t[mr];var r=t.constructor;return bl(r)&&t instanceof r?r.prototype:t instanceof bt?Sl:null},El=ae,On=function(e,t,r,n){return n&&n.enumerable?e[t]=r:El(e,t,r),e},_l=N,Tl=_,Ol=G,wl=_n,$r=Tn,Pl=On,Al=P,yt=Al("iterator"),wn=!1,x,et,tt;[].keys&&(tt=[].keys(),"next"in tt?(et=$r($r(tt)),et!==Object.prototype&&(x=et)):wn=!0);var Il=!Ol(x)||_l(function(){var e={};return x[yt].call(e)!==e});Il?x={}:x=wl(x);Tl(x[yt])||Pl(x,yt,function(){return this});var Pn={IteratorPrototype:x,BUGGY_SAFARI_ITERATORS:wn},Rl=At,Ll=xe,xl=Rl?{}.toString:function(){return"[object "+Ll(this)+"]"},Nl=At,Cl=X.f,Dl=ae,kl=k,jl=xl,Fl=P,Sr=Fl("toStringTag"),An=function(e,t,r,n){if(e){var a=r?e:e.prototype;kl(a,Sr)||Cl(a,Sr,{configurable:!0,value:t}),n&&!Nl&&Dl(a,"toString",jl)}},Ml=Pn.IteratorPrototype,Bl=_n,Ul=Ie,Gl=An,Kl=J,Vl=function(){return this},Wl=function(e,t,r,n){var a=t+" Iterator";return e.prototype=Bl(Ml,{next:Ul(+!n,r)}),Gl(e,a,!1,!0),Kl[a]=Vl,e},Hl=Pt,ql=D,In=As,zl=Wl,Yl=Tn,Ql=An,Er=On,Xl=P,_r=J,Rn=Pn,Jl=In.PROPER;In.CONFIGURABLE;Rn.IteratorPrototype;var ce=Rn.BUGGY_SAFARI_ITERATORS,rt=Xl("iterator"),Tr="keys",fe="values",Or="entries",Zl=function(){return this},eu=function(e,t,r,n,a,i,s){zl(r,t,n);var f=function(g){if(g===a&&c)return c;if(!ce&&g in o)return o[g];switch(g){case Tr:return function(){return new r(this,g)};case fe:return function(){return new r(this,g)};case Or:return function(){return new r(this,g)}}return function(){return new r(this)}},d=t+" Iterator",u=!1,o=e.prototype,l=o[rt]||o["@@iterator"]||a&&o[a],c=!ce&&l||f(a),h=t=="Array"&&o.entries||l,v,p,b;if(h&&(v=Yl(h.call(new e)),v!==Object.prototype&&v.next&&(Ql(v,d,!0,!0),_r[d]=Zl)),Jl&&a==fe&&l&&l.name!==fe&&(u=!0,c=function(){return ql(l,this)}),a)if(p={values:f(fe),keys:i?c:f(Tr),entries:f(Or)},s)for(b in p)(ce||u||!(b in o))&&Er(o,b,p[b]);else Hl({target:t,proto:!0,forced:ce||u},p);return s&&o[rt]!==c&&Er(o,rt,c,{name:a}),_r[t]=c,p},tu=function(e,t){return{value:e,done:t}},ru=re,wr=J,Ln=_s;X.f;var nu=eu,de=tu,xn="Array Iterator",au=Ln.set,ou=Ln.getterFor(xn);nu(Array,"Array",function(e,t){au(this,{type:xn,target:ru(e),index:0,kind:t})},function(){var e=ou(this),t=e.target,r=e.kind,n=e.index++;return!t||n>=t.length?(e.target=void 0,de(void 0,!0)):r=="keys"?de(n,!1):r=="values"?de(t[n],!1):de([n,t[n]],!1)},"values");wr.Arguments=wr.Array;var iu=P,su=J,lu=iu("iterator"),uu=Array.prototype,cu=function(e){return e!==void 0&&(su.Array===e||uu[lu]===e)},fu=xe,Pr=Le,du=Re,hu=J,vu=P,pu=vu("iterator"),Nn=function(e){if(!du(e))return Pr(e,pu)||Pr(e,"@@iterator")||hu[fu(e)]},gu=D,bu=Tt,yu=K,mu=_t,$u=Nn,Su=TypeError,Eu=function(e,t){var r=arguments.length<2?$u(e):t;if(bu(r))return yu(gu(r,e));throw Su(mu(e)+" is not iterable")},_u=D,Ar=K,Tu=Le,Ou=function(e,t,r){var n,a;Ar(e);try{if(n=Tu(e,"return"),!n){if(t==="throw")throw r;return r}n=_u(n,e)}catch(i){a=!0,n=i}if(t==="throw")throw r;if(a)throw n;return Ar(n),r},wu=fn,Pu=D,Au=K,Iu=_t,Ru=cu,Lu=mn,Ir=Et,xu=Eu,Nu=Nn,Rr=Ou,Cu=TypeError,ye=function(e,t){this.stopped=e,this.result=t},Lr=ye.prototype,Du=function(e,t,r){var n=r&&r.that,a=!!(r&&r.AS_ENTRIES),i=!!(r&&r.IS_RECORD),s=!!(r&&r.IS_ITERATOR),f=!!(r&&r.INTERRUPTED),d=wu(t,n),u,o,l,c,h,v,p,b=function(y){return u&&Rr(u,"normal",y),new ye(!0,y)},g=function(y){return a?(Au(y),f?d(y[0],y[1],b):d(y[0],y[1])):f?d(y,b):d(y)};if(i)u=e.iterator;else if(s)u=e;else{if(o=Nu(e),!o)throw Cu(Iu(e)+" is not iterable");if(Ru(o)){for(l=0,c=Lu(e);c>l;l++)if(h=g(e[l]),h&&Ir(Lr,h))return h;return new ye(!1)}u=xu(e,o)}for(v=i?e.next:u.next;!(p=Pu(v,u)).done;){try{h=g(p.value)}catch(y){Rr(u,"throw",y)}if(typeof h=="object"&&h&&Ir(Lr,h))return h}return new ye(!1)},ku=wt,ju=X,Fu=Ie,Mu=function(e,t,r){var n=ku(t);n in e?ju.f(e,n,Fu(0,r)):e[n]=r},Bu=Pt,Uu=Du,Gu=Mu;Bu({target:"Object",stat:!0},{fromEntries:function(t){var r={};return Uu(t,function(n,a){Gu(r,n,a)},{AS_ENTRIES:!0}),r}});var Ku=$t,Vu=Ku.Object.fromEntries,Wu={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},Hu=Wu,qu=w,zu=xe,Yu=ae,xr=J,Qu=P,Nr=Qu("toStringTag");for(var nt in Hu){var Cr=qu[nt],at=Cr&&Cr.prototype;at&&zu(at)!==Nr&&Yu(at,Nr,nt),xr[nt]=xr.Array}var Xu=Vu,Ju=Xu,Zu=Ju,ec=Zu,tc=Ur(ec);const rc=e=>{var t;const{operation:r,custom:n}=e,a=tc(Object.entries(n).map(([i,s])=>{var f,d,u;const o=(f=as[i])!==null&&f!==void 0?f:i;let l=s;return s&&(i==="mode"?l=(d=is[s])!==null&&d!==void 0?d:s:i==="quality"&&(l=(u=os[s])!==null&&u!==void 0?u:s)),[o,l]}));return{...e,operation:(t=ns[r])!==null&&t!==void 0?t:r,custom:a}},Dr="1.0.46-dev.df8758f1.0",nc="CIOPGQJGDIHBABABA",kr={[R.PROD]:"https://api.ok.ru",[R.VK_ALIAS]:"https://api.mycdn.me",[R.VIDEOTEST]:"https://videotestapi.ok.ru/api",[R.TEST]:"https://apitest.ok.ru",[R.AUTO]:""};var M;(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"})(M||(M={}));class ac{constructor(t){this.consequentAuthErrors=0,this.authorized$=new me(!1),this.params=t}async authorize(t){return this.authToken=t!=null?t:await this.refreshAuthToken(),this._authorizeWithBackoff()}logBeacon(t){const r="log.externalLog",n=this.createLogParams(t),a=this.sessionKey;if(!a)return;this.params.apiTransport.sendBeacon(r,n,a)||this.logRequest(t)}async logRequest(t){var r;const n="log.externalLog",a=this.createLogParams(t),i=(r=this.sessionKey)!==null&&r!==void 0?r:await this._authorizeWithBackoff();if(!i)return;const s=async(f,d=this.params.config.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(n,a,i)}catch(u){if(!u||!("error_code"in u)){this.params.error$.next({id:"logRequestUnknown",category:T.NETWORK,message:`Unknown ${n} error`,thrown:u});return}const o=u==null?void 0:u.error_code;switch(o){case M.PARAM_SESSION_EXPIRED:case M.PARAM_SESSION_KEY:case M.PARAM_SIGNATURE:return this.authorized$.next(!1),this.sessionKey=await this._authorizeWithBackoff(),d>0?s(f,d-1):void 0;case M.AUTH_LOGIN:return this.authorized$.next(!1),this.authToken=await this.refreshAuthToken(),this.sessionKey=await this._authorizeWithBackoff(),d>0?s(f,d-1):void 0;default:{this.params.error$.next({id:`LogRequest#${o}`,category:T.EXTERNAL_API,message:`${n} error`,data:u});return}}}};return s(t)}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}async refreshAuthToken(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=this.params.refreshAuthToken().finally(()=>{this.refreshAuthTokenPromise=void 0})),this.refreshAuthTokenPromise}createLogParams(t){return{collector:"ok.mobile.apps.video",data:JSON.stringify({application:`@vkontakte/videoplayer-statistics:${Dr}`,platform:this.params.mobile?"M_WEB":"WEB",items:this.params.config.shorten?t.map(rc):t})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();const t=Bn(this.consequentAuthErrors,this.params.config.backoff);return new Promise(r=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout(()=>{this._authorize().then(r).catch(n=>this.params.error$.next({id:"AuthorizeBackoff",category:T.NETWORK,message:"Otherwise unhandled error in authorization",thrown:n})).finally(()=>this.backoffTimeoutId=0)},t))})}async _authorize(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);const t="auth.anonymLogin",r={session_data:{version:2,device_id:this.params.uuid,client_version:Dr.split("-")[0],client_type:"SDK_JS"}};return this.authToken!==void 0&&(r.session_data.auth_token=this.authToken,r.session_data.version=3),this.authorizePromise=this.params.apiTransport.sendRequest(t,r).then(n=>{var a;return(!n||!n.session_key)&&this.params.error$.next({id:"AuthorizeFailed",category:T.EXTERNAL_API,message:"No session key",data:n}),this.sessionKey=(a=n==null?void 0:n.session_key)!==null&&a!==void 0?a:void 0,this.sessionKey}).catch(async n=>{this.sessionKey=void 0;const a=n==null?void 0:n.error_code;switch(a){case M.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this._authorizeWithBackoff()}a?this.params.error$.next({id:`Authorize#${a}`,category:T.EXTERNAL_API,message:"authorize error",data:n}):this.params.error$.next({id:"AuthorizeUnknown",category:T.NETWORK,message:"authorize error",thrown:n})}).finally(()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(this.sessionKey!==void 0)}),this.authorizePromise}}class jr{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(t,r,n){t in this.listeners||(this.listeners[t]=[]),this.listeners[t].push({callback:r,options:n})}removeEventListener(t,r){if(!(t in this.listeners))return;const n=this.listeners[t];for(let a=0,i=n.length;a<i;a++)if(n[a].callback===r){n.splice(a,1);return}}dispatchEvent(t){if(!(t.type in this.listeners))return;const n=this.listeners[t.type].slice();for(let a=0,i=n.length;a<i;a++){const s=n[a];try{s.callback.call(this,t)}catch(f){Promise.resolve().then(()=>{throw f})}s.options&&s.options.once&&this.removeEventListener(t.type,s.callback)}return!t.defaultPrevented}}class Cn extends jr{constructor(){super(),this.listeners||jr.call(this),Object.defineProperty(this,"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,"reason",{value:void 0,writable:!0,configurable:!0})}toString(){return"[object AbortSignal]"}dispatchEvent(t){t.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,t)),super.dispatchEvent(t)}}class oc{constructor(){Object.defineProperty(this,"signal",{value:new Cn,writable:!0,configurable:!0})}abort(t){let r;try{r=new Event("abort")}catch(a){typeof document!="undefined"?document.createEvent?(r=document.createEvent("Event"),r.initEvent("abort",!1,!1)):(r=document.createEventObject(),r.type="abort"):r={type:"abort",bubbles:!1,cancelable:!1}}let n=t;if(n===void 0)if(typeof document=="undefined")n=new Error("This operation was aborted"),n.name="AbortError";else try{n=new DOMException("signal is aborted without reason")}catch(a){n=new Error("This operation was aborted"),n.name="AbortError"}this.signal.reason=n,this.signal.dispatchEvent(r)}toString(){return"[object AbortController]"}}typeof Symbol!="undefined"&&Symbol.toStringTag&&(oc.prototype[Symbol.toStringTag]="AbortController",Cn.prototype[Symbol.toStringTag]="AbortSignal");function Dn(e){return e.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):typeof e.Request=="function"&&!e.Request.prototype.hasOwnProperty("signal")||!e.AbortController}function ic(e){typeof e=="function"&&(e={fetch:e});const{fetch:t,Request:r=t.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:a=!1}=e;if(!Dn({fetch:t,Request:r,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:a}))return{fetch:t,Request:i};let i=r;(i&&!i.prototype.hasOwnProperty("signal")||a)&&(i=function(u,o){let l;o&&o.signal&&(l=o.signal,delete o.signal);const c=new r(u,o);return l&&Object.defineProperty(c,"signal",{writable:!1,enumerable:!1,configurable:!0,value:l}),c},i.prototype=r.prototype);const s=t;return{fetch:(d,u)=>{const o=i&&i.prototype.isPrototypeOf(d)?d.signal:u?u.signal:void 0;if(o){let l;try{l=new DOMException("Aborted","AbortError")}catch(h){l=new Error("Aborted"),l.name="AbortError"}if(o.aborted)return Promise.reject(l);const c=new Promise((h,v)=>{o.addEventListener("abort",()=>v(l),{once:!0})});return u&&u.signal&&delete u.signal,Promise.race([c,s(d,u)])}return s(d,u)},Request:i}}const Ct=Dn({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),kn=Ct?ic({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,Fr=Ct?kn.fetch:window.fetch;Ct?kn.Request:window.Request;class sc{constructor(t){this.params=t,this.apiKey=t.apiKey,this.apiEnv=t.config.apiEnv,this.apiBaseUrl=kr[this.apiEnv],this.timeSynchronisation=t.timeSynchronisation,this.isApiBaseUrlFetched=!1}async resolveApiBaseUrl(){var t;if(this.apiEnv!==R.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const r=atob("aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ="),a=await(await Fr(r,{method:"GET",mode:"cors",cache:"no-cache"})).json(),i=(t=a==null?void 0:a.Answer[0])===null||t===void 0?void 0:t.data;if(!i)throw new Error("Wrong DNS response");return i}catch(r){return this.params.error$.next({id:"OneStat:ApiTransport:resolveApiBaseUrl",category:T.NETWORK,message:"Unhandled resolve api base url error",thrown:r}),kr[R.VK_ALIAS]}finally{this.isApiBaseUrlFetched=!0}}sendBeacon(t,r,n){if(!window.Blob||!window.navigator.sendBeacon)return!1;const a=this._prepareQueryParams({method:t,queryParams:r,sessionKey:n}),i=new window.Blob([a.toString()],{type:"application/x-www-form-urlencoded"});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,i)}catch(s){this.params.error$.next({id:"OneStat:ApiTransport:sendBeacon",category:T.NETWORK,message:"Unhandled beacon error",thrown:s,data:{method:t,params:r}})}return!1}async sendRequest(t,r,n){const a=S(),i=s=>{if(s instanceof TypeError&&["Failed to fetch","NetworkError when attempting to fetch resource."].includes(s.message)){this.params.error$.next({id:"Network",category:T.NETWORK,message:"Request failed",thrown:s});return}this.params.error$.next({id:"OneStat:ApiTransport:sendRequest",category:T.NETWORK,message:"Unhandled request error",thrown:s,data:{method:t,params:r,sessionKey:n,time:S()-a}})};return this.apiBaseUrl=await this.resolveApiBaseUrl(),Fr(`${this.apiBaseUrl}/fb.do`,{method:"post",headers:{"Content-type":"application/x-www-form-urlencoded"},body:this._prepareQueryParams({method:t,queryParams:r,sessionKey:n})}).then(s=>{var f,d;const u=Number(s.headers.get("content-length"))===0,o=new Date((f=s.headers.get("date"))!==null&&f!==void 0?f:"").getTime(),l=S()-a;if(isFinite(o)&&((d=this.timeSynchronisation)===null||d===void 0||d.addServerTime(o,l)),!u)return s.json().then(c=>Object.prototype.hasOwnProperty.call(c,"error_msg")?Promise.reject(c):c,i)},i)}_prepareQueryParams(t){const r=new URLSearchParams({format:"JSON",method:t.method,application_key:this.apiKey});return t.sessionKey!==void 0&&r.append("session_key",t.sessionKey),Object.entries(t.queryParams).forEach(([n,a])=>r.append(n,typeof a=="string"?a:JSON.stringify(a))),r}}const he="onestat_events",ot=e=>t=>t.timestamp+e>=S();class lc{constructor(t){this.unsaltedStorage=[],this.isPaused=!1,this.isUrgent=n=>{const{operation:a}=n;return["action_play","watch_coverage_record","watch_coverage_live"].includes(a)},this.params=t,this.api=t.api,this.error$=t.error$,this.userSalt=t.userSalt,this.loggerDebugLog=t.debugLogger.createComponentLog("stat logger"),this.firstFlush=Dt(()=>this.safeFlush(),this.params.config.firstFlushTime,{maxWait:this.params.config.firstFlushTime});const r=F.isPersistent()?this.params.config.flushMaxWait:0;this.debouncedFlush=Dt(()=>this.safeFlush(),this.params.config.flushDebounceTime,{maxWait:r}),this.subscription=this.api.authorized$.subscribe(n=>{n&&this.debouncedFlush()}),this.housekeepStorage()}safeFlush(){var t;try{this.flush()}catch(r){this.error$.next({id:"LoggerError",category:T.WTF,message:(t=String(r))!==null&&t!==void 0?t:"Unknown logger error",thrown:r})}}readFromStorage(){const t=F.get(he);try{return t?JSON.parse(t):{}}catch(r){}return{}}addToStorage(t){var r;if(!this.userSalt){this.unsaltedStorage.push(t);return}const n=this.readFromStorage(),i=((r=n[this.userSalt])!==null&&r!==void 0?r:[]).filter(ot(this.params.config.storageExpiration));F.set(he,JSON.stringify({...n,[this.userSalt]:[...i,t]}))}getFromStorage(){var t;return this.userSalt?((t=this.readFromStorage()[this.userSalt])!==null&&t!==void 0?t:[]).filter(ot(this.params.config.storageExpiration)):this.unsaltedStorage}markStorageSent(){if(!this.userSalt){this.unsaltedStorage=[];return}const t=this.readFromStorage();delete t[this.userSalt],F.set(he,JSON.stringify(t))}housekeepStorage(){const t=this.readFromStorage();for(const[r,n]of Object.entries(t)){const a=n.filter(ot(this.params.config.storageExpiration));a.length?t[r]=a:delete t[r],this.loggerDebugLog({message:`${n.length} retrieved from storage, ${a.length} of them actual`})}F.set(he,JSON.stringify(t))}log(t){this.addToStorage(t),!this.isPaused&&(this.isUrgent(t)?this.flush():this.lastVsid!==t.custom.vsid?this.firstFlush():this.debouncedFlush(),this.lastVsid=t.custom.vsid)}flush(t=!1){const r=this.getFromStorage();r.length!==0&&(this.api.authorized$.getValue()?(t&&this.params.config.useBeacon?(this.loggerDebugLog({message:`Flushing ${r.length} events through beacon`}),this.api.logBeacon(r)):(this.loggerDebugLog({message:`Flushing ${r.length} events`}),this.api.logRequest(r)),this.markStorageSent()):this.api.authorize(),this.firstFlush.cancel(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe(),this.firstFlush.cancel(),this.debouncedFlush.cancel()}}const uc=e=>e&&{[A.INVARIANT]:E.UNKNOWN,[A.Q_144P]:E.Q144P,[A.Q_240P]:E.Q240P,[A.Q_360P]:E.Q360P,[A.Q_480P]:E.Q480P,[A.Q_720P]:E.Q720P,[A.Q_1080P]:E.Q1080P,[A.Q_1440P]:E.Q1440P,[A.Q_2160P]:E.Q2160P,[A.Q_4320P]:E.UNKNOWN}[e],Mr=e=>e&&{[Ce.HTTP1]:ee.HTTP1,[Ce.HTTP2]:ee.HTTP2,[Ce.QUIC]:ee.HTTP3}[e],cc=e=>{if(e!==void 0)switch(e){case m.MPEG:return $.MP4;case m.DASH:case m.DASH_LIVE:return $.DASH;case m.DASH_SEP:return $.DASH_SEP;case m.DASH_ONDEMAND:return $.ONDEMAND_DASH;case m.DASH_WEBM:case m.DASH_LIVE_WEBM:return $.WEBM;case m.DASH_WEBM_AV1:return $.AV1;case m.DASH_LIVE_CMAF:return $.ONDEMAND_DASH_LIVE;case m.HLS:case m.HLS_LIVE:return $.HLS;case m.HLS_ONDEMAND:return $.ONDEMAND_HLS;case m.HLS_LIVE_CMAF:return $.ONDEMAND_HLS_LIVE;case m.WEB_RTC_LIVE:return $.WEBRTC;default:return Br(e)}},it=e=>{if(e!==void 0)switch(e){case Z.NONE:case Z.INLINE:return;case Z.FULLSCREEN:return B.FULLSCREEN;case Z.SECOND_SCREEN:return B.CHROMECAST;case Z.PIP:return B.PIP;default:return Br(e)}},fc=e=>{switch(e){case"slow-2g":return Q.POOR;case"2g":return Q.POOR;case"3g":return Q.GOOD;case"4g":return Q.EXCELLENT}};class dc{constructor(t){this.offset=void 0,this.offset=t}getOffset(){var t;return(t=this.offset)!==null&&t!==void 0?t:0}setOffset(t){this.offset=t}now(){var t;return Date.now()+((t=this.offset)!==null&&t!==void 0?t:0)}date(t=new Date){var r;return t.setTime(t.getTime()+((r=this.offset)!==null&&r!==void 0?r:0)),t}addServerTime(t,r){const n=Date.now(),a=t-n-r/2;if(Math.abs(a)<1e3){this.offset=0;return}this.offset===void 0?this.offset=Math.round(a):this.offset=Math.round(.2*a+(1-.2)*this.offset)}}const hc=()=>Math.floor(Math.random()*2**32).toString(36).padStart(8,"0"),vc=(e,t)=>new Un(r=>{const n=new $e,a=ve(ut(window,"beforeunload"),e.events.willDestruct$),i=new me(void 0);let s;n.add(e.info.isLive$.pipe(Gn()).subscribe(j=>{s&&(s.unsubscribe(),i.next(void 0)),j?s=e.info.liveTime$.pipe(Kn(Ne=>Ne&&Ne/1e3)).subscribe(i):s=e.info.position$.subscribe(i),n.add(s)}));const{playing$:f,paused$:d}=e.events,u=e.events.willSeek$.pipe(kt(()=>e.info.playbackState$.getValue()===Ft.PLAYING)),o=e.events.seeked$.pipe(kt(()=>e.info.playbackState$.getValue()===Ft.PLAYING));let l=!1;const c=new pe;n.add(u.subscribe(()=>{l||c.next(),l=!0})),n.add(o.subscribe(()=>l=!1));const h=new pe,v=new pe,p=ve(f,o,h),b=ve(d,c,a,e.events.looped$,v);let g;const y=()=>g=i.getValue(),jn=()=>{const j=i.getValue();Se(g)||g===j||Se(j)||(r.next({from:g,to:j}),g=void 0)},Fn=()=>{v.next(),h.next()};if(n.add(p.subscribe(y)),n.add(b.subscribe(jn)),t.forceInterval&&isFinite(t.forceInterval)){let j=0;n.add(p.subscribe(()=>j=window.setTimeout(Fn,t.forceInterval))),n.add(b.subscribe(()=>window.clearTimeout(j)))}return n}),pc="_one-stat_",st=`${pc}uuid`,lt=()=>{const e=new $e;return{subscription:e,subscribe:(t,r)=>{t&&e.add(t.subscribe(r))}}};class yc{constructor(t,r){var n,a;this.subscription=new $e,this.debugLogger=new Vn,this.oneStatDebugLog=this.debugLogger.createComponentLog("onestat"),this.loopCounter=0,this.disabled=!1,this.vsid$=new me(void 0),this.seekAction$=new me(Te.UNKNOWN),this.statContext=t,this.config=ls((n=r.config)!==null&&n!==void 0?n:{}),V(r.apiEnv)&&(this.config.apiEnv=r.apiEnv),this.config.synchronizeTime&&(this.timeSynchronisation=new dc);const i=new pe;this.experimental={error$:i};const s=F.get(st);s?s.startsWith('"')&&s.endsWith('"')?(this.uuid=rs(s,'"',""),F.set(st,this.uuid)):this.uuid=s:(this.uuid=us(),F.set(st,this.uuid)),r.vsid?this.vsid$.next(r.vsid):this.resetViewSession();const f=new sc({apiKey:nc,config:this.config,error$:i,timeSynchronisation:this.timeSynchronisation});this.api=new ac({config:this.config,apiTransport:f,refreshAuthToken:r.refreshAuthToken,mobile:(a=this.statContext.mobile)!==null&&a!==void 0?a:!1,uuid:this.uuid,error$:i}),this.logger=new lc({config:this.config,debugLogger:this.debugLogger,api:this.api,error$:i,userSalt:r.userSalt});const{isEmbed:d,host:u}=Wn();this.isEmbed=d,this.embedParent=u,this.subscribe()}updateContext(t){this.statContext={...this.statContext,...t}}attachTo(t){const r=new $e,n=(o,l)=>r.add(o.subscribe(l));n(t.events.willStart$,()=>{const o=t.info.position$.getValue();this.logActionPlay({position:o}),this.statContext.projectId&&this.logActionPlayWithProjectId({position:o})}),n(t.events.looped$,()=>{this.resetViewSession(),++this.loopCounter>this.config.maxLoops&&(this.disabled=!0),this.logActionPlay({position:t.info.position$.getValue()})}),n(t.events.seeked$,()=>{this.logSeek({action:this.seekAction$.getValue(),time:t.info.position$.getValue()}),this.seekAction$.next(Te.UNKNOWN)}),n(t.events.paused$,()=>{this.logPause({position:t.info.position$.getValue()})}),n(t.events.willResume$,()=>{this.logPlay()}),n(t.events.started$,()=>{this.statContext.clip&&this.logWatchCoverageRecord({start:0,end:0})}),n(vc(t,{forceInterval:this.config.watchCoverageInterval}),o=>{const l=t.info.isLive$.getValue(),c={start:parseFloat(o.from.toFixed(3)),end:parseFloat(o.to.toFixed(3))};l?this.logWatchCoverageLive(c):this.logWatchCoverageRecord(c)});let a;n(t.info.isStalled$,o=>{o?a=S():(V(a)&&this.logEmptyBuffer({duration:S()-a}),a=void 0)});let i=!1;r.add(t.events.fatalError$.pipe(Hn()).subscribe(()=>i=!0)),n(t.events.willStop$,()=>{if(t.info.isStalled$.getValue()){const l=V(a)?S()-a:void 0;this.logCloseAtEmptyBuffer({duration:l!=null?l:0}),a=void 0}else i||this.logActionStop()}),n(t.events.managedError$,({id:o})=>{this.logError({fatal:!1,errorType:o})}),n(t.events.fatalError$,({id:o})=>{this.logError({fatal:!0,errorType:o})});let s,f,d=!1;n(t.events.firstBytes$,o=>{s=S(),this.logFirstBytes({time:o})}),n(t.events.willStart$,()=>f=S()),n(t.info.currentBuffer$,o=>{!d&&o&&o.end-o.start>0&&V(s)&&(this.logPlayerReady({duration:S()-s}),d=!0)}),n(t.events.firstFrame$,()=>{V(s)&&!d&&(this.logPlayerReady({duration:S()-s}),d=!0),V(f)&&this.logFirstFrame({time:S()-f})}),n(t.info.atLiveEdge$,o=>this.updateContext({liveEdge:o})),n(jt({muted:t.info.muted$,volume:t.info.volume$}),({muted:o,volume:l})=>this.updateContext({audible:!o&&l>0})),n(t.info.currentQuality$,o=>this.updateContext({quality:uc(o)})),n(t.info.isAutoQualityEnabled$,o=>this.updateContext({autoQuality:o})),n(t.info.currentFormat$,o=>this.updateContext({contentType:cc(o)})),n(t.info.currentPlaybackRate$,o=>this.updateContext({rate:o})),n(t.info.is3DVideo$,o=>this.updateContext({is3d:o}));let u;return n(t.info.hostname$,o=>{this.updateContext({cdnHostname:o,failover:u!==void 0&&u!==o}),u=o}),n(t.info.throughputEstimation$,o=>this.updateContext({downloadSpeed:o})),n(t.info.httpConnectionType$,o=>{this.statContext.firstConnectionType||this.updateContext({firstConnectionType:Mr(o)}),this.updateContext({connectionType:Mr(o)})}),n(t.info.httpConnectionReused$,o=>{Se(this.statContext.firstConnectionReused)&&this.updateContext({firstConnectionReused:o}),this.updateContext({connectionReused:o})}),n(t.info.surface$,o=>this.updateContext({mode:it(o)})),n(jt({current:t.info.currentTextTrack$,available:t.info.availableTextTracks$}),({current:o,available:l})=>{const c=l.find(({id:v})=>v===o),h=c&&(c.isAuto?`${c.language}_auto`:c.language);this.updateContext({subtitles:h})}),this.player=t,this.uiEvents&&this.attachToUi(this.uiEvents),this.resubscribeBeforeunload(),this.subscription.add(r),r}attachToUi(t){this.uiEvents=t;const{subscription:r,subscribe:n}=lt();return this.player&&(n(t.actionRewind$,()=>{this.player&&(this.resetViewSession(),this.logActionPlay({position:this.player.info.position$.getValue()}))}),n(t.actionSeek$,this.seekAction$),n(t.inPiP$,a=>{var i;const s=a?B.PIP:it((i=this.player)===null||i===void 0?void 0:i.info.surface$.getValue());this.updateContext({mode:s})}),n(t.inFullscreen$,a=>{var i;const s=a?B.FULLSCREEN:it((i=this.player)===null||i===void 0?void 0:i.info.surface$.getValue());this.updateContext({mode:s})}),n(t.actionSetSubtitle$,a=>this.updateContext({subtitles:a})),n(t.nextMovie$,a=>this.logNextMovie(a)),this.resubscribeBeforeunload(),this.subscription.add(r)),r}attachToAds(t){const{subscription:r,subscribe:n}=lt();return n(t.slotRequested$,()=>this.logAdSlotRequest()),n(t.started$,a=>this.logAdStarted(a)),n(t.paused$,()=>this.logAdPaused()),n(t.resumed$,()=>this.logAdResumed()),n(t.ended$,()=>this.logAdEnded()),n(t.skipped$,()=>this.logAdSkipped()),n(t.clicked$,()=>this.logAdClicked()),this.resubscribeBeforeunload(),this.subscription.add(r),r}attachToInteractive(t){const{subscription:r,subscribe:n}=lt();return n(t.click$,a=>this.logInterfaceClick(a)),n(t.nextMovie$,a=>this.logNextMovie(a)),this.resubscribeBeforeunload(),this.subscription.add(r),r}authorize(t){return this.api.authorize(t)}pause(){this.logger.pause(),this.oneStatDebugLog({message:"paused"})}resume(){this.logger.resume(),this.oneStatDebugLog({message:"resumed"})}destroy(){this.logger.flush(),this.subscription.unsubscribe(),this.api.destroy(),this.logger.destroy()}resetViewSession(){this.oneStatDebugLog({message:"VSID reset"}),this.vsid$.next(hc())}getDeviceId(){return this.uuid}setFieldBlacklist(){}logInited(){}logReady(t){this.log({operation:"player_ready",param:String(t.time)})}logStarted(...t){this.logActionPlay(...t)}logPlay(){this.log({operation:"play_toggle"})}logPause(t){this.log({operation:"pause",param:String(Math.round(t.position))})}logSeek(t){this.log({operation:"seek",param:t.action,time:t.time})}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:"content_error",param:`${t.fatal?"fatal":"recoverable"}_${t.errorType}`})}logWatchCoverageRecord(t){this.log({operation:"watch_coverage_record",param:`${t.start}-${t.end}`})}logWatchCoverageLive(t){var r,n;const a=(n=(r=this.timeSynchronisation)===null||r===void 0?void 0:r.getOffset())!==null&&n!==void 0?n:0,i=t.start+a,s=t.end+a;this.log({operation:"watch_coverage_live",param:`${i}-${s}`})}logEmptyBuffer(t){this.log({operation:"empty_buffer",param:String(t.duration)})}logDownloadSpeed(){}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"})}logInterfaceClick(t){this.log({operation:"player_interface_click",param:t})}logNextMovie(t){this.log({operation:"next_movie",param:String(t)})}subscribe(){this.resubscribeBeforeunload();const t=window.navigator.connection;t&&"onchange"in t&&"effectiveType"in t&&this.subscription.add(ve(ut(t,"change"),qn(["init"])).subscribe(()=>this.updateContext({network:fc(t.effectiveType)}))),this.config.debugLog&&this.debugLogger.log$.subscribe(r=>{console.debug("%c stat ","background:#fa6470;",`component: ${r.component}.`,r.message)})}resubscribeBeforeunload(){var t;(t=this.beforeunloadSubscription)===null||t===void 0||t.unsubscribe(),this.beforeunloadSubscription=ut(window,"beforeunload").subscribe(()=>this.logger.flush(!0)),this.subscription.add(this.beforeunloadSubscription)}logPlayerReady(t){this.log({operation:"player_ready",param:String(Math.round(t.duration))})}logActionPlay(t){this.log({operation:"action_play",param:String(Math.round(t.position))})}logActionPlayWithProjectId(t){this.statContext.projectId&&this.log({operation:"action_play",param:String(Math.round(t.position))},{vid:this.statContext.projectId})}logCloseAtEmptyBuffer(t){this.log({operation:"close_at_empty_buffer",param:String(Math.round(t.duration))})}logActionStop(){this.log({operation:"action_stop"})}log(t,r={}){if(this.disabled){this.oneStatDebugLog({message:`operation ${t.operation} but statistics is disabled`});return}if(this.config.disabledOperations.includes(t.operation)){this.oneStatDebugLog({message:`operation ${t.operation} but it is disabled`});return}this.oneStatDebugLog({message:`operation ${t.operation} ${t.param}`});const n=this.createLogItem(t,r);this.logger.log(n)}createLogItem({operation:t,param:r,time:n},a={}){var i,s;const f=(s=(i=this.timeSynchronisation)===null||i===void 0?void 0:i.now())!==null&&s!==void 0?s:S(),d=this.vsid$.getValue();zn(d);const u=t==="empty_buffer"||t==="close_at_empty_buffer"?this.statContext.connectionType:this.statContext.firstConnectionType,o=this.statContext.firstConnectionReused;let l,c;if(this.isEmbed){l=this.embedParent;const v=[...new URLSearchParams(location.search).entries()].filter(([p,b])=>this.config.embedUrlParams.includes(p));c=new URLSearchParams(v).toString()}else this.statContext.place==="direct"&&(document.referrer&&(l=new URL(document.referrer).hostname),c=location.href.substring(0,1024));const h={vsid:d,vid:this.statContext.movieId,ct:this.statContext.contentType,place:this.isEmbed?"embed":this.statContext.place,quality:this.statContext.quality,cdn_host:this.statContext.cdnHostname,stat_type:this.statContext.autoplay===!0?_e.AUTO:this.statContext.autoplay===!1?_e.MANUAL:void 0,param:r,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode,connection_type:u,connection_reused:o===!0?L.YES:o===!1?L.NO:void 0,cached_data:this.statContext.cached===!0?L.YES:this.statContext.cached===!1?L.NO:void 0,live:this.statContext.liveEdge?L.YES:void 0,muted:this.statContext.audible===!1?L.YES:void 0,mode:this.statContext.mode,subtitles:this.statContext.subtitles,download_speed:this.statContext.downloadSpeed,manual_quality:this.statContext.autoQuality?void 0:L.YES,ref_domain:l,direct_url:c,rate:this.statContext.rate===1||Se(this.statContext.rate)?void 0:this.statContext.rate.toFixed(2),view_360:this.statContext.is3d?1:void 0,aid:this.statContext.albumId,vk_playlist_id:this.statContext.vkPlaylistId,...a};for(const v of this.config.disabledCustomFields)delete h[v];return{operation:t,type:1,time:n,network:this.statContext.network,timestamp:f,custom:h}}}export{R as ApiEnv,ee as ConnectionType,$ as ContentType,ur as InteractiveInterfaceClick,yc as OneStat,E as Quality,Te as SeekAction,Dr as VERSION};
|
package/esnext.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-statistics v1.0.
|
|
3
|
-
*
|
|
4
|
-
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-
|
|
2
|
+
* @vkontakte/videoplayer-statistics v1.0.46-dev.df8758f1.0
|
|
3
|
+
* Wed, 13 Mar 2024 12:50:02 GMT
|
|
4
|
+
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-46/doc/
|
|
5
5
|
*/
|
|
6
|
-
"use strict";var r=require("@vkontakte/videoplayer-shared/esnext.cjs.js"),c=require("@vkontakte/videoplayer-core/esnext.cjs.js");exports.ApiEnv=void 0;(function(t){t.PROD="prod",t.VK_ALIAS="vk_alias",t.VIDEOTEST="videotest",t.TEST="test",t.AUTO="auto"})(exports.ApiEnv||(exports.ApiEnv={}));exports.Quality=void 0;(function(t){t.Q144P="mobile",t.Q240P="lowest",t.Q360P="low",t.Q480P="medium",t.Q720P="high",t.Q1080P="fullhd",t.Q1440P="quadhd",t.Q2160P="ultrahd",t.UNKNOWN="unknown"})(exports.Quality||(exports.Quality={}));exports.ContentType=void 0;(function(t){t.MP4="mp4",t.DASH="dash",t.DASH_SEP="dash_sep",t.ONDEMAND_DASH="ondemand_dash",t.HLS="hls",t.ONDEMAND_HLS="ondemand_hls",t.WEBM="webm",t.AV1="av1",t.ONDEMAND_DASH_LIVE="ondemand_dash_live",t.ONDEMAND_HLS_LIVE="ondemand_hls_live",t.WEBRTC="webrtc",t.UNKNOWN="unknown",t.RTMP="rtmp"})(exports.ContentType||(exports.ContentType={}));var v;(function(t){t.AUTO="auto",t.MANUAL=""})(v||(v={}));exports.ConnectionType=void 0;(function(t){t.HTTP1="http1",t.HTTP2="http2",t.HTTP3="http3"})(exports.ConnectionType||(exports.ConnectionType={}));var p;(function(t){t[t.YES=1]="YES",t[t.NO=0]="NO"})(p||(p={}));var y;(function(t){t.EXCELLENT="excellent",t.GOOD="good",t.POOR="poor"})(y||(y={}));var _;(function(t){t.PIP="pip",t.FULLSCREEN="fullscreen",t.EXTERNAL="external",t.PREFETCH="prefetch",t.AIRPLAY="airplay",t.CHROMECAST="chromecast",t.INVISIBLE="invisible"})(_||(_={}));exports.SeekAction=void 0;(function(t){t.SLIDER="slider",t.DOUBLE_TAP="double_tap",t.TIME_CODE="time_code",t.EPISODE="episode",t.REWIND="rewind",t.LIVE="live",t.UNKNOWN="unknown"})(exports.SeekAction||(exports.SeekAction={}));exports.InteractiveInterfaceClick=void 0;(function(t){t.GRAPH_SHOW="iGraphShow",t.GRAPH_HIDE="iGraphHide",t.NEXT_AREA="iNextChapterArea",t.NEXT_BUTTON="iNextChapterBtn",t.WATCH_AGAIN="iWatchAgainBtn"})(exports.InteractiveInterfaceClick||(exports.InteractiveInterfaceClick={}));const M={action_play:"ap",first_bytes:"fb",player_ready:"pr",first_frame:"ff",seek:"sk",watch_coverage_record:"wr",watch_coverage_live:"wl",empty_buffer:"eb",action_stop:"as",close_at_empty_buffer:"cb",content_error:"er",player_interface_click:"pc",next_movie:"nm",track_switch:"ts"},Q={vsid:"si",vid:"vi",place:"pl",quality:"qt",cdn_host:"ch",stat_type:"st",param:"pm",vk_app_id:"va",track_code:"tc",connection_type:"cnt",connection_reused:"cr",cached_data:"cd",live:"lv",muted:"mu",mode:"mo",subtitles:"sb",failover:"fo",download_speed:"ds",manual_quality:"mq",ref_domain:"rd",direct_url:"du"},K={unknown:"un",mobile:"m",lowest:"ls",low:"l",medium:"md",high:"h",fullhd:"f",quadhd:"q",ultrahd:"u"},j={pip:"pi",fullscreen:"fs",external:"ex",prefetch:"pr",airplay:"ap",chromecast:"cc",invisible:"iv"},z={apiEnv:exports.ApiEnv.VK_ALIAS,requestRetryCount:1,firstFlushTime:5e3,flushDebounceTime:1e4,flushMaxWait:6e4,storageExpiration:36*60*60*1e3,watchCoverageInterval:15e3,disabledOperations:[],disabledCustomFields:[],shorten:!0,maxLoops:100,embedUrlParams:[],useBeacon:!0,synchronizeTime:!0,debugLog:!1,backoff:{start:1e3,factor:1.5,max:5*60*1e3,random:.1}},G=t=>r.fillWithDefault(t,z);function Y(){const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),e=new Array(36);let s=0,i,o;for(o=0;o<36;o++)o===8||o===13||o===18||o===23?e[o]="-":o===14?e[o]="4":(s<=2&&(s=33554432+Math.random()*16777216|0),i=s&15,s=s>>4,e[o]=t[o===19?i&3|8:i]);return e.join("")}const X=t=>{const{operation:e,custom:s}=t,i=Object.fromEntries(Object.entries(s).map(([o,a])=>{const u=Q[o]??o;let f=a;return a&&(o==="mode"?f=j[a]??a:o==="quality"&&(f=K[a]??a)),[u,f]}));return{...t,operation:M[e]??e,custom:i}},L="1.0.45",J="CIOPGQJGDIHBABABA",k={[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 E;(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"})(E||(E={}));class Z{params;authToken;sessionKey;authorizePromise;refreshAuthTokenPromise;consequentAuthErrors=0;authorized$=new r.ValueSubject(!1);backoffTimeoutId;constructor(e){this.params=e}async authorize(e){return this.authToken=e??await this.refreshAuthToken(),this._authorizeWithBackoff()}logBeacon(e){const s="log.externalLog",i=this.createLogParams(e),o=this.sessionKey;if(!o)return;this.params.apiTransport.sendBeacon(s,i,o)||this.logRequest(e)}async logRequest(e){const s="log.externalLog",i=this.createLogParams(e),o=this.sessionKey??await this._authorizeWithBackoff();if(!o)return;const a=async(u,f=this.params.config.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(s,i,o)}catch(h){if(!h||!("error_code"in h)){this.params.error$.next({id:"logRequestUnknown",category:r.ErrorCategory.NETWORK,message:`Unknown ${s} error`,thrown:h});return}const d=h?.error_code;switch(d){case E.PARAM_SESSION_EXPIRED:case E.PARAM_SESSION_KEY:case E.PARAM_SIGNATURE:return this.authorized$.next(!1),this.sessionKey=await this._authorizeWithBackoff(),f>0?a(u,f-1):void 0;case E.AUTH_LOGIN:return this.authorized$.next(!1),this.authToken=await this.refreshAuthToken(),this.sessionKey=await this._authorizeWithBackoff(),f>0?a(u,f-1):void 0;default:{this.params.error$.next({id:`LogRequest#${d}`,category:r.ErrorCategory.EXTERNAL_API,message:`${s} error`,data:h});return}}}};return a(e)}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}async refreshAuthToken(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=this.params.refreshAuthToken().finally(()=>{this.refreshAuthTokenPromise=void 0})),this.refreshAuthTokenPromise}createLogParams(e){return{collector:"ok.mobile.apps.video",data:JSON.stringify({application:`@vkontakte/videoplayer-statistics:${L}`,platform:this.params.mobile?"M_WEB":"WEB",items:this.params.config.shorten?e.map(X):e})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();const e=r.getExponentialDelay(this.consequentAuthErrors,this.params.config.backoff);return new Promise(s=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout(()=>{this._authorize().then(s).catch(i=>this.params.error$.next({id:"AuthorizeBackoff",category:r.ErrorCategory.NETWORK,message:"Otherwise unhandled error in authorization",thrown:i})).finally(()=>this.backoffTimeoutId=0)},e))})}async _authorize(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);const e="auth.anonymLogin",s={session_data:{version:2,device_id:this.params.uuid,client_version:L.split("-")[0],client_type:"SDK_JS"}};return this.authToken!==void 0&&(s.session_data.auth_token=this.authToken,s.session_data.version=3),this.authorizePromise=this.params.apiTransport.sendRequest(e,s).then(i=>((!i||!i.session_key)&&this.params.error$.next({id:"AuthorizeFailed",category:r.ErrorCategory.EXTERNAL_API,message:"No session key",data:i}),this.sessionKey=i?.session_key??void 0,this.sessionKey)).catch(async i=>{this.sessionKey=void 0;const o=i?.error_code;switch(o){case E.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this._authorizeWithBackoff()}o?this.params.error$.next({id:`Authorize#${o}`,category:r.ErrorCategory.EXTERNAL_API,message:"authorize error",data:i}):this.params.error$.next({id:"AuthorizeUnknown",category:r.ErrorCategory.NETWORK,message:"authorize error",thrown:i})}).finally(()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(this.sessionKey!==void 0)}),this.authorizePromise}}class I{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,s,i){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:s,options:i})}removeEventListener(e,s){if(!(e in this.listeners))return;const i=this.listeners[e];for(let o=0,a=i.length;o<a;o++)if(i[o].callback===s){i.splice(o,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;const i=this.listeners[e.type].slice();for(let o=0,a=i.length;o<a;o++){const u=i[o];try{u.callback.call(this,e)}catch(f){Promise.resolve().then(()=>{throw f})}u.options&&u.options.once&&this.removeEventListener(e.type,u.callback)}return!e.defaultPrevented}}class V extends I{constructor(){super(),this.listeners||I.call(this),Object.defineProperty(this,"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,"reason",{value:void 0,writable:!0,configurable:!0})}toString(){return"[object AbortSignal]"}dispatchEvent(e){e.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,e)),super.dispatchEvent(e)}}class ee{constructor(){Object.defineProperty(this,"signal",{value:new V,writable:!0,configurable:!0})}abort(e){let s;try{s=new Event("abort")}catch{typeof document<"u"?document.createEvent?(s=document.createEvent("Event"),s.initEvent("abort",!1,!1)):(s=document.createEventObject(),s.type="abort"):s={type:"abort",bubbles:!1,cancelable:!1}}let i=e;if(i===void 0)if(typeof document>"u")i=new Error("This operation was aborted"),i.name="AbortError";else try{i=new DOMException("signal is aborted without reason")}catch{i=new Error("This operation was aborted"),i.name="AbortError"}this.signal.reason=i,this.signal.dispatchEvent(s)}toString(){return"[object AbortController]"}}typeof Symbol<"u"&&Symbol.toStringTag&&(ee.prototype[Symbol.toStringTag]="AbortController",V.prototype[Symbol.toStringTag]="AbortSignal");function B(t){return t.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):typeof t.Request=="function"&&!t.Request.prototype.hasOwnProperty("signal")||!t.AbortController}function te(t){typeof t=="function"&&(t={fetch:t});const{fetch:e,Request:s=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o=!1}=t;if(!B({fetch:e,Request:s,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o}))return{fetch:e,Request:a};let a=s;(a&&!a.prototype.hasOwnProperty("signal")||o)&&(a=function(d,n){let l;n&&n.signal&&(l=n.signal,delete n.signal);const g=new s(d,n);return l&&Object.defineProperty(g,"signal",{writable:!1,enumerable:!1,configurable:!0,value:l}),g},a.prototype=s.prototype);const u=e;return{fetch:(h,d)=>{const n=a&&a.prototype.isPrototypeOf(h)?h.signal:d?d.signal:void 0;if(n){let l;try{l=new DOMException("Aborted","AbortError")}catch{l=new Error("Aborted"),l.name="AbortError"}if(n.aborted)return Promise.reject(l);const g=new Promise((m,S)=>{n.addEventListener("abort",()=>S(l),{once:!0})});return d&&d.signal&&delete d.signal,Promise.race([g,u(h,d)])}return u(h,d)},Request:a}}const $=B({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),U=$?te({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,D=$?U.fetch:window.fetch;$?U.Request:window.Request;class ie{apiKey;apiBaseUrl;apiEnv;timeSynchronisation;isApiBaseUrlFetched;params;constructor(e){this.params=e,this.apiKey=e.apiKey,this.apiEnv=e.config.apiEnv,this.apiBaseUrl=k[this.apiEnv],this.timeSynchronisation=e.timeSynchronisation,this.isApiBaseUrlFetched=!1}async resolveApiBaseUrl(){if(this.apiEnv!==exports.ApiEnv.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const e=atob("aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ="),o=(await(await D(e,{method:"GET",mode:"cors",cache:"no-cache"})).json())?.Answer[0]?.data;if(!o)throw new Error("Wrong DNS response");return o}catch(e){return this.params.error$.next({id:"OneStat:ApiTransport:resolveApiBaseUrl",category:r.ErrorCategory.NETWORK,message:"Unhandled resolve api base url error",thrown:e}),k[exports.ApiEnv.VK_ALIAS]}finally{this.isApiBaseUrlFetched=!0}}sendBeacon(e,s,i){if(!window.Blob||!window.navigator.sendBeacon)return!1;const o=this._prepareQueryParams({method:e,queryParams:s,sessionKey:i}),a=new window.Blob([o.toString()],{type:"application/x-www-form-urlencoded"});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,a)}catch(u){this.params.error$.next({id:"OneStat:ApiTransport:sendBeacon",category:r.ErrorCategory.NETWORK,message:"Unhandled beacon error",thrown:u,data:{method:e,params:s}})}return!1}async sendRequest(e,s,i){const o=r.now(),a=u=>{if(u instanceof TypeError&&["Failed to fetch","NetworkError when attempting to fetch resource."].includes(u.message)){this.params.error$.next({id:"Network",category:r.ErrorCategory.NETWORK,message:"Request failed",thrown:u});return}this.params.error$.next({id:"OneStat:ApiTransport:sendRequest",category:r.ErrorCategory.NETWORK,message:"Unhandled request error",thrown:u,data:{method:e,params:s,sessionKey:i,time:r.now()-o}})};return this.apiBaseUrl=await this.resolveApiBaseUrl(),D(`${this.apiBaseUrl}/fb.do`,{method:"post",headers:{"Content-type":"application/x-www-form-urlencoded"},body:this._prepareQueryParams({method:e,queryParams:s,sessionKey:i})}).then(u=>{const f=Number(u.headers.get("content-length"))===0,h=new Date(u.headers.get("date")??"").getTime(),d=r.now()-o;if(isFinite(h)&&this.timeSynchronisation?.addServerTime(h,d),!f)return u.json().then(n=>Object.prototype.hasOwnProperty.call(n,"error_msg")?Promise.reject(n):n,a)},a)}_prepareQueryParams(e){const s=new URLSearchParams({format:"JSON",method:e.method,application_key:this.apiKey});return e.sessionKey!==void 0&&s.append("session_key",e.sessionKey),Object.entries(e.queryParams).forEach(([i,o])=>s.append(i,typeof o=="string"?o:JSON.stringify(o))),s}}const w="onestat_events",P=t=>e=>e.timestamp+t>=r.now();class se{params;api;error$;subscription;userSalt;unsaltedStorage=[];lastVsid;isPaused=!1;firstFlush;debouncedFlush;loggerDebugLog;constructor(e){this.params=e,this.api=e.api,this.error$=e.error$,this.userSalt=e.userSalt,this.loggerDebugLog=e.debugLogger.createComponentLog("stat logger"),this.firstFlush=r.debounceFn(()=>this.safeFlush(),this.params.config.firstFlushTime,{maxWait:this.params.config.firstFlushTime});const s=r.safeStorage.isPersistent()?this.params.config.flushMaxWait:0;this.debouncedFlush=r.debounceFn(()=>this.safeFlush(),this.params.config.flushDebounceTime,{maxWait:s}),this.subscription=this.api.authorized$.subscribe(i=>{i&&this.debouncedFlush()}),this.housekeepStorage()}isUrgent=e=>{const{operation:s}=e;return["action_play","watch_coverage_record","watch_coverage_live"].includes(s)};safeFlush(){try{this.flush()}catch(e){this.error$.next({id:"LoggerError",category:r.ErrorCategory.WTF,message:String(e)??"Unknown logger error",thrown:e})}}readFromStorage(){const e=r.safeStorage.get(w);try{return e?JSON.parse(e):{}}catch{}return{}}addToStorage(e){if(!this.userSalt){this.unsaltedStorage.push(e);return}const s=this.readFromStorage(),o=(s[this.userSalt]??[]).filter(P(this.params.config.storageExpiration));r.safeStorage.set(w,JSON.stringify({...s,[this.userSalt]:[...o,e]}))}getFromStorage(){return this.userSalt?(this.readFromStorage()[this.userSalt]??[]).filter(P(this.params.config.storageExpiration)):this.unsaltedStorage}markStorageSent(){if(!this.userSalt){this.unsaltedStorage=[];return}const e=this.readFromStorage();delete e[this.userSalt],r.safeStorage.set(w,JSON.stringify(e))}housekeepStorage(){const e=this.readFromStorage();for(const[s,i]of Object.entries(e)){const o=i.filter(P(this.params.config.storageExpiration));o.length?e[s]=o:delete e[s],this.loggerDebugLog({message:`${i.length} retrieved from storage, ${o.length} of them actual`})}r.safeStorage.set(w,JSON.stringify(e))}log(e){this.addToStorage(e),!this.isPaused&&(this.isUrgent(e)?this.flush():this.lastVsid!==e.custom.vsid?this.firstFlush():this.debouncedFlush(),this.lastVsid=e.custom.vsid)}flush(e=!1){const s=this.getFromStorage();s.length!==0&&(this.api.authorized$.getValue()?(e&&this.params.config.useBeacon?(this.loggerDebugLog({message:`Flushing ${s.length} events through beacon`}),this.api.logBeacon(s)):(this.loggerDebugLog({message:`Flushing ${s.length} events`}),this.api.logRequest(s)),this.markStorageSent()):this.api.authorize(),this.firstFlush.cancel(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe(),this.firstFlush.cancel(),this.debouncedFlush.cancel()}}const oe=t=>t&&{[c.VideoQuality.INVARIANT]:exports.Quality.UNKNOWN,[c.VideoQuality.Q_144P]:exports.Quality.Q144P,[c.VideoQuality.Q_240P]:exports.Quality.Q240P,[c.VideoQuality.Q_360P]:exports.Quality.Q360P,[c.VideoQuality.Q_480P]:exports.Quality.Q480P,[c.VideoQuality.Q_720P]:exports.Quality.Q720P,[c.VideoQuality.Q_1080P]:exports.Quality.Q1080P,[c.VideoQuality.Q_1440P]:exports.Quality.Q1440P,[c.VideoQuality.Q_2160P]:exports.Quality.Q2160P,[c.VideoQuality.Q_4320P]:exports.Quality.UNKNOWN}[t],F=t=>t&&{[c.HttpConnectionType.HTTP1]:exports.ConnectionType.HTTP1,[c.HttpConnectionType.HTTP2]:exports.ConnectionType.HTTP2,[c.HttpConnectionType.QUIC]:exports.ConnectionType.HTTP3}[t],re=t=>{if(t!==void 0)switch(t){case c.VideoFormat.MPEG:return exports.ContentType.MP4;case c.VideoFormat.DASH:case c.VideoFormat.DASH_LIVE:return exports.ContentType.DASH;case c.VideoFormat.DASH_SEP:return exports.ContentType.DASH_SEP;case c.VideoFormat.DASH_ONDEMAND:return exports.ContentType.ONDEMAND_DASH;case c.VideoFormat.DASH_WEBM:case c.VideoFormat.DASH_LIVE_WEBM:return exports.ContentType.WEBM;case c.VideoFormat.DASH_WEBM_AV1:return exports.ContentType.AV1;case c.VideoFormat.DASH_LIVE_CMAF:return exports.ContentType.ONDEMAND_DASH_LIVE;case c.VideoFormat.HLS:case c.VideoFormat.HLS_LIVE:return exports.ContentType.HLS;case c.VideoFormat.HLS_ONDEMAND:return exports.ContentType.ONDEMAND_HLS;case c.VideoFormat.HLS_LIVE_CMAF:return exports.ContentType.ONDEMAND_HLS_LIVE;case c.VideoFormat.WEB_RTC_LIVE:return exports.ContentType.WEBRTC;default:return r.assertNever(t)}},C=t=>{if(t!==void 0)switch(t){case c.Surface.NONE:case c.Surface.INLINE:return;case c.Surface.FULLSCREEN:return _.FULLSCREEN;case c.Surface.SECOND_SCREEN:return _.CHROMECAST;case c.Surface.PIP:return _.PIP;default:return r.assertNever(t)}},ne=t=>{switch(t){case"slow-2g":return y.POOR;case"2g":return y.POOR;case"3g":return y.GOOD;case"4g":return y.EXCELLENT}};class ae{offset=void 0;constructor(e){this.offset=e}getOffset(){return this.offset??0}setOffset(e){this.offset=e}now(){return Date.now()+(this.offset??0)}date(e=new Date){return e.setTime(e.getTime()+(this.offset??0)),e}addServerTime(e,s){const i=Date.now(),o=e-i-s/2;if(Math.abs(o)<1e3){this.offset=0;return}this.offset===void 0?this.offset=Math.round(o):this.offset=Math.round(.2*o+(1-.2)*this.offset)}}const ue=()=>Math.floor(Math.random()*2**32).toString(36).padStart(8,"0"),ce=(t,e)=>new r.Observable(s=>{const i=new r.Subscription,o=r.merge(r.fromEvent(window,"beforeunload"),t.events.willDestruct$),a=new r.ValueSubject(void 0);let u;i.add(t.info.isLive$.pipe(r.filterChanged()).subscribe(b=>{u&&(u.unsubscribe(),a.next(void 0)),b?u=t.info.liveTime$.pipe(r.map(T=>T&&T/1e3)).subscribe(a):u=t.info.position$.subscribe(a),i.add(u)}));const{playing$:f,paused$:h}=t.events,d=t.events.willSeek$.pipe(r.filter(()=>t.info.playbackState$.getValue()===c.PlaybackState.PLAYING)),n=t.events.seeked$.pipe(r.filter(()=>t.info.playbackState$.getValue()===c.PlaybackState.PLAYING));let l=!1;const g=new r.Subject;i.add(d.subscribe(()=>{l||g.next(),l=!0})),i.add(n.subscribe(()=>l=!1));const m=new r.Subject,S=new r.Subject,O=r.merge(f,n,m),R=r.merge(h,g,o,t.events.looped$,S);let A;const q=()=>A=a.getValue(),H=()=>{const b=a.getValue();r.isNullable(A)||A===b||r.isNullable(b)||(s.next({from:A,to:b}),A=void 0)},W=()=>{S.next(),m.next()};if(i.add(O.subscribe(q)),i.add(R.subscribe(H)),e.forceInterval&&isFinite(e.forceInterval)){let b=0;i.add(O.subscribe(()=>b=window.setTimeout(W,e.forceInterval))),i.add(R.subscribe(()=>window.clearTimeout(b)))}return i}),le="_one-stat_",N=`${le}uuid`,x=()=>{const t=new r.Subscription;return{subscription:t,subscribe:(e,s)=>{e&&t.add(e.subscribe(s))}}};class he{api;logger;config;subscription=new r.Subscription;beforeunloadSubscription;timeSynchronisation;debugLogger=new r.Logger;oneStatDebugLog=this.debugLogger.createComponentLog("onestat");loopCounter=0;disabled=!1;experimental;vsid$=new r.ValueSubject(void 0);statContext;isEmbed;embedParent;uiEvents;player;seekAction$=new r.ValueSubject(exports.SeekAction.UNKNOWN);uuid;constructor(e,s){this.statContext=e,this.config=G(s.config??{}),r.isNonNullable(s.apiEnv)&&(this.config.apiEnv=s.apiEnv),this.config.synchronizeTime&&(this.timeSynchronisation=new ae);const i=new r.Subject;this.experimental={error$:i};const o=r.safeStorage.get(N);o?o.startsWith('"')&&o.endsWith('"')?(this.uuid=o.replaceAll('"',""),r.safeStorage.set(N,this.uuid)):this.uuid=o:(this.uuid=Y(),r.safeStorage.set(N,this.uuid)),this.resetViewSession();const a=new ie({apiKey:J,config:this.config,error$:i,timeSynchronisation:this.timeSynchronisation});this.api=new Z({config:this.config,apiTransport:a,refreshAuthToken:s.refreshAuthToken,mobile:this.statContext.mobile??!1,uuid:this.uuid,error$:i}),this.logger=new se({config:this.config,debugLogger:this.debugLogger,api:this.api,error$:i,userSalt:s.userSalt});const{isEmbed:u,host:f}=r.detectEmbed();this.isEmbed=u,this.embedParent=f,this.subscribe()}updateContext(e){this.statContext={...this.statContext,...e}}attachTo(e){const s=new r.Subscription,i=(n,l)=>s.add(n.subscribe(l));i(e.events.willStart$,()=>{const n=e.info.position$.getValue();this.logActionPlay({position:n}),this.statContext.projectId&&this.logActionPlayWithProjectId({position:n})}),i(e.events.looped$,()=>{this.resetViewSession(),++this.loopCounter>this.config.maxLoops&&(this.disabled=!0),this.logActionPlay({position:e.info.position$.getValue()})}),i(e.events.seeked$,()=>{this.logSeek({action:this.seekAction$.getValue(),time:e.info.position$.getValue()}),this.seekAction$.next(exports.SeekAction.UNKNOWN)}),i(e.events.paused$,()=>{this.logPause({position:e.info.position$.getValue()})}),i(e.events.willResume$,()=>{this.logPlay()}),i(e.events.started$,()=>{this.statContext.clip&&this.logWatchCoverageRecord({start:0,end:0})}),i(ce(e,{forceInterval:this.config.watchCoverageInterval}),n=>{const l=e.info.isLive$.getValue(),g={start:parseFloat(n.from.toFixed(3)),end:parseFloat(n.to.toFixed(3))};l?this.logWatchCoverageLive(g):this.logWatchCoverageRecord(g)});let o;i(e.info.isStalled$,n=>{n?o=r.now():(r.isNonNullable(o)&&this.logEmptyBuffer({duration:r.now()-o}),o=void 0)});let a=!1;s.add(e.events.fatalError$.pipe(r.once()).subscribe(()=>a=!0)),i(e.events.willStop$,()=>{if(e.info.isStalled$.getValue()){const l=r.isNonNullable(o)?r.now()-o:void 0;this.logCloseAtEmptyBuffer({duration:l??0}),o=void 0}else a||this.logActionStop()}),i(e.events.managedError$,({id:n})=>{this.logError({fatal:!1,errorType:n})}),i(e.events.fatalError$,({id:n})=>{this.logError({fatal:!0,errorType:n})});let u,f,h=!1;i(e.events.firstBytes$,n=>{u=r.now(),this.logFirstBytes({time:n})}),i(e.events.willStart$,()=>f=r.now()),i(e.info.currentBuffer$,n=>{!h&&n&&n.end-n.start>0&&r.isNonNullable(u)&&(this.logPlayerReady({duration:r.now()-u}),h=!0)}),i(e.events.firstFrame$,()=>{r.isNonNullable(u)&&!h&&(this.logPlayerReady({duration:r.now()-u}),h=!0),r.isNonNullable(f)&&this.logFirstFrame({time:r.now()-f})}),i(e.info.atLiveEdge$,n=>this.updateContext({liveEdge:n})),i(r.combine({muted:e.info.muted$,volume:e.info.volume$}),({muted:n,volume:l})=>this.updateContext({audible:!n&&l>0})),i(e.info.currentQuality$,n=>this.updateContext({quality:oe(n)})),i(e.info.isAutoQualityEnabled$,n=>this.updateContext({autoQuality:n})),i(e.info.currentFormat$,n=>this.updateContext({contentType:re(n)})),i(e.info.currentPlaybackRate$,n=>this.updateContext({rate:n})),i(e.info.is3DVideo$,n=>this.updateContext({is3d:n}));let d;return i(e.info.hostname$,n=>{this.updateContext({cdnHostname:n,failover:d!==void 0&&d!==n}),d=n}),i(e.info.throughputEstimation$,n=>this.updateContext({downloadSpeed:n})),i(e.info.httpConnectionType$,n=>{this.statContext.firstConnectionType||this.updateContext({firstConnectionType:F(n)}),this.updateContext({connectionType:F(n)})}),i(e.info.httpConnectionReused$,n=>{r.isNullable(this.statContext.firstConnectionReused)&&this.updateContext({firstConnectionReused:n}),this.updateContext({connectionReused:n})}),i(e.info.surface$,n=>this.updateContext({mode:C(n)})),i(r.combine({current:e.info.currentTextTrack$,available:e.info.availableTextTracks$}),({current:n,available:l})=>{const g=l.find(({id:S})=>S===n),m=g&&(g.isAuto?`${g.language}_auto`:g.language);this.updateContext({subtitles:m})}),this.player=e,this.uiEvents&&this.attachToUi(this.uiEvents),this.resubscribeBeforeunload(),this.subscription.add(s),s}attachToUi(e){this.uiEvents=e;const{subscription:s,subscribe:i}=x();return this.player&&(i(e.actionRewind$,()=>{this.player&&(this.resetViewSession(),this.logActionPlay({position:this.player.info.position$.getValue()}))}),i(e.actionSeek$,this.seekAction$),i(e.inPiP$,o=>{const a=o?_.PIP:C(this.player?.info.surface$.getValue());this.updateContext({mode:a})}),i(e.inFullscreen$,o=>{const a=o?_.FULLSCREEN:C(this.player?.info.surface$.getValue());this.updateContext({mode:a})}),i(e.actionSetSubtitle$,o=>this.updateContext({subtitles:o})),i(e.nextMovie$,o=>this.logNextMovie(o)),this.resubscribeBeforeunload(),this.subscription.add(s)),s}attachToAds(e){const{subscription:s,subscribe:i}=x();return i(e.slotRequested$,()=>this.logAdSlotRequest()),i(e.started$,o=>this.logAdStarted(o)),i(e.paused$,()=>this.logAdPaused()),i(e.resumed$,()=>this.logAdResumed()),i(e.ended$,()=>this.logAdEnded()),i(e.skipped$,()=>this.logAdSkipped()),i(e.clicked$,()=>this.logAdClicked()),this.resubscribeBeforeunload(),this.subscription.add(s),s}attachToInteractive(e){const{subscription:s,subscribe:i}=x();return i(e.click$,o=>this.logInterfaceClick(o)),i(e.nextMovie$,o=>this.logNextMovie(o)),this.resubscribeBeforeunload(),this.subscription.add(s),s}authorize(e){return this.api.authorize(e)}pause(){this.logger.pause(),this.oneStatDebugLog({message:"paused"})}resume(){this.logger.resume(),this.oneStatDebugLog({message:"resumed"})}destroy(){this.logger.flush(),this.subscription.unsubscribe(),this.api.destroy(),this.logger.destroy()}resetViewSession(){this.oneStatDebugLog({message:"VSID reset"}),this.vsid$.next(ue())}getDeviceId(){return this.uuid}setFieldBlacklist(){}logInited(){}logReady(e){this.log({operation:"player_ready",param:String(e.time)})}logStarted(...e){this.logActionPlay(...e)}logPlay(){this.log({operation:"play_toggle"})}logPause(e){this.log({operation:"pause",param:String(Math.round(e.position))})}logSeek(e){this.log({operation:"seek",param:e.action,time:e.time})}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:"content_error",param:`${e.fatal?"fatal":"recoverable"}_${e.errorType}`})}logWatchCoverageRecord(e){this.log({operation:"watch_coverage_record",param:`${e.start}-${e.end}`})}logWatchCoverageLive(e){const s=this.timeSynchronisation?.getOffset()??0,i=e.start+s,o=e.end+s;this.log({operation:"watch_coverage_live",param:`${i}-${o}`})}logEmptyBuffer(e){this.log({operation:"empty_buffer",param:String(e.duration)})}logDownloadSpeed(){}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"})}logInterfaceClick(e){this.log({operation:"player_interface_click",param:e})}logNextMovie(e){this.log({operation:"next_movie",param:String(e)})}subscribe(){this.resubscribeBeforeunload();const e=window.navigator.connection;e&&"onchange"in e&&"effectiveType"in e&&this.subscription.add(r.merge(r.fromEvent(e,"change"),r.observableFrom(["init"])).subscribe(()=>this.updateContext({network:ne(e.effectiveType)}))),this.config.debugLog&&this.debugLogger.log$.subscribe(s=>{console.debug("%c stat ","background:#fa6470;",`component: ${s.component}.`,s.message)})}resubscribeBeforeunload(){this.beforeunloadSubscription?.unsubscribe(),this.beforeunloadSubscription=r.fromEvent(window,"beforeunload").subscribe(()=>this.logger.flush(!0)),this.subscription.add(this.beforeunloadSubscription)}logPlayerReady(e){this.log({operation:"player_ready",param:String(Math.round(e.duration))})}logActionPlay(e){this.log({operation:"action_play",param:String(Math.round(e.position))})}logActionPlayWithProjectId(e){this.statContext.projectId&&this.log({operation:"action_play",param:String(Math.round(e.position))},{vid:this.statContext.projectId})}logCloseAtEmptyBuffer(e){this.log({operation:"close_at_empty_buffer",param:String(Math.round(e.duration))})}logActionStop(){this.log({operation:"action_stop"})}log(e,s={}){if(this.disabled){this.oneStatDebugLog({message:`operation ${e.operation} but statistics is disabled`});return}if(this.config.disabledOperations.includes(e.operation)){this.oneStatDebugLog({message:`operation ${e.operation} but it is disabled`});return}this.oneStatDebugLog({message:`operation ${e.operation} ${e.param}`});const i=this.createLogItem(e,s);this.logger.log(i)}createLogItem({operation:e,param:s,time:i},o={}){const a=this.timeSynchronisation?.now()??r.now(),u=this.vsid$.getValue();r.assertNonNullable(u);const f=e==="empty_buffer"||e==="close_at_empty_buffer"?this.statContext.connectionType:this.statContext.firstConnectionType,h=this.statContext.firstConnectionReused;let d,n;if(this.isEmbed){d=this.embedParent;const g=[...new URLSearchParams(location.search).entries()].filter(([m,S])=>this.config.embedUrlParams.includes(m));n=new URLSearchParams(g).toString()}else this.statContext.place==="direct"&&(document.referrer&&(d=new URL(document.referrer).hostname),n=location.href.substring(0,1024));const l={vsid:u,vid:this.statContext.movieId,ct:this.statContext.contentType,place:this.isEmbed?"embed":this.statContext.place,quality:this.statContext.quality,cdn_host:this.statContext.cdnHostname,stat_type:this.statContext.autoplay===!0?v.AUTO:this.statContext.autoplay===!1?v.MANUAL:void 0,param:s,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode,connection_type:f,connection_reused:h===!0?p.YES:h===!1?p.NO:void 0,cached_data:this.statContext.cached===!0?p.YES:this.statContext.cached===!1?p.NO:void 0,live:this.statContext.liveEdge?p.YES:void 0,muted:this.statContext.audible===!1?p.YES:void 0,mode:this.statContext.mode,subtitles:this.statContext.subtitles,download_speed:this.statContext.downloadSpeed,manual_quality:this.statContext.autoQuality?void 0:p.YES,ref_domain:d,direct_url:n,rate:this.statContext.rate===1||r.isNullable(this.statContext.rate)?void 0:this.statContext.rate.toFixed(2),view_360:this.statContext.is3d?1:void 0,aid:this.statContext.albumId,vk_playlist_id:this.statContext.vkPlaylistId,...o};for(const g of this.config.disabledCustomFields)delete l[g];return{operation:e,type:1,time:i,network:this.statContext.network,timestamp:a,custom:l}}}exports.OneStat=he;exports.VERSION=L;
|
|
6
|
+
"use strict";var r=require("@vkontakte/videoplayer-shared/esnext.cjs.js"),c=require("@vkontakte/videoplayer-core/esnext.cjs.js");exports.ApiEnv=void 0;(function(t){t.PROD="prod",t.VK_ALIAS="vk_alias",t.VIDEOTEST="videotest",t.TEST="test",t.AUTO="auto"})(exports.ApiEnv||(exports.ApiEnv={}));exports.Quality=void 0;(function(t){t.Q144P="mobile",t.Q240P="lowest",t.Q360P="low",t.Q480P="medium",t.Q720P="high",t.Q1080P="fullhd",t.Q1440P="quadhd",t.Q2160P="ultrahd",t.UNKNOWN="unknown"})(exports.Quality||(exports.Quality={}));exports.ContentType=void 0;(function(t){t.MP4="mp4",t.DASH="dash",t.DASH_SEP="dash_sep",t.ONDEMAND_DASH="ondemand_dash",t.HLS="hls",t.ONDEMAND_HLS="ondemand_hls",t.WEBM="webm",t.AV1="av1",t.ONDEMAND_DASH_LIVE="ondemand_dash_live",t.ONDEMAND_HLS_LIVE="ondemand_hls_live",t.WEBRTC="webrtc",t.UNKNOWN="unknown",t.RTMP="rtmp"})(exports.ContentType||(exports.ContentType={}));var v;(function(t){t.AUTO="auto",t.MANUAL=""})(v||(v={}));exports.ConnectionType=void 0;(function(t){t.HTTP1="http1",t.HTTP2="http2",t.HTTP3="http3"})(exports.ConnectionType||(exports.ConnectionType={}));var p;(function(t){t[t.YES=1]="YES",t[t.NO=0]="NO"})(p||(p={}));var y;(function(t){t.EXCELLENT="excellent",t.GOOD="good",t.POOR="poor"})(y||(y={}));var _;(function(t){t.PIP="pip",t.FULLSCREEN="fullscreen",t.EXTERNAL="external",t.PREFETCH="prefetch",t.AIRPLAY="airplay",t.CHROMECAST="chromecast",t.INVISIBLE="invisible"})(_||(_={}));exports.SeekAction=void 0;(function(t){t.SLIDER="slider",t.DOUBLE_TAP="double_tap",t.TIME_CODE="time_code",t.EPISODE="episode",t.REWIND="rewind",t.LIVE="live",t.UNKNOWN="unknown"})(exports.SeekAction||(exports.SeekAction={}));exports.InteractiveInterfaceClick=void 0;(function(t){t.GRAPH_SHOW="iGraphShow",t.GRAPH_HIDE="iGraphHide",t.NEXT_AREA="iNextChapterArea",t.NEXT_BUTTON="iNextChapterBtn",t.WATCH_AGAIN="iWatchAgainBtn"})(exports.InteractiveInterfaceClick||(exports.InteractiveInterfaceClick={}));const M={action_play:"ap",first_bytes:"fb",player_ready:"pr",first_frame:"ff",seek:"sk",watch_coverage_record:"wr",watch_coverage_live:"wl",empty_buffer:"eb",action_stop:"as",close_at_empty_buffer:"cb",content_error:"er",player_interface_click:"pc",next_movie:"nm",track_switch:"ts"},Q={vsid:"si",vid:"vi",place:"pl",quality:"qt",cdn_host:"ch",stat_type:"st",param:"pm",vk_app_id:"va",track_code:"tc",connection_type:"cnt",connection_reused:"cr",cached_data:"cd",live:"lv",muted:"mu",mode:"mo",subtitles:"sb",failover:"fo",download_speed:"ds",manual_quality:"mq",ref_domain:"rd",direct_url:"du"},K={unknown:"un",mobile:"m",lowest:"ls",low:"l",medium:"md",high:"h",fullhd:"f",quadhd:"q",ultrahd:"u"},j={pip:"pi",fullscreen:"fs",external:"ex",prefetch:"pr",airplay:"ap",chromecast:"cc",invisible:"iv"},z={apiEnv:exports.ApiEnv.VK_ALIAS,requestRetryCount:1,firstFlushTime:5e3,flushDebounceTime:1e4,flushMaxWait:6e4,storageExpiration:36*60*60*1e3,watchCoverageInterval:15e3,disabledOperations:[],disabledCustomFields:[],shorten:!0,maxLoops:100,embedUrlParams:[],useBeacon:!0,synchronizeTime:!0,debugLog:!1,backoff:{start:1e3,factor:1.5,max:5*60*1e3,random:.1}},G=t=>r.fillWithDefault(t,z);function Y(){const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),e=new Array(36);let s=0,i,o;for(o=0;o<36;o++)o===8||o===13||o===18||o===23?e[o]="-":o===14?e[o]="4":(s<=2&&(s=33554432+Math.random()*16777216|0),i=s&15,s=s>>4,e[o]=t[o===19?i&3|8:i]);return e.join("")}const X=t=>{const{operation:e,custom:s}=t,i=Object.fromEntries(Object.entries(s).map(([o,a])=>{const u=Q[o]??o;let f=a;return a&&(o==="mode"?f=j[a]??a:o==="quality"&&(f=K[a]??a)),[u,f]}));return{...t,operation:M[e]??e,custom:i}},$="1.0.46-dev.df8758f1.0",J="CIOPGQJGDIHBABABA",k={[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 E;(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"})(E||(E={}));class Z{params;authToken;sessionKey;authorizePromise;refreshAuthTokenPromise;consequentAuthErrors=0;authorized$=new r.ValueSubject(!1);backoffTimeoutId;constructor(e){this.params=e}async authorize(e){return this.authToken=e??await this.refreshAuthToken(),this._authorizeWithBackoff()}logBeacon(e){const s="log.externalLog",i=this.createLogParams(e),o=this.sessionKey;if(!o)return;this.params.apiTransport.sendBeacon(s,i,o)||this.logRequest(e)}async logRequest(e){const s="log.externalLog",i=this.createLogParams(e),o=this.sessionKey??await this._authorizeWithBackoff();if(!o)return;const a=async(u,f=this.params.config.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(s,i,o)}catch(h){if(!h||!("error_code"in h)){this.params.error$.next({id:"logRequestUnknown",category:r.ErrorCategory.NETWORK,message:`Unknown ${s} error`,thrown:h});return}const d=h?.error_code;switch(d){case E.PARAM_SESSION_EXPIRED:case E.PARAM_SESSION_KEY:case E.PARAM_SIGNATURE:return this.authorized$.next(!1),this.sessionKey=await this._authorizeWithBackoff(),f>0?a(u,f-1):void 0;case E.AUTH_LOGIN:return this.authorized$.next(!1),this.authToken=await this.refreshAuthToken(),this.sessionKey=await this._authorizeWithBackoff(),f>0?a(u,f-1):void 0;default:{this.params.error$.next({id:`LogRequest#${d}`,category:r.ErrorCategory.EXTERNAL_API,message:`${s} error`,data:h});return}}}};return a(e)}destroy(){window.clearTimeout(this.backoffTimeoutId),this.backoffTimeoutId=0}async refreshAuthToken(){if(this.params.refreshAuthToken)return this.refreshAuthTokenPromise||(this.refreshAuthTokenPromise=this.params.refreshAuthToken().finally(()=>{this.refreshAuthTokenPromise=void 0})),this.refreshAuthTokenPromise}createLogParams(e){return{collector:"ok.mobile.apps.video",data:JSON.stringify({application:`@vkontakte/videoplayer-statistics:${$}`,platform:this.params.mobile?"M_WEB":"WEB",items:this.params.config.shorten?e.map(X):e})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();const e=r.getExponentialDelay(this.consequentAuthErrors,this.params.config.backoff);return new Promise(s=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout(()=>{this._authorize().then(s).catch(i=>this.params.error$.next({id:"AuthorizeBackoff",category:r.ErrorCategory.NETWORK,message:"Otherwise unhandled error in authorization",thrown:i})).finally(()=>this.backoffTimeoutId=0)},e))})}async _authorize(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);const e="auth.anonymLogin",s={session_data:{version:2,device_id:this.params.uuid,client_version:$.split("-")[0],client_type:"SDK_JS"}};return this.authToken!==void 0&&(s.session_data.auth_token=this.authToken,s.session_data.version=3),this.authorizePromise=this.params.apiTransport.sendRequest(e,s).then(i=>((!i||!i.session_key)&&this.params.error$.next({id:"AuthorizeFailed",category:r.ErrorCategory.EXTERNAL_API,message:"No session key",data:i}),this.sessionKey=i?.session_key??void 0,this.sessionKey)).catch(async i=>{this.sessionKey=void 0;const o=i?.error_code;switch(o){case E.AUTH_LOGIN:return this.authToken=await this.refreshAuthToken(),this._authorizeWithBackoff()}o?this.params.error$.next({id:`Authorize#${o}`,category:r.ErrorCategory.EXTERNAL_API,message:"authorize error",data:i}):this.params.error$.next({id:"AuthorizeUnknown",category:r.ErrorCategory.NETWORK,message:"authorize error",thrown:i})}).finally(()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(this.sessionKey!==void 0)}),this.authorizePromise}}class I{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,s,i){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:s,options:i})}removeEventListener(e,s){if(!(e in this.listeners))return;const i=this.listeners[e];for(let o=0,a=i.length;o<a;o++)if(i[o].callback===s){i.splice(o,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;const i=this.listeners[e.type].slice();for(let o=0,a=i.length;o<a;o++){const u=i[o];try{u.callback.call(this,e)}catch(f){Promise.resolve().then(()=>{throw f})}u.options&&u.options.once&&this.removeEventListener(e.type,u.callback)}return!e.defaultPrevented}}class V extends I{constructor(){super(),this.listeners||I.call(this),Object.defineProperty(this,"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,"reason",{value:void 0,writable:!0,configurable:!0})}toString(){return"[object AbortSignal]"}dispatchEvent(e){e.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,e)),super.dispatchEvent(e)}}class ee{constructor(){Object.defineProperty(this,"signal",{value:new V,writable:!0,configurable:!0})}abort(e){let s;try{s=new Event("abort")}catch{typeof document<"u"?document.createEvent?(s=document.createEvent("Event"),s.initEvent("abort",!1,!1)):(s=document.createEventObject(),s.type="abort"):s={type:"abort",bubbles:!1,cancelable:!1}}let i=e;if(i===void 0)if(typeof document>"u")i=new Error("This operation was aborted"),i.name="AbortError";else try{i=new DOMException("signal is aborted without reason")}catch{i=new Error("This operation was aborted"),i.name="AbortError"}this.signal.reason=i,this.signal.dispatchEvent(s)}toString(){return"[object AbortController]"}}typeof Symbol<"u"&&Symbol.toStringTag&&(ee.prototype[Symbol.toStringTag]="AbortController",V.prototype[Symbol.toStringTag]="AbortSignal");function B(t){return t.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):typeof t.Request=="function"&&!t.Request.prototype.hasOwnProperty("signal")||!t.AbortController}function te(t){typeof t=="function"&&(t={fetch:t});const{fetch:e,Request:s=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o=!1}=t;if(!B({fetch:e,Request:s,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:o}))return{fetch:e,Request:a};let a=s;(a&&!a.prototype.hasOwnProperty("signal")||o)&&(a=function(d,n){let l;n&&n.signal&&(l=n.signal,delete n.signal);const g=new s(d,n);return l&&Object.defineProperty(g,"signal",{writable:!1,enumerable:!1,configurable:!0,value:l}),g},a.prototype=s.prototype);const u=e;return{fetch:(h,d)=>{const n=a&&a.prototype.isPrototypeOf(h)?h.signal:d?d.signal:void 0;if(n){let l;try{l=new DOMException("Aborted","AbortError")}catch{l=new Error("Aborted"),l.name="AbortError"}if(n.aborted)return Promise.reject(l);const g=new Promise((m,S)=>{n.addEventListener("abort",()=>S(l),{once:!0})});return d&&d.signal&&delete d.signal,Promise.race([g,u(h,d)])}return u(h,d)},Request:a}}const L=B({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),U=L?te({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,D=L?U.fetch:window.fetch;L?U.Request:window.Request;class ie{apiKey;apiBaseUrl;apiEnv;timeSynchronisation;isApiBaseUrlFetched;params;constructor(e){this.params=e,this.apiKey=e.apiKey,this.apiEnv=e.config.apiEnv,this.apiBaseUrl=k[this.apiEnv],this.timeSynchronisation=e.timeSynchronisation,this.isApiBaseUrlFetched=!1}async resolveApiBaseUrl(){if(this.apiEnv!==exports.ApiEnv.AUTO||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{const e=atob("aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ="),o=(await(await D(e,{method:"GET",mode:"cors",cache:"no-cache"})).json())?.Answer[0]?.data;if(!o)throw new Error("Wrong DNS response");return o}catch(e){return this.params.error$.next({id:"OneStat:ApiTransport:resolveApiBaseUrl",category:r.ErrorCategory.NETWORK,message:"Unhandled resolve api base url error",thrown:e}),k[exports.ApiEnv.VK_ALIAS]}finally{this.isApiBaseUrlFetched=!0}}sendBeacon(e,s,i){if(!window.Blob||!window.navigator.sendBeacon)return!1;const o=this._prepareQueryParams({method:e,queryParams:s,sessionKey:i}),a=new window.Blob([o.toString()],{type:"application/x-www-form-urlencoded"});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,a)}catch(u){this.params.error$.next({id:"OneStat:ApiTransport:sendBeacon",category:r.ErrorCategory.NETWORK,message:"Unhandled beacon error",thrown:u,data:{method:e,params:s}})}return!1}async sendRequest(e,s,i){const o=r.now(),a=u=>{if(u instanceof TypeError&&["Failed to fetch","NetworkError when attempting to fetch resource."].includes(u.message)){this.params.error$.next({id:"Network",category:r.ErrorCategory.NETWORK,message:"Request failed",thrown:u});return}this.params.error$.next({id:"OneStat:ApiTransport:sendRequest",category:r.ErrorCategory.NETWORK,message:"Unhandled request error",thrown:u,data:{method:e,params:s,sessionKey:i,time:r.now()-o}})};return this.apiBaseUrl=await this.resolveApiBaseUrl(),D(`${this.apiBaseUrl}/fb.do`,{method:"post",headers:{"Content-type":"application/x-www-form-urlencoded"},body:this._prepareQueryParams({method:e,queryParams:s,sessionKey:i})}).then(u=>{const f=Number(u.headers.get("content-length"))===0,h=new Date(u.headers.get("date")??"").getTime(),d=r.now()-o;if(isFinite(h)&&this.timeSynchronisation?.addServerTime(h,d),!f)return u.json().then(n=>Object.prototype.hasOwnProperty.call(n,"error_msg")?Promise.reject(n):n,a)},a)}_prepareQueryParams(e){const s=new URLSearchParams({format:"JSON",method:e.method,application_key:this.apiKey});return e.sessionKey!==void 0&&s.append("session_key",e.sessionKey),Object.entries(e.queryParams).forEach(([i,o])=>s.append(i,typeof o=="string"?o:JSON.stringify(o))),s}}const w="onestat_events",P=t=>e=>e.timestamp+t>=r.now();class se{params;api;error$;subscription;userSalt;unsaltedStorage=[];lastVsid;isPaused=!1;firstFlush;debouncedFlush;loggerDebugLog;constructor(e){this.params=e,this.api=e.api,this.error$=e.error$,this.userSalt=e.userSalt,this.loggerDebugLog=e.debugLogger.createComponentLog("stat logger"),this.firstFlush=r.debounceFn(()=>this.safeFlush(),this.params.config.firstFlushTime,{maxWait:this.params.config.firstFlushTime});const s=r.safeStorage.isPersistent()?this.params.config.flushMaxWait:0;this.debouncedFlush=r.debounceFn(()=>this.safeFlush(),this.params.config.flushDebounceTime,{maxWait:s}),this.subscription=this.api.authorized$.subscribe(i=>{i&&this.debouncedFlush()}),this.housekeepStorage()}isUrgent=e=>{const{operation:s}=e;return["action_play","watch_coverage_record","watch_coverage_live"].includes(s)};safeFlush(){try{this.flush()}catch(e){this.error$.next({id:"LoggerError",category:r.ErrorCategory.WTF,message:String(e)??"Unknown logger error",thrown:e})}}readFromStorage(){const e=r.safeStorage.get(w);try{return e?JSON.parse(e):{}}catch{}return{}}addToStorage(e){if(!this.userSalt){this.unsaltedStorage.push(e);return}const s=this.readFromStorage(),o=(s[this.userSalt]??[]).filter(P(this.params.config.storageExpiration));r.safeStorage.set(w,JSON.stringify({...s,[this.userSalt]:[...o,e]}))}getFromStorage(){return this.userSalt?(this.readFromStorage()[this.userSalt]??[]).filter(P(this.params.config.storageExpiration)):this.unsaltedStorage}markStorageSent(){if(!this.userSalt){this.unsaltedStorage=[];return}const e=this.readFromStorage();delete e[this.userSalt],r.safeStorage.set(w,JSON.stringify(e))}housekeepStorage(){const e=this.readFromStorage();for(const[s,i]of Object.entries(e)){const o=i.filter(P(this.params.config.storageExpiration));o.length?e[s]=o:delete e[s],this.loggerDebugLog({message:`${i.length} retrieved from storage, ${o.length} of them actual`})}r.safeStorage.set(w,JSON.stringify(e))}log(e){this.addToStorage(e),!this.isPaused&&(this.isUrgent(e)?this.flush():this.lastVsid!==e.custom.vsid?this.firstFlush():this.debouncedFlush(),this.lastVsid=e.custom.vsid)}flush(e=!1){const s=this.getFromStorage();s.length!==0&&(this.api.authorized$.getValue()?(e&&this.params.config.useBeacon?(this.loggerDebugLog({message:`Flushing ${s.length} events through beacon`}),this.api.logBeacon(s)):(this.loggerDebugLog({message:`Flushing ${s.length} events`}),this.api.logRequest(s)),this.markStorageSent()):this.api.authorize(),this.firstFlush.cancel(),this.debouncedFlush.cancel())}pause(){this.isPaused=!0,this.debouncedFlush.cancel()}resume(){this.isPaused=!1,this.debouncedFlush()}destroy(){this.subscription.unsubscribe(),this.firstFlush.cancel(),this.debouncedFlush.cancel()}}const oe=t=>t&&{[c.VideoQuality.INVARIANT]:exports.Quality.UNKNOWN,[c.VideoQuality.Q_144P]:exports.Quality.Q144P,[c.VideoQuality.Q_240P]:exports.Quality.Q240P,[c.VideoQuality.Q_360P]:exports.Quality.Q360P,[c.VideoQuality.Q_480P]:exports.Quality.Q480P,[c.VideoQuality.Q_720P]:exports.Quality.Q720P,[c.VideoQuality.Q_1080P]:exports.Quality.Q1080P,[c.VideoQuality.Q_1440P]:exports.Quality.Q1440P,[c.VideoQuality.Q_2160P]:exports.Quality.Q2160P,[c.VideoQuality.Q_4320P]:exports.Quality.UNKNOWN}[t],F=t=>t&&{[c.HttpConnectionType.HTTP1]:exports.ConnectionType.HTTP1,[c.HttpConnectionType.HTTP2]:exports.ConnectionType.HTTP2,[c.HttpConnectionType.QUIC]:exports.ConnectionType.HTTP3}[t],re=t=>{if(t!==void 0)switch(t){case c.VideoFormat.MPEG:return exports.ContentType.MP4;case c.VideoFormat.DASH:case c.VideoFormat.DASH_LIVE:return exports.ContentType.DASH;case c.VideoFormat.DASH_SEP:return exports.ContentType.DASH_SEP;case c.VideoFormat.DASH_ONDEMAND:return exports.ContentType.ONDEMAND_DASH;case c.VideoFormat.DASH_WEBM:case c.VideoFormat.DASH_LIVE_WEBM:return exports.ContentType.WEBM;case c.VideoFormat.DASH_WEBM_AV1:return exports.ContentType.AV1;case c.VideoFormat.DASH_LIVE_CMAF:return exports.ContentType.ONDEMAND_DASH_LIVE;case c.VideoFormat.HLS:case c.VideoFormat.HLS_LIVE:return exports.ContentType.HLS;case c.VideoFormat.HLS_ONDEMAND:return exports.ContentType.ONDEMAND_HLS;case c.VideoFormat.HLS_LIVE_CMAF:return exports.ContentType.ONDEMAND_HLS_LIVE;case c.VideoFormat.WEB_RTC_LIVE:return exports.ContentType.WEBRTC;default:return r.assertNever(t)}},C=t=>{if(t!==void 0)switch(t){case c.Surface.NONE:case c.Surface.INLINE:return;case c.Surface.FULLSCREEN:return _.FULLSCREEN;case c.Surface.SECOND_SCREEN:return _.CHROMECAST;case c.Surface.PIP:return _.PIP;default:return r.assertNever(t)}},ne=t=>{switch(t){case"slow-2g":return y.POOR;case"2g":return y.POOR;case"3g":return y.GOOD;case"4g":return y.EXCELLENT}};class ae{offset=void 0;constructor(e){this.offset=e}getOffset(){return this.offset??0}setOffset(e){this.offset=e}now(){return Date.now()+(this.offset??0)}date(e=new Date){return e.setTime(e.getTime()+(this.offset??0)),e}addServerTime(e,s){const i=Date.now(),o=e-i-s/2;if(Math.abs(o)<1e3){this.offset=0;return}this.offset===void 0?this.offset=Math.round(o):this.offset=Math.round(.2*o+(1-.2)*this.offset)}}const ue=()=>Math.floor(Math.random()*2**32).toString(36).padStart(8,"0"),ce=(t,e)=>new r.Observable(s=>{const i=new r.Subscription,o=r.merge(r.fromEvent(window,"beforeunload"),t.events.willDestruct$),a=new r.ValueSubject(void 0);let u;i.add(t.info.isLive$.pipe(r.filterChanged()).subscribe(b=>{u&&(u.unsubscribe(),a.next(void 0)),b?u=t.info.liveTime$.pipe(r.map(T=>T&&T/1e3)).subscribe(a):u=t.info.position$.subscribe(a),i.add(u)}));const{playing$:f,paused$:h}=t.events,d=t.events.willSeek$.pipe(r.filter(()=>t.info.playbackState$.getValue()===c.PlaybackState.PLAYING)),n=t.events.seeked$.pipe(r.filter(()=>t.info.playbackState$.getValue()===c.PlaybackState.PLAYING));let l=!1;const g=new r.Subject;i.add(d.subscribe(()=>{l||g.next(),l=!0})),i.add(n.subscribe(()=>l=!1));const m=new r.Subject,S=new r.Subject,O=r.merge(f,n,m),R=r.merge(h,g,o,t.events.looped$,S);let A;const q=()=>A=a.getValue(),H=()=>{const b=a.getValue();r.isNullable(A)||A===b||r.isNullable(b)||(s.next({from:A,to:b}),A=void 0)},W=()=>{S.next(),m.next()};if(i.add(O.subscribe(q)),i.add(R.subscribe(H)),e.forceInterval&&isFinite(e.forceInterval)){let b=0;i.add(O.subscribe(()=>b=window.setTimeout(W,e.forceInterval))),i.add(R.subscribe(()=>window.clearTimeout(b)))}return i}),le="_one-stat_",N=`${le}uuid`,x=()=>{const t=new r.Subscription;return{subscription:t,subscribe:(e,s)=>{e&&t.add(e.subscribe(s))}}};class he{api;logger;config;subscription=new r.Subscription;beforeunloadSubscription;timeSynchronisation;debugLogger=new r.Logger;oneStatDebugLog=this.debugLogger.createComponentLog("onestat");loopCounter=0;disabled=!1;experimental;vsid$=new r.ValueSubject(void 0);statContext;isEmbed;embedParent;uiEvents;player;seekAction$=new r.ValueSubject(exports.SeekAction.UNKNOWN);uuid;constructor(e,s){this.statContext=e,this.config=G(s.config??{}),r.isNonNullable(s.apiEnv)&&(this.config.apiEnv=s.apiEnv),this.config.synchronizeTime&&(this.timeSynchronisation=new ae);const i=new r.Subject;this.experimental={error$:i};const o=r.safeStorage.get(N);o?o.startsWith('"')&&o.endsWith('"')?(this.uuid=o.replaceAll('"',""),r.safeStorage.set(N,this.uuid)):this.uuid=o:(this.uuid=Y(),r.safeStorage.set(N,this.uuid)),s.vsid?this.vsid$.next(s.vsid):this.resetViewSession();const a=new ie({apiKey:J,config:this.config,error$:i,timeSynchronisation:this.timeSynchronisation});this.api=new Z({config:this.config,apiTransport:a,refreshAuthToken:s.refreshAuthToken,mobile:this.statContext.mobile??!1,uuid:this.uuid,error$:i}),this.logger=new se({config:this.config,debugLogger:this.debugLogger,api:this.api,error$:i,userSalt:s.userSalt});const{isEmbed:u,host:f}=r.detectEmbed();this.isEmbed=u,this.embedParent=f,this.subscribe()}updateContext(e){this.statContext={...this.statContext,...e}}attachTo(e){const s=new r.Subscription,i=(n,l)=>s.add(n.subscribe(l));i(e.events.willStart$,()=>{const n=e.info.position$.getValue();this.logActionPlay({position:n}),this.statContext.projectId&&this.logActionPlayWithProjectId({position:n})}),i(e.events.looped$,()=>{this.resetViewSession(),++this.loopCounter>this.config.maxLoops&&(this.disabled=!0),this.logActionPlay({position:e.info.position$.getValue()})}),i(e.events.seeked$,()=>{this.logSeek({action:this.seekAction$.getValue(),time:e.info.position$.getValue()}),this.seekAction$.next(exports.SeekAction.UNKNOWN)}),i(e.events.paused$,()=>{this.logPause({position:e.info.position$.getValue()})}),i(e.events.willResume$,()=>{this.logPlay()}),i(e.events.started$,()=>{this.statContext.clip&&this.logWatchCoverageRecord({start:0,end:0})}),i(ce(e,{forceInterval:this.config.watchCoverageInterval}),n=>{const l=e.info.isLive$.getValue(),g={start:parseFloat(n.from.toFixed(3)),end:parseFloat(n.to.toFixed(3))};l?this.logWatchCoverageLive(g):this.logWatchCoverageRecord(g)});let o;i(e.info.isStalled$,n=>{n?o=r.now():(r.isNonNullable(o)&&this.logEmptyBuffer({duration:r.now()-o}),o=void 0)});let a=!1;s.add(e.events.fatalError$.pipe(r.once()).subscribe(()=>a=!0)),i(e.events.willStop$,()=>{if(e.info.isStalled$.getValue()){const l=r.isNonNullable(o)?r.now()-o:void 0;this.logCloseAtEmptyBuffer({duration:l??0}),o=void 0}else a||this.logActionStop()}),i(e.events.managedError$,({id:n})=>{this.logError({fatal:!1,errorType:n})}),i(e.events.fatalError$,({id:n})=>{this.logError({fatal:!0,errorType:n})});let u,f,h=!1;i(e.events.firstBytes$,n=>{u=r.now(),this.logFirstBytes({time:n})}),i(e.events.willStart$,()=>f=r.now()),i(e.info.currentBuffer$,n=>{!h&&n&&n.end-n.start>0&&r.isNonNullable(u)&&(this.logPlayerReady({duration:r.now()-u}),h=!0)}),i(e.events.firstFrame$,()=>{r.isNonNullable(u)&&!h&&(this.logPlayerReady({duration:r.now()-u}),h=!0),r.isNonNullable(f)&&this.logFirstFrame({time:r.now()-f})}),i(e.info.atLiveEdge$,n=>this.updateContext({liveEdge:n})),i(r.combine({muted:e.info.muted$,volume:e.info.volume$}),({muted:n,volume:l})=>this.updateContext({audible:!n&&l>0})),i(e.info.currentQuality$,n=>this.updateContext({quality:oe(n)})),i(e.info.isAutoQualityEnabled$,n=>this.updateContext({autoQuality:n})),i(e.info.currentFormat$,n=>this.updateContext({contentType:re(n)})),i(e.info.currentPlaybackRate$,n=>this.updateContext({rate:n})),i(e.info.is3DVideo$,n=>this.updateContext({is3d:n}));let d;return i(e.info.hostname$,n=>{this.updateContext({cdnHostname:n,failover:d!==void 0&&d!==n}),d=n}),i(e.info.throughputEstimation$,n=>this.updateContext({downloadSpeed:n})),i(e.info.httpConnectionType$,n=>{this.statContext.firstConnectionType||this.updateContext({firstConnectionType:F(n)}),this.updateContext({connectionType:F(n)})}),i(e.info.httpConnectionReused$,n=>{r.isNullable(this.statContext.firstConnectionReused)&&this.updateContext({firstConnectionReused:n}),this.updateContext({connectionReused:n})}),i(e.info.surface$,n=>this.updateContext({mode:C(n)})),i(r.combine({current:e.info.currentTextTrack$,available:e.info.availableTextTracks$}),({current:n,available:l})=>{const g=l.find(({id:S})=>S===n),m=g&&(g.isAuto?`${g.language}_auto`:g.language);this.updateContext({subtitles:m})}),this.player=e,this.uiEvents&&this.attachToUi(this.uiEvents),this.resubscribeBeforeunload(),this.subscription.add(s),s}attachToUi(e){this.uiEvents=e;const{subscription:s,subscribe:i}=x();return this.player&&(i(e.actionRewind$,()=>{this.player&&(this.resetViewSession(),this.logActionPlay({position:this.player.info.position$.getValue()}))}),i(e.actionSeek$,this.seekAction$),i(e.inPiP$,o=>{const a=o?_.PIP:C(this.player?.info.surface$.getValue());this.updateContext({mode:a})}),i(e.inFullscreen$,o=>{const a=o?_.FULLSCREEN:C(this.player?.info.surface$.getValue());this.updateContext({mode:a})}),i(e.actionSetSubtitle$,o=>this.updateContext({subtitles:o})),i(e.nextMovie$,o=>this.logNextMovie(o)),this.resubscribeBeforeunload(),this.subscription.add(s)),s}attachToAds(e){const{subscription:s,subscribe:i}=x();return i(e.slotRequested$,()=>this.logAdSlotRequest()),i(e.started$,o=>this.logAdStarted(o)),i(e.paused$,()=>this.logAdPaused()),i(e.resumed$,()=>this.logAdResumed()),i(e.ended$,()=>this.logAdEnded()),i(e.skipped$,()=>this.logAdSkipped()),i(e.clicked$,()=>this.logAdClicked()),this.resubscribeBeforeunload(),this.subscription.add(s),s}attachToInteractive(e){const{subscription:s,subscribe:i}=x();return i(e.click$,o=>this.logInterfaceClick(o)),i(e.nextMovie$,o=>this.logNextMovie(o)),this.resubscribeBeforeunload(),this.subscription.add(s),s}authorize(e){return this.api.authorize(e)}pause(){this.logger.pause(),this.oneStatDebugLog({message:"paused"})}resume(){this.logger.resume(),this.oneStatDebugLog({message:"resumed"})}destroy(){this.logger.flush(),this.subscription.unsubscribe(),this.api.destroy(),this.logger.destroy()}resetViewSession(){this.oneStatDebugLog({message:"VSID reset"}),this.vsid$.next(ue())}getDeviceId(){return this.uuid}setFieldBlacklist(){}logInited(){}logReady(e){this.log({operation:"player_ready",param:String(e.time)})}logStarted(...e){this.logActionPlay(...e)}logPlay(){this.log({operation:"play_toggle"})}logPause(e){this.log({operation:"pause",param:String(Math.round(e.position))})}logSeek(e){this.log({operation:"seek",param:e.action,time:e.time})}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:"content_error",param:`${e.fatal?"fatal":"recoverable"}_${e.errorType}`})}logWatchCoverageRecord(e){this.log({operation:"watch_coverage_record",param:`${e.start}-${e.end}`})}logWatchCoverageLive(e){const s=this.timeSynchronisation?.getOffset()??0,i=e.start+s,o=e.end+s;this.log({operation:"watch_coverage_live",param:`${i}-${o}`})}logEmptyBuffer(e){this.log({operation:"empty_buffer",param:String(e.duration)})}logDownloadSpeed(){}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"})}logInterfaceClick(e){this.log({operation:"player_interface_click",param:e})}logNextMovie(e){this.log({operation:"next_movie",param:String(e)})}subscribe(){this.resubscribeBeforeunload();const e=window.navigator.connection;e&&"onchange"in e&&"effectiveType"in e&&this.subscription.add(r.merge(r.fromEvent(e,"change"),r.observableFrom(["init"])).subscribe(()=>this.updateContext({network:ne(e.effectiveType)}))),this.config.debugLog&&this.debugLogger.log$.subscribe(s=>{console.debug("%c stat ","background:#fa6470;",`component: ${s.component}.`,s.message)})}resubscribeBeforeunload(){this.beforeunloadSubscription?.unsubscribe(),this.beforeunloadSubscription=r.fromEvent(window,"beforeunload").subscribe(()=>this.logger.flush(!0)),this.subscription.add(this.beforeunloadSubscription)}logPlayerReady(e){this.log({operation:"player_ready",param:String(Math.round(e.duration))})}logActionPlay(e){this.log({operation:"action_play",param:String(Math.round(e.position))})}logActionPlayWithProjectId(e){this.statContext.projectId&&this.log({operation:"action_play",param:String(Math.round(e.position))},{vid:this.statContext.projectId})}logCloseAtEmptyBuffer(e){this.log({operation:"close_at_empty_buffer",param:String(Math.round(e.duration))})}logActionStop(){this.log({operation:"action_stop"})}log(e,s={}){if(this.disabled){this.oneStatDebugLog({message:`operation ${e.operation} but statistics is disabled`});return}if(this.config.disabledOperations.includes(e.operation)){this.oneStatDebugLog({message:`operation ${e.operation} but it is disabled`});return}this.oneStatDebugLog({message:`operation ${e.operation} ${e.param}`});const i=this.createLogItem(e,s);this.logger.log(i)}createLogItem({operation:e,param:s,time:i},o={}){const a=this.timeSynchronisation?.now()??r.now(),u=this.vsid$.getValue();r.assertNonNullable(u);const f=e==="empty_buffer"||e==="close_at_empty_buffer"?this.statContext.connectionType:this.statContext.firstConnectionType,h=this.statContext.firstConnectionReused;let d,n;if(this.isEmbed){d=this.embedParent;const g=[...new URLSearchParams(location.search).entries()].filter(([m,S])=>this.config.embedUrlParams.includes(m));n=new URLSearchParams(g).toString()}else this.statContext.place==="direct"&&(document.referrer&&(d=new URL(document.referrer).hostname),n=location.href.substring(0,1024));const l={vsid:u,vid:this.statContext.movieId,ct:this.statContext.contentType,place:this.isEmbed?"embed":this.statContext.place,quality:this.statContext.quality,cdn_host:this.statContext.cdnHostname,stat_type:this.statContext.autoplay===!0?v.AUTO:this.statContext.autoplay===!1?v.MANUAL:void 0,param:s,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode,connection_type:f,connection_reused:h===!0?p.YES:h===!1?p.NO:void 0,cached_data:this.statContext.cached===!0?p.YES:this.statContext.cached===!1?p.NO:void 0,live:this.statContext.liveEdge?p.YES:void 0,muted:this.statContext.audible===!1?p.YES:void 0,mode:this.statContext.mode,subtitles:this.statContext.subtitles,download_speed:this.statContext.downloadSpeed,manual_quality:this.statContext.autoQuality?void 0:p.YES,ref_domain:d,direct_url:n,rate:this.statContext.rate===1||r.isNullable(this.statContext.rate)?void 0:this.statContext.rate.toFixed(2),view_360:this.statContext.is3d?1:void 0,aid:this.statContext.albumId,vk_playlist_id:this.statContext.vkPlaylistId,...o};for(const g of this.config.disabledCustomFields)delete l[g];return{operation:e,type:1,time:i,network:this.statContext.network,timestamp:a,custom:l}}}exports.OneStat=he;exports.VERSION=$;
|