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