@vkontakte/videoplayer-statistics 1.0.44 → 1.0.45-dev.41346c2e.0

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