@vkontakte/videoplayer-statistics 1.0.77-dev.38c1ddaf.0 → 1.0.77-dev.4c6dbe21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es2015.cjs.js +3 -3
- package/es2015.esm.js +3 -3
- package/es2018.cjs.js +3 -3
- package/es2018.esm.js +3 -3
- package/es2024.cjs.js +3 -3
- package/es2024.esm.js +3 -3
- package/esnext.cjs.js +3 -3
- package/esnext.esm.js +3 -3
- package/evergreen.esm.js +3 -3
- package/package.json +3 -3
- package/types/index.d.ts +6 -2
- package/types/oneStat/index.d.ts +0 -6
- package/types/thinOneStat/Api.d.ts +0 -38
- package/types/thinOneStat/ApiTransport.d.ts +0 -25
- package/types/thinOneStat/Logger.d.ts +0 -42
- package/types/thinOneStat/ThinOneStat.d.ts +0 -169
- package/types/thinOneStat/config.d.ts +0 -17
- package/types/thinOneStat/env.d.ts +0 -7
- package/types/thinOneStat/index.d.ts +0 -4
- package/types/thinOneStat/types.d.ts +0 -27
- package/types/thinOneStat/uiEvents.d.ts +0 -10
- package/types/thinOneStat/utils/calculateTotalViewTime.d.ts +0 -5
- package/types/thinOneStat/utils/mappers.d.ts +0 -8
- package/types/thinOneStat/utils/timeSynchronisation.d.ts +0 -10
- package/types/thinOneStat/utils/uuid.d.ts +0 -1
- package/types/thinOneStat/utils/vsid.d.ts +0 -2
- package/types/thinOneStat/utils/watchCoverage.d.ts +0 -6
- package/types/thinOneStat/utils/watchedN.d.ts +0 -7
- package/types/thinOneStat/values.d.ts +0 -74
- /package/types/{oneStat/Api.d.ts → Api.d.ts} +0 -0
- /package/types/{oneStat/ApiTransport.d.ts → ApiTransport.d.ts} +0 -0
- /package/types/{oneStat/Logger.d.ts → Logger.d.ts} +0 -0
- /package/types/{oneStat/OneStat.d.ts → OneStat.d.ts} +0 -0
- /package/types/{oneStat/config.d.ts → config.d.ts} +0 -0
- /package/types/{oneStat/env.d.ts → env.d.ts} +0 -0
- /package/types/{oneStat/types.d.ts → types.d.ts} +0 -0
- /package/types/{oneStat/uiEvents.d.ts → uiEvents.d.ts} +0 -0
- /package/types/{oneStat/utils → utils}/mappers.d.ts +0 -0
- /package/types/{oneStat/utils → utils}/shorten.d.ts +0 -0
- /package/types/{oneStat/utils → utils}/timeSynchronisation.d.ts +0 -0
- /package/types/{oneStat/utils → utils}/uuid.d.ts +0 -0
- /package/types/{oneStat/utils → utils}/vsid.d.ts +0 -0
- /package/types/{oneStat/utils → utils}/watchCoverage.d.ts +0 -0
- /package/types/{oneStat/values.d.ts → values.d.ts} +0 -0
package/evergreen.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-statistics v1.0.77-dev.
|
|
3
|
-
*
|
|
2
|
+
* @vkontakte/videoplayer-statistics v1.0.77-dev.4c6dbe21.0
|
|
3
|
+
* Thu, 24 Apr 2025 15:22:16 GMT
|
|
4
4
|
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-77/doc/
|
|
5
5
|
*/
|
|
6
|
-
var Et=Object.defineProperty;var At=(r,e)=>{for(var o in e)Et(r,o,{get:e[o],enumerable:!0})};var R=(n=>(n.PROD="prod",n.VK_ALIAS="vk_alias",n.VIDEOTEST="videotest",n.TEST="test",n.OKCDN="okcdn",n.AUTO="auto",n))(R||{}),oe=(l=>(l.Q144P="mobile",l.Q240P="lowest",l.Q360P="low",l.Q480P="medium",l.Q720P="high",l.Q1080P="fullhd",l.Q1440P="quadhd",l.Q2160P="ultrahd",l.UNKNOWN="unknown",l))(oe||{}),re=(c=>(c.MP4="mp4",c.DASH="dash",c.DASH_SEP="dash_sep",c.ONDEMAND_DASH="ondemand_dash",c.HLS="hls",c.ONDEMAND_HLS="ondemand_hls",c.WEBM="webm",c.AV1="av1",c.ONDEMAND_DASH_LIVE="ondemand_dash_live",c.ONDEMAND_HLS_LIVE="ondemand_hls_live",c.WEBRTC="webrtc",c.UNKNOWN="unknown",c.RTMP="rtmp",c))(re||{});var se=(t=>(t.HTTP1="http1",t.HTTP2="http2",t.HTTP3="http3",t))(se||{});var ne=(d=>(d.SLIDER="slider",d.DOUBLE_TAP="double_tap",d.TIME_CODE="time_code",d.EPISODE="episode",d.REWIND="rewind",d.LIVE="live",d.UNKNOWN="unknown",d))(ne||{}),we=(s=>(s.GRAPH_SHOW="iGraphShow",s.GRAPH_HIDE="iGraphHide",s.NEXT_AREA="iNextChapterArea",s.NEXT_BUTTON="iNextChapterBtn",s.WATCH_AGAIN="iWatchAgainBtn",s))(we||{}),xe={action_play:"ap",action_play_interactive:"api",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",failover:"fo",quality:"qt"},ke={vsid:"si",isid:"is",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"},Le={unknown:"un",mobile:"m",lowest:"ls",low:"l",medium:"md",high:"h",fullhd:"f",quadhd:"q",ultrahd:"u"},Ce={pip:"pi",fullscreen:"fs",external:"ex",prefetch:"pr",airplay:"ap",chromecast:"cc",invisible:"iv"};import{fillWithDefault as Tt}from"@vkontakte/videoplayer-shared/evergreen";var F="__VERSION__",$e="CIOPGQJGDIHBABABA",ae={prod:"https://api.ok.ru",vk_alias:"https://api.mycdn.me",videotest:"https://videotestapi.ok.ru/api",test:"https://apitest.ok.ru",okcdn:"https://api.okcdn.ru",auto:""};var wt={apiEnv:"vk_alias",apiKey:$e,requestRetryCount:1,firstFlushTime:5e3,flushDebounceTime:1e4,flushMaxWait:6e4,storageExpiration:36*60*60*1e3,watchCoverageInterval:15e3,disabledOperations:["quality"],disabledCustomFields:[],shorten:!0,maxLoops:100,embedUrlParams:[],useBeacon:!0,synchronizeTime:!0,debugLog:!1,clearStorageAtUnload:!0,useVKComIsMobileLogic:!1,backoff:{start:1e3,factor:1.5,max:5*60*1e3,random:.1}},De=r=>Tt(r,wt);function de(){let r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),e=new Array(36),o=0,t,i;for(i=0;i<36;i++)i===8||i===13||i===18||i===23?e[i]="-":i===14?e[i]="4":(o<=2&&(o=33554432+Math.random()*16777216|0),t=o&15,o=o>>4,e[i]=r[i===19?t&3|8:t]);return e.join("")}import{assertNonNullable as Bt,combine as Qe,fromEvent as ze,isNonNullable as $,isNullable as je,merge as Ft,now as T,observableFrom as Ht,once as Wt,safeStorage as Ge,Subject as Kt,Subscription as me,ValueSubject as z,createURL as Ye}from"@vkontakte/videoplayer-shared/evergreen";import{Logger as qt,detectEmbed as Qt}from"@vkontakte/videoplayer-shared/evergreen";var Ne=r=>{let{operation:e,custom:o}=r,t=Object.fromEntries(Object.entries(o).map(([i,s])=>{let n=ke[i]??i,d=s;return s&&(i==="mode"?d=Ce[s]??s:i==="quality"&&(d=Le[s]??s)),[n,d]}));return{...r,operation:xe[e]??e,custom:t}};import{ValueSubject as xt,getExponentialDelay as kt,ErrorCategory as L}from"@vkontakte/videoplayer-shared/evergreen";var Lt=/Mobile|mini|Fennec|Android|iP(ad|od|hone)|opera (mini|mobi)/i,V=class{constructor(e){this.consequentAuthErrors=0;this.authorized$=new xt(!1);this.params=e}async authorize(e){return this.authToken=e??await this.refreshAuthToken(),this._authorizeWithBackoff()}logBeacon(e){let o="log.externalLog",t=this.createLogParams(e),i=this.sessionKey;if(!i)return;this.params.apiTransport.sendBeacon(o,t,i)||this.logRequest(e).catch(()=>{})}async logRequest(e){let o="log.externalLog",t=this.createLogParams(e),i=this.sessionKey??await this._authorizeWithBackoff();if(!i)return;let s=async(n,d=this.params.config.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(o,t,i)}catch(u){if(!u||!("error_code"in u)){this.params.error$.next({id:"logRequestUnknown",category:L.NETWORK,message:`Unknown ${o} error`,thrown:u});return}let l=u?.error_code;switch(l){case 102:case 103:case 104:return this.authorized$.next(!1),this.sessionKey=await this._authorizeWithBackoff(),d>0?s(n,d-1):void 0;case 401:return this.authorized$.next(!1),this.authToken=await this.refreshAuthToken(),this.sessionKey=await this._authorizeWithBackoff(),d>0?s(n,d-1):void 0;default:{this.params.error$.next({id:`LogRequest#${l}`,category:L.EXTERNAL_API,message:`${o} error`,data:u});return}}}};return s(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){let o="WEB",t=!1;if(this.params.config.useVKComIsMobileLogic){let{appVersion:i}=window.navigator;t=Lt.test(i)}else this.params.mobile&&(t=!0);return t&&(o="M_WEB"),{collector:"ok.mobile.apps.video",data:JSON.stringify({application:`@vkontakte/videoplayer-statistics:${F}`,platform:o,items:this.params.config.shorten?e.map(Ne):e})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();let e=kt(this.consequentAuthErrors,this.params.config.backoff);return new Promise(o=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout(()=>{this._authorize().then(o).catch(t=>this.params.error$.next({id:"AuthorizeBackoff",category:L.NETWORK,message:"Otherwise unhandled error in authorization",thrown:t})).finally(()=>this.backoffTimeoutId=0)},e))})}async _authorize(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);let e="auth.anonymLogin",o={session_data:{version:2,device_id:this.params.deviceId,client_version:F.split("-")[0],client_type:"SDK_JS"}};return this.authToken!==void 0&&(o.session_data.auth_token=this.authToken,o.session_data.version=3),this.authorizePromise=this.params.apiTransport.sendRequest(e,o).then(t=>((!t||!t.session_key)&&this.params.error$.next({id:"AuthorizeFailed",category:L.EXTERNAL_API,message:"No session key",data:t}),this.sessionKey=t?.session_key??void 0,this.sessionKey)).catch(async t=>{this.sessionKey=void 0;let i=t?.error_code;switch(i){case 401:return this.authToken=await this.refreshAuthToken(),this._authorizeWithBackoff()}i?this.params.error$.next({id:`Authorize#${i}`,category:L.EXTERNAL_API,message:"authorize error",data:t}):this.params.error$.next({id:"AuthorizeUnknown",category:L.NETWORK,message:"authorize error",thrown:t})}).finally(()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(this.sessionKey!==void 0)}),this.authorizePromise}};import{ErrorCategory as H,now as ce}from"@vkontakte/videoplayer-shared/evergreen";var M=class{constructor(e){this.params=e,this.apiKey=e.config.apiKey,this.apiEnv=e.config.apiEnv,this.apiBaseUrl=ae[this.apiEnv],this.timeSynchronisation=e.timeSynchronisation,this.isApiBaseUrlFetched=!1}async resolveApiBaseUrl(){if(this.apiEnv!=="auto"||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{let e=atob("aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ="),i=(await(await fetch(e,{method:"GET",mode:"cors",cache:"no-cache"})).json())?.Answer[0]?.data;if(!i)throw new Error("Wrong DNS response");return i}catch(e){return this.params.error$.next({id:"OneStat:ApiTransport:resolveApiBaseUrl",category:H.NETWORK,message:"Unhandled resolve api base url error",thrown:e}),ae.vk_alias}finally{this.isApiBaseUrlFetched=!0}}sendBeacon(e,o,t){if(!window.Blob||!window.navigator.sendBeacon)return!1;let i=this._prepareQueryParams({method:e,queryParams:o,sessionKey:t}),s=new window.Blob([i.toString()],{type:"application/x-www-form-urlencoded"});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,s)}catch(n){this.params.error$.next({id:"OneStat:ApiTransport:sendBeacon",category:H.NETWORK,message:"Unhandled beacon error",thrown:n,data:{method:e,params:o}})}return!1}async sendRequest(e,o,t){let i=ce(),s=n=>{if(n instanceof TypeError&&["Failed to fetch","NetworkError when attempting to fetch resource."].includes(n.message)){this.params.error$.next({id:"Network",category:H.NETWORK,message:"Request failed",thrown:n});return}this.params.error$.next({id:"OneStat:ApiTransport:sendRequest",category:H.NETWORK,message:"Unhandled request error",thrown:n,data:{method:e,params:o,sessionKey:t,time:ce()-i}})};return this.apiBaseUrl=await this.resolveApiBaseUrl(),fetch(`${this.apiBaseUrl}/fb.do`,{method:"post",headers:{"Content-type":"application/x-www-form-urlencoded"},body:this._prepareQueryParams({method:e,queryParams:o,sessionKey:t})}).then(n=>{let d=Number(n.headers.get("content-length"))===0,u=new Date(n.headers.get("date")??"").getTime(),l=ce()-i;if(isFinite(u)&&this.timeSynchronisation?.addServerTime(u,l),!d)return n.json().then(h=>Object.prototype.hasOwnProperty.call(h,"error_msg")?Promise.reject(h):h,s)},s)}_prepareQueryParams(e){let o=new URLSearchParams({format:"JSON",method:e.method,application_key:this.apiKey});return e.sessionKey!==void 0&&o.append("session_key",e.sessionKey),Object.entries(e.queryParams).forEach(([t,i])=>o.append(t,typeof i=="string"?i:JSON.stringify(i))),o}};import{ErrorCategory as Ct,now as $t,safeStorage as U,debounceFn as Oe}from"@vkontakte/videoplayer-shared/evergreen";var W="onestat_events",ue=r=>e=>e.timestamp+r>=$t(),K=class{constructor(e){this.unsaltedStorage=[];this.isPaused=!1;this.isUrgent=e=>{let{operation:o}=e;return["action_play","watch_coverage_record","watch_coverage_live"].includes(o)};this.params=e,this.api=e.api,this.error$=e.error$,this.userSalt=e.userSalt,this.loggerDebugLog=e.debugLogger.createComponentLog("stat logger"),this.firstFlush=Oe(()=>this.safeFlush(),this.params.config.firstFlushTime,{maxWait:this.params.config.firstFlushTime});let o=U.isPersistent()?this.params.config.flushMaxWait:0;this.debouncedFlush=Oe(()=>this.safeFlush(),this.params.config.flushDebounceTime,{maxWait:o}),this.subscription=this.api.authorized$.subscribe(t=>{t&&this.debouncedFlush()}),this.housekeepStorage()}safeFlush(){try{this.flush()}catch(e){this.error$.next({id:"LoggerError",category:Ct.WTF,message:e?String(e):"Unknown logger error",thrown:e})}}readFromStorage(){let e=U.get(W);try{return e?JSON.parse(e):{}}catch{}return{}}addToStorage(e){if(!this.userSalt){this.unsaltedStorage.push(e);return}let o=this.readFromStorage(),i=(o[this.userSalt]??[]).filter(ue(this.params.config.storageExpiration));U.set(W,JSON.stringify({...o,[this.userSalt]:[...i,e]}))}getFromStorage(){return this.userSalt?(this.readFromStorage()[this.userSalt]??[]).filter(ue(this.params.config.storageExpiration)):this.unsaltedStorage}markStorageSent(){if(!this.userSalt){this.unsaltedStorage=[];return}let e=this.readFromStorage();delete e[this.userSalt],U.set(W,JSON.stringify(e))}housekeepStorage(){let e=this.readFromStorage();for(let[o,t]of Object.entries(e)){let i=t.filter(ue(this.params.config.storageExpiration));i.length?e[o]=i:delete e[o],this.loggerDebugLog({message:`${t.length} retrieved from storage, ${i.length} of them actual`})}U.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({wantBeacon:e,clearStorage:o}={wantBeacon:!1,clearStorage:!0}){let t=this.getFromStorage();t.length!==0&&(this.api.authorized$.getValue()?(e&&this.params.config.useBeacon?(this.loggerDebugLog({message:`Flushing ${t.length} events through beacon`}),this.api.logBeacon(t)):(this.loggerDebugLog({message:`Flushing ${t.length} events`}),this.api.logRequest(t)),o&&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()}};import{HttpConnectionType as le,Surface as C,VideoFormat as v,VideoQuality as _}from"@vkontakte/videoplayer-core/evergreen";import{assertNever as Re}from"@vkontakte/videoplayer-shared/evergreen";var Ve=r=>r&&{[_.INVARIANT]:"unknown",[_.Q_144P]:"mobile",[_.Q_240P]:"lowest",[_.Q_360P]:"low",[_.Q_480P]:"medium",[_.Q_576P]:"unknown",[_.Q_720P]:"high",[_.Q_1080P]:"fullhd",[_.Q_1440P]:"quadhd",[_.Q_2160P]:"ultrahd",[_.Q_4320P]:"unknown"}[r],he=r=>r&&{[le.HTTP1]:"http1",[le.HTTP2]:"http2",[le.QUIC]:"http3"}[r],Me=r=>{if(r!==void 0)switch(r){case v.MPEG:return"mp4";case v.DASH:case v.DASH_LIVE:case v.DASH_STREAMS:return"dash";case v.DASH_SEP:return"dash_sep";case v.DASH_ONDEMAND:return"ondemand_dash";case v.DASH_WEBM:case v.DASH_LIVE_WEBM:return"webm";case v.DASH_WEBM_AV1:return"av1";case v.DASH_LIVE_CMAF:return"ondemand_dash_live";case v.HLS:case v.HLS_LIVE:return"hls";case v.HLS_ONDEMAND:return"ondemand_hls";case v.HLS_LIVE_CMAF:return"ondemand_hls_live";case v.WEB_RTC_LIVE:return"webrtc";default:return Re(r)}},q=r=>{if(r!==void 0)switch(r){case C.NONE:case C.INLINE:return;case C.FULLSCREEN:return"fullscreen";case C.SECOND_SCREEN:return"chromecast";case C.PIP:return"pip";case C.INVISIBLE:return"invisible";default:return Re(r)}},Ue=r=>{switch(r){case"slow-2g":return"poor";case"2g":return"poor";case"3g":return"good";case"4g":return"excellent"}};var Q=class{constructor(e){this.offset=void 0;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,o){let t=Date.now(),i=e-t-o/2;if(Math.abs(i)<1e3){this.offset=0;return}this.offset===void 0?this.offset=Math.round(i):this.offset=Math.round(.2*i+(1-.2)*this.offset)}};var Be=()=>Math.floor(Math.random()*4294967296).toString(36).padStart(7,"0"),Fe=()=>Math.floor(Math.random()*18446744073709552e3).toString(36).padStart(13,"0");import{PlaybackState as He}from"@vkontakte/videoplayer-core/evergreen";import{filter as We,filterChanged as Nt,fromEvent as Ot,isNullable as Ke,map as Rt,merge as pe,Observable as Vt,Subject as fe,Subscription as Mt,ValueSubject as Ut}from"@vkontakte/videoplayer-shared/evergreen";var qe=(r,e)=>new Vt(o=>{let t=new Mt,i=pe(Ot(window,"beforeunload"),r.events.willDestruct$),s=new Ut(void 0),n;t.add(r.info.isLive$.pipe(Nt()).subscribe(g=>{n&&(n.unsubscribe(),s.next(void 0)),g?n=r.info.liveTime$.pipe(Rt(y=>y&&y/1e3)).subscribe(s):n=r.info.position$.subscribe(s),t.add(n)}));let{playing$:d,paused$:u}=r.events,l=r.events.willSeek$.pipe(We(()=>r.info.playbackState$.getValue()===He.PLAYING)),h=r.events.seeked$.pipe(We(()=>r.info.playbackState$.getValue()===He.PLAYING)),f=!1,a=new fe;t.add(l.subscribe(()=>{f||a.next(),f=!0})),t.add(h.subscribe(()=>f=!1));let c=new fe,m=new fe,p=pe(d,h,c),I=pe(u,a,i,r.events.looped$,m),S,w=()=>S=s.getValue(),E=()=>{let g=s.getValue();Ke(S)||S===g||Ke(g)||(o.next({from:S,to:g}),S=void 0)},A=()=>{m.next(),c.next()};if(t.add(p.subscribe(w)),t.add(I.subscribe(E)),e.forceInterval&&isFinite(e.forceInterval)){let g=0;t.add(p.subscribe(()=>g=window.setTimeout(A,e.forceInterval))),t.add(I.subscribe(()=>window.clearTimeout(g)))}return t});var Je="_one-stat_",zo=`${Je}uuid`,Xe=`${Je}deviceId`,ge=()=>{let r=new me;return{subscription:r,subscribe:(e,o)=>{e&&r.add(e.subscribe(o))}}},be=class{constructor(e,o){this.subscription=new me;this.debugLogger=new qt;this.oneStatDebugLog=this.debugLogger.createComponentLog("onestat");this.loopCounter=0;this.disabled=!1;this.vsid$=new z(void 0);this.isid$=new z(void 0);this.zenUid$=new z(void 0);this.seekAction$=new z("unknown");this.statContext=e,this.config=De(o.config??{}),$(o.apiEnv)&&(this.config.apiEnv=o.apiEnv),this.config.synchronizeTime&&(this.timeSynchronisation=new Q);let t=new Kt;this.experimental={error$:t};let i=Ge.get(Xe);this.statContext.deviceId?this.deviceId=this.statContext.deviceId:i?this.deviceId=i:(this.deviceId=de(),Ge.set(Xe,this.deviceId)),this.resetViewSession(),o.useIsid&&this.isid$.next(o.isid??Fe()),this.zenUid$.next(o.zenUid);let s=new M({config:this.config,error$:t,timeSynchronisation:this.timeSynchronisation});this.api=new V({config:this.config,apiTransport:s,refreshAuthToken:o.refreshAuthToken,mobile:this.statContext.mobile??!1,deviceId:this.deviceId,error$:t}),this.logger=new K({config:this.config,debugLogger:this.debugLogger,api:this.api,error$:t,userSalt:o.userSalt});let{isEmbed:n,topOrigin:d}=Qt();this.isEmbed=n,this.embedParent=d?new URL(d).hostname:void 0,this.subscribe()}updateContext(e){this.statContext={...this.statContext,...e}}attachTo(e){let o=new me,t=(a,c)=>o.add(a.subscribe(c));t(e.events.willStart$,()=>{let a=e.info.position$.getValue();this.logActionPlay({position:a}),this.statContext.projectId&&this.logActionPlayInteractive()}),t(e.events.looped$,()=>{this.resetViewSession(),++this.loopCounter>this.config.maxLoops&&(this.disabled=!0),this.logActionPlay({position:e.info.position$.getValue()})}),t(e.events.seeked$,()=>{this.logSeek({action:this.seekAction$.getValue(),time:e.info.position$.getValue()}),this.seekAction$.next("unknown")}),t(e.events.paused$,()=>{this.logPause({position:e.info.position$.getValue()})}),t(e.events.willResume$,()=>{this.logPlay()}),t(e.events.started$,()=>{this.statContext.clip&&this.logWatchCoverageRecord({start:0,end:0})}),t(e.events.playing$,()=>{this.logPlaying()}),t(qe(e,{forceInterval:this.config.watchCoverageInterval}),a=>{let c=e.info.isLive$.getValue(),m=e.info.atLiveEdge$.getValue(),p={start:parseFloat(a.from.toFixed(3)),end:parseFloat(a.to.toFixed(3))};if(m){let I=e.info.liveLatency$.getValue()??0,S=e.info.currentBuffer$.getValue()?.end??0,w=e.info.liveBufferTime$.getValue()??0,E=Math.round((I-(S-w))*1e3),A=Math.round(I*1e3);E&&A&&(p.latency=E,p.bufferLatency=A)}c?this.logWatchCoverageLive(p):this.logWatchCoverageRecord(p)});let i;t(e.info.isStalled$,a=>{a?i=T():($(i)&&this.logEmptyBuffer({duration:T()-i}),i=void 0)});let s=!1;o.add(e.events.fatalError$.pipe(Wt()).subscribe(()=>s=!0)),t(e.events.willStop$,()=>{if(e.info.isStalled$.getValue()){let c=$(i)?T()-i:void 0;this.logCloseAtEmptyBuffer({duration:c??0}),i=void 0}else s||this.logActionStop()}),t(e.events.managedError$,({id:a})=>{this.logError({fatal:!1,errorType:a})}),t(e.events.fatalError$,({id:a})=>{this.logError({fatal:!0,errorType:a})});let n,d,u=!1;t(e.events.firstBytes$,a=>{n=T(),this.logFirstBytes({time:a})}),t(e.events.willStart$,()=>d=T()),t(e.info.currentBuffer$,a=>{!u&&a&&a.end-a.start>0&&$(n)&&(this.logPlayerReady({duration:T()-n}),u=!0)}),t(e.events.firstFrame$,()=>{$(n)&&!u&&(this.logPlayerReady({duration:T()-n}),u=!0),$(d)&&this.logFirstFrame({time:T()-d})});let l;t(e.info.currentVideoStream$,a=>{a&&(l&&a.id!==l&&this.logTrackSwitch(a),l=a.id)});let h;t(e.info.currentAudioStream$,a=>{a&&(h&&a.id!==h&&this.logTrackSwitch(a),h=a.id)}),t(e.info.atLiveEdge$,a=>this.updateContext({liveEdge:a})),t(Qe({muted:e.info.muted$,volume:e.info.volume$}),({muted:a,volume:c})=>this.updateContext({audible:!a&&c>0})),t(e.info.currentQuality$,a=>{let c=Ve(a);this.updateContext({quality:c}),c&&this.logQuality(c)}),t(e.info.isAutoQualityEnabled$,a=>this.updateContext({autoQuality:a})),t(e.info.currentFormat$,a=>this.updateContext({contentType:Me(a)})),t(e.info.currentPlaybackRate$,a=>this.updateContext({rate:a})),t(e.info.is3DVideo$,a=>this.updateContext({is3d:a}));let f;return t(e.info.hostname$,a=>{let c=f!==void 0&&f!==a;this.updateContext({cdnHostname:a,failover:c}),c&&this.logFailover(a),f=a}),t(e.info.throughputEstimation$,a=>this.updateContext({downloadSpeed:a})),t(e.info.httpConnectionType$,a=>{this.statContext.firstConnectionType||this.updateContext({firstConnectionType:he(a)}),this.updateContext({connectionType:he(a)})}),t(e.info.httpConnectionReused$,a=>{je(this.statContext.firstConnectionReused)&&this.updateContext({firstConnectionReused:a}),this.updateContext({connectionReused:a})}),t(e.info.surface$,a=>this.updateContext({mode:q(a)})),t(Qe({current:e.info.currentTextTrack$,available:e.info.availableTextTracks$}),({current:a,available:c})=>{let m=c.find(({id:I})=>I===a),p=m&&(m.isAuto?`${m.language}_auto`:m.language);this.updateContext({subtitles:p?.split(".")[0]})}),this.player=e,this.uiEvents&&this.attachToUi(this.uiEvents),this.resubscribeBeforeunload(),this.subscription.add(o),o}attachToUi(e){this.uiEvents=e;let{subscription:o,subscribe:t}=ge();return this.player&&(t(e.actionRewind$,()=>{this.player&&(this.resetViewSession(),this.logActionPlay({position:this.player.info.position$.getValue()}))}),t(e.actionSeek$,this.seekAction$),t(e.inPiP$,i=>{let s=i?"pip":q(this.player?.info.surface$.getValue());this.updateContext({mode:s})}),t(e.inFullscreen$,i=>{let s=i?"fullscreen":q(this.player?.info.surface$.getValue());this.updateContext({mode:s})}),t(e.actionSetSubtitle$,i=>this.updateContext({subtitles:i.split(".")[0]})),t(e.nextMovie$,i=>this.logNextMovie(i)),this.resubscribeBeforeunload(),this.subscription.add(o)),o}attachToAds(e){let{subscription:o,subscribe:t}=ge();return t(e.slotRequested$,()=>this.logAdSlotRequest()),t(e.started$,i=>this.logAdStarted(i)),t(e.paused$,()=>this.logAdPaused()),t(e.resumed$,()=>this.logAdResumed()),t(e.ended$,()=>this.logAdEnded()),t(e.skipped$,()=>this.logAdSkipped()),t(e.clicked$,()=>this.logAdClicked()),t(e.error$,i=>this.logError({errorType:i,fatal:!1})),this.resubscribeBeforeunload(),this.subscription.add(o),o}attachToInteractive(e){let{subscription:o,subscribe:t}=ge();return t(e.click$,i=>this.logInterfaceClick(i)),t(e.nextMovie$,i=>this.logNextMovie(i)),this.resubscribeBeforeunload(),this.subscription.add(o),o}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(Be())}getDeviceId(){return this.deviceId}setFieldBlacklist(){}logInited(){}logReady(e){this.log({operation:"player_ready",param:String(e.time)})}logStarted(...e){this.logActionPlay(...e)}logPlay(){this.log({operation:"play_toggle"})}logPlaying(){this.log({operation:"playing"})}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}`},{in_history:this.statContext.inHistory?1:void 0})}logWatchCoverageLive(e){let o=this.timeSynchronisation?.getOffset()??0,t=e.start+o,i=e.end+o;this.log({operation:"watch_coverage_live",param:`${t}-${i}`},{in_history:this.statContext.inHistory?1:void 0,latency:e.latency,buffer_latency:e.bufferLatency})}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();let e=window.navigator.connection;e&&"onchange"in e&&"effectiveType"in e&&this.subscription.add(Ft(ze(e,"change"),Ht(["init"])).subscribe(()=>this.updateContext({network:Ue(e.effectiveType)}))),this.config.debugLog&&this.debugLogger.log$.subscribe(o=>{console.debug("%c stat ","background:#fa6470;",`component: ${o.component}.`,o.message)})}resubscribeBeforeunload(){this.beforeunloadSubscription?.unsubscribe(),this.beforeunloadSubscription=ze(window,"beforeunload").subscribe(()=>this.logger.flush({wantBeacon:!0,clearStorage:this.config.clearStorageAtUnload})),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))})}logActionPlayInteractive(){this.statContext.projectId&&this.log({operation:"action_play_interactive",param:String(this.statContext.movieId)},{vid:this.statContext.projectId})}logFailover(e){this.log({operation:"failover",param:e})}logCloseAtEmptyBuffer(e){this.log({operation:"close_at_empty_buffer",param:String(Math.round(e.duration))})}logActionStop(){this.log({operation:"action_stop"})}logTrackSwitch(e){this.log({operation:"track_switch",param:e.id})}logQuality(e){this.log({operation:"quality",param:e})}log(e,o={}){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}`});let t=this.createLogItem(e,o);this.logger.log(t)}createLogItem({operation:e,param:o,time:t},i={}){let s=this.timeSynchronisation?.now()??T(),n=this.vsid$.getValue();Bt(n);let d=this.isid$.getValue(),u=e==="empty_buffer"||e==="close_at_empty_buffer"?this.statContext.connectionType:this.statContext.firstConnectionType,l=this.statContext.firstConnectionReused,h,f;if(this.isEmbed||this.statContext.place==="embed"){h=this.embedParent;let c=[...new URLSearchParams(location.search).entries()].filter(([m,p])=>this.config.embedUrlParams.includes(m));f=new URLSearchParams(c).toString()}else this.statContext.place==="direct"&&(this.statContext.refDomain?h=Ye(this.statContext.refDomain)?.hostname??this.statContext.refDomain:document.referrer&&(h=Ye(document.referrer)?.hostname??document.referrer),f=location.href.substring(0,1024));let a={vsid:n,isid:d,vid:this.statContext.movieId,uid:this.zenUid$.getValue(),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?"auto":this.statContext.autoplay===!1?"":void 0,param:o,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode,connection_type:u,connection_reused:l===!0?1:l===!1?0:void 0,cached_data:this.statContext.cached===!0?1:this.statContext.cached===!1?0:void 0,live:this.statContext.liveEdge?1:void 0,muted:this.statContext.audible===!1?1:void 0,mode:this.statContext.mode,subtitles:this.statContext.subtitles,download_speed:this.statContext.downloadSpeed,manual_quality:this.statContext.autoQuality?void 0:1,ref_domain:h,direct_url:f,rate:this.statContext.rate===1||je(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,...i};for(let c of this.config.disabledCustomFields)delete a[c];return{operation:e,type:1,time:t,network:this.statContext.network,timestamp:s,custom:a}}};var yt={};At(yt,{SeekType:()=>j,ThinOneStat:()=>te,VERSION:()=>x});import{assertNonNullable as ai,detectEmbed as di,fromEvent as ci,Logger as ui,merge as li,safeStorage as vt,Subject as hi,Subscription as Te,ValueSubject as Ae}from"@vkontakte/videoplayer-shared/evergreen";import{clientChecker as O,PlaybackState as It}from"@vkontakte/videoplayer-core/evergreen";import{fillWithDefault as zt}from"@vkontakte/videoplayer-shared/evergreen";var j=(d=>(d.SLIDER="slider",d.DOUBLE_TAP="double_tap",d.TIME_CODE="time_code",d.EPISODE="episode",d.REWIND="rewind",d.LIVE="live",d.UNKNOWN="unknown",d))(j||{});var x="__VERSION__",et="CIOPGQJGDIHBABABA",ve={prod:"https://api.ok.ru",vk_alias:"https://api.mycdn.me",videotest:"https://videotestapi.ok.ru/api",test:"https://apitest.ok.ru",okcdn:"https://api.okcdn.ru",auto:""};var jt={apiKey:et,apiEnv:"vk_alias",requestRetryCount:1,firstFlushTime:5e3,flushDebounceTime:1e4,flushMaxWait:6e4,storageExpiration:36*60*60*1e3,watchCoverageHeartbeatInterval:15,synchronizeTime:!0,useBeacon:!1,alwaysSendDesktop:!1},tt=r=>zt(r,jt);import{getExponentialDelay as Gt,ErrorCategory as D,ValueSubject as Yt}from"@vkontakte/videoplayer-shared/evergreen";var G=class{constructor(e){this.params=e,this.authorized$=new Yt(!1),this.consequentAuthErrors=0}async authorize(e){return this.authToken=e??await this.refreshAuthToken(),this.authorizeWithBackoff()}logBeacon(e){let o="log.logUvStat",t=this.createLogParams(e),i=this.sessionKey;if(!i)return;this.params.apiTransport.sendBeacon(o,t,i)||this.logRequest(e).catch(()=>{})}async logRequest(e){let o="log.logUvStat",t=this.createLogParams(e),i=this.sessionKey??await this.authorizeWithBackoff();if(!i)return;let s=async(n,d=this.params.config.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(o,t,i)}catch(u){if(!u||!("error_code"in u)){this.params.error$.next({id:"logRequestUnknown",category:D.NETWORK,message:`Unknown ${o} error`,thrown:u});return}let l=u?.error_code;switch(l){case 102:case 103:case 104:return this.authorized$.next(!1),this.sessionKey=await this.authorizeWithBackoff(),d>0?s(n,d-1):void 0;case 401:return this.authorized$.next(!1),this.authToken=await this.refreshAuthToken(),this.sessionKey=await this.authorizeWithBackoff(),d>0?s(n,d-1):void 0;default:{this.params.error$.next({id:`LogRequest#${l}`,category:D.EXTERNAL_API,message:`${o} error`,data:u});return}}}};return s(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",uv_stat_data:JSON.stringify({application:`@vkontakte/videoplayer-statistics:${x}`,platform:e[0].platform,product:e[0].product,events:e})}}authorizeWithBackoff(){if(!this.consequentAuthErrors)return this.doAuthorize();let e=Gt(this.consequentAuthErrors);return new Promise(o=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout(async()=>{try{let t=await this.doAuthorize();o(t)}catch(t){this.params.error$.next({id:"AuthorizeBackoff",category:D.NETWORK,message:"Otherwise unhandled error in authorization",thrown:t})}finally{this.backoffTimeoutId=0}},e))})}doAuthorize(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);let e="auth.anonymLogin",o={session_data:{version:2,device_id:this.params.deviceId,client_version:x.split("-")[0],client_type:"SDK_JS"}};return this.authToken!==void 0&&(o.session_data.auth_token=this.authToken,o.session_data.version=3),this.authorizePromise=this.params.apiTransport.sendRequest(e,o).then(t=>((!t||!t.session_key)&&this.params.error$.next({id:"AuthorizeFailed",category:D.EXTERNAL_API,message:"No session key",data:t}),this.sessionKey=t?.session_key??void 0,this.sessionKey)).catch(async t=>{this.sessionKey=void 0;let i=t?.error_code;switch(i){case 401:return this.authToken=await this.refreshAuthToken(),this.authorizeWithBackoff()}i?this.params.error$.next({id:`Authorize#${i}`,category:D.EXTERNAL_API,message:"authorize error",data:t}):this.params.error$.next({id:"AuthorizeUnknown",category:D.NETWORK,message:"authorize error",thrown:t})}).finally(()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(this.sessionKey!==void 0)}),this.authorizePromise}};import{now as Ie,ErrorCategory as Y}from"@vkontakte/videoplayer-shared/evergreen";var X=class{constructor(e){this.params=e,this.apiKey=e.config.apiKey,this.apiEnv=e.config.apiEnv,this.apiBaseUrl=ve[this.apiEnv],this.timeSynchronisation=e.timeSynchronisation,this.isApiBaseUrlFetched=!1}sendBeacon(e,o,t){if(!window.Blob||!window.navigator.sendBeacon)return!1;let i=this.prepareQueryParams({method:e,queryParams:o,sessionKey:t}),s=new window.Blob([i.toString()],{type:"application/x-www-form-urlencoded"});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,s)}catch(n){this.params.error$.next({id:"OneStat:ApiTransport:sendBeacon",category:Y.NETWORK,message:"Unhandled beacon error",thrown:n,data:{method:e,params:o}})}return!1}async sendRequest(e,o,t){let i=Ie(),s=n=>{if(n instanceof TypeError&&["Failed to fetch","NetworkError when attempting to fetch resource."].includes(n.message)){this.params.error$.next({id:"Network",category:Y.NETWORK,message:"Request failed",thrown:n});return}this.params.error$.next({id:"ThinOneStat:ApiTransport:sendRequest",category:Y.NETWORK,message:"Unhandled request error",thrown:n,data:{method:e,params:o,sessionKey:t,time:Ie()-i}})};return this.apiBaseUrl=await this.resolveApiBaseUrl(),fetch(`${this.apiBaseUrl}/fb.do`,{method:"post",headers:{"Content-type":"application/x-www-form-urlencoded"},body:this.prepareQueryParams({method:e,queryParams:o,sessionKey:t})}).then(n=>{let d=Number(n.headers.get("content-length"))===0,u=new Date(n.headers.get("date")??"").getTime(),l=Ie()-i;if(isFinite(u)&&this.timeSynchronisation?.addServerTime(u,l),!d)return n.json().then(h=>Object.prototype.hasOwnProperty.call(h,"error_msg")?Promise.reject(h):h,s)},s)}async resolveApiBaseUrl(){if(this.apiEnv!=="auto"||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{let e=atob("aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ="),i=(await(await fetch(e,{method:"GET",mode:"cors",cache:"no-cache"})).json())?.Answer[0]?.data;if(!i)throw new Error("Wrong DNS response");return i}catch(e){return this.params.error$.next({id:"ThinOneStat:ApiTransport:resolveApiBaseUrl",category:Y.NETWORK,message:"Unhandled resolve api base url error",thrown:e}),ve.vk_alias}finally{this.isApiBaseUrlFetched=!0}}prepareQueryParams(e){let o=new URLSearchParams({format:"JSON",method:e.method,application_key:this.apiKey});return e.sessionKey!==void 0&&o.append("session_key",e.sessionKey),Object.entries(e.queryParams).forEach(([t,i])=>o.append(t,typeof i=="string"?i:JSON.stringify(i))),o}};import{ErrorCategory as Xt,now as Jt,safeStorage as B,debounceFn as it}from"@vkontakte/videoplayer-shared/evergreen";var J="thinonestat_events",Se=r=>e=>e.client_time+r>=Jt(),Z=class{constructor(e){this.unsaltedStorage=[];this.isPaused=!1;this.isUrgent=e=>{let{event_name:o}=e;return["watch_coverage","watch_coverage_live","watched_n","playback_started"].includes(o)};this.params=e,this.api=e.api,this.error$=e.error$,this.userSalt=e.userSalt,this.loggerDebugLog=e.debugLogger.createComponentLog("stat logger"),this.firstFlush=it(()=>this.safeFlush(),this.params.config.firstFlushTime,{maxWait:this.params.config.firstFlushTime});let o=B.isPersistent()?this.params.config.flushMaxWait:0;this.debouncedFlush=it(()=>this.safeFlush(),this.params.config.flushDebounceTime,{maxWait:o}),this.subscription=this.api.authorized$.subscribe(t=>{t&&this.debouncedFlush()}),this.housekeepStorage()}safeFlush(){try{this.flush()}catch(e){this.error$.next({id:"LoggerError",category:Xt.WTF,message:String(e)??"Unknown logger error",thrown:e})}}readFromStorage(){let e=B.get(J);try{return e?JSON.parse(e):{}}catch{}return{}}addToStorage(e){if(!this.userSalt){this.unsaltedStorage.push(e);return}let o=this.readFromStorage(),i=(o[this.userSalt]??[]).filter(Se(this.params.config.storageExpiration));B.set(J,JSON.stringify({...o,[this.userSalt]:[...i,e]}))}getFromStorage(){return this.userSalt?(this.readFromStorage()[this.userSalt]??[]).filter(Se(this.params.config.storageExpiration)):this.unsaltedStorage}markStorageSent(){if(!this.userSalt){this.unsaltedStorage=[];return}let e=this.readFromStorage();delete e[this.userSalt],B.set(J,JSON.stringify(e))}housekeepStorage(){let e=this.readFromStorage();for(let[o,t]of Object.entries(e)){let i=t.filter(Se(this.params.config.storageExpiration));i.length?e[o]=i:delete e[o],this.loggerDebugLog({message:`${t.length} retrieved from storage, ${i.length} of them actual`})}B.set(J,JSON.stringify(e))}log(e){this.addToStorage(e),!this.isPaused&&(this.isUrgent(e)?this.flush():this.lastVsid!==e.vsid?this.firstFlush():this.debouncedFlush(),this.lastVsid=e.vsid)}flush({wantBeacon:e,clearStorage:o}={wantBeacon:!1,clearStorage:!0}){let t=this.getFromStorage();t.length!==0&&(this.api.authorized$.getValue()?(e&&this.params.config.useBeacon?(this.loggerDebugLog({message:`Flushing ${t.length} events through beacon`}),this.api.logBeacon(t)):(this.loggerDebugLog({message:`Flushing ${t.length} events`}),this.api.logRequest(t)),o&&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()}};function ye(){let r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),e=new Array(36),o=0,t,i;for(i=0;i<36;i++)i===8||i===13||i===18||i===23?e[i]="-":i===14?e[i]="4":(o<=2&&(o=33554432+Math.random()*16777216|0),t=o&15,o=o>>4,e[i]=r[i===19?t&3|8:t]);return e.join("")}var ee=class{constructor(e){this.offset=void 0;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,o){let t=Date.now(),i=e-t-o/2;if(Math.abs(i)<1e3){this.offset=0;return}this.offset===void 0?this.offset=Math.round(i):this.offset=Math.round(.2*i+(1-.2)*this.offset)}};import{PlaybackState as ot}from"@vkontakte/videoplayer-core/evergreen";import{Observable as Zt,Subscription as ei,ValueSubject as ti,Subject as _e,fromEvent as ii,isNullable as rt,merge as Pe,filter as st,filterChanged as nt}from"@vkontakte/videoplayer-shared/evergreen";var at=(r,e)=>new Zt(o=>{let t=new ei,i=new ti(void 0),s;t.add(r.info.isLive$.pipe(nt()).subscribe(y=>{s&&(s.unsubscribe(),i.next(void 0)),y?s=r.info.liveTime$.pipe(nt()).subscribe(i):s=r.info.position$.subscribe(i),t.add(s)}));let{playing$:n,paused$:d,ended$:u,looped$:l}=r.events,h=r.events.willSeek$.pipe(st(()=>r.info.playbackState$.getValue()===ot.PLAYING)),f=r.events.seeked$.pipe(st(()=>r.info.playbackState$.getValue()===ot.PLAYING)),a=!1,c=new _e;t.add(h.subscribe(()=>{a||c.next(),a=!0})).add(f.subscribe(()=>a=!1));let m=Pe(ii(window,"beforeunload"),r.events.willDestruct$),p,I=()=>p=i.getValue(),S=()=>{let y=i.getValue();rt(p)||rt(y)||p===y||(o.next({from:p,to:y}),p=void 0)},w=new _e,E=new _e,A=Pe(n,c,w),g=Pe(d,f,m,u,l,E);if(t.add(A.subscribe(I)).add(g.subscribe(S)),e.heartbeatInterval&&isFinite(e.heartbeatInterval)){let y=[],_t=e.heartbeatInterval*1e3,Pt=()=>{E.next(),w.next()};t.add(A.subscribe(()=>{let ie=window.setTimeout(Pt,_t);y.push(ie)})).add(g.subscribe(()=>{y.forEach(ie=>{window.clearTimeout(ie)}),y=[]}))}return t});import{Subscription as oi}from"@vkontakte/videoplayer-core/evergreen";import{Observable as ri}from"@vkontakte/videoplayer-shared/evergreen";var dt=(r,e)=>new ri(o=>{let t=new oi,i=1e4,s=0;return t.add(r.info.position$.subscribe(()=>{let n=e.getTotalViewTime()*1e3;n>s&&n%i===0&&(s=n,o.next({target_duration:i,current_tvt:n}))})),t});import{Observable as si,Subscription as ni,merge as ct}from"@vkontakte/videoplayer-shared/evergreen";var ut=r=>new si(e=>{let o=new ni,t=0,i=1,s=0,n=!1,d=!1,u=()=>{if(!n)return;let g=Date.now();s+=(g-t)*i,t=g},l=()=>{(!n||d)&&(t=Date.now(),n=!0,d=!1)},h=()=>{n&&(u(),n=!1)},f=()=>{n&&(u(),n=!1,d=!0)},a=g=>{n&&u(),i=g,t=Date.now()},{started$:c,playing$:m,paused$:p,willSeek$:I,ended$:S,willDestruct$:w}=r.events,{currentPlaybackRate$:E}=r.info;o.add(I.subscribe(f)).add(ct(c,m).subscribe(l)).add(ct(p,S,w).subscribe(h)).add(E.subscribe(a));let A=()=>{let g=s;return n&&(g+=(Date.now()-t)*i),Math.floor(g/1e3)};return e.next(A),o});import{assertNever as lt}from"@vkontakte/videoplayer-shared/evergreen";import{Surface as N,VideoFormat as b,VideoQuality as P}from"@vkontakte/videoplayer-core/evergreen";var Ee=r=>{if(r!==void 0)switch(r){case b.MPEG:return"MP4";case b.DASH:case b.DASH_LIVE:return"DASH";case b.DASH_SEP:return"DASH_SEP";case b.DASH_ONDEMAND:return"ONDEMAND_DASH";case b.HLS_ONDEMAND:return"ONDEMAND_HLS";case b.HLS:case b.HLS_LIVE:return"HLS";case b.DASH_WEBM:case b.DASH_LIVE_WEBM:return"WEBM";case b.DASH_LIVE_CMAF:return"ONDEMAND_DASH_LIVE";case b.HLS_LIVE_CMAF:return"ONDEMAND_HLS_LIVE";case b.WEB_RTC_LIVE:return"WEBRTC";case b.DASH_WEBM_AV1:return"AV1";case b.DASH_STREAMS:return"MULTI_DASH";default:return lt(r)}},k=r=>{if(r!==void 0)switch(r){case P.Q_144P:return"144p";case P.Q_240P:return"240p";case P.Q_360P:return"360p";case P.Q_480P:return"480p";case P.Q_720P:return"720p";case P.Q_1080P:return"1080p";case P.Q_1440P:return"1440p";case P.Q_2160P:return"2160p";case P.INVARIANT:case P.Q_576P:case P.Q_4320P:return"UNKNOWN";default:return lt(r)}},ht=r=>{if(r!==void 0)switch(r){case"MP4":case"ONDEMAND_DASH":case"ONDEMAND_DASH_LIVE":case"ONDEMAND_HLS":case"ONDEMAND_HLS_LIVE":case"MULTI_DASH":case"WEBM":case"AV1":return"vod";case"DASH":case"HLS":case"WEBRTC":return"live";default:return}},pt=(r,e,o)=>{if(r&&e)switch(r){case b.MPEG:return o&&e[r]&&e[r][o];default:return e[r]?.url}},ft=r=>{if(r!==void 0)switch(r){case N.NONE:return;case N.INLINE:return"inline";case N.FULLSCREEN:return"fullscreen";case N.SECOND_SCREEN:return"chromecast";case N.PIP:return"pip_external"}},gt=r=>{if(r!==void 0)return r===N.INVISIBLE?"background":"foreground"};var mt=()=>Math.floor(Math.random()*4294967296).toString(36).padStart(13,"0"),bt=()=>Math.floor(Math.random()*18446744073709552e3).toString(36).padStart(13,"0");var pi="_thin-one-stat_",St=`${pi}deviceId`,fi=()=>{let r=new Te;return{subscription:r,subscribe:(e,o)=>{e&&r.add(e.subscribe(o))}}},te=class{constructor(e,o){this.debugLogger=new ui;this.thinOneStatDebugLog=this.debugLogger.createComponentLog("ThinOneStat");this.eventNumber=1;this.seekAction$=new Ae("unknown");this.vsid$=new Ae(void 0);this.isid$=new Ae(void 0);this.statContext=e,this.config=tt(o.config??{}),this.subscription=new Te,this.config.synchronizeTime&&(this.timeSynchronisation=new ee);let t=new hi,i=vt.get(St);this.statContext.deviceId?this.deviceId=this.statContext.deviceId:i?this.deviceId=i:(this.deviceId=ye(),vt.set(St,this.deviceId)),this.resetViewSession(),o.useIsid&&this.isid$.next(o.isid??bt());let s=new X({error$:t,config:this.config,timeSynchronisation:this.timeSynchronisation});this.api=new G({config:this.config,apiTransport:s,error$:t,deviceId:this.deviceId,refreshAuthToken:o.refreshAuthToken}),this.logger=new Z({config:this.config,debugLogger:this.debugLogger,api:this.api,error$:t,userSalt:o.userSalt});let{isEmbed:n,topOrigin:d}=di();this.isEmbed=n,this.embedHostname=d?new URL(d).hostname:void 0}authorize(e){return this.api.authorize(e)}updateContext(e){this.statContext={...this.statContext,...e}}attachTo(e){let o=new Te,t=(i,s)=>o.add(i.subscribe(s));return t(ut(e),i=>{this.getTotalViewTime=i}),t(e.info.isLive$,i=>this.isLive=i),t(e.info.position$,i=>this.position=i),t(e.info.hostname$,i=>this.cdnHostname=i),t(at(e,{heartbeatInterval:this.config.watchCoverageHeartbeatInterval}),i=>{let s=Math.round(i.from*1e3),n=Math.round(i.to*1e3),d={watch_interval:`${s}-${n}`,in_history:!!this.statContext.inHistory,content_type:Ee(e.info.currentFormat$.getValue()),playback_quality:k(e.info.currentQuality$.getValue()),recom_info:this.statContext.recomInfo};if(!e.info.isLive$.getValue())this.logWatchCoverage(d);else{let l=e.info.atLiveEdge$.getValue();this.logWatchCoverageLive({...d,live:!!l})}}),t(dt(e,{getTotalViewTime:this.getTotalViewTime}),i=>{this.logWatchedN(i)}),t(li(e.events.willStart$,e.events.looped$),()=>{let i={isid:this.isid$.getValue(),stream_profile:ht(Ee(e.info.currentFormat$.getValue())),dpi:O.display.pixelRatio,web_layout:O.device.isMobile?"mobile":"desktop",iframe_host:this.isEmbed?this.embedHostname??void 0:null,from_downloads:!0,preloaded:this.statContext.preload,navigation:this.statContext.navigation,recom_info:this.statContext.recomInfo};this.logStartSession(i)}),t(e.events.willReady$,()=>{if(this.statContext.preload){let i=e.info.currentFormat$.getValue(),s=e.info.availableSources$.getValue(),n=e.info.currentBuffer$.getValue(),d=e.info.currentQuality$.getValue(),u={target_buffer_time:n?n.end-n.start:void 0,playback_url:pt(i,s,d),playback_quality:k(d)};this.logPreloadStarted(u)}}),t(e.events.ready$,()=>{if(this.statContext.preload){let i=e.info.currentBuffer$.getValue(),s={buffer_time:i?i.end-i.start:void 0};this.logPreloadEnded(s)}}),t(e.events.playing$,()=>{this.logPlay()}),t(e.info.playbackState$,i=>{if(i===It.PLAYING){let s=e.info.currentBuffer$.getValue(),n={buffer_time:s?s.end-s.start:void 0};if(this.logPlaying(n),this.isStarted)this.logResume();else{this.isStarted=!0;let d=e.info.currentQuality$.getValue(),u=e.info.isAutoQualityEnabled$.getValue(),l=e.info.muted$.getValue(),h=e.info.volume$.getValue(),f=e.info.surface$.getValue(),a=e.info.availableTextTracks$.getValue(),c=e.info.currentTextTrack$.getValue(),m=e.info.currentAudioStream$.getValue(),p=e.info.currentPlaybackRate$.getValue(),I={playback_quality:k(d),user_quality:u?"auto":k(d),player_width:0,player_height:0,muted:l,sound_volume:h,buffer_time:s?s.end-s.start:void 0,mode:ft(f),visibility:gt(f),subtitles_enabled:!!c,auto_subtitles:!!a.find(({id:S})=>S===c)?.isAuto,audio_track_lang:m?.language,playback_rate:p,recom_info:this.statContext.recomInfo};this.logPlaybackStarted(I)}}else i===It.PAUSED&&this.logPause()}),t(e.events.willSeek$,({to:i})=>{let s={target_position:i,seek_type:this.seekAction$.getValue()};this.logSeeking(s)}),t(e.events.seeked$,()=>{let s={target_position:e.info.position$.getValue(),seek_type:this.seekAction$.getValue()};this.logSeeked(s),this.seekAction$.next("unknown")}),t(e.info.isBuffering$,i=>{i&&this.logShowLoader()}),t(e.info.currentQuality$,i=>{if(i){let s=e.info.isAutoQualityEnabled$.getValue(),n=e.info.currentVideoStream$.getValue()?.codec,d=e.info.currentAudioStream$.getValue()?.codec,u={user_quality:s?"auto":k(i),playback_quality:k(i),download_quality:k(i),codec_info:n&&d?`${n},${d}`:void 0,manual_switch:!s};this.logQualityChanged(u)}}),this.resubscribeBeforeunload(),this.subscription.add(o),o}attachToUi(e){let{subscribe:o,subscription:t}=fi();return o(e.actionSeek$,this.seekAction$),this.subscription.add(t),t}getDeviceId(){return this.deviceId}resetViewSession(){this.thinOneStatDebugLog({message:"VSID reset"}),this.vsid$.next(mt()),this.eventNumber=0}destroy(){this.api.destroy()}createRequiredParams(e){let o=this.vsid$.getValue();return ai(o),{vsid:o,uv_movie_id:this.statContext.movieId,user_id:this.statContext.userId,uv_user_id:this.statContext.uvUserId,device_id:this.statContext.deviceId,event_name:e,client_time:Date.now(),application:`@vkontakte/videoplayer-statistics:${x}`,platform:`web:${this.config.alwaysSendDesktop||!O.device.isMobile?"desktop":"mobile"}`,product:this.statContext.product,event_number:this.eventNumber++,playback_position:this.isLive?void 0:Math.round(this.position),current_tvt:this.getTotalViewTime(),cdn_host:this.cdnHostname}}createRequiredFatParams(){return{stats_version:x,browser:O.browser.current,browser_version:"",os:O.device.current,os_version:"",device_type:O.device.isMobile?"mobile":"desktop",navigation:this.statContext.navigation}}log(e,o,t=!1){let i=this.createRequiredParams(e),s={};t&&(s=this.createRequiredFatParams()),this.logger.log({...i,...s,...o})}logWatchCoverage(e){this.log("watch_coverage",e,!0)}logWatchCoverageLive(e){this.log("watch_coverage_live",e,!0)}logWatchedN(e){this.log("watched_n",e,!0)}logStartSession(e){this.log("start_session",e,!0)}logPreloadStarted(e){this.log("preload_started",e)}logPreloadEnded(e){this.log("preload_ended",e)}logPlaybackStarted(e){this.log("playback_started",e,!0)}logPlay(){this.log("play")}logPlaying(e){this.log("playing",e)}logPause(){this.log("pause")}logResume(){this.log("resume")}logSeeking(e){this.log("seeking",e)}logSeeked(e){this.log("seeked",e)}logShowLoader(){this.log("show_loader")}logQualityChanged(e){this.log("quality_changed",e)}resubscribeBeforeunload(){this.beforeunloadSubscription?.unsubscribe(),this.beforeunloadSubscription=ci(window,"beforeunload").subscribe(()=>{}),this.subscription.add(this.beforeunloadSubscription)}};export{R as ApiEnv,se as ConnectionType,re as ContentType,we as InteractiveInterfaceClick,be as OneStat,oe as Quality,ne as SeekAction,yt as ThinOneStat,F as VERSION};
|
|
6
|
+
var A=(a=>(a.PROD="prod",a.VK_ALIAS="vk_alias",a.VIDEOTEST="videotest",a.TEST="test",a.OKCDN="okcdn",a.AUTO="auto",a))(A||{}),U=(u=>(u.Q144P="mobile",u.Q240P="lowest",u.Q360P="low",u.Q480P="medium",u.Q720P="high",u.Q1080P="fullhd",u.Q1440P="quadhd",u.Q2160P="ultrahd",u.UNKNOWN="unknown",u))(U||{}),W=(d=>(d.MP4="mp4",d.DASH="dash",d.DASH_SEP="dash_sep",d.ONDEMAND_DASH="ondemand_dash",d.HLS="hls",d.ONDEMAND_HLS="ondemand_hls",d.WEBM="webm",d.AV1="av1",d.ONDEMAND_DASH_LIVE="ondemand_dash_live",d.ONDEMAND_HLS_LIVE="ondemand_hls_live",d.WEBRTC="webrtc",d.UNKNOWN="unknown",d.RTMP="rtmp",d))(W||{});var H=(t=>(t.HTTP1="http1",t.HTTP2="http2",t.HTTP3="http3",t))(H||{});var K=(c=>(c.SLIDER="slider",c.DOUBLE_TAP="double_tap",c.TIME_CODE="time_code",c.EPISODE="episode",c.REWIND="rewind",c.LIVE="live",c.UNKNOWN="unknown",c))(K||{}),ie=(n=>(n.GRAPH_SHOW="iGraphShow",n.GRAPH_HIDE="iGraphHide",n.NEXT_AREA="iNextChapterArea",n.NEXT_BUTTON="iNextChapterBtn",n.WATCH_AGAIN="iWatchAgainBtn",n))(ie||{}),oe={action_play:"ap",action_play_interactive:"api",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",failover:"fo",quality:"qt"},se={vsid:"si",isid:"is",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"},re={unknown:"un",mobile:"m",lowest:"ls",low:"l",medium:"md",high:"h",fullhd:"f",quadhd:"q",ultrahd:"u"},ne={pip:"pi",fullscreen:"fs",external:"ex",prefetch:"pr",airplay:"ap",chromecast:"cc",invisible:"iv"};import{fillWithDefault as Te}from"@vkontakte/videoplayer-shared/evergreen";var k="1.0.77-dev.4c6dbe21.0",ae="CIOPGQJGDIHBABABA",q={prod:"https://api.ok.ru",vk_alias:"https://api.mycdn.me",videotest:"https://videotestapi.ok.ru/api",test:"https://apitest.ok.ru",okcdn:"https://api.okcdn.ru",auto:""};var we={apiEnv:"vk_alias",apiKey:ae,requestRetryCount:1,firstFlushTime:5e3,flushDebounceTime:1e4,flushMaxWait:6e4,storageExpiration:36*60*60*1e3,watchCoverageInterval:15e3,disabledOperations:["quality"],disabledCustomFields:[],shorten:!0,maxLoops:100,embedUrlParams:[],useBeacon:!0,synchronizeTime:!0,debugLog:!1,clearStorageAtUnload:!0,useVKComIsMobileLogic:!1,backoff:{start:1e3,factor:1.5,max:5*60*1e3,random:.1}},de=r=>Te(r,we);function z(){let r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),e=new Array(36),i=0,t,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),t=i&15,i=i>>4,e[o]=r[o===19?t&3|8:t]);return e.join("")}import{assertNonNullable as We,combine as ye,fromEvent as Pe,isNonNullable as _,isNullable as Ee,merge as He,now as v,observableFrom as Ke,once as qe,safeStorage as M,Subject as ze,Subscription as ee,ValueSubject as B,createURL as _e}from"@vkontakte/videoplayer-shared/evergreen";import{Logger as Qe,detectEmbed as je}from"@vkontakte/videoplayer-shared/evergreen";var ce=r=>{let{operation:e,custom:i}=r,t=Object.fromEntries(Object.entries(i).map(([o,n])=>{let a=se[o]??o,c=n;return n&&(o==="mode"?c=ne[n]??n:o==="quality"&&(c=re[n]??n)),[a,c]}));return{...r,operation:oe[e]??e,custom:t}};import{ValueSubject as Le,getExponentialDelay as ke,ErrorCategory as P}from"@vkontakte/videoplayer-shared/evergreen";var $e=/Mobile|mini|Fennec|Android|iP(ad|od|hone)|opera (mini|mobi)/i,x=class{constructor(e){this.consequentAuthErrors=0;this.authorized$=new Le(!1);this.params=e}async authorize(e){return this.authToken=e??await this.refreshAuthToken(),this._authorizeWithBackoff()}logBeacon(e){let i="log.externalLog",t=this.createLogParams(e),o=this.sessionKey;if(!o)return;this.params.apiTransport.sendBeacon(i,t,o)||this.logRequest(e).catch(()=>{})}async logRequest(e){let i="log.externalLog",t=this.createLogParams(e),o=this.sessionKey??await this._authorizeWithBackoff();if(!o)return;let n=async(a,c=this.params.config.requestRetryCount)=>{try{return await this.params.apiTransport.sendRequest(i,t,o)}catch(l){if(!l||!("error_code"in l)){this.params.error$.next({id:"logRequestUnknown",category:P.NETWORK,message:`Unknown ${i} error`,thrown:l});return}let u=l?.error_code;switch(u){case 102:case 103:case 104:return this.authorized$.next(!1),this.sessionKey=await this._authorizeWithBackoff(),c>0?n(a,c-1):void 0;case 401:return this.authorized$.next(!1),this.authToken=await this.refreshAuthToken(),this.sessionKey=await this._authorizeWithBackoff(),c>0?n(a,c-1):void 0;default:{this.params.error$.next({id:`LogRequest#${u}`,category:P.EXTERNAL_API,message:`${i} error`,data:l});return}}}};return n(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){let i="WEB",t=!1;if(this.params.config.useVKComIsMobileLogic){let{appVersion:o}=window.navigator;t=$e.test(o)}else this.params.mobile&&(t=!0);return t&&(i="M_WEB"),{collector:"ok.mobile.apps.video",data:JSON.stringify({application:`@vkontakte/videoplayer-statistics:${k}`,platform:i,items:this.params.config.shorten?e.map(ce):e})}}_authorizeWithBackoff(){if(!this.consequentAuthErrors)return this._authorize();let e=ke(this.consequentAuthErrors,this.params.config.backoff);return new Promise(i=>{this.backoffTimeoutId||(this.backoffTimeoutId=window.setTimeout(()=>{this._authorize().then(i).catch(t=>this.params.error$.next({id:"AuthorizeBackoff",category:P.NETWORK,message:"Otherwise unhandled error in authorization",thrown:t})).finally(()=>this.backoffTimeoutId=0)},e))})}async _authorize(){if(this.authorizePromise)return this.authorizePromise;this.sessionKey=void 0,this.authorized$.next(!1);let e="auth.anonymLogin",i={session_data:{version:2,device_id:this.params.deviceId,client_version:k.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(t=>((!t||!t.session_key)&&this.params.error$.next({id:"AuthorizeFailed",category:P.EXTERNAL_API,message:"No session key",data:t}),this.sessionKey=t?.session_key??void 0,this.sessionKey)).catch(async t=>{this.sessionKey=void 0;let o=t?.error_code;switch(o){case 401:return this.authToken=await this.refreshAuthToken(),this._authorizeWithBackoff()}o?this.params.error$.next({id:`Authorize#${o}`,category:P.EXTERNAL_API,message:"authorize error",data:t}):this.params.error$.next({id:"AuthorizeUnknown",category:P.NETWORK,message:"authorize error",thrown:t})}).finally(()=>{this.authorizePromise=void 0,this.consequentAuthErrors=this.sessionKey?0:this.consequentAuthErrors+1,this.authorized$.next(this.sessionKey!==void 0)}),this.authorizePromise}};import{ErrorCategory as $,now as Q}from"@vkontakte/videoplayer-shared/evergreen";var C=class{constructor(e){this.params=e,this.apiKey=e.config.apiKey,this.apiEnv=e.config.apiEnv,this.apiBaseUrl=q[this.apiEnv],this.timeSynchronisation=e.timeSynchronisation,this.isApiBaseUrlFetched=!1}async resolveApiBaseUrl(){if(this.apiEnv!=="auto"||this.isApiBaseUrlFetched)return this.apiBaseUrl;try{let e=atob("aHR0cHM6Ly9kbnMuZ29vZ2xlL3Jlc29sdmU/bmFtZT12aWRlby5fZW5kcG9pbnQub2sucnUmdHlwZT1UWFQ="),o=(await(await fetch(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:$.NETWORK,message:"Unhandled resolve api base url error",thrown:e}),q.vk_alias}finally{this.isApiBaseUrlFetched=!0}}sendBeacon(e,i,t){if(!window.Blob||!window.navigator.sendBeacon)return!1;let o=this._prepareQueryParams({method:e,queryParams:i,sessionKey:t}),n=new window.Blob([o.toString()],{type:"application/x-www-form-urlencoded"});try{return window.navigator.sendBeacon(`${this.apiBaseUrl}/fb.do`,n)}catch(a){this.params.error$.next({id:"OneStat:ApiTransport:sendBeacon",category:$.NETWORK,message:"Unhandled beacon error",thrown:a,data:{method:e,params:i}})}return!1}async sendRequest(e,i,t){let o=Q(),n=a=>{if(a instanceof TypeError&&["Failed to fetch","NetworkError when attempting to fetch resource."].includes(a.message)){this.params.error$.next({id:"Network",category:$.NETWORK,message:"Request failed",thrown:a});return}this.params.error$.next({id:"OneStat:ApiTransport:sendRequest",category:$.NETWORK,message:"Unhandled request error",thrown:a,data:{method:e,params:i,sessionKey:t,time:Q()-o}})};return this.apiBaseUrl=await this.resolveApiBaseUrl(),fetch(`${this.apiBaseUrl}/fb.do`,{method:"post",headers:{"Content-type":"application/x-www-form-urlencoded"},body:this._prepareQueryParams({method:e,queryParams:i,sessionKey:t})}).then(a=>{let c=Number(a.headers.get("content-length"))===0,l=new Date(a.headers.get("date")??"").getTime(),u=Q()-o;if(isFinite(l)&&this.timeSynchronisation?.addServerTime(l,u),!c)return a.json().then(p=>Object.prototype.hasOwnProperty.call(p,"error_msg")?Promise.reject(p):p,n)},n)}_prepareQueryParams(e){let 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(([t,o])=>i.append(t,typeof o=="string"?o:JSON.stringify(o))),i}};import{ErrorCategory as Re,now as Oe,safeStorage as T,debounceFn as ue}from"@vkontakte/videoplayer-shared/evergreen";var R="onestat_events",j=r=>e=>e.timestamp+r>=Oe(),O=class{constructor(e){this.unsaltedStorage=[];this.isPaused=!1;this.isUrgent=e=>{let{operation:i}=e;return["action_play","watch_coverage_record","watch_coverage_live"].includes(i)};this.params=e,this.api=e.api,this.error$=e.error$,this.userSalt=e.userSalt,this.loggerDebugLog=e.debugLogger.createComponentLog("stat logger"),this.firstFlush=ue(()=>this.safeFlush(),this.params.config.firstFlushTime,{maxWait:this.params.config.firstFlushTime});let i=T.isPersistent()?this.params.config.flushMaxWait:0;this.debouncedFlush=ue(()=>this.safeFlush(),this.params.config.flushDebounceTime,{maxWait:i}),this.subscription=this.api.authorized$.subscribe(t=>{t&&this.debouncedFlush()}),this.housekeepStorage()}safeFlush(){try{this.flush()}catch(e){this.error$.next({id:"LoggerError",category:Re.WTF,message:e?String(e):"Unknown logger error",thrown:e})}}readFromStorage(){let e=T.get(R);try{return e?JSON.parse(e):{}}catch{}return{}}addToStorage(e){if(!this.userSalt){this.unsaltedStorage.push(e);return}let i=this.readFromStorage(),o=(i[this.userSalt]??[]).filter(j(this.params.config.storageExpiration));T.set(R,JSON.stringify({...i,[this.userSalt]:[...o,e]}))}getFromStorage(){return this.userSalt?(this.readFromStorage()[this.userSalt]??[]).filter(j(this.params.config.storageExpiration)):this.unsaltedStorage}markStorageSent(){if(!this.userSalt){this.unsaltedStorage=[];return}let e=this.readFromStorage();delete e[this.userSalt],T.set(R,JSON.stringify(e))}housekeepStorage(){let e=this.readFromStorage();for(let[i,t]of Object.entries(e)){let o=t.filter(j(this.params.config.storageExpiration));o.length?e[i]=o:delete e[i],this.loggerDebugLog({message:`${t.length} retrieved from storage, ${o.length} of them actual`})}T.set(R,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({wantBeacon:e,clearStorage:i}={wantBeacon:!1,clearStorage:!0}){let t=this.getFromStorage();t.length!==0&&(this.api.authorized$.getValue()?(e&&this.params.config.useBeacon?(this.loggerDebugLog({message:`Flushing ${t.length} events through beacon`}),this.api.logBeacon(t)):(this.loggerDebugLog({message:`Flushing ${t.length} events`}),console.log({items:t}),this.api.logRequest(t)),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()}};import{HttpConnectionType as G,Surface as E,VideoFormat as h,VideoQuality as m}from"@vkontakte/videoplayer-core/evergreen";import{assertNever as le}from"@vkontakte/videoplayer-shared/evergreen";var pe=r=>r&&{[m.INVARIANT]:"unknown",[m.Q_144P]:"mobile",[m.Q_240P]:"lowest",[m.Q_360P]:"low",[m.Q_480P]:"medium",[m.Q_576P]:"unknown",[m.Q_720P]:"high",[m.Q_1080P]:"fullhd",[m.Q_1440P]:"quadhd",[m.Q_2160P]:"ultrahd",[m.Q_4320P]:"unknown"}[r],Y=r=>r&&{[G.HTTP1]:"http1",[G.HTTP2]:"http2",[G.QUIC]:"http3"}[r],he=r=>{if(r!==void 0)switch(r){case h.MPEG:return"mp4";case h.DASH:case h.DASH_LIVE:case h.DASH_STREAMS:return"dash";case h.DASH_SEP:return"dash_sep";case h.DASH_ONDEMAND:return"ondemand_dash";case h.DASH_WEBM:case h.DASH_LIVE_WEBM:return"webm";case h.DASH_WEBM_AV1:return"av1";case h.DASH_LIVE_CMAF:return"ondemand_dash_live";case h.HLS:case h.HLS_LIVE:return"hls";case h.HLS_ONDEMAND:return"ondemand_hls";case h.HLS_LIVE_CMAF:return"ondemand_hls_live";case h.WEB_RTC_LIVE:return"webrtc";default:return le(r)}},D=r=>{if(r!==void 0)switch(r){case E.NONE:case E.INLINE:return;case E.FULLSCREEN:return"fullscreen";case E.SECOND_SCREEN:return"chromecast";case E.PIP:return"pip";case E.INVISIBLE:return"invisible";default:return le(r)}},fe=r=>{switch(r){case"slow-2g":return"poor";case"2g":return"poor";case"3g":return"good";case"4g":return"excellent"}};var N=class{constructor(e){this.offset=void 0;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){let t=Date.now(),o=e-t-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)}};var ge=()=>Math.floor(Math.random()*4294967296).toString(36).padStart(7,"0"),me=()=>Math.floor(Math.random()*18446744073709552e3).toString(36).padStart(13,"0");import{PlaybackState as be}from"@vkontakte/videoplayer-core/evergreen";import{filter as ve,filterChanged as Ne,fromEvent as Me,isNullable as Ie,map as Be,merge as X,Observable as Fe,Subject as J,Subscription as Ve,ValueSubject as Ue}from"@vkontakte/videoplayer-shared/evergreen";var Se=(r,e)=>new Fe(i=>{let t=new Ve,o=X(Me(window,"beforeunload"),r.events.willDestruct$),n=new Ue(void 0),a;t.add(r.info.isLive$.pipe(Ne()).subscribe(I=>{a&&(a.unsubscribe(),n.next(void 0)),I?a=r.info.liveTime$.pipe(Be(V=>V&&V/1e3)).subscribe(n):a=r.info.position$.subscribe(n),t.add(a)}));let{playing$:c,paused$:l}=r.events,u=r.events.willSeek$.pipe(ve(()=>r.info.playbackState$.getValue()===be.PLAYING)),p=r.events.seeked$.pipe(ve(()=>r.info.playbackState$.getValue()===be.PLAYING)),f=!1,s=new J;t.add(u.subscribe(()=>{f||s.next(),f=!0})),t.add(p.subscribe(()=>f=!1));let d=new J,g=new J,b=X(c,p,d),S=X(l,s,o,r.events.looped$,g),y,F=()=>y=n.getValue(),w=()=>{let I=n.getValue();Ie(y)||y===I||Ie(I)||(i.next({from:y,to:I}),y=void 0)},L=()=>{g.next(),d.next()};if(t.add(b.subscribe(F)),t.add(S.subscribe(w)),e.forceInterval&&isFinite(e.forceInterval)){let I=0;t.add(b.subscribe(()=>I=window.setTimeout(L,e.forceInterval))),t.add(S.subscribe(()=>window.clearTimeout(I)))}return t});var Ce="_one-stat_",Ae=`${Ce}uuid`,xe=`${Ce}deviceId`,Z=()=>{let r=new ee;return{subscription:r,subscribe:(e,i)=>{e&&r.add(e.subscribe(i))}}},te=class{constructor(e,i){this.subscription=new ee;this.debugLogger=new Qe;this.oneStatDebugLog=this.debugLogger.createComponentLog("onestat");this.loopCounter=0;this.disabled=!1;this.vsid$=new B(void 0);this.isid$=new B(void 0);this.zenUid$=new B(void 0);this.seekAction$=new B("unknown");this.statContext=e,this.config=de(i.config??{}),_(i.apiEnv)&&(this.config.apiEnv=i.apiEnv),this.config.synchronizeTime&&(this.timeSynchronisation=new N);let t=new ze;this.experimental={error$:t},M.get(Ae)&&M.remove(Ae);let n=M.get(xe);this.statContext.deviceId?this.deviceId=this.statContext.deviceId:n?this.deviceId=n:(this.deviceId=z(),M.set(xe,this.deviceId)),this.resetViewSession(),i.useIsid&&this.isid$.next(i.isid??me()),this.zenUid$.next(i.zenUid);let a=new C({config:this.config,error$:t,timeSynchronisation:this.timeSynchronisation});this.api=new x({config:this.config,apiTransport:a,refreshAuthToken:i.refreshAuthToken,mobile:this.statContext.mobile??!1,deviceId:this.deviceId,error$:t}),this.logger=new O({config:this.config,debugLogger:this.debugLogger,api:this.api,error$:t,userSalt:i.userSalt});let{isEmbed:c,topOrigin:l}=je();this.isEmbed=c,this.embedParent=l?new URL(l).hostname:void 0,this.subscribe()}updateContext(e){this.statContext={...this.statContext,...e}}attachTo(e){let i=new ee,t=(s,d)=>i.add(s.subscribe(d));t(e.events.willStart$,()=>{let s=e.info.position$.getValue();this.logActionPlay({position:s}),this.statContext.projectId&&this.logActionPlayInteractive()}),t(e.events.looped$,()=>{this.resetViewSession(),++this.loopCounter>this.config.maxLoops&&(this.disabled=!0),this.logActionPlay({position:e.info.position$.getValue()})}),t(e.events.seeked$,()=>{this.logSeek({action:this.seekAction$.getValue(),time:e.info.position$.getValue()}),this.seekAction$.next("unknown")}),t(e.events.paused$,()=>{this.logPause({position:e.info.position$.getValue()})}),t(e.events.willResume$,()=>{this.logPlay()}),t(e.events.started$,()=>{this.statContext.clip&&this.logWatchCoverageRecord({start:0,end:0})}),t(e.events.playing$,()=>{this.logPlaying()}),t(Se(e,{forceInterval:this.config.watchCoverageInterval}),s=>{let d=e.info.isLive$.getValue(),g=e.info.atLiveEdge$.getValue(),b={start:parseFloat(s.from.toFixed(3)),end:parseFloat(s.to.toFixed(3))};if(g){let S=e.info.liveLatency$.getValue()??0,y=e.info.currentBuffer$.getValue()?.end??0,F=e.info.liveBufferTime$.getValue()??0,w=Math.round((S-(y-F))*1e3),L=Math.round(S*1e3);w&&L&&(b.latency=w,b.bufferLatency=L)}d?this.logWatchCoverageLive(b):this.logWatchCoverageRecord(b)});let o;t(e.info.isStalled$,s=>{s?o=v():(_(o)&&this.logEmptyBuffer({duration:v()-o}),o=void 0)});let n=!1;i.add(e.events.fatalError$.pipe(qe()).subscribe(()=>n=!0)),t(e.events.willStop$,()=>{if(e.info.isStalled$.getValue()){let d=_(o)?v()-o:void 0;this.logCloseAtEmptyBuffer({duration:d??0}),o=void 0}else n||this.logActionStop()}),t(e.events.managedError$,({id:s})=>{this.logError({fatal:!1,errorType:s})}),t(e.events.fatalError$,({id:s})=>{this.logError({fatal:!0,errorType:s})});let a,c,l=!1;t(e.events.firstBytes$,s=>{a=v(),this.logFirstBytes({time:s})}),t(e.events.willStart$,()=>c=v()),t(e.info.currentBuffer$,s=>{!l&&s&&s.end-s.start>0&&_(a)&&(this.logPlayerReady({duration:v()-a}),l=!0)}),t(e.events.firstFrame$,()=>{_(a)&&!l&&(this.logPlayerReady({duration:v()-a}),l=!0),_(c)&&this.logFirstFrame({time:v()-c})});let u;t(e.info.currentVideoStream$,s=>{s&&(u&&s.id!==u&&this.logTrackSwitch(s),u=s.id)});let p;t(e.info.currentAudioStream$,s=>{s&&(p&&s.id!==p&&this.logTrackSwitch(s),p=s.id)}),t(e.info.atLiveEdge$,s=>this.updateContext({liveEdge:s})),t(ye({muted:e.info.muted$,volume:e.info.volume$}),({muted:s,volume:d})=>this.updateContext({audible:!s&&d>0})),t(e.info.currentQuality$,s=>{let d=pe(s);this.updateContext({quality:d}),d&&this.logQuality(d)}),t(e.info.isAutoQualityEnabled$,s=>this.updateContext({autoQuality:s})),t(e.info.currentFormat$,s=>this.updateContext({contentType:he(s)})),t(e.info.currentPlaybackRate$,s=>this.updateContext({rate:s})),t(e.info.is3DVideo$,s=>this.updateContext({is3d:s}));let f;return t(e.info.hostname$,s=>{let d=f!==void 0&&f!==s;this.updateContext({cdnHostname:s,failover:d}),d&&this.logFailover(s),f=s}),t(e.info.throughputEstimation$,s=>this.updateContext({downloadSpeed:s})),t(e.info.httpConnectionType$,s=>{this.statContext.firstConnectionType||this.updateContext({firstConnectionType:Y(s)}),this.updateContext({connectionType:Y(s)})}),t(e.info.httpConnectionReused$,s=>{Ee(this.statContext.firstConnectionReused)&&this.updateContext({firstConnectionReused:s}),this.updateContext({connectionReused:s})}),t(e.info.surface$,s=>this.updateContext({mode:D(s)})),t(ye({current:e.info.currentTextTrack$,available:e.info.availableTextTracks$}),({current:s,available:d})=>{let g=d.find(({id:S})=>S===s),b=g&&(g.isAuto?`${g.language}_auto`:g.language);this.updateContext({subtitles:b?.split(".")[0]})}),this.player=e,this.uiEvents&&this.attachToUi(this.uiEvents),this.resubscribeBeforeunload(),this.subscription.add(i),i}attachToUi(e){this.uiEvents=e;let{subscription:i,subscribe:t}=Z();return this.player&&(t(e.actionRewind$,()=>{this.player&&(this.resetViewSession(),this.logActionPlay({position:this.player.info.position$.getValue()}))}),t(e.actionSeek$,this.seekAction$),t(e.inPiP$,o=>{let n=o?"pip":D(this.player?.info.surface$.getValue());this.updateContext({mode:n})}),t(e.inFullscreen$,o=>{let n=o?"fullscreen":D(this.player?.info.surface$.getValue());console.log({mode:n}),this.updateContext({mode:n})}),t(e.actionSetSubtitle$,o=>this.updateContext({subtitles:o.split(".")[0]})),t(e.nextMovie$,o=>this.logNextMovie(o)),this.resubscribeBeforeunload(),this.subscription.add(i)),i}attachToAds(e){let{subscription:i,subscribe:t}=Z();return t(e.slotRequested$,()=>this.logAdSlotRequest()),t(e.started$,o=>this.logAdStarted(o)),t(e.paused$,()=>this.logAdPaused()),t(e.resumed$,()=>this.logAdResumed()),t(e.ended$,()=>this.logAdEnded()),t(e.skipped$,()=>this.logAdSkipped()),t(e.clicked$,()=>this.logAdClicked()),t(e.error$,o=>this.logError({errorType:o,fatal:!1})),this.resubscribeBeforeunload(),this.subscription.add(i),i}attachToInteractive(e){let{subscription:i,subscribe:t}=Z();return t(e.click$,o=>this.logInterfaceClick(o)),t(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(ge())}getDeviceId(){return this.deviceId}setFieldBlacklist(){}logInited(){}logReady(e){this.log({operation:"player_ready",param:String(e.time)})}logStarted(...e){this.logActionPlay(...e)}logPlay(){this.log({operation:"play_toggle"})}logPlaying(){this.log({operation:"playing"})}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}`},{in_history:this.statContext.inHistory?1:void 0})}logWatchCoverageLive(e){let i=this.timeSynchronisation?.getOffset()??0,t=e.start+i,o=e.end+i;this.log({operation:"watch_coverage_live",param:`${t}-${o}`},{in_history:this.statContext.inHistory?1:void 0,latency:e.latency,buffer_latency:e.bufferLatency})}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();let e=window.navigator.connection;e&&"onchange"in e&&"effectiveType"in e&&this.subscription.add(He(Pe(e,"change"),Ke(["init"])).subscribe(()=>this.updateContext({network:fe(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=Pe(window,"beforeunload").subscribe(()=>this.logger.flush({wantBeacon:!0,clearStorage:this.config.clearStorageAtUnload})),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))})}logActionPlayInteractive(){this.statContext.projectId&&this.log({operation:"action_play_interactive",param:String(this.statContext.movieId)},{vid:this.statContext.projectId})}logFailover(e){this.log({operation:"failover",param:e})}logCloseAtEmptyBuffer(e){this.log({operation:"close_at_empty_buffer",param:String(Math.round(e.duration))})}logActionStop(){this.log({operation:"action_stop"})}logTrackSwitch(e){this.log({operation:"track_switch",param:e.id})}logQuality(e){this.log({operation:"quality",param:e})}log(e,i={}){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}`});let t=this.createLogItem(e,i);this.logger.log(t)}createLogItem({operation:e,param:i,time:t},o={}){let n=this.timeSynchronisation?.now()??v(),a=this.vsid$.getValue();We(a);let c=this.isid$.getValue(),l=e==="empty_buffer"||e==="close_at_empty_buffer"?this.statContext.connectionType:this.statContext.firstConnectionType,u=this.statContext.firstConnectionReused,p,f;if(this.isEmbed||this.statContext.place==="embed"){p=this.embedParent;let d=[...new URLSearchParams(location.search).entries()].filter(([g,b])=>this.config.embedUrlParams.includes(g));f=new URLSearchParams(d).toString()}else this.statContext.place==="direct"&&(this.statContext.refDomain?p=_e(this.statContext.refDomain)?.hostname??this.statContext.refDomain:document.referrer&&(p=_e(document.referrer)?.hostname??document.referrer),f=location.href.substring(0,1024));let s={vsid:a,isid:c,vid:this.statContext.movieId,uid:this.zenUid$.getValue(),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?"auto":this.statContext.autoplay===!1?"":void 0,param:i,vk_app_id:this.statContext.vkAppId,track_code:this.statContext.trackCode,connection_type:l,connection_reused:u===!0?1:u===!1?0:void 0,cached_data:this.statContext.cached===!0?1:this.statContext.cached===!1?0:void 0,live:this.statContext.liveEdge?1:void 0,muted:this.statContext.audible===!1?1:void 0,mode:this.statContext.mode,subtitles:this.statContext.subtitles,download_speed:this.statContext.downloadSpeed,manual_quality:this.statContext.autoQuality?void 0:1,ref_domain:p,direct_url:f,rate:this.statContext.rate===1||Ee(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(let d of this.config.disabledCustomFields)delete s[d];return console.log({custom:s}),{operation:e,type:1,time:t,network:this.statContext.network,timestamp:n,custom:s}}};export{A as ApiEnv,H as ConnectionType,W as ContentType,ie as InteractiveInterfaceClick,te as OneStat,U as Quality,K as SeekAction,k as VERSION};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vkontakte/videoplayer-statistics",
|
|
3
|
-
"version": "1.0.77-dev.
|
|
3
|
+
"version": "1.0.77-dev.4c6dbe21.0",
|
|
4
4
|
"author": "vk.com",
|
|
5
5
|
"description": "Statistics library for vk.com videoplayer",
|
|
6
6
|
"homepage": "https://vk.com",
|
|
@@ -54,9 +54,9 @@
|
|
|
54
54
|
"**/*.d.ts"
|
|
55
55
|
],
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@vkontakte/videoplayer-shared": "1.0.
|
|
57
|
+
"@vkontakte/videoplayer-shared": "1.0.58"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"@vkontakte/videoplayer-core": "2.0.
|
|
60
|
+
"@vkontakte/videoplayer-core": "2.0.130"
|
|
61
61
|
}
|
|
62
62
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { IOneStat, OneStat, IStatContext, IConstructorParams } from './OneStat';
|
|
2
|
+
import { ApiEnv, ContentType, Quality, ConnectionType, SeekAction, InterfaceClick, InteractiveInterfaceClick } from './values';
|
|
3
|
+
import { IUIEvents, IAdsEvents, IInteractiveEvents } from './uiEvents';
|
|
4
|
+
export { OneStat, IOneStat, IStatContext, IConstructorParams, ApiEnv, ContentType, Quality, ConnectionType, SeekAction, IUIEvents, IAdsEvents, IInteractiveEvents, InterfaceClick, InteractiveInterfaceClick, };
|
|
5
|
+
export { VERSION } from './env';
|
|
6
|
+
export { IOptionalConfig } from './config';
|
package/types/oneStat/index.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { IOneStat, OneStat, IStatContext, IConstructorParams } from './OneStat';
|
|
2
|
-
import { ApiEnv, ContentType, Quality, ConnectionType, SeekAction, InterfaceClick, InteractiveInterfaceClick } from './values';
|
|
3
|
-
import { IUIEvents, IAdsEvents, IInteractiveEvents } from './uiEvents';
|
|
4
|
-
export { OneStat, IOneStat, IStatContext, IConstructorParams, ApiEnv, ContentType, Quality, ConnectionType, SeekAction, IUIEvents, IAdsEvents, IInteractiveEvents, InterfaceClick, InteractiveInterfaceClick, };
|
|
5
|
-
export { VERSION } from './env';
|
|
6
|
-
export { IOptionalConfig } from './config';
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { ISubject, IError, IValueObservable } from '@vkontakte/videoplayer-shared';
|
|
2
|
-
import { ValueSubject } from '@vkontakte/videoplayer-shared';
|
|
3
|
-
import type { IApiTransport } from './ApiTransport';
|
|
4
|
-
import type { ILogItem } from './types';
|
|
5
|
-
import type { IConfig } from './config';
|
|
6
|
-
export interface IApi {
|
|
7
|
-
authorized$: IValueObservable<boolean>;
|
|
8
|
-
authorize(authToken?: string): Promise<string | undefined>;
|
|
9
|
-
logBeacon(items: ILogItem[]): void;
|
|
10
|
-
logRequest(items: ILogItem[]): Promise<void>;
|
|
11
|
-
destroy(): void;
|
|
12
|
-
}
|
|
13
|
-
export interface IApiParams {
|
|
14
|
-
config: IConfig;
|
|
15
|
-
deviceId: string;
|
|
16
|
-
apiTransport: IApiTransport;
|
|
17
|
-
error$: ISubject<IError>;
|
|
18
|
-
refreshAuthToken?: () => Promise<string | undefined>;
|
|
19
|
-
}
|
|
20
|
-
export declare class Api implements IApi {
|
|
21
|
-
authorized$: ValueSubject<boolean>;
|
|
22
|
-
private params;
|
|
23
|
-
private authToken?;
|
|
24
|
-
private sessionKey?;
|
|
25
|
-
private authorizePromise?;
|
|
26
|
-
private refreshAuthTokenPromise?;
|
|
27
|
-
private consequentAuthErrors;
|
|
28
|
-
private backoffTimeoutId;
|
|
29
|
-
constructor(params: IApiParams);
|
|
30
|
-
authorize(authToken?: string): Promise<string | undefined>;
|
|
31
|
-
logBeacon(items: ILogItem[]): void;
|
|
32
|
-
logRequest(items: ILogItem[]): Promise<void>;
|
|
33
|
-
destroy(): void;
|
|
34
|
-
private refreshAuthToken;
|
|
35
|
-
private createLogParams;
|
|
36
|
-
private authorizeWithBackoff;
|
|
37
|
-
private doAuthorize;
|
|
38
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { ISubject, IError } from '@vkontakte/videoplayer-shared';
|
|
2
|
-
import type { IConfig } from './config';
|
|
3
|
-
import type { TimeSynchronisation } from './utils/timeSynchronisation';
|
|
4
|
-
export interface IApiTransport {
|
|
5
|
-
sendBeacon(method: string, params: Record<string, unknown>, sessionKey?: string): boolean;
|
|
6
|
-
sendRequest<T = unknown>(method: string, params: Record<string, unknown>, sessionKey?: string): Promise<T>;
|
|
7
|
-
}
|
|
8
|
-
export interface IApiTransportParams {
|
|
9
|
-
config: IConfig;
|
|
10
|
-
timeSynchronisation?: TimeSynchronisation;
|
|
11
|
-
error$: ISubject<IError>;
|
|
12
|
-
}
|
|
13
|
-
export declare class ApiTransport implements IApiTransport {
|
|
14
|
-
private params;
|
|
15
|
-
private apiKey;
|
|
16
|
-
private apiBaseUrl;
|
|
17
|
-
private apiEnv;
|
|
18
|
-
private isApiBaseUrlFetched;
|
|
19
|
-
private timeSynchronisation?;
|
|
20
|
-
constructor(params: IApiTransportParams);
|
|
21
|
-
sendBeacon(method: string, params: Record<string, unknown>, sessionKey?: string): boolean;
|
|
22
|
-
sendRequest<T = unknown>(method: string, params: Record<string, unknown>, sessionKey?: string): Promise<T>;
|
|
23
|
-
private resolveApiBaseUrl;
|
|
24
|
-
private prepareQueryParams;
|
|
25
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { IConfig } from './config';
|
|
2
|
-
import { ILogger as IDebugLogger, IError, ISubject } from '@vkontakte/videoplayer-shared';
|
|
3
|
-
import { IApi } from './Api';
|
|
4
|
-
import { ILogItem } from './types';
|
|
5
|
-
export interface ILoggerParams {
|
|
6
|
-
config: IConfig;
|
|
7
|
-
api: IApi;
|
|
8
|
-
debugLogger: IDebugLogger;
|
|
9
|
-
error$: ISubject<IError>;
|
|
10
|
-
userSalt?: string;
|
|
11
|
-
}
|
|
12
|
-
type FlushParams = {
|
|
13
|
-
wantBeacon?: boolean;
|
|
14
|
-
clearStorage?: boolean;
|
|
15
|
-
};
|
|
16
|
-
export declare class Logger {
|
|
17
|
-
private params;
|
|
18
|
-
private api;
|
|
19
|
-
private error$;
|
|
20
|
-
private subscription;
|
|
21
|
-
private userSalt;
|
|
22
|
-
private unsaltedStorage;
|
|
23
|
-
private lastVsid;
|
|
24
|
-
private isPaused;
|
|
25
|
-
private firstFlush;
|
|
26
|
-
private debouncedFlush;
|
|
27
|
-
private loggerDebugLog;
|
|
28
|
-
constructor(params: ILoggerParams);
|
|
29
|
-
private isUrgent;
|
|
30
|
-
private safeFlush;
|
|
31
|
-
private readFromStorage;
|
|
32
|
-
private addToStorage;
|
|
33
|
-
private getFromStorage;
|
|
34
|
-
private markStorageSent;
|
|
35
|
-
private housekeepStorage;
|
|
36
|
-
log(item: ILogItem): void;
|
|
37
|
-
flush({ wantBeacon, clearStorage }?: FlushParams): void;
|
|
38
|
-
pause(): void;
|
|
39
|
-
resume(): void;
|
|
40
|
-
destroy(): void;
|
|
41
|
-
}
|
|
42
|
-
export {};
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import type { ISubscription, IValueObservable, Milliseconds, Seconds } from '@vkontakte/videoplayer-shared';
|
|
2
|
-
import { ValueSubject } from '@vkontakte/videoplayer-shared';
|
|
3
|
-
import type { IPlayer } from '@vkontakte/videoplayer-core';
|
|
4
|
-
import type { IOptionalConfig } from './config';
|
|
5
|
-
import { Mode, Quality, SeekType, AutoQuality, Visibility } from './values';
|
|
6
|
-
import type { IUIEvents } from './uiEvents';
|
|
7
|
-
export interface IThinOneStat {
|
|
8
|
-
vsid$: IValueObservable<string | undefined>;
|
|
9
|
-
isid$: IValueObservable<string | undefined>;
|
|
10
|
-
/**
|
|
11
|
-
* Лучше авторизоваться сразу, чтобы избежать ситуации:
|
|
12
|
-
* 1. Накапливаем запросы в очереди через debounce send
|
|
13
|
-
* 2. Пользователь закрывает приложение
|
|
14
|
-
* 3. Запрос пытается уйти через sendBeacon и падает без авторизации
|
|
15
|
-
*/
|
|
16
|
-
authorize(authToken?: string): Promise<unknown>;
|
|
17
|
-
/**
|
|
18
|
-
* Обновляет общие параметры событий
|
|
19
|
-
*/
|
|
20
|
-
updateContext(context: Partial<IStatContext>): void;
|
|
21
|
-
/**
|
|
22
|
-
* Привязываемся к событиям и разным изменениям состояний плеера
|
|
23
|
-
*/
|
|
24
|
-
attachTo(player: IPlayer): ISubscription;
|
|
25
|
-
attachToUi(uiEvents: IUIEvents): ISubscription;
|
|
26
|
-
/**
|
|
27
|
-
* Идентификатор текущего устройства
|
|
28
|
-
*/
|
|
29
|
-
getDeviceId(): string;
|
|
30
|
-
/**
|
|
31
|
-
* Деструктор класса
|
|
32
|
-
*/
|
|
33
|
-
destroy(): void;
|
|
34
|
-
}
|
|
35
|
-
export interface IStatContext {
|
|
36
|
-
movieId?: number;
|
|
37
|
-
deviceId?: string;
|
|
38
|
-
preload?: boolean;
|
|
39
|
-
userId?: string;
|
|
40
|
-
uvUserId?: string;
|
|
41
|
-
inHistory?: boolean;
|
|
42
|
-
recomInfo?: Record<string, any>;
|
|
43
|
-
product?: string;
|
|
44
|
-
navigation?: Record<string, any>;
|
|
45
|
-
}
|
|
46
|
-
export interface IConstructorParams {
|
|
47
|
-
config: IOptionalConfig;
|
|
48
|
-
userSalt?: string;
|
|
49
|
-
refreshAuthToken?: () => Promise<string | undefined>;
|
|
50
|
-
isid?: string;
|
|
51
|
-
useIsid?: boolean;
|
|
52
|
-
}
|
|
53
|
-
export interface IWatchCoveragePayload {
|
|
54
|
-
watch_interval: string;
|
|
55
|
-
in_history: boolean;
|
|
56
|
-
content_type?: string;
|
|
57
|
-
playback_quality?: string;
|
|
58
|
-
recom_info?: Record<string, any>;
|
|
59
|
-
}
|
|
60
|
-
export interface IWatchCoverageLivePayload extends IWatchCoveragePayload {
|
|
61
|
-
live: boolean;
|
|
62
|
-
}
|
|
63
|
-
export interface IWatchedNPayload {
|
|
64
|
-
target_duration: Milliseconds;
|
|
65
|
-
current_tvt: Milliseconds;
|
|
66
|
-
}
|
|
67
|
-
export interface IStartSessionPayload {
|
|
68
|
-
isid?: string;
|
|
69
|
-
stream_profile?: 'live' | 'vod';
|
|
70
|
-
dpi: number;
|
|
71
|
-
web_layout: 'desktop' | 'mobile';
|
|
72
|
-
iframe_host?: string | 'unknown' | null;
|
|
73
|
-
from_downloads?: boolean;
|
|
74
|
-
preloaded?: boolean;
|
|
75
|
-
navigation?: Record<string, any>;
|
|
76
|
-
recom_info?: Record<string, any>;
|
|
77
|
-
}
|
|
78
|
-
export interface IPreloadStartedPayload {
|
|
79
|
-
target_buffer_time?: Milliseconds;
|
|
80
|
-
playback_url?: string;
|
|
81
|
-
playback_quality?: Quality;
|
|
82
|
-
}
|
|
83
|
-
export interface IPreloadEndedPayload {
|
|
84
|
-
buffer_time?: Milliseconds;
|
|
85
|
-
}
|
|
86
|
-
export interface IPlaybackStartedPayload {
|
|
87
|
-
playback_quality?: Quality;
|
|
88
|
-
user_quality?: Quality | AutoQuality;
|
|
89
|
-
player_width?: number;
|
|
90
|
-
player_height?: number;
|
|
91
|
-
muted?: boolean;
|
|
92
|
-
sound_volume?: number;
|
|
93
|
-
buffer_time?: Milliseconds;
|
|
94
|
-
mode?: Mode;
|
|
95
|
-
visibility?: Visibility;
|
|
96
|
-
subtitles_enabled?: boolean;
|
|
97
|
-
auto_subtitles?: boolean;
|
|
98
|
-
audio_track_lang?: string;
|
|
99
|
-
playback_rate?: number;
|
|
100
|
-
recom_info?: Record<string, any>;
|
|
101
|
-
}
|
|
102
|
-
export interface IPlayingPayload {
|
|
103
|
-
buffer_time?: Milliseconds;
|
|
104
|
-
}
|
|
105
|
-
export interface ISeekingPayload {
|
|
106
|
-
target_position?: number;
|
|
107
|
-
seek_type?: SeekType;
|
|
108
|
-
}
|
|
109
|
-
export interface ISeekedPayload {
|
|
110
|
-
target_position?: number;
|
|
111
|
-
seek_type?: SeekType;
|
|
112
|
-
}
|
|
113
|
-
export interface IQualityChangedPayload {
|
|
114
|
-
user_quality?: Quality | AutoQuality;
|
|
115
|
-
playback_quality?: Quality | AutoQuality;
|
|
116
|
-
download_quality?: Quality;
|
|
117
|
-
codec_info?: string;
|
|
118
|
-
manual_switch?: boolean;
|
|
119
|
-
}
|
|
120
|
-
export declare class ThinOneStat implements IThinOneStat {
|
|
121
|
-
private api;
|
|
122
|
-
private logger;
|
|
123
|
-
private config;
|
|
124
|
-
private subscription;
|
|
125
|
-
private beforeunloadSubscription?;
|
|
126
|
-
private timeSynchronisation?;
|
|
127
|
-
private statContext;
|
|
128
|
-
private deviceId;
|
|
129
|
-
private debugLogger;
|
|
130
|
-
private thinOneStatDebugLog;
|
|
131
|
-
private eventNumber;
|
|
132
|
-
private isStarted?;
|
|
133
|
-
private isLive?;
|
|
134
|
-
private position;
|
|
135
|
-
private cdnHostname?;
|
|
136
|
-
private isEmbed;
|
|
137
|
-
private embedHostname?;
|
|
138
|
-
private seekAction$;
|
|
139
|
-
vsid$: ValueSubject<string | undefined>;
|
|
140
|
-
isid$: ValueSubject<string | undefined>;
|
|
141
|
-
getTotalViewTime: () => Seconds;
|
|
142
|
-
constructor(statContext: IStatContext, params: IConstructorParams);
|
|
143
|
-
authorize(authToken?: string): Promise<unknown>;
|
|
144
|
-
updateContext(newContext: Partial<IStatContext>): void;
|
|
145
|
-
attachTo(player: IPlayer): ISubscription;
|
|
146
|
-
attachToUi(events: IUIEvents): ISubscription;
|
|
147
|
-
getDeviceId(): string;
|
|
148
|
-
resetViewSession(): void;
|
|
149
|
-
destroy(): void;
|
|
150
|
-
private createRequiredParams;
|
|
151
|
-
private createRequiredFatParams;
|
|
152
|
-
private log;
|
|
153
|
-
private logWatchCoverage;
|
|
154
|
-
private logWatchCoverageLive;
|
|
155
|
-
private logWatchedN;
|
|
156
|
-
private logStartSession;
|
|
157
|
-
private logPreloadStarted;
|
|
158
|
-
private logPreloadEnded;
|
|
159
|
-
private logPlaybackStarted;
|
|
160
|
-
private logPlay;
|
|
161
|
-
private logPlaying;
|
|
162
|
-
private logPause;
|
|
163
|
-
private logResume;
|
|
164
|
-
private logSeeking;
|
|
165
|
-
private logSeeked;
|
|
166
|
-
private logShowLoader;
|
|
167
|
-
private logQualityChanged;
|
|
168
|
-
private resubscribeBeforeunload;
|
|
169
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Milliseconds, RecursivePartial, Seconds } from '@vkontakte/videoplayer-shared';
|
|
2
|
-
import { ApiEnv } from './values';
|
|
3
|
-
export interface IConfig {
|
|
4
|
-
apiKey: string;
|
|
5
|
-
apiEnv: ApiEnv;
|
|
6
|
-
requestRetryCount: number;
|
|
7
|
-
firstFlushTime: Milliseconds;
|
|
8
|
-
flushDebounceTime: Milliseconds;
|
|
9
|
-
flushMaxWait: Milliseconds;
|
|
10
|
-
storageExpiration: Milliseconds;
|
|
11
|
-
watchCoverageHeartbeatInterval: Seconds;
|
|
12
|
-
synchronizeTime: boolean;
|
|
13
|
-
useBeacon: boolean;
|
|
14
|
-
alwaysSendDesktop: boolean;
|
|
15
|
-
}
|
|
16
|
-
export type IOptionalConfig = RecursivePartial<IConfig>;
|
|
17
|
-
export declare const fillDefault: (partial: IOptionalConfig) => IConfig;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { EventName } from './values';
|
|
2
|
-
export interface IRequiredParams {
|
|
3
|
-
vsid: string;
|
|
4
|
-
event_name: EventName;
|
|
5
|
-
client_time: number;
|
|
6
|
-
event_number: number;
|
|
7
|
-
current_tvt: number;
|
|
8
|
-
uv_movie_id?: number;
|
|
9
|
-
user_id?: string;
|
|
10
|
-
uv_user_id?: string;
|
|
11
|
-
device_id?: string;
|
|
12
|
-
application?: string;
|
|
13
|
-
platform?: string;
|
|
14
|
-
product?: string;
|
|
15
|
-
playback_position?: number;
|
|
16
|
-
cdn_host?: string;
|
|
17
|
-
}
|
|
18
|
-
export interface IRequiredFatParams {
|
|
19
|
-
stats_version: string;
|
|
20
|
-
browser: string;
|
|
21
|
-
browser_version: string;
|
|
22
|
-
os: string;
|
|
23
|
-
os_version: string;
|
|
24
|
-
device_type: 'desktop' | 'mobile';
|
|
25
|
-
navigation?: Record<string, any>;
|
|
26
|
-
}
|
|
27
|
-
export type ILogItem = IRequiredParams & Partial<IRequiredFatParams>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { IObservable } from '@vkontakte/videoplayer-shared';
|
|
2
|
-
import { SeekType } from './values';
|
|
3
|
-
export interface IUIEvents {
|
|
4
|
-
actionRewind$?: IObservable<void>;
|
|
5
|
-
actionSeek$?: IObservable<SeekType>;
|
|
6
|
-
inPiP$?: IObservable<boolean>;
|
|
7
|
-
inFullscreen$?: IObservable<boolean>;
|
|
8
|
-
actionSetSubtitle$?: IObservable<string>;
|
|
9
|
-
nextMovie$?: IObservable<number>;
|
|
10
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { Seconds } from '@vkontakte/videoplayer-shared';
|
|
2
|
-
import type { IPlayer, IObservable } from '@vkontakte/videoplayer-core';
|
|
3
|
-
type GetTotalViewTime = () => Seconds;
|
|
4
|
-
export declare const calculateTotalViewTime: (player: IPlayer) => IObservable<GetTotalViewTime>;
|
|
5
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ISources, Surface, VideoFormat, VideoQuality } from '@vkontakte/videoplayer-core';
|
|
2
|
-
import { ContentType, Mode, Quality, StreamingProfile, Visibility } from '../values';
|
|
3
|
-
export declare const contentType: (format?: VideoFormat) => ContentType | undefined;
|
|
4
|
-
export declare const quality: (coreQuality?: VideoQuality) => Quality | undefined;
|
|
5
|
-
export declare const streamingProfile: (contentType?: ContentType) => StreamingProfile | undefined;
|
|
6
|
-
export declare const formatUrl: (format?: VideoFormat, sources?: ISources, quality?: VideoQuality) => string | undefined;
|
|
7
|
-
export declare const mode: (surface?: Surface) => Mode | undefined;
|
|
8
|
-
export declare const visibility: (surface?: Surface) => Visibility | undefined;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Milliseconds } from '@vkontakte/videoplayer-shared';
|
|
2
|
-
export declare class TimeSynchronisation {
|
|
3
|
-
private offset;
|
|
4
|
-
constructor(initialOffset?: Milliseconds);
|
|
5
|
-
getOffset(): Milliseconds;
|
|
6
|
-
setOffset(offset: Milliseconds): void;
|
|
7
|
-
now(): number;
|
|
8
|
-
date(date?: Date): Date;
|
|
9
|
-
addServerTime(serverTime: Milliseconds, rtt: Milliseconds): void;
|
|
10
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function uuid(): string;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { IPlayer } from '@vkontakte/videoplayer-core';
|
|
2
|
-
import type { Seconds, IObservable, IRange } from '@vkontakte/videoplayer-shared';
|
|
3
|
-
export type IParams = {
|
|
4
|
-
heartbeatInterval?: Seconds;
|
|
5
|
-
};
|
|
6
|
-
export declare const watchCoverage: (player: IPlayer, params: IParams) => IObservable<IRange<Seconds>>;
|